コード例 #1
0
        /// <summary>
        /// 载入道具返回
        /// </summary>
        /// <param name="dbi"></param>
        private void loadBack(DbAccessItem dbi)
        {
            if (dbi.Result.ErrCode != 0)
            {
                SvLogger.Error("DB Access Fail : Op=Load Item, ErrMsg={0}, Data={1}.", dbi.Result.ErrMsg, dbi.SpName);
            }
            else
            {
                DataTable dt = dbi.OutDs.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    TItem t = new TItem();
                    t.id   = HTBaseFunc.NullToLong(dr["ID"]);
                    t.name = HTBaseFunc.NullToStr(dr["Name"]);
                    t.desc = HTBaseFunc.NullToStr(dr["Desc"]);
                    string        marksStr  = HTBaseFunc.NullToStr(dr["Marks"]);
                    List <string> marksList = MarksStringToList(marksStr);
                    t.marks = new TStrList();
                    t.marks.GetElements().AddRange(marksList);
                    Item i = new Item(t);
                    m_itemDic[t.id] = i;
                }

                DataLoadManager.Instance.AddLoadSuccTableCount();
            }

            OnLoadDataFromDBFinish(dbi.Result.ErrCode == 0);
        }
コード例 #2
0
        /// <summary>
        /// 载入道具返回
        /// </summary>
        /// <param name="dbi"></param>
        private void loadBack(DbAccessItem dbi)
        {
            if (dbi.Result.ErrCode != 0)
            {
                SvLogger.Error("DB Access Fail : Op=Load Shipping, ErrMsg={0}, Data={1}.", dbi.Result.ErrMsg, dbi.SpName);
            }
            else
            {
                DataTable dt = dbi.OutDs.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    TShipping t = new TShipping();
                    t.id       = HTBaseFunc.NullToLong(dr["ID"]);
                    t.name     = HTBaseFunc.NullToStr(dr["Name"]);
                    t.desc     = HTBaseFunc.NullToStr(dr["Desc"]);
                    t.country  = HTBaseFunc.NullToStr(dr["Country"]);
                    t.address  = HTBaseFunc.NullToStr(dr["Addres"]);
                    t.tel      = HTBaseFunc.NullToStr(dr["Tel"]);
                    t.linkMans = LinkmanStringToList(HTBaseFunc.NullToStr(dr["linkman"]));
                    Shipping s = new Shipping(t);
                    m_shippingDic[s.m_Data.id] = s;
                }

                DataLoadManager.Instance.AddLoadSuccTableCount();
            }

            OnLoadDataFromDBFinish(dbi.Result.ErrCode == 0);
        }
コード例 #3
0
        /// <summary>
        /// 载入道具返回
        /// </summary>
        /// <param name="dbi"></param>
        private void loadBack(DbAccessItem dbi)
        {
            if (dbi.Result.ErrCode != 0)
            {
                SvLogger.Error("DB Access Fail : Op=Load Account, ErrMsg={0}, Data={1}.", dbi.Result.ErrMsg, dbi.SpName);
            }
            else
            {
                DataTable dt = dbi.OutDs.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    TAccount t = new TAccount();
                    t.account    = HTBaseFunc.NullToStr(dr["LoginName"]);
                    t.token      = HTBaseFunc.NullToStr(dr["Token"]);
                    t.showName   = HTBaseFunc.NullToStr(dr["ShowName"]);
                    t.power      = HTBaseFunc.NullToInt(dr["Power"]);
                    t.createTime = HTBaseFunc.NullToDateTime(dr["CreateTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                    Account acc = new Account(t);
                    m_dataDic[acc.m_Data.account] = acc;
                }

                DataLoadManager.Instance.AddLoadSuccTableCount();
            }

            OnLoadDataFromDBFinish(dbi.Result.ErrCode == 0);
        }
コード例 #4
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
        /// <summary>
        /// 检查调用保护,返回剩余秒数
        /// </summary>
        /// <param name="campid">匹配ID</param>
        /// <param name="calledOper">调用操作</param>
        /// <param name="allowInterval">允许的间隔,毫秒级</param>
        /// <returns>返回剩余的间隔</returns>
        public int CheckCall(string campid, string calledOper, int allowInterval)
        {
            Hashtable callHash = (Hashtable)_callProtectList[campid];

            if (callHash == null)
            {
                return(0);
            }
            else
            {
                if (callHash.Contains(calledOper))
                {
                    DateTime endCall = HTBaseFunc.NullToDateTime(callHash[calledOper]).AddMilliseconds(allowInterval);
                    DateTime dtNow   = HTBaseFunc.GetTime(0);
                    if (endCall > dtNow)
                    {
                        TimeSpan ts = (TimeSpan)(endCall - dtNow);
                        return((int)ts.TotalMilliseconds);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// 处理SqlLog记录
        /// </summary>
        /// <param name="dbi">要记录</param>
        /// <param name="pos"></param>
        /// <param name="translist"></param>
        /// <returns></returns>
        private void DoSqlLog(DbAccessItem dbi, int pos, ArrayList translist)
        {
            try
            {
                if (_sqlLogPool != null)
                {
                    DateTime  dtNow        = HTBaseFunc.GetTime(0);
                    string    occurgroup   = ((pos == 0) ? "" : Environment.TickCount.ToString() + "_" + pos.ToString());
                    ArrayList newtranslist = new ArrayList();

                    ArrayList oParams = new ArrayList();
                    HTDBBaseFunc.StoredProcedureParam lSPparam;
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_poolFlag", "int", _poolFlag, false);
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_recTime", "datetime", dtNow, false);
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_recSql", "text", GenSql(dbi), false);
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_execResult", "int", ((dbi.Result.ErrCode == 0) ? 0 : 1), false);//执行结果:0-成功,1-错误,2-未执行
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_errMsg", "text", ((dbi.Result.ErrCode == 0) ? "" : dbi.Result.ErrMsg), false);
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_occurGroup", "string", occurgroup, false);
                    oParams.Add(lSPparam);
                    lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_occurPos", "int", pos, false);
                    oParams.Add(lSPparam);
                    newtranslist.Add(new DbAccessItem("xsp_AddSqlLog", oParams, null, null, true));

                    if (translist != null && translist.Count > 0)
                    {
                        for (int i = pos + 1; i < translist.Count; i++)
                        {
                            DbAccessItem ldbi = (DbAccessItem)translist[i];
                            oParams  = new ArrayList();
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_poolFlag", "int", _poolFlag, false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_recTime", "datetime", dtNow, false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_recSql", "blob", GenSql(ldbi), false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_execResult", "int", 2, false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_errMsg", "text", "", false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_occurGroup", "string", occurgroup, false);
                            oParams.Add(lSPparam);
                            lSPparam = DbAccessPool._sqlLogPool.DbComponent.GenStoredProcedureParam("p_occurPos", "int", i, false);
                            oParams.Add(lSPparam);
                            newtranslist.Add(new DbAccessItem("xsp_AddSqlLog", oParams, null, null, true));
                        }
                    }

                    _sqlLogPool.Push(newtranslist);
                }
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex, "DoSqlLog error : {0}.", ex.Message);
            }
        }
コード例 #6
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
        private Hashtable _callProtectList = new Hashtable();//以campid为key存储Hashtable(以操作名为key存储上次操作时间)

        /// <summary>
        /// 添加调用保护
        /// </summary>
        /// <param name="campid">匹配ID</param>
        /// <param name="calledOper">调用操作</param>
        public void AddCall(string campid, string calledOper)
        {
            Hashtable callHash = (Hashtable)_callProtectList[campid];

            if (callHash == null)
            {
                callHash = new Hashtable();
                _callProtectList.Add(campid, callHash);
            }

            callHash[calledOper] = HTBaseFunc.GetTime(0);
        }
コード例 #7
0
        public TXDGatewayCfgData XDGatewayServerRunParamConver(string[] runParams, out string moniteorIP, out int moniteorPort)
        {
            TXDGatewayCfgData cfgData = new TXDGatewayCfgData();

            cfgData.gameID       = Convert.ToInt32(runParams[1]);
            cfgData.index        = Convert.ToInt32(runParams[2]);
            cfgData.machineName  = runParams[3];
            cfgData.insideIPAddr = runParams[4];
            cfgData.insidePort   = Convert.ToInt32(runParams[5]);
            cfgData.outsidePort  = Convert.ToInt32(runParams[6]);
            moniteorIP           = HTBaseFunc.DepartStr(runParams[7], ",", 0);
            moniteorPort         = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[7], ",", 1));
            return(cfgData);
        }
コード例 #8
0
        public TWorldBossServerCfgData WorldBossServerRunParamConver(string[] runParams, out string moniteorSvrAddr, out int moniteorSvrPort)
        {
            moniteorSvrAddr = "";
            moniteorSvrPort = 0;
            TWorldBossServerCfgData cfgData = new TWorldBossServerCfgData();

            cfgData.gameID             = Convert.ToInt32(runParams[1]);
            cfgData.serverID           = Convert.ToInt32(runParams[2]);
            cfgData.lanIPAddr          = runParams[3];
            cfgData.inPort             = Convert.ToInt32(runParams[4]);
            cfgData.centerServer       = new TStrKeyValue();
            cfgData.centerServer.key   = HTBaseFunc.DepartStr(runParams[5], ",", 0);
            cfgData.centerServer.value = HTBaseFunc.DepartStr(runParams[5], ",", 1);
            moniteorSvrAddr            = HTBaseFunc.DepartStr(runParams[6], ",", 0);
            moniteorSvrPort            = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[6], ",", 1));

            return(cfgData);
        }
コード例 #9
0
 /// <summary>
 /// 打印Fatal日志
 /// </summary>
 /// <param name="err">异常对象</param>
 /// <param name="description">错误描述</param>
 /// <param name="param">错误参数</param>
 public static void Fatal(Exception err, string description, params object[] param)
 {
     if (_logger != null)
     {
         if (err.Message.Contains("OutOfMemoryException"))
         {
             try
             {
                 long usedMem  = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
                 long availMem = HTBaseFunc.GetMemoryAvailable();
                 description += string.Format("(CurrUseMem = {0}MB, CurrAvailMem = {1}MB)", usedMem / 1024 / 1024, availMem / 1024 / 1024);
             }
             catch
             {
                 description += "(GetMemFail)";
             }
         }
         _logger.Fatal(err, description, param);
     }
 }
コード例 #10
0
        public TGateWayCfgData GateWayServerRunParamConvert(string[] runParams, out string protalSvrAddr, out int protalSvrPort)
        {
            protalSvrAddr = "";
            protalSvrPort = 0;
            TGateWayCfgData cfgData = new TGateWayCfgData();

            cfgData.gameID    = Convert.ToInt32(runParams[1]);
            cfgData.serverID  = Convert.ToInt32(runParams[2]);
            cfgData.index     = Convert.ToInt32(runParams[3]);
            cfgData.wanIPAddr = runParams[4];
            cfgData.outShortConnectionPort = Convert.ToInt32(runParams[5]);
            cfgData.outLongConnectionPort  = Convert.ToInt32(runParams[6]);
            cfgData.inPort             = Convert.ToInt32(runParams[7]);
            cfgData.centerServer       = new TStrKeyValue();
            cfgData.centerServer.key   = HTBaseFunc.DepartStr(runParams[8], ",", 0);
            cfgData.centerServer.value = HTBaseFunc.DepartStr(runParams[8], ",", 1);
            protalSvrAddr = HTBaseFunc.DepartStr(runParams[9], ",", 0);
            protalSvrPort = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[9], ",", 1));

            return(cfgData);
        }
コード例 #11
0
        public TPortalServerCfgData PortalServerRunParamConvert(string[] runParams, out string moniteorSvrAddr, out int moniteorSvrPort)
        {
            moniteorSvrAddr = "";
            moniteorSvrPort = 0;
            TPortalServerCfgData cfgData = new TPortalServerCfgData();

            cfgData.gameID                      = Convert.ToInt32(runParams[1]);
            cfgData.index                       = Convert.ToInt32(runParams[2]);
            cfgData.wanIPAddr                   = runParams[3];
            cfgData.outPort                     = Convert.ToInt32(runParams[4]);
            cfgData.inPort                      = Convert.ToInt32(runParams[5]);
            cfgData.platformDockingServer       = new TIDStrKeyValue();
            cfgData.platformDockingServer.Key   = HTBaseFunc.DepartStr(runParams[6], ",", 0);
            cfgData.platformDockingServer.Value = HTBaseFunc.DepartStr(runParams[6], ",", 1);
            cfgData.pushNotice                  = runParams[7];

            moniteorSvrAddr = HTBaseFunc.DepartStr(runParams[8], ",", 0);
            moniteorSvrPort = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[8], ",", 1));

            return(cfgData);
        }
コード例 #12
0
        public TRankServerCfgData RankServerRunParamConvert(string[] runParams, out string protalSvrAddr, out int protalSvrPort)
        {
            protalSvrAddr = "";
            protalSvrPort = 0;
            TRankServerCfgData cfgData = new TRankServerCfgData();

            cfgData.gameID             = Convert.ToInt32(runParams[1]);
            cfgData.serverID           = Convert.ToInt32(runParams[2]);
            cfgData.lanIPAddr          = runParams[3];
            cfgData.inPort             = Convert.ToInt32(runParams[4]);
            cfgData.centerServer       = new TStrKeyValue();
            cfgData.centerServer.key   = HTBaseFunc.DepartStr(runParams[5], ",", 0);
            cfgData.centerServer.value = HTBaseFunc.DepartStr(runParams[5], ",", 1);

            cfgData.dbCfgList = new TDBCfgList();
            int    index  = 0;
            string curStr = HTBaseFunc.DepartStr(runParams[6], ";", index);

            while (curStr != "")
            {
                TDBCfg dbCfg = new TDBCfg();
                dbCfg.dbType         = Convert.ToInt32(HTBaseFunc.DepartStr(curStr, ",", 0));
                dbCfg.lanIPAddr      = HTBaseFunc.DepartStr(curStr, ",", 1);
                dbCfg.dbName         = HTBaseFunc.DepartStr(curStr, ",", 2);
                dbCfg.loginName      = HTBaseFunc.DepartStr(curStr, ",", 3);
                dbCfg.passworld      = HTBaseFunc.DepartStr(curStr, ",", 4);
                dbCfg.port           = Convert.ToInt32(HTBaseFunc.DepartStr(curStr, ",", 5));
                dbCfg.childConnCount = Convert.ToInt32(HTBaseFunc.DepartStr(curStr, ",", 6));

                cfgData.dbCfgList.Add(dbCfg);

                ++index;
                curStr = HTBaseFunc.DepartStr(runParams[6], ";", index);
            }

            protalSvrAddr = HTBaseFunc.DepartStr(runParams[7], ",", 0);
            protalSvrPort = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[7], ",", 1));

            return(cfgData);
        }
コード例 #13
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
        private void CheckTimeOut(int times, long elapsed, long TimerID, object param)
        {
            if (_requestaddlist.Count > 0)
            {
                DateTime dtnow = HTBaseFunc.GetTime(0);

looprpt:
                DateTime expiretime = _requestaddlist.Keys[0];
                List <long> protectidlist = _requestaddlist[expiretime];
                if (expiretime <= dtnow)
                {
                    for (int i = protectidlist.Count - 1; i >= 0; i--)
                    {
                        long pid = protectidlist[i];
                        DelRequestProtect(pid);
                    }
                    _requestaddlist.Remove(expiretime);
                    if (_requestaddlist.Count > 0)
                    {
                        goto looprpt;
                    }
                }
            }
        }
コード例 #14
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
        /// <summary>
        /// 添加请求保护
        /// </summary>
        /// <param name="userid">玩家ID</param>
        /// <param name="calledOper">调用操作</param>
        /// <param name="callTime">调用时间</param>
        /// <param name="holdIntervals">保持时长,毫秒级</param>
        /// <param name="args">参数列表,注意最后面要留2个空位以内部填入保护ID和调用时间</param>
        /// <returns>成功返回大于0的ProtectID,否则返回0</returns>
        private long AddRequestProtect(int userid, string calledOper, DateTime callTime, int holdIntervals, object[] args)
        {
            long     protectid = 0;
            DateTime dtnow     = HTBaseFunc.GetTime(0);
            DateTime expiretime;

            if (holdIntervals < 0)
            {
                expiretime = HTBaseFunc.NullDateTime;
            }
            else
            {
                expiretime = callTime.AddMilliseconds(holdIntervals);
            }

            Dictionary <string, object[]> operlist = null;

            if (_requestProtectList.ContainsKey(userid))
            {
                operlist = (Dictionary <string, object[]>)_requestProtectList[userid];
            }
            else
            {
                operlist = new Dictionary <string, object[]>();
                _requestProtectList.Add(userid, operlist);
            }

            object[] arglist = null;
            if (operlist.ContainsKey(calledOper))
            {
                arglist = operlist[calledOper];
                long     oldprotectid  = (long)arglist[arglist.Length - 2];
                DateTime oldexpiretime = Convert.ToDateTime(arglist[arglist.Length - 1]);
                if (oldexpiretime <= dtnow && oldexpiretime > HTBaseFunc.NullDateTime)
                {
                    //删除原来过期的
                    operlist.Remove(calledOper);
                    _requestidlist.Remove(oldprotectid);
                    if (_requestaddlist.ContainsKey(oldexpiretime))
                    {
                        _requestaddlist[oldexpiretime].Remove(oldprotectid);
                        if (_requestaddlist[oldexpiretime].Count == 0)
                        {
                            _requestaddlist.Remove(oldexpiretime);
                        }
                    }

                    //添加新的
                    arglist   = args;
                    protectid = GetProtectID();
                    if (protectid > 0)
                    {
                        arglist[arglist.Length - 2] = protectid;
                        arglist[arglist.Length - 1] = expiretime;
                        operlist.Add(calledOper, arglist);
                    }
                }
            }
            else
            {
                arglist   = args;
                protectid = GetProtectID();
                if (protectid > 0)
                {
                    arglist[arglist.Length - 2] = protectid;
                    arglist[arglist.Length - 1] = expiretime;
                    operlist.Add(calledOper, arglist);
                }
            }

            if (operlist.Count == 0)
            {
                _requestProtectList.Remove(userid);
            }

            if (protectid > 0)
            {
                _requestidlist[protectid] = new object[] { userid, calledOper };

                if (expiretime > HTBaseFunc.NullDateTime)
                {
                    List <long> protectidlist = null;
                    if (_requestaddlist.ContainsKey(expiretime))
                    {
                        protectidlist = _requestaddlist[expiretime];
                    }
                    else
                    {
                        protectidlist = new List <long>();
                        _requestaddlist.Add(expiretime, protectidlist);
                    }
                    protectidlist.Add(protectid);
                }
            }

            return(protectid);
        }
コード例 #15
0
        private string GenSql(DbAccessItem dbi)
        {
            if (dbi.IsSqlRun)
            {
                return(dbi.SpName);
            }
            else
            {
                string sql = "", outsql = "";
                try
                {
                    HTDBBaseFunc.ConnectionTypeEnum dbtype = GetConnectType(_dbType);
                    if (dbtype == HTDBBaseFunc.ConnectionTypeEnum.MySql || dbtype == HTDBBaseFunc.ConnectionTypeEnum.MySqlUseTran)
                    {
                        for (int i = 0; i < dbi.SpParams.Count; i++)
                        {
                            if (sql != "")
                            {
                                sql += ", ";
                            }

                            HTDBBaseFunc.StoredProcedureParam sparm = (HTDBBaseFunc.StoredProcedureParam)dbi.SpParams[i];
                            if (sparm.Type.Trim().ToLower() == "image" || sparm.Type.Trim().ToLower() == "blob")
                            {
                                if (outsql != "")
                                {
                                    outsql += "\n";
                                }
                                string pname = "@p" + i.ToString();
                                outsql += "set " + pname + "=" + HTBaseFunc.GetSqledValue(sparm.Value.GetType(), sparm.Value);
                                sql    += pname;
                            }
                            else
                            {
                                if (sparm.Direction == ParameterDirection.Output || sparm.Direction == ParameterDirection.InputOutput)
                                {
                                    if (outsql != "")
                                    {
                                        outsql += "\n";
                                    }
                                    string pname = "@p" + i.ToString();
                                    outsql += "set " + pname + "=" + HTBaseFunc.GetSqledValue(sparm.Value.GetType(), sparm.Value);
                                    if (sparm.Direction == ParameterDirection.Output)
                                    {
                                        sql += "out " + pname;
                                    }
                                    else
                                    {
                                        sql += "inout " + pname;
                                    }
                                }
                                else
                                {
                                    sql += HTBaseFunc.GetSqledValue(sparm.Value.GetType(), sparm.Value);
                                }
                            }
                        }
                        sql = "call " + dbi.SpName + "(" + sql + ");";
                    }
                    else if (dbtype == HTDBBaseFunc.ConnectionTypeEnum.Sql || dbtype == HTDBBaseFunc.ConnectionTypeEnum.SqlOleDB || dbtype == HTDBBaseFunc.ConnectionTypeEnum.SybaseOleDB ||
                             dbtype == HTDBBaseFunc.ConnectionTypeEnum.Oracle)
                    {
                        for (int i = 0; i < dbi.SpParams.Count; i++)
                        {
                            if (sql != "")
                            {
                                sql += ", ";
                            }

                            HTDBBaseFunc.StoredProcedureParam sparm = (HTDBBaseFunc.StoredProcedureParam)dbi.SpParams[i];
                            sql += sparm.Name + "=" + HTBaseFunc.GetSqledValue(sparm.Value.GetType(), sparm.Value);
                            if (sparm.Direction == ParameterDirection.Output || sparm.Direction == ParameterDirection.InputOutput)
                            {
                                sql += " output";
                            }
                        }
                        sql = "exec " + dbi.SpName + " " + sql + ";";
                    }
                    if (outsql != "")
                    {
                        sql = outsql + "\n" + sql;
                    }
                }
                catch (Exception ex)
                {
                    sql = dbi.SpName + string.Format("(Param generate error : {0})", ex.Message);
                }
                return(sql);
            }
        }
コード例 #16
0
        public TCenterServerCfgData CenterServerRunParamConvert(string[] runParams, out string moniteorSvrAddr, out int moniteorSvrPort)
        {
            moniteorSvrAddr = "";
            moniteorSvrPort = 0;

            TCenterServerCfgData cfgData = new TCenterServerCfgData();

            cfgData.serverGroupName = runParams[1];
            cfgData.gameID          = Convert.ToInt32(runParams[2]);
            cfgData.serverID        = Convert.ToInt32(runParams[3]);
            cfgData.lanIPAddr       = runParams[4];
            cfgData.inPort          = Convert.ToInt32(runParams[5]);

            TIDStrKeyValue idIPPort = new TIDStrKeyValue();

            idIPPort.Key   = HTBaseFunc.DepartStr(runParams[6], ",", 0);
            idIPPort.Value = HTBaseFunc.DepartStr(runParams[6], ",", 1);

            if (idIPPort.Value == "")
            {
                idIPPort.Value = "0";
            }
            cfgData.crossRealmServer = idIPPort;

            cfgData.protalServerList = new TIDStrKeyValueList();
            int    index  = 0;
            string curStr = HTBaseFunc.DepartStr(runParams[7], ";", index);

            while (curStr != "")
            {
                idIPPort       = new TIDStrKeyValue();
                idIPPort.Key   = HTBaseFunc.DepartStr(curStr, ",", 0);
                idIPPort.Value = HTBaseFunc.DepartStr(curStr, ",", 1);
                if (idIPPort.Value == "")
                {
                    idIPPort.Value = "0";
                }
                cfgData.protalServerList.Add(idIPPort);

                ++index;
                curStr = HTBaseFunc.DepartStr(runParams[7], ";", index);
            }

            idIPPort       = new TIDStrKeyValue();
            idIPPort.Key   = HTBaseFunc.DepartStr(runParams[8], ",", 0);
            idIPPort.Value = HTBaseFunc.DepartStr(runParams[8], ",", 1);
            if (idIPPort.Value == "")
            {
                idIPPort.Value = "0";
            }
            cfgData.gmServer = idIPPort;

            idIPPort       = new TIDStrKeyValue();
            idIPPort.Key   = HTBaseFunc.DepartStr(runParams[9], ",", 0);
            idIPPort.Value = HTBaseFunc.DepartStr(runParams[9], ",", 1);
            if (idIPPort.Value == "")
            {
                idIPPort.Value = "0";
            }
            cfgData.platformDockingServer = idIPPort;

            moniteorSvrAddr = HTBaseFunc.DepartStr(runParams[10], ",", 0);
            moniteorSvrPort = Convert.ToInt32(HTBaseFunc.DepartStr(runParams[10], ",", 1));

            return(cfgData);
        }
コード例 #17
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
 /// <summary>
 /// 添加请求保护(持久保护直到删除)
 /// </summary>
 /// <param name="userid">玩家ID</param>
 /// <param name="calledOper">调用操作</param>
 /// <returns>成功返回大于0的ProtectID,否则返回0</returns>
 public long AddRequestProtect(int userid, string calledOper, object[] args)
 {
     return(AddRequestProtect(userid, calledOper, HTBaseFunc.GetTime(0), -1, args));
 }
コード例 #18
0
ファイル: SortedParamTimer.cs プロジェクト: zjbsean/TM
 /// <summary>
 /// 获取当前时间加上addInterval以后的时间
 /// </summary>
 /// <param name="addInterval">增加间隔,毫秒级</param>
 /// <returns>返回当前时间加上addInterval以后的时间</returns>
 public static DateTime GetTime(long addInterval)
 {
     return(HTBaseFunc.GetTime(addInterval));
 }
コード例 #19
0
ファイル: SortedParamTimer.cs プロジェクト: zjbsean/TM
 /// <summary>
 /// 获取2个时间之间的间隔
 /// </summary>
 /// <param name="minuendTime">被减的时间</param>
 /// <param name="subtrahendTime">减的时间</param>
 /// <returns>返回间隔</returns>
 public long GetInterval(DateTime minuendTime, DateTime subtrahendTime)
 {
     return(HTBaseFunc.GetInterval(minuendTime, subtrahendTime));
 }
コード例 #20
0
        /// <summary>
        /// 服务逻辑更新
        /// </summary>
        public void Update()
        {
            try
            {
                #region 协议处理
                ClientProtocolDealManager.Instance.TransferRecvClientData(ref m_protocolList);
                if (m_protocolList.Count > 0)
                {
                    for (int i = 0; i < m_protocolList.Count; i++)
                    {
                        try
                        {
                            //ServerProtocolDealManager.Instance.ServerSend2ClientData(clientSessionID, protocolData);
                        }
                        catch (Exception ex)
                        {
                            SvLogger.Fatal(ex, string.Format("Param Proto Exception : {0}\r\nStackTrace : \r\n{1}", ex.Message, ex.StackTrace));
                        }
                    }
                    m_protocolList.Clear();
                }
                #endregion

                #region 数据库回调处理

                List <DbAccessPoolVistor> dapvistorlist = DbAccessPool.GetVistorList();
                for (int i = 0; i < dapvistorlist.Count; i++)
                {
                    DbAccessPoolVistor dapvistor = dapvistorlist[i];
                    int      callbackNum         = dapvistor.GetCallbackNum();
                    int      doBackNum           = 0;
                    int      vStartTick          = Environment.TickCount;
                    int      doStartTick;
                    DateTime doStartTime;
                    while (doBackNum < callbackNum)
                    {
                        doStartTick = Environment.TickCount;
                        doStartTime = HTBaseFunc.GetTime(0);
                        DbAccessItem dbi = dapvistor.PopupCallback();
                        if (dbi != null)
                        {
                            dbi.OnFinish(dbi);
                        }
                        ++doBackNum;
                        int doEndTick    = Environment.TickCount;
                        int doSpendTicks = (doEndTick >= doStartTick ? doEndTick - doStartTick : (int.MaxValue + doEndTick) + (int.MaxValue - doStartTick));
                        if (doSpendTicks >= 1000)
                        {
                            SvLogger.Warn("Update TimeOut : DbAccessPoolCallback {0}, SpendMs = {1}, SpName = {2}, StartTime = {3}.", dapvistor.Flag, doSpendTicks, ((dbi != null) ? dbi.SpName : ""), doStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                        }
                        int vSpendTicks = (doEndTick >= vStartTick ? doEndTick - vStartTick : doEndTick + (int.MaxValue - vStartTick));
                        if (vSpendTicks >= SvrCommCfg.Instance.DbAccessPoolCallbackDealInterval)
                        {
                            break;
                        }
                    }
                }

                #endregion

                #region 定时打印服务器监控信息

                m_svrCheckEndTicket   = Environment.TickCount;
                m_svrCheckSpendTicket = (m_svrCheckEndTicket >= m_svrCheckStartTicket ? m_svrCheckEndTicket - m_svrCheckStartTicket : (int.MaxValue + m_svrCheckEndTicket) + (int.MaxValue - m_svrCheckStartTicket));
                if (m_svrCheckSpendTicket >= 60000)
                {
                    m_svrCheckStartTicket = m_svrCheckEndTicket;
                    ServerCommon.DbAccess.Instance.ShowDBAccCountInPool();
                }

                #endregion

                #region 内存回收

                if (m_lastMemoryCheck.AddSeconds(30) < HTBaseFunc.GetTime(0))
                {
                    if (m_lastGcTime.AddSeconds(30) < HTBaseFunc.GetTime(0) && System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 > 128 * 1024 * 1024)
                    {
                        GC.Collect();
                        m_lastGcTime = HTBaseFunc.GetTime(0);
                    }

                    m_lastMemoryCheck = HTBaseFunc.GetTime(0);
                }

                #endregion
            }
            catch (Exception ex)
            {
                SvLogger.Fatal(ex, string.Format("Main Logic Exception : {0}\r\nStackTrace : \r\n{1}", ex.Message, ex.StackTrace));
            }
        }
コード例 #21
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
 public string AddStatusProtect(string campid, string calledOper)
 {
     return(AddStatusProtect(campid, calledOper, HTBaseFunc.GetTime(0)));
 }
コード例 #22
0
ファイル: LogicProtect.cs プロジェクト: zjbsean/TM
        private long GetProtectID()
        {
            long lastprotectid = _currprotectid;
            bool bfind         = false;

            while (_currprotectid <= long.MaxValue)
            {
                if (_requestidlist.ContainsKey(_currprotectid) || _currprotectid == 0)
                {
                    _currprotectid++;
                }
                else
                {
                    bfind = true;
                    break;
                }
            }
            if (!bfind)
            {
                _currprotectid = 0;
                while (_currprotectid < lastprotectid)
                {
                    if (_requestidlist.ContainsKey(_currprotectid) || _currprotectid == 0)
                    {
                        _currprotectid++;
                    }
                    else
                    {
                        bfind = true;
                        break;
                    }
                }
            }

            if (!bfind)
            {
                DateTime    expiretime    = _requestaddlist.Keys[0];
                List <long> protectidlist = _requestaddlist[expiretime];
                DateTime    dtnow         = HTBaseFunc.GetTime(0);
                if (expiretime <= dtnow)
                {
                    long pid = protectidlist[0];
                    DelRequestProtect(pid);
                    _currprotectid = pid;
                    bfind          = true;
                }
            }

            long protectid = 0;

            if (bfind)
            {
                protectid = _currprotectid;
                if (_currprotectid == int.MaxValue)
                {
                    _currprotectid = 0;
                }
                else
                {
                    _currprotectid++;
                }
            }
            return(protectid);
        }