示例#1
0
 /// <summary>
 /// 查询玩家在游戏最后一次登录的服务器
 /// </summary>
 /// <param name="UserId">用户Id</param>
 /// <param name="GameId">游戏Id</param>
 /// <returns>返回登陆记录</returns>
 public OnlineLog GetLastLogin(int UserId, int GameId)
 {
     OnlineLog ol = null;
     try
     {
         string sql = "select top 1 * from onlinelog where userid=@UserId and gameid=@GameId order by logtime desc";
         SqlParameter[] sp = new SqlParameter[]
        {
            new SqlParameter("@UserId",UserId),
            new SqlParameter("@GameId",GameId)
        };
         using (SqlDataReader reder = db.GetReader(sql, sp))
         {
             while (reder.Read())
             {
                 ol = new OnlineLog((int)reder["id"], (int)reder["userid"], (int)reder["gameid"], (int)reder["serverid"], (DateTime)reder["logtime"], (int)reder["state"], (int)reder["astate"]);
             }
         }
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
     return ol;
 }
示例#2
0
 /// <summary>
 /// 添加一次登录日志
 /// </summary>
 /// <param name="ol">登录日志</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddOnlineLog(OnlineLog ol)
 {
     try
     {
         string sql = "insert into onlinelog(userid,gameid, serverid,logtime)values (@UserId,@GameId,@ServerId,@LogTime)";
         SqlParameter[] sp = new SqlParameter[]
         {
             new SqlParameter("@UserId", ol.UserId),
             new SqlParameter("@GameId", ol.GameId),
             new SqlParameter("@ServerId",ol.ServerId),
             new SqlParameter("@LogTime",ol.LogTime)
         };
         return db.ExecuteScalar(sql, sp) > 0;
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
 }
示例#3
0
        public ActionResult LoginGame(string GameNo, int Qf)
        {
            g = gm.GetGame(GameNo);
            GameServer gs = new GameServer();
            gs = sm.GetGameServer(g.Id, Qf);
            ViewData["Title"] = "5577yx-" + g.Name;
            ViewData["ServerName"] = g.Name + "-" + gs.Name;
            ViewData["GameNo"] = g.GameNo;
            ViewData["Qf"] = Qf;
            if (gs.State == 1 && gs.StartTime < DateTime.Now)
            {
                gs.State = 4;
                sm.UpdateServer(gs);
            }
            if (gs.State != 1 && gs.StartTime > DateTime.Now)
            {
                gs.State = 1;
                sm.UpdateServer(gs);
            }
            if (gs.State == 1 && gs.StartTime > DateTime.Now)
            {
                TimeSpan ts = gs.StartTime - DateTime.Now;
                ViewData["TimeSpan"] = ts.TotalMilliseconds;
            }
            if (gs.State == 1 || gs.State == 2)
            {
                ViewData["State"] = gs.State;
                return View("~/Views/GameCenter/LoginGame.cshtml");
            }
            int UserId = BBRequest.GetUserId();
            if (UserId > 0)
            {
                ViewData["LoginUrl"] = gm.LoginUrl(g.Id, UserId, gs.Id, 0);
                gum.UpdateLastLogin(UserId);
                OnlineLog ol = new OnlineLog(0, UserId, g.Id, gs.Id, DateTime.Now, 0, 0);
                new OnlineLogManager().AddOnlineLog(ol);
            }
            else
            {
                if (Utils.GetCookie("6qmgamesame") != "")
                {
                    string value = Utils.GetCookie("6qmgamesame");
                    string UserName = DESEncrypt.DesDecrypt(value.Split('|')[0]);
                    string PWD = DESEncrypt.DesDecrypt(value.Split('|')[1]);
                    GameUser gu = gum.GetGameUser(UserName, DESEncrypt.Md5(PWD, 32));
                    if (gu != null)
                    {
                        BBRequest.WriteUserId(gu.Id);
                        gum.UpdateLastLogin(gu.Id);
                        ViewData["LoginUrl"] = gm.LoginUrl(g.Id, gu.Id, gs.Id, 0);
                        OnlineLog ol = new OnlineLog(0, gu.Id, g.Id, gs.Id, DateTime.Now, 0, 0);
                        new OnlineLogManager().AddOnlineLog(ol);
                    }
                    else
                    {
                        return RedirectToAction("Login", "Home");
                    }
                }
                else
                {
                    return RedirectToAction("Login", "Home");
                }
            }

            return View("~/Views/GameCenter/LoginGame.cshtml");
        }
示例#4
0
        public ActionResult WdServers()
        {
            int UserId = BBRequest.GetUserId();
            g = gm.GetGame("nslm");
            if (UserId > 0)
            {
                GameUser gu = new GameUser();
                gu = gum.GetGameUser(UserId);
                ViewData["UserName"] = gu.UserName;
                ViewData["TjqfHref"] = "#";
                ViewData["TjqfName"] = "暂无推荐区服";
                ViewData["LLHref"] = "#";
                ViewData["LLName"] = "暂无记录";
                OnlineLog ol = new OnlineLog();
                ol = new OnlineLogManager().GetLastLogin(UserId, g.Id);
                if (ol != null)
                {
                    GameServer Llqf = sm.GetGameServer(ol.ServerId);
                    ViewData["LLHref"] = "/" + g.GameNo + "/LoginGame?S=" + Llqf.QuFu;
                    ViewData["LLName"] = Llqf.Name;
                }
                if (g.tjqf > 0)
                {
                    GameServer tjqf = sm.GetGameServer(g.tjqf);
                    ViewData["TjqfHref"] = "/" + g.GameNo + "/LoginGame?S=" + tjqf.QuFu;
                    ViewData["TjqfName"] = tjqf.Name;
                }
                List<GameServer> gsList = new List<GameServer>();
                gsList = sm.GetServersByGame(g.Id);
                string ServerHtml = "";
                foreach (GameServer gs in gsList)
                {
                    switch (gs.State)
                    {
                        case 1:
                            ServerHtml += "<li><a  class=\"s2\"><span>" + gs.Name + "</span>即将开启</a></li>";
                            break;
                        case 2:
                            ServerHtml += "<li><a  class=\"s1\"><span>" + gs.Name + "</span>停服维护</a></li>";
                            break;
                        case 3:
                            ServerHtml += "<li><a href=\"/" + g.GameNo + "/LoginGame?S=" + gs.QuFu + "\" target=\"_game\" class=\"s6\"><span>" + gs.Name + "</span>流畅</a></li>";
                            break;
                        case 4:
                            ServerHtml += "<li><a href=\"/" + g.GameNo + "/LoginGame?S=" + gs.QuFu + "\" target=\"_game\" class=\"s4\"><span>" + gs.Name + "</span>火爆</a></li>";
                            break;
                        default:
                            break;
                    }
                }
                ViewData["gsHtml"] = ServerHtml;

                Utils.WriteCookie2("miniloader", "1", "5577yx.com");

                return View();
            }
            else
            {
                return RedirectToAction("Wd");
            }
        }
示例#5
0
 /// <summary>
 /// 添加一次登录日志
 /// </summary>
 /// <param name="ol">登录日志</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddOnlineLog(OnlineLog ol)
 {
     return ols.AddOnlineLog(ol);
 }
示例#6
0
 /// <summary>
 /// 获取玩家登录记录
 /// </summary>
 /// <param name="UserId">用户Id</param>
 /// <param name="Top">几条</param>
 /// <returns>返回玩家登录记录</returns>
 public List<OnlineLog> GetOnlineLog(int UserId, int Top)
 {
     List<OnlineLog> list = new List<OnlineLog>();
     try
     {
         string sql = "SELECT top " + Top + " * FROM onlinelog WHERE id IN (select MAX(id) from onlinelog where userid=@UserId GROUP BY serverid ) order by logtime desc";
         SqlParameter[] sp = new SqlParameter[]
        {
            new SqlParameter("@UserId",UserId),
            new SqlParameter("@Top",Top)
        };
         using (SqlDataReader reder = db.GetReader(sql, sp))
         {
             while (reder.Read())
             {
                 OnlineLog ol = new OnlineLog((int)reder["id"], (int)reder["userid"], (int)reder["gameid"], (int)reder["serverid"], (DateTime)reder["logtime"], (int)reder["state"], (int)reder["astate"]);
                 list.Add(ol);
             }
         }
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
     return list;
 }