Exemplo n.º 1
0
    // 查到结果
    private void onFindPlayer(Dictionary <string, object> data, string guid, object param)
    {
        if (data == null || param == null)
        {
            return;
        }

        try
        {
            if (data.ContainsKey("IsBot"))
            {
                bool isbot = Convert.ToBoolean(data["IsBot"]);
                // 是机器人就加
                if (isbot)
                {
                    AddMoneyParam p        = (AddMoneyParam)param;
                    int           playerid = Convert.ToInt32(data["Id"]);
                    _addPlayerMoney(playerid, p.m_gold, p.m_gem, p.m_dbId);
                }
            }
            else
            {
                LOG.Info("批量查询玩家数据时,有错,玩家guid [{0}]", guid);
            }
        }
        catch (System.Exception ex)
        {
            LOG.Info(ex.Message);
            LOG.Info(ex.StackTrace);
        }
    }
Exemplo n.º 2
0
 // 将数据保存到tablename内
 public bool save(string tablename, Dictionary <string, object> data, IMongoQuery query, int serverid, int dbid)
 {
     if (data == null)
     {
         return(false);
     }
     try
     {
         Dictionary <string, object> tmp = m_mongoServer[serverid].getDB(dbid).ExecuteGetByQuery(tablename, query);
         // 没有数据,新插入一行
         if (tmp == null)
         {
             return(m_mongoServer[serverid].getDB(dbid).ExecuteInsert(tablename, data));
         }
         else // 有,则替换
         {
             return(m_mongoServer[serverid].getDB(dbid).ExecuteStoreByQuery(tablename, query, data));
         }
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.ToString());
     }
     return(false);
 }
Exemplo n.º 3
0
        public void _Init()
        {
            float start = JHSTime.Time;

            dbService     = DbService.Instance;
            leagueManager = LeagueManager.Instance;
            leagueManager.RequiredGames = Settings.MIN_GAMES_TO_DECIDE_RANKING_SKILLS;
            List <RankConfig> configs = ConfigManager.GetRankConfigs();

            leagueManager._Configure(configs);
            leagueManager.OnPlayerChanged  = OnPlayerChanged;
            leagueManager.OnPlayerDemoted  = OnPlayerDemoted;
            leagueManager.OnPlayerPromoted = OnPlayerPromoted;
            leagueManager.OnPlayerRemoved  = OnPlayerRemoved;
            foreach (RankConfig config in configs)
            {
                LeagueType rank = config.RankId;

                IList <Rankings> usr = DbService.Instance.GetRank(rank);
                foreach (Rankings usrrank in usr)
                {
                    RankinngOBJ obj = dbService.GetRankinData(new RankinngOBJ(usrrank.UserId, usrrank.PlayerName));
                    if (obj != null)
                    {
                        KnownPlayers.Add(usrrank.UserId, obj);
                        leagueManager._AddPlayer(obj.RefLeagueData);
                    }
                }
            }
            LOG.Info("Finished loading ranking, time-consuming:" + (JHSTime.Time - start) + " sec.");
            LOG.Info(leagueManager.ToString());
        }
Exemplo n.º 4
0
    public static bool loadXml <T>(string file, T obj) where T : IUserTabe
    {
        if (obj == null)
        {
            LOG.Info("loadXml 传入了空的引用");
            return(false);
        }

        XmlReader cr = new XmlReader();

        if (!cr.load(file))
        {
            return(false);
        }

        int row = 0;

        cr.gotoLine(row);
        obj.beginRead();
        while (!cr.isFinish())
        {
            obj.readLine(cr);
            row++;
            cr.gotoLine(row);
        }
        obj.endRead();
        return(true);
    }
Exemplo n.º 5
0
    public bool load(string file, char end_flag)
    {
        if (!File.Exists(file))
        {
            LOG.Info("文件[{0}]不存在!", file);
            return(false);
        }

        StreamReader sr   = new StreamReader(file, Encoding.Default);
        string       line = sr.ReadLine();

        if (line != null)
        {
            if (!init(line))
            {
                return(false);
            }
        }

        int row = 0;

        line = readLine(sr, end_flag);//sr.ReadLine();
        while (line != null)
        {
            if (!isEmptyLine(line))
            {
                addLine(line, row);
                row++;
            }
            line = readLine(sr, end_flag); //sr.ReadLine();
        }
        m_totalRows = row;
        sr.Close();
        return(true);
    }
Exemplo n.º 6
0
    public Dictionary <string, object> ExecuteGetByQuery(string table, IMongoQuery queries, string[] fields = null)
    {
        Dictionary <string, object> retval = null;

        try
        {
            var cb   = check_table(table);
            var retf = cb.Find(queries);

            if (fields != null)
            {
                retf = retf.SetFields(fields);
            }

            var it = retf.GetEnumerator();

            if (it.MoveNext())
            {
                if (it.Current.Contains("_id"))
                {
                    it.Current.Remove("_id");
                }
                retval = it.Current.ToDictionary();
            }
            return(retval);
        }
        catch (Exception ex)
        {
            LOG.Info(ex.ToString());
        }
        return(retval);
    }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Api api = new Api();

            try
            {
                api.ServerName = "BattleServer";
                api.Init(args);
            }
            catch (Exception e)
            {
                LOG.Error("{0} init failed:{1}", api.ServerName, e.ToString());
                api.Exit();
                return;
            }

            Thread thread = new Thread(api.Run);

            thread.Start();

            LOG.Info("{0} OnReady..", api.ServerName);

            while (thread.IsAlive)
            {
                api.ProcessInput();
                Thread.Sleep(1000);
            }

            api.Exit();
            LOG.Info("{0} Exit..", api.ServerName);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Console.Title = "Surf Shark Server";
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/Net4Log.xml")));
            configs = new IniFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/Config.ini"));
            AppDomain.CurrentDomain.DomainUnload += CleanupBeforeExit;
            AppDomain.CurrentDomain.ProcessExit  += new EventHandler(CurrentDomain_ProcessExit);
            JHSDebug.LogReciver = new LOG();
            NetConfig.logFilter = JHSLogFilter.Error;
            var v = DbService.GetDBSession;
            var x = UserManager.Instance;

            SharkServer.Start();
WAIT_REGION:

            string line = Console.ReadLine();

            if (line == "exit")
            {
                goto EXIT_REGION;
            }


            goto WAIT_REGION;

EXIT_REGION:
            LOG.Info("Saving Database.");
            if (DbService.ForceQuit())
            {
                LOG.Info("Server is now down.");
            }
        }
        public void GenerateReport()
        {
            LOG.Info("正在写入基础信息...");
            Dictionary <string, string> Pict = new Dictionary <string, string>();
            WordHelper helper = SetReportBasicInfo(true);

            //选择试验生成图片
            //MessageBox.Show("HI");
            if (File.Exists(图片路径))
            {
                if (MainForm.test == 6)
                {
                    //string key = "位移时间曲线";

                    Pict.Add("$动态油缸位移时间曲线$", 图片路径);
                    helper.Insertpicture(Pict);
                    LOG.Debug("正在写入图片");
                    helper.SaveDocument(保存路径);
                }
                else if (MainForm.test == 8)
                {
                    // string key = "负载效率曲线";
                    Pict.Add("$动态油缸负载效率试验曲线$", 图片路径);
                    helper.Insertpicture(Pict);
                    LOG.Debug("正在写入图片");
                    helper.SaveDocument(保存路径);
                }
            }
            else
            {
                LOG.Error("因为本次实验没有保存图片,无法生成试验报告");
            }
            MessageBox.Show("本次试验报告文档保存在项目MainProj的report中,请查收");
        }
Exemplo n.º 10
0
    // 给指定玩家加钱,gold金币, gem钻石
    public bool addPlayerMoney(int playerid, int gold, int gem, GMUser account)
    {
        if (gold < 0 || gem < 0 || account == null)
        {
            LOG.Info("给玩家id [{0}]增加金币时出错,传入的值为负!", playerid);
            return(false);
        }

        bool res = _addPlayerMoney(playerid, gold, gem, account.getDbServerID());

        if (res)
        {
            Dictionary <string, object> data =
                null; // DBMgr.getInstance().getTableData("EtPlayer", "Id", playerid, account.getDbServerID(), DbName.DB_FISH_LORD);
            if (data != null)
            {
                if (data.ContainsKey("IsBot"))
                {
                    bool isbot = Convert.ToBoolean(data["IsBot"]);
                    if (!isbot)
                    {
                        OpLogMgr.getInstance().addLog(LogType.ADD_MONEY, new ParamAddMoney(playerid, gold, gem), account);
                    }
                }
            }
        }
        account.setOpResult(res ? OpRes.opres_success : OpRes.op_res_failed);
        return(res);
    }
Exemplo n.º 11
0
 // 将数据保存到tablename内
 public bool save(string tablename, Dictionary <string, object> data, string filedname, object val, int serverid, int dbid)
 {
     if (data == null)
     {
         return(false);
     }
     try
     {
         Dictionary <string, object> tmp = m_mongoServer[serverid].getDB(dbid).ExecuteGetBykey(tablename, filedname, val);
         // 没有数据,新插入一行
         if (tmp == null)
         {
             return(m_mongoServer[serverid].getDB(dbid).ExecuteInsert(tablename, data));
         }
         else // 有,则替换
         {
             return(m_mongoServer[serverid].getDB(dbid).ExecuteStoreBykey(tablename, filedname, val, data));
         }
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.Message);
         LOG.Info(ex.StackTrace);
     }
     return(false);
 }
Exemplo n.º 12
0
        public void Start()
        {
            float start = JHSTime.Time;

            LOG.Info("Loading database service ...");
            try
            {
                XmlConfigurator.Configure(new Uri(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/Net4Log.xml")));
                config = new Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs/hibernate.xml"));
                Type[] typelist = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "LoginServer.MYSQL.Tables");
                bool   Added    = false;
                for (int i = 0; i < typelist.Length; i++)
                {
                    Added = false;
                    string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
                    xml += "<hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.2\">";
                    xml += "<class name=\"LoginServer.MYSQL.Tables." + typelist[i].Name + ", LoginServer\" table=\"" + typelist[i].Name.ToLower() + "\">";
                    foreach (PropertyInfo prop in typelist[i].GetProperties())
                    {
                        if (prop.GetCustomAttribute(typeof(IndexAttribute)) != null && !Added)
                        {
                            IndexAttribute att = (IndexAttribute)prop.GetCustomAttribute(typeof(IndexAttribute));
                            if (!att.IsEnum)
                            {
                                xml += "<id name=\"" + prop.Name + "\" column=\"" + prop.Name + "\" type=\"" + prop.PropertyType.Name + "\">";
                                if (att.IsAutoGenerate)
                                {
                                    xml += "<generator class=\"native\"></generator>";
                                }
                                xml += "</id>";
                            }
                            else
                            {
                                xml += "<property name=\"" + prop.Name + "\" type =\"" + att.ClassName + "\" />";
                            }
                            Added = true;
                        }
                        else
                        {
                            xml += "<property name=\"" + prop.Name + "\" column=\"" + prop.Name + "\" type =\"" + prop.PropertyType.Name + "\"></property>";
                        }
                    }
                    xml += "</class>";
                    xml += "</hibernate-mapping>";
                    config.AddXmlString(xml);
                }
                factory = config.BuildSessionFactory();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Timer aTimer = new Timer();

            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = UpdateEvery * 1000;
            aTimer.Enabled  = true;
            LOG.Info("Finished loading database service, time-consuming:" + (JHSTime.Time - start) + " sec.");
        }
Exemplo n.º 13
0
 /// <summary>
 /// Make the process use less memory by emptying the working set
 /// </summary>
 public static void EmptyWorkingSet()
 {
     LOG.Info("Calling EmptyWorkingSet");
     using (Process currentProcess = Process.GetCurrentProcess())
     {
         EmptyWorkingSet(currentProcess.Handle);
     }
 }
Exemplo n.º 14
0
 private static void CleanupBeforeExit(object sender, EventArgs e)
 {
     LOG.Info("Saving Database.");
     if (DbService.ForceQuit())
     {
         LOG.Info("Server is now down.");
     }
 }
Exemplo n.º 15
0
 private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
 {
     LOG.Info("Saving Database.");
     if (DbService.ForceQuit())
     {
         LOG.Info("Server is now down.");
     }
 }
Exemplo n.º 16
0
 public MongodbHelper getDB(int index)
 {
     if (index < 0 || index >= DbName.DB_NAME_MAX)
     {
         LOG.Info("获取某数据库服务器上某个db时出错,索引超出范围, index = {0}", index);
         return(null);
     }
     return(m_client[index]);
 }
Exemplo n.º 17
0
 // 发放福利的接口
 public OpRes doGrantBenefit(object param, GrantType type, GMUser user)
 {
     if (!m_items.ContainsKey(type))
     {
         LOG.Info("不存在名称为[{0}]的发放福利功能", type);
         return(OpRes.op_res_failed);
     }
     return(m_items[type].doGrantBenefit(param, user));
 }
Exemplo n.º 18
0
 /// <summary>
 /// The real save implementation, this first disables the watch otherwise we would be informed of our own changes.
 /// </summary>
 /// <param name="iniLocation"></param>
 private static void SaveInternally(string iniLocation)
 {
     WatchConfigFile(false);
     try
     {
         LOG.Info("Saving configuration to: " + iniLocation);
         if (!Directory.Exists(Path.GetDirectoryName(iniLocation)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(iniLocation));
         }
         using (TextWriter writer = new StreamWriter(iniLocation, false, Encoding.UTF8))
         {
             foreach (IniSection section in sectionMap.Values)
             {
                 // Only save EditorConfiguration
                 if (section != null && section.IniSectionAttribute != null && section.IniSectionAttribute.Name == "Editor")
                 {
                     section.Write(writer, false);
                     // Add empty line after section
                     writer.WriteLine();
                     section.IsDirty = false;
                 }
             }
             writer.WriteLine();
             // Write left over properties
             foreach (string sectionName in sections.Keys)
             {
                 // Check if the section is one that is "registered", if so skip it!
                 if (!sectionMap.ContainsKey(sectionName))
                 {
                     writer.WriteLine("; The section {0} hasn't been 'claimed' since the last start of Greenshot, therefor it doesn't have additional information here!", sectionName);
                     writer.WriteLine("; The reason could be that the section {0} just hasn't been used, a plugin has an error and can't claim it or maybe the whole section {0} is obsolete.", sectionName);
                     // Write section name
                     writer.WriteLine("[{0}]", sectionName);
                     Dictionary <string, string> properties = sections[sectionName];
                     // Loop and write properties
                     foreach (string propertyName in properties.Keys)
                     {
                         writer.WriteLine("{0}={1}", propertyName, properties[propertyName]);
                     }
                     writer.WriteLine();
                 }
             }
         }
     }
     finally
     {
         try
         {
             WatchConfigFile(true);
         }
         catch (Exception ex)
         {
             LOG.Error("A problem occured while enabling the WatchConfigFile: ", ex);
         }
     }
 }
Exemplo n.º 19
0
        protected override void InBlock(string shcode, bool isNext = false)
        {
            var szTrCode = _resModel.Name;

            LOG.Debug($"trCountLimit : {_query.GetTRCountLimit(szTrCode)}, trCountRequest : {_query.GetTRCountRequest(szTrCode)}, trCountBaseSec : {_query.GetTRCountBaseSec(szTrCode)}, trCountPerSec : {_query.GetTRCountPerSec(szTrCode)}");
            if (_query.GetTRCountLimit(szTrCode) != 0)
            {
                while (_query.GetTRCountLimit(szTrCode) <= _query.GetTRCountRequest(szTrCode))
                {
                    LOG.Debug($"sleep {szTrCode} {_query.GetTRCountLimit(szTrCode)}, {_query.GetTRCountRequest(szTrCode)}");
                    Thread.Sleep(10000);
                }
            }
            if (isNext == false)
            {
                fi = new FileInfo(Settings.Default.data_path + "\\xing\\" + szTrCode + "-" + shcode + ".csv");
                if (fi.Directory != null && !fi.Directory.Exists)
                {
                    System.IO.Directory.CreateDirectory(fi.DirectoryName);
                }
                fi.Delete();
                var today = DateTime.Now;
                _inBlock = new _t4201InBlock()
                {
                    shcode = shcode,
                    gubun  = "0",
                    ncnt   = 1,
                    qrycnt = 500,
                    tdgb   = "0",
                    sdate  = today.AddDays(-5).ToString("yyyyMMdd"),
                    edate  = today.ToString("yyyyMMdd"),
                };
            }

            var block = _resModel.Blocks[szTrCode + "InBlock"];

            _query.SetFieldData(block.Name, "shcode", 0, _inBlock.shcode);
            _query.SetFieldData(block.Name, "gubun", 0, _inBlock.gubun);
            _query.SetFieldData(block.Name, "ncnt", 0, _inBlock.ncnt.ToString());
            _query.SetFieldData(block.Name, "qrycnt", 0, _inBlock.qrycnt.ToString());
            _query.SetFieldData(block.Name, "tdgb", 0, _inBlock.tdgb);
            _query.SetFieldData(block.Name, "sdate", 0, _inBlock.sdate);
            _query.SetFieldData(block.Name, "edate", 0, _inBlock.edate);
            _query.SetFieldData(block.Name, "cts_date", 0, _inBlock.cts_date);
            _query.SetFieldData(block.Name, "cts_time", 0, _inBlock.cts_time);
            _query.SetFieldData(block.Name, "cts_daygb", 0, _inBlock.cts_daygb);
            _query.Request(isNext);
            LOG.Info("s==============InBlock=================");
            LOG.Info("===========  GetTrCode");
            LOG.Info(_query.GetTrCode());
            LOG.Info("===========  GetTrDesc");
            LOG.Info(_query.GetTrDesc());
            LOG.Info("===========  InBlock Data");
            LOG.Info(PrintUtil.PrintProperties(_inBlock));
            LOG.Info("e==============InBlock=================");
        }
Exemplo n.º 20
0
 public override void init()
 {
     LOG.Info("AccountBalance: " + AccountBalance());
     LOG.Info("AccountCompany: " + AccountCompany());
     LOG.Info("AccountEquity: " + AccountEquity());
     LOG.Info("AccountFreeMargin: " + AccountFreeMargin());
     LOG.Info("AccountName: " + AccountName());
     LOG.Info("AccountNumber: " + AccountNumber());
     ObjectCreate(ChartID(), "test", OBJECT_TYPE.OBJ_TREND, 0, DateTime.Now.AddDays(-1), iHigh(Symbol(), (int)TIMEFRAME.PERIOD_D1, 1), DateTime.Now.AddDays(+1), 1.086);
     LOG.Info("init() done: ");
 }
Exemplo n.º 21
0
    public FieldCsv fetch(string col_name)
    {
        if (!m_nameToCol.ContainsKey(col_name))
        {
            LOG.Info("表格中列名[{0}]不存在!", col_name);
            return(null);
        }
        int col = m_nameToCol[col_name];

        return(get(m_curRow, col));
    }
Exemplo n.º 22
0
 public void RemoveServer(uint connectionId)
 {
     lock (servers)
     {
         if (!servers.ContainsKey(connectionId))
         {
             return;
         }
         servers.Remove(connectionId);
         LOG.Info("OnDelSession ServerId[" + connectionId + "]");
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// check if the form was closed with an OK, if so store the values in the GreenshotControls
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClosed(EventArgs e)
 {
     if (!DesignMode && !_storeFieldsManually)
     {
         if (DialogResult == DialogResult.OK)
         {
             LOG.Info("Form was closed with OK: storing field values.");
             StoreFields();
         }
     }
     base.OnClosed(e);
 }
Exemplo n.º 24
0
 // 从数据库移除记录
 public bool remove(string tablename, string filedname, object val, int serverid, int dbid)
 {
     try
     {
         return(m_mongoServer[serverid].getDB(dbid).ExecuteRemoveBykey(tablename, filedname, val));
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.ToString());
     }
     return(false);
 }
Exemplo n.º 25
0
 // 返回表tablename中满足条件的记录个数
 public long getRecordCount(string tablename, IMongoQuery query, int serverid, int dbid)
 {
     try
     {
         return(m_mongoServer[serverid].getDB(dbid).ExecuteGetCount(tablename, query));
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.ToString());
     }
     return(0);
 }
Exemplo n.º 26
0
 public SettingsPageObject CheckingSpecialization(string spec)
 {
     try
     {
         WaitUntil.WaitElement(_webDriver, _specializationInput, TestSettings.WaitTime);
         _webDriver.FindElement(_specializationInput).Equals(spec);
     }
     catch (Exception)
     {
         LOG.Info("Элемент не соответствует заявленным данным: " + spec);
     }
     return(this);
 }
Exemplo n.º 27
0
 public SettingsPageObject CheckingRealName(string name)
 {
     try
     {
         WaitUntil.WaitElement(_webDriver, _realNameInput, TestSettings.WaitTime);
         _webDriver.FindElement(_realNameInput).Equals(name);
     }
     catch (Exception)
     {
         LOG.Info("Элемент не соответствует заявленным данным: " + name);
     }
     return(this);
 }
Exemplo n.º 28
0
        public void Info()
        {
            using (ILOGInstance instance = new AsyncLOGInstance(true, SyncType.EventWaitHandle, true, new[] { new TestOutputter() }, new[] { new KeyValuePair <string, string>("SessionID", "TestSession") }))
            {
                _testingAdditionalfields.Add("SessionID", "TestSession");

                _testingMessage  = "test info message";
                _testingTag      = "info";
                _testingSeverity = LogSeverity.Info;
                instance.Info(_testingMessage, _testingTag);
                LOG.Info(_testingMessage, _testingTag);
            }
        }
Exemplo n.º 29
0
 // 取得表tablename中, 字段名fieldname 为value行
 public Dictionary <string, object> getTableData(string tablename, string fieldname, object val, string[] fields, int serverid, int dbid)
 {
     try
     {
         return(m_mongoServer[serverid].getDB(dbid).ExecuteGetOneBykey(tablename, fieldname, val, fields));
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.Message);
         LOG.Info(ex.StackTrace);
     }
     return(null);
 }
Exemplo n.º 30
0
 // 取得表tablename中, 字段名fieldname 为value行
 public Dictionary <string, object> getTableData(string tablename, int serverid, int dbid, IMongoQuery query, string[] fields = null)
 {
     try
     {
         return(m_mongoServer[serverid].getDB(dbid).ExecuteGetByQuery(tablename, query, fields));
     }
     catch (System.Exception ex)
     {
         LOG.Info(ex.Message);
         LOG.Info(ex.StackTrace);
     }
     return(null);
 }