Beispiel #1
0
        public bool ProcessPoint(string userId, int point)
        {
            UserInfo userInfo = Database.GetInstance().FindUser(userId);

            if (userInfo == null)
            {
                SetError(ErrorType.Unknown_User, "申请者信息不准确.");
                return(false);
            }

            userInfo.Point += point;

            if (userInfo.Point < 0)
            {
                SetError(ErrorType.Notenough_Point, "积分不足.");
                return(false);
            }

            if (Database.GetInstance().UpdateUser(userInfo) == false)
            {
                ErrorInfo errorInfo = BaseInfo.GetError();
                MessageBox.Show(errorInfo.ErrorString);
                return(false);
            }

            UserInfo loginUserInfo = Users.GetInstance().FindUser(userId);

            if (loginUserInfo != null)
            {
                loginUserInfo.Point    = userInfo.Point;
                View._isUpdateUserList = true;
            }

            PointHistoryInfo pointHistoryInfo = new PointHistoryInfo();

            pointHistoryInfo.TargetId  = userId;
            pointHistoryInfo.Point     = point;
            pointHistoryInfo.AgreeTime = DateTime.Now;
            pointHistoryInfo.Content   = "manager";

            if (Database.GetInstance().AddPointHistory(pointHistoryInfo) == 0)
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public void RefreshPointHistoryList()
        {
            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 <PointHistoryInfo> pointList = Database.GetInstance().GetDayPointHistoryList(_Kind, year, month, day);

            if (pointList == null)
            {
                MessageBox.Show("不能在资料库获取积分信息.");
                return;
            }

            HistoryView.Rows.Clear();

            for (int i = 0; i < pointList.Count; i++)
            {
                PointHistoryInfo historyInfo = pointList[i];

                HistoryView.Rows.Add(
                    historyInfo.TargetId,
                    historyInfo.Point,
                    historyInfo.Content,
                    BaseInfo.ConvDateToString(historyInfo.AgreeTime)
                    );
            }

            //labelSummary.Text = string.Format("총건수: {0}", _ChargeList.Count);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }