public static void ReplyError(Socket socket) { ResultInfo resultInfo = new ResultInfo(); ErrorInfo errorInfo = BaseInfo.GetError(); resultInfo.ErrorType = errorInfo.ErrorType; ErrorView.AddErrorString(); Server.GetInstance().Send(socket, NotifyType.Reply_Error, resultInfo); }
private void timer1_Tick(object sender, EventArgs e) { try { timerDelay++; pingDelay++; refreshDelay++; // control game and chat flow if (pingDelay > 10) { pingDelay = 0; //Cash.GetInstance().NotifyCash(); //Auto.GetInstance().NotifyTimer(); lock (Server.GetInstance()._objLockMain) { Game.GetInstance().NotifyTimer(); Users.GetInstance().NotifyPing(); } } // control auto if (timerDelay > 300) { timerDelay = 0; Users.GetInstance().NotifyAutoCheck(); } // refresh if (refreshDelay > 100) { refreshDelay = 0; _ErrorView.RefreshError(); _LogView.RefreshLog(); _View.RefreshView(); } } catch (Exception ex) { BaseInfo.SetError(ErrorType.Exception_Occur, ex.ToString()); ErrorView.AddErrorString(); } }
public void ShowForm(Form form) { try { foreach (Form openForm in Application.OpenForms) { if (openForm.GetType() == form.GetType()) { openForm.BringToFront(); openForm.Focus(); return; } } //form.MdiParent = this; form.ShowDialog(); } catch (Exception ex) { BaseInfo.SetError(ErrorType.Exception_Occur, ex.ToString()); ErrorView.AddErrorString(); } }
//private Object lockObject = new Object(); public void RefreshView() { Database database = Database.GetInstance(); Users users = Users.GetInstance(); // Show user List if (_isUpdateUserList == true) { List <UserInfo> userList = Users.GetInstance().GetUsers(); if (userList == null) { ErrorView.AddErrorString(); return; } UserView.Rows.Clear(); //lock (lockObject) { for (int i = 0; i < userList.Count; i++) { UserInfo userInfo = userList[i]; int chatCash = database.SumChatHistory(userInfo, DateTime.Now); int gameCash = database.SumGameHistory(userInfo, DateTime.Now); int chargeCash = database.SumChargeHistory(userInfo.Id, DateTime.Now, -1); string auto = string.Empty; if (userInfo.Auto == 1) { auto = "auto"; } UserView.Rows.Add( userInfo.Id, userInfo.Nickname, userInfo.KindString, string.Format("{0} / {1}", userInfo.Cash, userInfo.Point), userInfo.LoginTime, userInfo.RoomId, chatCash, userInfo.GameId, gameCash, chargeCash, auto ); } } int liveCount = Auto.GetInstance().GetLiveCount(); int autoCount = Auto.GetInstance().GetAutoCount(); labelAutoSummary.Text = string.Format("Auto: {0}/{1}", liveCount, autoCount); Main._TotalView.RefreshTotal(); _isUpdateUserList = false; } // Show meet List //if (_isUpdateRoomList == true) //{ // List<RoomInfo> meetList = Chat.GetInstance().GetMeetings(); // if (meetList == null) // { // ErrorView.AddErrorString(); // return; // } // MeetView.Rows.Clear(); // for (int i = 0; i < meetList.Count; i++) // { // RoomInfo meetInfo = meetList[i]; // List<UserInfo> meetUsers = Users.GetInstance().GetRoomUsers(meetInfo.Id); // //if (meetUsers == null || meetUsers.Count != 2) // //{ // // BaseInfo.SetError(ErrorType.Invalid_Id, "没有聊天对象."); // // ErrorView.AddErrorString(); // // continue; // //} // UserInfo servicemanInfo = meetUsers[0]; // UserInfo buyerInfo = meetUsers[1]; // if (servicemanInfo.Id != meetInfo.Owner) // { // servicemanInfo = meetUsers[1]; // buyerInfo = meetUsers[0]; // } // TimeSpan delayTime = DateTime.Now - servicemanInfo.EnterTime; // MeetView.Rows.Add( // meetInfo.Id, // string.Format("{0} ( {1} )", servicemanInfo.Nickname, servicemanInfo.Id), // string.Format("{0} ( {1} )", buyerInfo.Nickname, buyerInfo.Id), // BaseInfo.ConvDateToString(servicemanInfo.EnterTime), // string.Format("{0:00}:{1:00}:{2:00}", delayTime.Hours, delayTime.Minutes, delayTime.Seconds), // meetInfo.Cash, // -Database.GetInstance().SumChatHistory(meetInfo.Id, DateTime.Now) // ); // } // // _isUpdateMeetList = false; // //} // // Show room List // //if (_isUpdateRoomList == true) // //{ // List<RoomInfo> roomList = Chat.GetInstance().GetRooms(); // //RoomView.Rows.Clear(); // for (int i = 0; i < roomList.Count; i++) // { // RoomInfo roomInfo = roomList[i]; // List<UserInfo> roomUsers = Users.GetInstance().GetRoomUsers(roomInfo.Id); // if (roomUsers == null || roomUsers.Count < 1) // { // BaseInfo.SetError(ErrorType.Invalid_Id, "此频道不能进入."); // ErrorView.AddErrorString(); // continue; // } // string buyers = ""; // for (int k = 0; k < roomUsers.Count; k++) // { // if (roomUsers[k].Id == roomInfo.Owner) // continue; // buyers += roomUsers[k].Id; // if (k < roomUsers.Count - 1) // buyers += ", "; // } // //RoomView.Rows.Add( // // roomInfo.Id, // // roomInfo.Name, // // roomInfo.Cash, // // string.Format("{0} / {1} ", roomUsers.Count, roomInfo.MaxUsers), // // roomInfo.Owner, // // buyers, // // -Database.GetInstance().SumChatHistory(roomInfo.Id, DateTime.Now ) // // ); // } // _isUpdateRoomList = false; //} // show game list //if (_isUpdateGameList == true) //{ // List<GameTable> gameList = Game.GetInstance().GetGameTables(); // if (gameList == null) // { // ErrorView.AddErrorString(); // return; // } // GameView.Rows.Clear(); // for (int i = 0; i < gameList.Count; i++) // { // GameInfo gameInfo = gameList[i]._GameInfo; // TableInfo tableInfo = gameList[i]._TableInfo; // string gamers = string.Empty; // foreach (UserInfo userInfo in tableInfo._Players) // { // gamers += userInfo.Id; // if (userInfo != tableInfo._Players[tableInfo._Players.Count - 1]) // gamers += ", "; // } // string round = tableInfo._RoundIndex.ToString(); // if (tableInfo._RoundIndex == 0) // round += " (Ready)"; // else if (tableInfo._RoundIndex == gameList[i]._Rounds.Count - 1) // round += " (End)"; // else // round += " (Run)"; // GameView.Rows.Add( // gameInfo.GameId, // gameInfo.GameName, // gameInfo.Commission, // tableInfo._Players.Count, // gamers, // round, // -Database.GetInstance().SumGameHistory(gameInfo.GameId, DateTime.Now) // ); // } // _isUpdateGameList = false; //} }