private void MngCash_Load(object sender, EventArgs e) { UserInfo userInfo = Database.GetInstance().FindUser(_UserId); if (userInfo == null) { return; } int cashTotal = 0; int chatTotal = 0; int gameTotal = 0; int presentTotal = 0; List <ChatHistoryInfo> chatHistoryList = Database.GetInstance().GetAllChatHistories(_UserId); if (chatHistoryList != null) { for (int i = 0; i < chatHistoryList.Count; i++) { ChatHistoryInfo historyInfo = chatHistoryList[i]; int total = 0; string targetId = ""; switch (userInfo.Kind) { case (int)UserKind.Buyer: case (int)UserKind.Recommender: case (int)UserKind.RecommendOfficer: total = historyInfo.BuyerTotal; targetId = historyInfo.ServicemanId; break; case (int)UserKind.ServiceWoman: total = historyInfo.ServicemanTotal; targetId = historyInfo.BuyerId; break; case (int)UserKind.ServiceOfficer: total = historyInfo.ServiceOfficerTotal; targetId = historyInfo.ServicemanId; break; case (int)UserKind.Manager: total = historyInfo.ManagerTotal; targetId = historyInfo.ServicemanId; break; } TimeSpan duration = historyInfo.EndTime - historyInfo.StartTime; chatTotal += total; ChatHistoryView.Rows.Add( targetId, string.Format("{0}:{1}:{2}", duration.Hours, duration.Minutes, duration.Seconds), total, BaseInfo.ConvDateToString(historyInfo.StartTime) ); } } List <ChargeHistoryInfo> chargeHistoryList = Database.GetInstance().GetAllChargeList(_UserId); if (chargeHistoryList != null) { for (int i = 0; i < chargeHistoryList.Count; i++) { ChargeHistoryInfo historyInfo = chargeHistoryList[i]; if (historyInfo.Complete != (int)CompleteKind.Agree) { continue; } cashTotal += historyInfo.Cash; ChargeHistoryView.Rows.Add( historyInfo.KindString, historyInfo.Cash, BaseInfo.ConvDateToString(historyInfo.StartTime), BaseInfo.ConvDateToString(historyInfo.EndTime) ); } } List <PresentHistoryInfo> presentHistoryList = Database.GetInstance().GetAllPresentHistories(_UserId); if (presentHistoryList != null) { for (int i = 0; i < presentHistoryList.Count; i++) { PresentHistoryInfo presentHistoryInfo = presentHistoryList[i]; string sendId = presentHistoryInfo.SendId; string receiveId = presentHistoryInfo.ReceiveId; int cash = presentHistoryInfo.Cash; if (sendId == _UserId) { sendId = ""; cash = -cash; } else { receiveId = ""; } PresentHistoryView.Rows.Add( BaseInfo.ConvDateToString(presentHistoryInfo.SendTime), sendId, receiveId, cash ); presentTotal += cash; } } labelChargeSum.Text = "合计: " + cashTotal; labelChatSum.Text = "合计: " + chatTotal; labelGameSum.Text = "合计: " + gameTotal; labelPresentSum.Text = "合计: " + presentTotal; }
public UserInfo EndRoom(UserInfo userInfo, RoomInfo roomInfo, bool isMeeting) { //userInfo.RoomId = ""; ChatHistoryInfo chatHistoryInfo = Database.GetInstance().FindChatHistory(userInfo.ChatHistoryId); if (chatHistoryInfo != null) { chatHistoryInfo.EndTime = DateTime.Now; Database.GetInstance().UpdateChatHistory(chatHistoryInfo); } PointHistoryInfo pointHistoryInfo = Database.GetInstance().FindPointHistory(userInfo.PointHistoryId); if (pointHistoryInfo != null) { pointHistoryInfo.AgreeTime = DateTime.Now; Database.GetInstance().UpdatePointHistory(pointHistoryInfo); } //if (userInfo.GameId != null) // Game.GetInstance().OutGame(userInfo); userInfo.RoomId = roomInfo.Id; // 2013-12-29: GreenRose if (isMeeting == true) { Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_OutMeeting, userInfo); } else { Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_OutRoom, userInfo); } //ReplyRoomDetailInfo(roomInfo.Id); //List<UserInfo> roomUsers = Users.GetInstance().GetRoomUsers(roomInfo.Id); //if (roomUsers.Count == 0) //{ // if (isMeeting == true) // { // //_Meetings.Remove(roomInfo); // } // else // { // _Rooms.Remove(roomInfo); // } //} //ReplyRoomList(); //Users.GetInstance().ReplyUserList(null); View._isUpdateUserList = true; View._isUpdateRoomList = true; string str = string.Format("{0} 님이 {1} 방에서 나갔습니다.", userInfo.Id, roomInfo.Id); LogView.AddLogString(str); return(userInfo); }
public void RefreshUserList() { int year = 0; int month = 0; int day = 0; try { year = Convert.ToInt32(comboYear.Text); month = Convert.ToInt32(comboMonth.Text); day = Convert.ToInt32(comboDay.Text); } catch { } List <ChatHistoryInfo> chatHistoryList = Database.GetInstance().GetDayChatHistories(year, month, day); if (chatHistoryList == null) { MessageBox.Show("不能在资料库获取聊天记录目录."); return; } HistoryView.Rows.Clear(); SumView.Rows.Clear(); int sumBuyerTotal = 0; int sumServicemanTotal = 0; int sumOfficerTotal = 0; int sumManagerTotal = 0; for (int i = 0; i < chatHistoryList.Count; i++) { ChatHistoryInfo historyInfo = chatHistoryList[i]; TimeSpan duration = historyInfo.EndTime - historyInfo.StartTime; //string managerId = Users.ManagerInfo.Id; //int managerCash = 0; //switch (Users.ManagerInfo.Kind) //{ // case (int)UserKind.Manager: // managerCash = historyInfo.ManagerTotal; // break; // case (int)UserKind.ServiceOfficer: // managerCash = historyInfo.ServiceOfficerTotal; // break; //} HistoryView.Rows.Add( BaseInfo.ConvDateToString(historyInfo.StartTime), string.Format("{0:00}:{1:00}:{2:00}", duration.Hours, duration.Minutes, duration.Seconds), historyInfo.ServicePrice, historyInfo.BuyerId, historyInfo.BuyerTotal, historyInfo.ServicemanId, historyInfo.ServicemanTotal, historyInfo.OfficerId, historyInfo.ServiceOfficerTotal, historyInfo.ManagerId, historyInfo.ManagerTotal ); sumBuyerTotal += historyInfo.BuyerTotal; sumServicemanTotal += historyInfo.ServicemanTotal; sumOfficerTotal += historyInfo.ServiceOfficerTotal; sumManagerTotal += historyInfo.ManagerTotal; } SumView.Rows.Add( "", "", "", "", sumBuyerTotal, "", sumServicemanTotal, "", sumOfficerTotal, "", sumManagerTotal); labelSummary.Text = string.Format("总数: {0}", chatHistoryList.Count); }
public UserInfo StartRoom(UserInfo userInfo, RoomInfo roomInfo, AskChatInfo askChatInfo) { userInfo = Users.GetInstance().FindUser(userInfo.Id); List <UserInfo> roomUsers = Users.GetInstance().GetRoomUsers(roomInfo.Id); //if (userInfo.Kind == (int)UserKind.ServiceWoman) //{ // if ( roomUsers.Count > 0 ) // { // SetError(ErrorType.Already_Serviceman, "이미 봉사자가 들어있는 방입니다."); // return null; // } // roomInfo.Owner = userInfo.Id; //} //else //{ // if ( roomUsers.Count <= 0 ) // { // SetError(ErrorType.Notallow_NoServiceman, "봉사자가 없는 방에 먼저 들어갈수 없습니다."); // return null; // } // if (roomInfo.Cash > 0 && userInfo.Cash < roomInfo.Cash) // { // SetError(ErrorType.Notenough_Cash, string.Format("{0}님의 캐쉬가 작아 채팅을 할수 없습니다.", userInfo.Id)); // return null; // } // if (roomInfo.Point > 0 && userInfo.Point < roomInfo.Point) // { // SetError(ErrorType.Notenough_Point, string.Format("{0}님의 포인트가 작아 채팅을 할수 없습니다.", userInfo.Point)); // return null; // } //} // 2013-12-17: GreenRose if (roomUsers.Count <= 0) { roomInfo.Owner = userInfo.Id; } userInfo.RoomId = roomInfo.Id; userInfo.EnterTime = DateTime.Now; userInfo.CashTime = userInfo.EnterTime; userInfo.WaitSecond = 0; //if (askChatInfo == null) //{ // if (FindRoom(roomInfo.Id) == null) // { // _Rooms.Add(roomInfo); // if (roomInfo.Point <= 0) // { // GameInfo gameInfo = Database.GetInstance().FindGameSource(GameSource.Dice); // gameInfo.GameId = roomInfo.Id; // GameTable gameTable = Game.GetInstance().MakeTable(gameInfo); // if (gameTable != null) // { // roomInfo.IsGame = 1; // roomInfo._GameInfo = gameInfo; // } // } // } // ReplyRoomList(); // Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_EnterRoom, roomInfo); //} //else { if (FindMeeting(roomInfo.Id) == null) { _Meetings.Add(roomInfo); } askChatInfo.MeetingInfo = roomInfo; Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_EnterMeeting, askChatInfo); } //if (roomInfo._GameInfo != null) //{ // //userInfo.GameId = roomInfo._GameInfo.GameId; // Game.GetInstance().NotifyOccured(NotifyType.Request_EnterGame, userInfo.Socket, roomInfo._GameInfo); // Game.GetInstance().NotifyOccured(NotifyType.Request_PlayerEnter, userInfo.Socket, userInfo); //} //Users.GetInstance().ReplyUserList(null); //ReplyRoomDetailInfo(roomInfo.Id); View._isUpdateUserList = true; View._isUpdateRoomList = true; string str = string.Format("{0} 님이 {1}방에 들어갔습니다.", userInfo.Id, roomInfo.Id); LogView.AddLogString(str); if (userInfo.Kind != (int)UserKind.ServiceWoman) { if (roomInfo.Cash > 0) { ChatHistoryInfo chatHistoryInfo = new ChatHistoryInfo(); chatHistoryInfo.RoomId = roomInfo.Id; chatHistoryInfo.BuyerId = userInfo.Id; chatHistoryInfo.ServicemanId = roomInfo.Owner; chatHistoryInfo.ServicePrice = roomInfo.Cash; chatHistoryInfo.StartTime = userInfo.EnterTime; chatHistoryInfo.EndTime = userInfo.EnterTime; userInfo.ChatHistoryId = Database.GetInstance().AddChatHistory(chatHistoryInfo); } if (roomInfo.Point > 0) { PointHistoryInfo pointHistoryInfo = new PointHistoryInfo(); pointHistoryInfo.TargetId = userInfo.Id; pointHistoryInfo.AgreeTime = DateTime.Now; pointHistoryInfo.Content = string.Format("{0}과 무료채팅", roomInfo.Owner); userInfo.PointHistoryId = Database.GetInstance().AddPointHistory(pointHistoryInfo); } } return(userInfo); }
public bool ProcessChatCash(UserInfo userInfo, RoomInfo roomInfo, bool bMeeting) { //List<UserInfo> users = Users.GetInstance().GetRoomUsers(roomInfo.Id); //if (users == null) //{ // ErrorView.AddErrorString(); // return false; //} //bool bUpdate = false; //for (int i = 0; i < users.Count; i++) //{ // UserInfo userInfo = users[i]; if (userInfo.Kind == (int)UserKind.Manager || userInfo.Kind == (int)UserKind.ServiceWoman || userInfo.Kind == (int)UserKind.ServiceOfficer) { return(true); } //bUpdate = true; if (roomInfo.Cash > 0) { if (GiveChatSum(userInfo.Id, -roomInfo.Cash) == false) { Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo); return(false); } if (userInfo.Auto > 0) { return(true); } //GiveChatSum(userInfo.Id, -roomInfo.Cash); if (bMeeting == true) { userInfo.CashTime = userInfo.CashTime.AddMinutes(1); } else { userInfo.CashTime = userInfo.CashTime.AddYears(1); } UserInfo servicer = Database.GetInstance().FindUser(roomInfo.Owner); UserInfo serviceOfficer = Database.GetInstance().FindUser(servicer.Recommender); // Database.GetInstance().GetManager(UserKind.ServiceOfficer); UserInfo manager = Database.GetInstance().GetManager(UserKind.Manager)[0]; int servicePercent = servicer.ChatPercent; int serviceOfficerPercent = serviceOfficer.ChatPercent; if (servicePercent > 100) { servicePercent = 100; } if (serviceOfficerPercent > 100) { serviceOfficerPercent = 100; } if (servicePercent > serviceOfficerPercent) { servicePercent = serviceOfficerPercent; } serviceOfficerPercent -= servicePercent; int serviceCash = ProcessCashPercent(servicer, servicePercent, roomInfo.Cash); int serviceOfficerCash = ProcessCashPercent(serviceOfficer, serviceOfficerPercent, roomInfo.Cash); int managerCash = roomInfo.Cash - serviceOfficerCash - serviceCash; if (servicer != null) { GiveChatSum(servicer.Id, serviceCash); } if (serviceOfficer != null) { GiveChatSum(serviceOfficer.Id, serviceOfficerCash); } GiveChatSum(manager.Id, managerCash); ChatHistoryInfo chatHistoryInfo = Database.GetInstance().FindChatHistory(userInfo.ChatHistoryId); if (chatHistoryInfo != null) { chatHistoryInfo.OfficerId = serviceOfficer.Id; chatHistoryInfo.ManagerId = manager.Id; chatHistoryInfo.BuyerTotal -= roomInfo.Cash; chatHistoryInfo.ServicemanTotal += serviceCash; chatHistoryInfo.ServiceOfficerTotal += serviceOfficerCash; chatHistoryInfo.ManagerTotal += managerCash; chatHistoryInfo.EndTime = DateTime.Now; Database.GetInstance().UpdateChatHistory(chatHistoryInfo); } View._isUpdateRoomList = true; } if (roomInfo.Point > 0) { if (userInfo.Point < roomInfo.Point) { SetError(ErrorType.Notenough_Point, string.Format("因{0}的账号余额不足 退出聊天频道.", userInfo.Id)); Main.ReplyError(userInfo.Socket); Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo); return(false); } UserInfo updateInfo = Database.GetInstance().FindUser(userInfo.Id); if (updateInfo == null) { Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo); return(false); } updateInfo.Point -= roomInfo.Point; if (Database.GetInstance().UpdateUser(updateInfo) == false) { Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo); return(false); } userInfo.Point = updateInfo.Point; PointHistoryInfo pointHistoryInfo = Database.GetInstance().FindPointHistory(userInfo.PointHistoryId); if (pointHistoryInfo != null) { pointHistoryInfo.Point -= roomInfo.Point; pointHistoryInfo.AgreeTime = DateTime.Now; Database.GetInstance().UpdatePointHistory(pointHistoryInfo); } userInfo.CashTime = userInfo.CashTime.AddMinutes(1); View._isUpdateUserList = true; View._isUpdateRoomList = true; } //} //if( bUpdate == true ) Chat.GetInstance().ReplyRoomDetailInfo(roomInfo.Id); return(true); }