当前位置: 首页>>代码示例>>C#>>正文


C# DBConnection.EvaluateTable方法代码示例

本文整理汇总了C#中DBConnection.EvaluateTable方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnection.EvaluateTable方法的具体用法?C# DBConnection.EvaluateTable怎么用?C# DBConnection.EvaluateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBConnection的用法示例。


在下文中一共展示了DBConnection.EvaluateTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IpAddresses

 public ActionResult IpAddresses(string ipAddress = null)
 {
     var model = new PlayerInfoModel();
     if (ipAddress != null)
     {
         using (var db = new DBConnection())
         {
             model.IpAddresses = db.EvaluateTable("select * from account_login where ipaddress = '{0}' order by datetime desc limit 100", DBConnection.AddSlashes(ipAddress));
         }
     }
     return View(model);
 }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:12,代码来源:HomeController.cs

示例2: SetSession

        public static void SetSession(Hashtable accountRow)
        {
            var account = Account.Load(accountRow);

            if (account == null)
                throw new Exception("Unable to log into null account.");

            account.SessionKey = System.Web.HttpContext.Current.Session.SessionID;
            System.Web.HttpContext.Current.Session["Account"] = account;

            var agent = System.Web.HttpContext.Current.Request.UserAgent;
            if (agent.Length > 250)
                agent = agent.Substring(0, 250);

            using (var db = new DBConnection())
            {
                db.Execute("update account set last_on = {0}, num_logins = num_logins + 1 where id = {1}", Utility.UnixTimestamp(DateTime.UtcNow), account.Id);
                //if (!account.IsAdmin)
                    db.Execute("insert ignore into account_login (account_id, datetime, ipaddress, browser, adminused) values ({0}, {1}, '{2}', '{3}', 'False')", account.Id, Utility.UnixTimestamp(DateTime.UtcNow), DBConnection.AddSlashes(System.Web.HttpContext.Current.Request.UserHostAddress), DBConnection.AddSlashes(agent));

                foreach (var message in db.EvaluateTable("select distinct(from_id), account.Name from message join account on account.Id = from_id where to_id = {0} and readflag = 'False'", account.Id))
                {
                    AddChatWindow((int)message["from_id"], (string)message["Name"]);
                }

                db.Execute("update message set readflag = 'True' where to_id = {0}", account.Id);
            }

            var existingAccount = GameServer.GetOnlineAccount(account.Id);
            if (existingAccount == null)
            {
                if (account != null)
                {
                    lock (GameServer.OnlineAccounts)
                    {
                        GameServer.OnlineAccounts.Add(account);
                    }
                }
                else
                    throw new Exception("Account record was null.  This should never happen.");
            }
            else
                existingAccount.SessionKey = System.Web.HttpContext.Current.Session.SessionID;
        }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:44,代码来源:AccountController.cs

示例3: LoadChatMessages

        public ActionResult LoadChatMessages(int targetId, string targetName)
        {
            if (!LoggedIn)
                return null;

            using (var db = new DBConnection())
            {
                var result = new ArrayList();

                foreach (var message in db.EvaluateTable("select to_id, from_id, text from message where (to_id = {0} and from_id = {1}) or (to_id = {1} and from_id = {0}) order by id desc limit 20", targetId, Account.Id))
                {
                    result.Add(new { name = (int)message["from_id"] == Account.Id ? "Me" : targetName, text = (string)message["text"] });
                }

                result.Reverse();

                AddChatWindow(targetId, targetName);

                return Json(result);
            }
        }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:21,代码来源:HomeController.cs

示例4: PlayerInfo

        public ActionResult PlayerInfo(int id)
        {
            if (id <= 0)
                return HttpNotFound();

            var model = new PlayerInfoModel();

            using (var db = new DBConnection())
            {
                model.Account = Account.Load(db.EvaluateRow("select * from account where id = {0}", id));

                if (model.Account == null)
                    return HttpNotFound();

                if (LoggedIn && Account.Id == id) // use freshest account record
                    Account = model.Account;

                if (IsSet("ShowLoginHistory"))
                    model.IpAddresses = db.EvaluateTable("select * from account_login where account_id = " + id + " order by datetime desc limit 100");

                if (IsSet("KillAccount") && Account.IsAdmin)
                {
                    db.Execute("update account set disabled_by = " + Account.Id + " where id=" + id);
                    ViewBag.ErrorMessage = "Account Disabled";
                }

                if (id > 1)
                    model.Games = GameServer.GetPlayerGames(id, IsSet("AllGames"));
                else
                    model.Games = new List<Game>();
            }

            return View("PlayerInfo", model);
        }
开发者ID:AdmiralPotato,项目名称:ggj2013,代码行数:34,代码来源:HomeController.cs


注:本文中的DBConnection.EvaluateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。