Ejemplo n.º 1
0
        // 更新 UserAccount 資料
        private bool UpdateUserAccount()
        {
            bool ret = false;

            try
            {
                List <UserAccount> accountList = db.GetSql().Queryable <UserAccount>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Update User Account , Total Count: {accountList.Count}");

                for (int idx = 0; idx < accountList.Count; idx++)
                {
                    UserAccount info = accountList[idx];

                    redis.GetRedis((int)Connect.RedisDB.emRedisDB_User).HashSet($"UserAccount_" + info.Email, hashTransfer.TransToHashEntryArray(info));

                    SaveLog($"[Info] Update User Account , User: {info.Email}");
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Update User Account Catch Error, Msg:{ex.Message}");
            }

            return(ret);
        }
Ejemplo n.º 2
0
        // 更新 TeamData 資料
        private bool UpdateTeamData()
        {
            bool ret = false;

            try
            {
                List <TeamData> teamList = db.GetSql().Queryable <TeamData>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Update Team Data , Total Count: {teamList.Count}");

                for (int idx = 0; idx < teamList.Count; idx++)
                {
                    TeamData info = teamList[idx];

                    redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).HashSet($"TeamData_" + info.TeamID, hashTransfer.TransToHashEntryArray(info));

                    SaveLog($"[Info] Update Team Data , Team: {info.TeamID}");
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Update Team Data Catch Error, Msg:{ex.Message}");
            }

            return(ret);
        }
Ejemplo n.º 3
0
        // 檢查 TeamBulletin 資料
        private bool CheckTeamBulletin()
        {
            bool ret = false;

            try
            {
                List <TeamBulletin> bulletinList = db.GetSql().Queryable <TeamBulletin>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Check Team Bulletin , Total Count: {bulletinList.Count}");

                for (int idx = 0; idx < bulletinList.Count; idx++)
                {
                    TeamBulletin info = bulletinList[idx];

                    DateTime createDate = DateTime.Parse(info.CreateDate);
                    DateTime curDate    = DateTime.UtcNow;
                    DateTime limitDate  = createDate.AddDays(info.Day);

                    // 超過時間
                    if (curDate > limitDate)
                    {
                        // 刪除DB的資料
                        if (db.GetSql().Deleteable <TeamBulletin>().With(SqlSugar.SqlWith.TabLockX).Where(it => it.BulletinID == info.BulletinID).ExecuteCommand() > 0)
                        {
                            // 刪除Redis中的資料
                            if (redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).KeyExists($"TeamBulletin_" + info.BulletinID))
                            {
                                redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).KeyDelete($"TeamBulletin_" + info.BulletinID);

                                redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).HashDelete($"BulletinIdList_" + info.TeamID, info.BulletinID);

                                SaveLog($"[Info] Check Team Bulletin , Delete Bulletin: {info.BulletinID}");
                            }
                            else
                            {
                                SaveLog($"[Error] Check Team Bulletin , Delete Bulletin: {info.BulletinID} Fail, Can Not Find Redis Data");
                            }
                        }
                        else
                        {
                            SaveLog($"[Error] Check Team Bulletin , Delete Bulletin: {info.BulletinID} From DB Fail");
                        }
                    }
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Check Team Bulletin Catch Error, Msg:{ex.Message}");
            }


            return(ret);
        }
Ejemplo n.º 4
0
        /**
         * 使用者加入
         */
        private void OnJoinService(JoinService packet)
        {
            JoinServiceResult rData = new JoinServiceResult();

            rData.Result = 0;

            DataBaseConnect dbConnect = sev.GetController().GetDataBase();

            try
            {
                List <UserAccount> accountList = dbConnect.GetSql().Queryable <UserAccount>().Where(it => it.Email == packet.Email && it.Password == packet.Password).ToList();

                // 有找到帳號
                if (accountList.Count() == 1)
                {
                    if (accountList[0].Password == packet.Password)
                    {
                        List <UserInfo> infoList = dbConnect.GetSql().Queryable <UserInfo>().Where(it => it.MemberID == accountList[0].MemberID).ToList();

                        // 有找到會員
                        if (infoList.Count() == 1)
                        {
                            if (sev.AddMember(teamID, memberID, this))
                            {
                                rData.Result = 1;

                                SaveLog($"[Info] ClientHandler::onUserJoin, Add Member:{memberID} Success");
                            }
                            else
                            {
                                SaveLog($"[Warning] ClientHandler::onUserJoin, Add Member:{memberID} Fail");
                            }
                        }
                        else
                        {
                            SaveLog("[Warning] ClientHandler::onUserJoin, Can't Find User Info");

                            rData.Result = 0;
                        }
                    }
                    else
                    {
                        rData.Result = 3;

                        SaveLog("[Info] ClientHandler::onUserJoin, Can't Password Error");
                    }
                }
                else
                {
                    rData.Result = 2;
                }
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] ClientHandler::onUserJoin, Catch Error, Msg:{ex.Message}");
            }

            JObject jsMain = new JObject();

            jsMain.Add("CmdID", (int)S2C_CmdID.emJoinServiceResult);
            jsMain.Add("Data", JsonConvert.DeserializeObject <JObject>(JsonConvert.SerializeObject(rData)));

            Send(jsMain.ToString());

            // 加入失敗
            if (rData.Result != 1)
            {
                //SaveLog($"[Warning] ClientHandler::onUserJoin, Can Not Find Member");

                // 強制斷線
            }
        }