Ejemplo n.º 1
0
        public void Update()
        {
            if (!IsNeedDownload())
            {
                return;
            }


            try
            {
                ClientServerListData clientListData = new ClientServerListData();
                clientListData.lTime  = TimeUtil.NOW();
                clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                byte[] clientBytes  = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl, clientBytes, 2000, 30000);
                if (responseData == null)
                {
                    return;
                }

                InputKingPaiHangDataEx tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length);

                if (tmpRankEx != null)
                {
                    rankEx = tmpRankEx;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, "PlatChargeKingManager.Update exception", ex);
            }
        }
Ejemplo n.º 2
0
 public KFRebornRoleData Reborn_GetRebornRoleData(int ptId, int roleId)
 {
     try
     {
         IKuaFuWorld kuaFuService = this.GetKuaFuService(false);
         if (null == kuaFuService)
         {
             return(null);
         }
         try
         {
             lock (this.Mutex)
             {
                 KeyValuePair <int, int>      key            = new KeyValuePair <int, int>(ptId, roleId);
                 KuaFuData <KFRebornRoleData> RebornRoleData = null;
                 if (!this.RebornRoleDataDict.TryGetValue(key, out RebornRoleData))
                 {
                     RebornRoleData = new KuaFuData <KFRebornRoleData>();
                     this.RebornRoleDataDict[key] = RebornRoleData;
                 }
                 KuaFuCmdData result = kuaFuService.Reborn_GetRebornRoleData(ptId, roleId, RebornRoleData.Age);
                 if (result == null || result.Age < 0L)
                 {
                     return(null);
                 }
                 if (result != null && result.Age > RebornRoleData.Age)
                 {
                     RebornRoleData.Age = result.Age;
                     if (null != result.Bytes0)
                     {
                         RebornRoleData.V = DataHelper2.BytesToObject <KFRebornRoleData>(result.Bytes0, 0, result.Bytes0.Length);
                     }
                     if (null != RebornRoleData.V)
                     {
                         this.RebornRoleDataDict[key] = RebornRoleData;
                     }
                 }
                 return(RebornRoleData.V);
             }
         }
         catch (Exception ex)
         {
             this.ResetKuaFuService();
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
     return(null);
 }
Ejemplo n.º 3
0
        public bool LoadZhanDuiData(Dictionary <int, TianTi5v5ZhanDuiData> dict)
        {
            bool   result = false;
            string sql    = "select `zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`duanweijifen`,`duanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`,`monthduanweirank`,leaderrolename,zoneid,zorkjifen,zorklastfighttime,escapejifen,escapelastfighttime from t_kf_5v5_zhandui";

            using (MySqlDataReader reader = DbHelperMySQL.ExecuteReader(sql, false))
            {
                result = true;
                while (reader.Read())
                {
                    try
                    {
                        TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                        data.ZhanDuiID    = Convert.ToInt32(reader[0].ToString());
                        data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                        data.XuanYan      = reader["xuanyan"].ToString();
                        data.ZhanDuiName  = reader["zhanduiname"].ToString();
                        data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                        data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                        byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                        data.teamerList          = DataHelper2.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                        data.DuanWeiJiFen        = Convert.ToInt32(reader["duanweijifen"].ToString());
                        data.DuanWeiRank         = Convert.ToInt32(reader["duanweirank"].ToString());
                        data.LianSheng           = Convert.ToInt32(reader["liansheng"].ToString());
                        data.FightCount          = Convert.ToInt32(reader["fightcount"].ToString());
                        data.SuccessCount        = Convert.ToInt32(reader["successcount"].ToString());
                        data.LastFightTime       = Convert.ToDateTime(reader["lastfighttime"].ToString());
                        data.MonthDuanWeiRank    = Convert.ToInt32(reader["monthduanweirank"].ToString());
                        data.LeaderRoleName      = reader["leaderrolename"].ToString();
                        data.ZoneID              = Convert.ToInt32(reader["zoneid"].ToString());
                        data.ZorkJiFen           = Convert.ToInt32(reader["zorkjifen"].ToString());
                        data.ZorkLastFightTime   = Convert.ToDateTime(reader["zorklastfighttime"].ToString());
                        data.EscapeJiFen         = Convert.ToInt32(reader["escapejifen"].ToString());
                        data.EscapeLastFightTime = Convert.ToDateTime(reader["escapelastfighttime"].ToString());
                        dict[data.ZhanDuiID]     = data;
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteException(ex.ToString());
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public KuaFuLueDuoBHData GetBHDataByBhid_KuaFuLueDuo(int bhid)
        {
            IKuaFuService kuaFuService = this.GetKuaFuService(false);

            if (null != kuaFuService)
            {
                try
                {
                    lock (this.Mutex)
                    {
                        KuaFuData <KuaFuLueDuoBHData> bhdata = null;
                        if (!this.KuaFuLueDuoBHDataDict.TryGetValue(bhid, out bhdata))
                        {
                            bhdata = new KuaFuData <KuaFuLueDuoBHData>();
                            this.KuaFuLueDuoBHDataDict[bhid] = bhdata;
                        }
                        KuaFuCmdData result = kuaFuService.GetBHDataByBhid_KuaFuLueDuo(bhid, bhdata.Age);
                        if (result == null || result.Age < 0L)
                        {
                            return(null);
                        }
                        if (result != null && result.Age > bhdata.Age)
                        {
                            bhdata.Age = result.Age;
                            if (null != result.Bytes0)
                            {
                                bhdata.V = DataHelper2.BytesToObject <KuaFuLueDuoBHData>(result.Bytes0, 0, result.Bytes0.Length);
                            }
                            if (null != bhdata.V)
                            {
                                this.KuaFuLueDuoBHDataDict[bhid] = bhdata;
                            }
                        }
                        return(bhdata.V);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteException(ex.ToString());
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public int LoadZhanDuiRankList(List <TianTi5v5ZhanDuiData> list, int dayID)
        {
            int    result = 0;
            string sql    = string.Format("select `zhanduiid`,`leaderid`,`xuanyan`,`zhanduiname`,`duanweiid`,`zhanli`,`data1`,`duanweijifen`,`duanweirank`,`liansheng`,`fightcount`,`successcount`,`lastfighttime`,`monthduanweirank`,leaderrolename,zoneid from t_kf_5v5_zhandui_paihang where dayid={0} order by duanweirank", dayID);

            using (MySqlDataReader reader = DbHelperMySQL.ExecuteReader(sql, false))
            {
                result = 1;
                while (reader.Read())
                {
                    try
                    {
                        TianTi5v5ZhanDuiData data = new TianTi5v5ZhanDuiData();
                        data.ZhanDuiID    = Convert.ToInt32(reader[0].ToString());
                        data.LeaderRoleID = Convert.ToInt32(reader["leaderid"].ToString());
                        data.XuanYan      = reader["xuanyan"].ToString();
                        data.ZhanDuiName  = reader["zhanduiname"].ToString();
                        data.DuanWeiId    = Convert.ToInt32(reader["duanweiid"].ToString());
                        data.ZhanDouLi    = Convert.ToInt64(reader["zhanli"].ToString());
                        byte[] bytes = (reader["data1"] as byte[]) ?? new byte[0];
                        data.teamerList       = DataHelper2.BytesToObject <List <TianTi5v5ZhanDuiRoleData> >(bytes, 0, bytes.Length);
                        data.DuanWeiJiFen     = Convert.ToInt32(reader["duanweijifen"].ToString());
                        data.DuanWeiRank      = Convert.ToInt32(reader["duanweirank"].ToString());
                        data.LianSheng        = Convert.ToInt32(reader["liansheng"].ToString());
                        data.FightCount       = Convert.ToInt32(reader["fightcount"].ToString());
                        data.SuccessCount     = Convert.ToInt32(reader["successcount"].ToString());
                        data.LastFightTime    = Convert.ToDateTime(reader["lastfighttime"].ToString());
                        data.MonthDuanWeiRank = Convert.ToInt32(reader["monthduanweirank"].ToString());
                        data.LeaderRoleName   = reader["leaderrolename"].ToString();
                        data.ZoneID           = Convert.ToInt32(reader["zoneid"].ToString());
                        list.Add(data);
                    }
                    catch (Exception ex)
                    {
                        LogManager.WriteException(ex.ToString());
                    }
                }
            }
            return(result);
        }
        private List <ZhanDuiZhengBaZhanDuiData> LoadZhengBaRankData(int nowMonth)
        {
            List <ZhanDuiZhengBaZhanDuiData> roleList = new List <ZhanDuiZhengBaZhanDuiData>();

            try
            {
                string strSql = string.Format("SELECT zhanduiid,zhanduiname,zoneid,duanweiid,duanweijifen,duanweirank,zhanli,grade,`group`,state,data1,data2 FROM t_zhandui_zhengba where `month`={0} ORDER BY duanweirank ASC;", nowMonth);
                using (MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false))
                {
                    while (sdr != null && sdr.Read())
                    {
                        ZhanDuiZhengBaZhanDuiData roleData = new ZhanDuiZhengBaZhanDuiData();
                        roleData.ZhanDuiID   = Convert.ToInt32(sdr["zhanduiid"]);
                        roleData.ZoneId      = Convert.ToInt32(sdr["zoneid"]);
                        roleData.ZhanDuiName = sdr["zhanduiname"].ToString();
                        roleData.DuanWeiId   = Convert.ToInt32(sdr["duanweiid"]);
                        roleData.DuanWeiRank = Convert.ToInt32(sdr["duanweirank"]);
                        roleData.ZhanLi      = Convert.ToInt64(sdr["zhanli"]);
                        if (!sdr.IsDBNull(sdr.GetOrdinal("data1")))
                        {
                            byte[] bytes = (byte[])sdr["data1"];
                            roleData.MemberList = DataHelper2.BytesToObject <List <RoleOccuNameZhanLi> >(bytes, 0, bytes.Length);
                        }
                        roleData.Grade = Convert.ToInt32(sdr["grade"]);
                        roleData.Group = Convert.ToInt32(sdr["group"]);
                        roleData.State = Convert.ToInt32(sdr["state"]);
                        roleList.Add(roleData);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteException(ex.ToString());
            }
            return(roleList);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 检测生成众生争霸排行榜
        /// </summary>
        /// <param name="now"></param>
        private bool CheckBuildZhengBaRank(int selectRoleIfNewCreate, int nowMonth)
        {
            bool bMonthFirst = false;

            try
            {
                DbHelperMySQL.ExecuteSql(
                    string.Format("INSERT IGNORE INTO t_async(`id`,`value`) VALUES({0},{1});",
                                  AsyncTypes.ZhengBaCurrMonth, ZhengBaConsts.DefaultAsyncMonth)
                    );

                // 防止人为的重新reload月排行榜导致众神争霸战斗信息丢失

                /* 这里有一些细节要注意:
                 * 1:每月1号凌晨3点更新月排行榜,然后触发更新争霸角色
                 * 2: 服务器启动的时候,尝试生成争霸角色
                 * 3:要防止当月的争霸角色重复生成
                 * 4:必须保证天梯排行角色已经生成,才能生成争霸角色 -->例如,1号凌晨两点启动,必须保证等到3点的时候,天梯月排行榜生成之后,能够生成本月的争霸角色
                 */
                int    oldMonth           = (int)DbHelperMySQL.GetSingle("select value from t_async where id = " + AsyncTypes.ZhengBaCurrMonth);
                object ageObj_tiantiMonth = DbHelperMySQL.GetSingle("select value from t_async where id = " + AsyncTypes.TianTiPaiHangModifyOffsetDay);
                if (oldMonth != nowMonth &&
                    ageObj_tiantiMonth != null &&
                    ZhengBaUtils.MakeMonth(DataHelper2.GetRealDate((int)ageObj_tiantiMonth)) == nowMonth)
                {
                    string strSql = string.Format("SELECT rid,rname,zoneid,duanweiid,duanweijifen,duanweirank,zhanli,data1,data2 FROM t_tianti_month_paihang ORDER BY duanweirank ASC LIMIT {0};", selectRoleIfNewCreate);
                    var    sdr    = DbHelperMySQL.ExecuteReader(strSql);
                    while (sdr != null && sdr.Read())
                    {
                        ZhengBaRoleInfoData roleData = new ZhengBaRoleInfoData();
                        roleData.RoleId       = (int)Convert.ToInt32(sdr["rid"]);
                        roleData.ZoneId       = (int)Convert.ToInt32(sdr["zoneid"]);
                        roleData.DuanWeiId    = (int)Convert.ToInt32(sdr["duanweiid"]);
                        roleData.DuanWeiJiFen = (int)Convert.ToInt32(sdr["duanweijifen"]);
                        roleData.DuanWeiRank  = (int)Convert.ToInt32(sdr["duanweirank"]);
                        roleData.ZhanLi       = (int)Convert.ToInt32(sdr["zhanli"]);
                        roleData.RoleName     = sdr["rname"].ToString();
                        if (!sdr.IsDBNull(sdr.GetOrdinal("data1")))
                        {
                            roleData.TianTiPaiHangRoleData = (byte[])(sdr["data1"]);
                        }
                        if (!sdr.IsDBNull(sdr.GetOrdinal("data2")))
                        {
                            roleData.PlayerJingJiMirrorData = (byte[])(sdr["data2"]);
                        }
                        if (string.IsNullOrEmpty(roleData.RoleName) && roleData.TianTiPaiHangRoleData != null)
                        {
                            var onlyName = DataHelper2.BytesToObject <TianTiPaiHangRoleData_OnlyName>(
                                roleData.TianTiPaiHangRoleData, 0, roleData.TianTiPaiHangRoleData.Length);
                            if (onlyName != null)
                            {
                                roleData.RoleName = onlyName.RoleName;
                            }
                        }

                        string repSql = string.Format(
                            "REPLACE INTO t_zhengba_roles(`month`,rid,zoneid,duanweiid,duanweijifen,duanweirank,zhanli,`grade`,`group`,state,rname,data1,data2) "
                            + "VALUES({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},'{10}',@content,@mirror)",
                            nowMonth, roleData.RoleId, roleData.ZoneId, roleData.DuanWeiId,
                            roleData.DuanWeiJiFen, roleData.DuanWeiRank, roleData.ZhanLi,
                            (int)EZhengBaGrade.Grade100, (int)ZhengBaConsts.NoneGroup, (int)EZhengBaState.None, roleData.RoleName);

                        DbHelperMySQL.ExecuteSqlInsertImg(repSql,
                                                          new List <Tuple <string, byte[]> > {
                            new Tuple <string, byte[]>("content", roleData.TianTiPaiHangRoleData),
                            new Tuple <string, byte[]>("mirror", roleData.PlayerJingJiMirrorData)
                        });
                    }
                    if (sdr != null)
                    {
                        sdr.Close();
                    }

                    DbHelperMySQL.ExecuteSql(
                        string.Format("REPLACE INTO t_async(`id`,`value`) VALUES({0},{1});",
                                      AsyncTypes.ZhengBaCurrMonth, nowMonth)
                        );

                    bMonthFirst = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(bMonthFirst);
        }
Ejemplo n.º 8
0
 public void Update()
 {
     try
     {
         lock (this.Mutex)
         {
             if (this.IsNeedDownload())
             {
                 bool flag = false;
                 List <InputKingPaiHangDataEx> list = new List <InputKingPaiHangDataEx>();
                 if (KuaFuServerManager.GetPlatChargeKingUrl != null)
                 {
                     for (int i = 0; i < KuaFuServerManager.GetPlatChargeKingUrl.Length; i++)
                     {
                         ClientServerListData clientListData = new ClientServerListData();
                         clientListData.lTime  = TimeUtil.NOW();
                         clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                         byte[] clientBytes  = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                         byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl[i], clientBytes, 2000, 30000);
                         if (responseData == null)
                         {
                             flag = true;
                             break;
                         }
                         InputKingPaiHangDataEx tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length);
                         if (tmpRankEx == null)
                         {
                             flag = true;
                             break;
                         }
                         list.Add(tmpRankEx);
                     }
                     if (flag)
                     {
                         this.rankEx = new InputKingPaiHangDataEx();
                     }
                     else
                     {
                         this.rankEx = this.MergePlatfromInputKingList(list);
                     }
                 }
             }
             if (this.IsNeedDownloadEveryDay())
             {
                 if (KuaFuServerManager.GetPlatChargeKingUrl_EveryDay != null)
                 {
                     bool flag = false;
                     Dictionary <int, List <InputKingPaiHangDataEx> > dict = new Dictionary <int, List <InputKingPaiHangDataEx> >();
                     for (int i = 0; i < KuaFuServerManager.GetPlatChargeKingUrl_EveryDay.Length; i++)
                     {
                         List <InputKingPaiHangDataEx> tempRankExList = new List <InputKingPaiHangDataEx>();
                         if (this.MeiRiPCKingFromDate < this.MeiRiPCKingToDate)
                         {
                             DateTime timeLoop = this.MeiRiPCKingFromDate;
                             while (timeLoop < this.MeiRiPCKingToDate && timeLoop < TimeUtil.NowDateTime())
                             {
                                 InputKingPaiHangDataEx tmpRankEx = null;
                                 byte[] clientBytes = DataHelper2.ObjectToBytes <InputKingPaiHangDataSearch>(new InputKingPaiHangDataSearch
                                 {
                                     startDate = timeLoop.ToString("yyyy-MM-dd HH:mm:ss"),
                                     endDate   = timeLoop.AddDays(1.0).AddSeconds(-1.0).ToString("yyyy-MM-dd HH:mm:ss")
                                 });
                                 byte[] responseData = WebHelper.RequestByPost(KuaFuServerManager.GetPlatChargeKingUrl_EveryDay[i], clientBytes, 2000, 30000);
                                 if (responseData != null)
                                 {
                                     tmpRankEx = DataHelper2.BytesToObject <InputKingPaiHangDataEx>(responseData, 0, responseData.Length);
                                 }
                                 if (null != tmpRankEx)
                                 {
                                     tempRankExList.Add(tmpRankEx);
                                 }
                                 else
                                 {
                                     tempRankExList.Add(new InputKingPaiHangDataEx());
                                     flag = true;
                                 }
                                 if (flag)
                                 {
                                     break;
                                 }
                                 timeLoop = timeLoop.AddDays(1.0);
                             }
                             if (flag)
                             {
                                 break;
                             }
                             if (!dict.ContainsKey(i))
                             {
                                 dict.Add(i, tempRankExList);
                             }
                         }
                     }
                     if (flag)
                     {
                         this.rankExList = new List <InputKingPaiHangDataEx>();
                     }
                     else
                     {
                         this.rankExList = this.MergePlatfromInputKingListEveryDay(dict);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, "PlatChargeKingManager.Update exception", ex, true);
     }
 }
Ejemplo n.º 9
0
        public static bool UpdateDataFromServer()
        {
            if (Monitor.TryEnter(MutexServerList))
            {
                try
                {
                    int nextServerListAge       = DataHelper2.UnixSecondsNow();
                    int nextServerGameConfigAge = DataHelper2.UnixSecondsNow();
                    if (Math.Abs(nextServerListAge - _ServerListAge) < 3)
                    {
                        return(false);
                    }

                    if (!LoadConfigFromServer)
                    {
                        return(false);
                    }

                    //确认是否配置了获取接口地址
                    if (string.IsNullOrEmpty(KuaFuServerListUrl) || string.IsNullOrEmpty(ServerListUrl))
                    {
                        return(false);
                    }

                    //首先获取普通服务器列表
                    //1其次获取跨服活动服务器列表
                    ClientServerListData clientListData = new ClientServerListData();
                    clientListData.lTime  = TimeUtil.NOW();
                    clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                    byte[] clientBytes  = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                    byte[] responseData = WebHelper.RequestByPost(ServerListUrl, clientBytes, 2000, 30000);
                    if (responseData == null)
                    {
                        return(false);
                    }

                    bool               serverInfoChanged = false;
                    HashSet <int>      existAllIds       = new HashSet <int>();
                    HashSet <int>      existKfIds        = new HashSet <int>();
                    BuffServerListData serverListResponseData;
                    BuffServerListData kuaFuServerListResponseData;
                    serverListResponseData = DataHelper2.BytesToObject <BuffServerListData>(responseData, 0, responseData.Length);
                    if (null == serverListResponseData || null == serverListResponseData.listServerData || serverListResponseData.listServerData.Count == 0)
                    {
                        return(false);
                    }

                    //其次获取跨服活动服务器列表
                    clientListData        = new ClientServerListData();
                    clientListData.lTime  = TimeUtil.NOW();
                    clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                    clientBytes           = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                    responseData          = WebHelper.RequestByPost(KuaFuServerListUrl, clientBytes, 2000, 30000);
                    if (responseData == null)
                    {
                        return(false);
                    }

                    kuaFuServerListResponseData = DataHelper2.BytesToObject <BuffServerListData>(responseData, 0, responseData.Length);
                    if (null == kuaFuServerListResponseData || null == kuaFuServerListResponseData.listServerData || kuaFuServerListResponseData.listServerData.Count == 0)
                    {
                        return(false);
                    }

                    if (null != serverListResponseData && null != serverListResponseData.listServerData)
                    {
                        lock (Mutex)
                        {
                            foreach (var item in serverListResponseData.listServerData)
                            {
                                existAllIds.Add(item.nServerID);
                                KuaFuServerInfo data;
                                if (UpdateServerInfo(item, _ServerListAge, ServerFlags.NormalServer, out data, _ServerIdServerInfoDict))
                                {
                                    serverInfoChanged = true;
                                }
                            }
                        }
                    }

                    if (null != kuaFuServerListResponseData && null != kuaFuServerListResponseData.listServerData)
                    {
                        lock (Mutex)
                        {
                            foreach (var item in kuaFuServerListResponseData.listServerData)
                            {
                                existAllIds.Add(item.nServerID);
                                KuaFuServerInfo data;
                                if (UpdateServerInfo(item, _ServerListAge, ServerFlags.KuaFuServer, out data, _ServerIdServerInfoDict))
                                {
                                    serverInfoChanged = true;
                                }
                            }

                            foreach (var id in _ServerIdServerInfoDict.Keys)
                            {
                                if (!existAllIds.Contains(id))
                                {
                                    RemoveServerInfo(id, _ServerIdServerInfoDict);
                                    serverInfoChanged = true;
                                }
                            }

                            if (serverInfoChanged)
                            {
                                _ServerListAge = nextServerListAge;
                            }

                            //默认所有跨服服务器都允许分配幻影寺院活动
                            foreach (var item in _ServerIdServerInfoDict.Values)
                            {
                                if ((item.Flags & ServerFlags.KuaFuServer) > 0)
                                {
                                    existKfIds.Add(item.ServerId);
                                }

                                item.Age = _ServerListAge;
                            }
                        }
                    }

                    ClientAgentManager.Instance().SetAllKfServerId(existKfIds);
                }
                catch (System.Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                finally
                {
                    Monitor.Exit(MutexServerList);
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        private bool CheckBuildZhengBaRank(int selectRoleIfNewCreate, int nowMonth)
        {
            bool bMonthFirst = false;

            try
            {
                DbHelperMySQL.ExecuteSql(string.Format("INSERT IGNORE INTO t_async(`id`,`value`) VALUES({0},{1});", 30, 201111));
                int    oldMonth           = (int)DbHelperMySQL.GetSingle("select value from t_async where id = " + 30);
                object ageObj_tiantiMonth = DbHelperMySQL.GetSingle("select value from t_async where id = " + 4);
                if (oldMonth != nowMonth && ageObj_tiantiMonth != null && ZhengBaUtils.MakeMonth(DataHelper2.GetRealDate((int)ageObj_tiantiMonth)) == nowMonth)
                {
                    string          strSql = string.Format("SELECT rid,rname,zoneid,duanweiid,duanweijifen,duanweirank,zhanli,data1,data2 FROM t_tianti_month_paihang ORDER BY duanweirank ASC LIMIT {0};", selectRoleIfNewCreate);
                    MySqlDataReader sdr    = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        ZhengBaRoleInfoData roleData = new ZhengBaRoleInfoData();
                        roleData.RoleId       = Convert.ToInt32(sdr["rid"]);
                        roleData.ZoneId       = Convert.ToInt32(sdr["zoneid"]);
                        roleData.DuanWeiId    = Convert.ToInt32(sdr["duanweiid"]);
                        roleData.DuanWeiJiFen = Convert.ToInt32(sdr["duanweijifen"]);
                        roleData.DuanWeiRank  = Convert.ToInt32(sdr["duanweirank"]);
                        roleData.ZhanLi       = Convert.ToInt32(sdr["zhanli"]);
                        roleData.RoleName     = sdr["rname"].ToString();
                        if (!sdr.IsDBNull(sdr.GetOrdinal("data1")))
                        {
                            roleData.TianTiPaiHangRoleData = (byte[])sdr["data1"];
                        }
                        if (!sdr.IsDBNull(sdr.GetOrdinal("data2")))
                        {
                            roleData.PlayerJingJiMirrorData = (byte[])sdr["data2"];
                        }
                        if (string.IsNullOrEmpty(roleData.RoleName) && roleData.TianTiPaiHangRoleData != null)
                        {
                            TianTiPaiHangRoleData_OnlyName onlyName = DataHelper2.BytesToObject <TianTiPaiHangRoleData_OnlyName>(roleData.TianTiPaiHangRoleData, 0, roleData.TianTiPaiHangRoleData.Length);
                            if (onlyName != null)
                            {
                                roleData.RoleName = onlyName.RoleName;
                            }
                        }
                        string repSql = string.Format("REPLACE INTO t_zhengba_roles(`month`,rid,zoneid,duanweiid,duanweijifen,duanweirank,zhanli,`grade`,`group`,state,rname,data1,data2) VALUES({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},'{10}',@content,@mirror)", new object[]
                        {
                            nowMonth,
                            roleData.RoleId,
                            roleData.ZoneId,
                            roleData.DuanWeiId,
                            roleData.DuanWeiJiFen,
                            roleData.DuanWeiRank,
                            roleData.ZhanLi,
                            100,
                            0,
                            0,
                            roleData.RoleName
                        });
                        DbHelperMySQL.ExecuteSqlInsertImg(repSql, new List <Tuple <string, byte[]> >
                        {
                            new Tuple <string, byte[]>("content", roleData.TianTiPaiHangRoleData),
                            new Tuple <string, byte[]>("mirror", roleData.PlayerJingJiMirrorData)
                        });
                    }
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                    DbHelperMySQL.ExecuteSql(string.Format("REPLACE INTO t_async(`id`,`value`) VALUES({0},{1});", 30, nowMonth));
                    bMonthFirst = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
            return(bMonthFirst);
        }