Exemplo n.º 1
0
        public void T007_BuildQueue()
        {
            var jsonData = System.IO.File.ReadAllText(@".\test_data\build_q.json");
            var conv     = new GameDataConverter();
            var q        = conv.GetBuidQueue(jsonData);

            Trace.TraceInformation(q.Count.ToString());
        }
Exemplo n.º 2
0
 public void raids_repors(string data)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(data))
         {
             var conv    = new GameDataConverter();
             var reports = conv.GetRaidReports(data);
             DoCurrentRaidReports(reports);
         }
     }
     catch (Exception e)
     {
         log.Error(e.Message, e);
     }
 }
Exemplo n.º 3
0
 public void troops_overview(string data)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(data))
         {
             log.Debug("troops_overview: " + data);
             var conv   = new GameDataConverter();
             var troops = conv.GetTroopsOverview(data);
             DoTroopsOverview(troops);
         }
     }
     catch (Exception e)
     {
         log.Error(e.Message, e);
     }
 }
Exemplo n.º 4
0
 public void raid_report(string data)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(data))
         {
             log.Debug("raid_report: " + data);
             var conv   = new GameDataConverter();
             var report = conv.GetRaidReport(data);
             DoCurrentRaidReport(report);
         }
     }
     catch (Exception e)
     {
         log.Error(e.Message, e);
     }
 }
Exemplo n.º 5
0
 public void T006_TroopsOverviewRep()
 {
     var jsonData = System.IO.File.ReadAllText(@".\test_data\all_troops.json");
     var conv     = new GameDataConverter();
     var troops   = conv.GetTroopsOverview(jsonData);
 }
Exemplo n.º 6
0
 public void T005_RaidRep()
 {
     var jsonData = System.IO.File.ReadAllText(@".\test_data\raid_report.json");
     var conv     = new GameDataConverter();
     var report   = conv.GetRaidReport(jsonData);
 }
Exemplo n.º 7
0
 public void T004_RaidsRepList()
 {
     var jsonData = System.IO.File.ReadAllText(@".\test_data\raids_reports_list.json");
     var conv     = new GameDataConverter();
     var reports  = conv.GetRaidReports(jsonData);
 }
Exemplo n.º 8
0
 public void T002_UnitsKillsParser()
 {
     var jsonData = System.IO.File.ReadAllText(@".\test_data\unitskills.json");
     var conv     = new GameDataConverter();
     var rankings = conv.GetUnitsKills(jsonData);
 }
Exemplo n.º 9
0
 public void T001_RankingsParser()
 {
     var jsonData = System.IO.File.ReadAllText(@".\test_data\rankings.json");
     var conv     = new GameDataConverter();
     var rankings = conv.GetRankings(jsonData);
 }
Exemplo n.º 10
0
        async public void rankings(string jsonData, string type, string continent)
        {
            try
            {
                log.InfoFormat("New rankings, type: {0}, continent: {1}, parsing...", type, continent);
                DoProgress(string.Format("New rankings, type:{0}, continent: {1}, parsing...", type, continent));

                var conv = new GameDataConverter();

                if (type == "0")
                {
                    var ranks = conv.GetRankings(jsonData);
                    log.InfoFormat("New empire rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New empire rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentEmpireRanking save = new SaveCurrentEmpireRanking();
                    save.Progress += (s, e) => DoProgress(e.Message);

                    await Task.Run(() =>
                    {
                        int c = int.Parse(continent);

                        foreach (var r in ranks)
                        {
                            r.Continent = c;
                        }

                        save.CurrentRankings = ranks;

                        Db.ExecuteWork(save);
                    });
                }
                else if (type == "5")
                {
                    var ranks = conv.GetUnitsKills(jsonData);
                    log.InfoFormat("New units kills rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New units kills rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentEmpireRanking save = new SaveCurrentEmpireRanking();
                    save.Progress += (s, e) => DoProgress(e.Message);

                    await Task.Run(() =>
                    {
                        foreach (var r in ranks)
                        {
                            r.Continent = 56;
                        }

                        save.CurrentRankings = ranks;
                        Db.ExecuteWork(save);
                    });
                }
                else if (type == "1")
                {
                    var ranks = conv.GetAliancesRanking(jsonData);
                    log.InfoFormat("New aliances rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New aliances rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentAlianceRanking save = new SaveCurrentAlianceRanking();
                    int total = ranks.Count;
                    int step  = 0;

                    await Task.Run(() =>
                    {
                        foreach (var r in ranks)
                        {
                            r.Continent       = int.Parse(continent);
                            save.AlianceScore = r;
                            Db.ExecuteWork(save);
                            step++;
                            DoProgress(string.Format("~Db updating.... {0}/{1}", step, total));
                        }
                    });
                }
                else if (type == "7")
                {
                    var ranks = conv.GetCaverns(jsonData);
                    log.InfoFormat("New caverns rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New caverns rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentEmpireRanking save = new SaveCurrentEmpireRanking();
                    save.Progress += (s, e) => DoProgress(e.Message);

                    await Task.Run(() =>
                    {
                        foreach (var r in ranks)
                        {
                            r.Continent = 56;
                        }

                        save.CurrentRankings = ranks;
                        Db.ExecuteWork(save);
                    });
                }
                else if (type == "4")
                {
                    //def rep
                    var ranks = conv.GetDefReputation(jsonData);
                    log.InfoFormat("New def reputation rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New def reputation rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentEmpireRanking save = new SaveCurrentEmpireRanking();
                    save.Progress += (s, e) => DoProgress(e.Message);

                    await Task.Run(() =>
                    {
                        foreach (var r in ranks)
                        {
                            r.Continent = 56;
                        }

                        save.CurrentRankings = ranks;
                        Db.ExecuteWork(save);
                    });
                }
                else if (type == "3")
                {
                    //off rep
                    var ranks = conv.GetOffReputation(jsonData);
                    log.InfoFormat("New off reputation rankings parsed, rows:{0}, updating database...", ranks.Count());
                    DoProgress(string.Format("New off reputation rankings parsed, rows:{0}, updating database...", ranks.Count()));

                    SaveCurrentEmpireRanking save = new SaveCurrentEmpireRanking();
                    save.Progress += (s, e) => DoProgress(e.Message);

                    await Task.Run(() =>
                    {
                        foreach (var r in ranks)
                        {
                            r.Continent = 56;
                        }

                        save.CurrentRankings = ranks;
                        Db.ExecuteWork(save);
                    });
                }

                log.Info("Database updated.");
                m_CurrentStep++;
                DoProgress("Database updated.");

                //pobieram następny z listy
                if (m_Continents.Count > 0)
                {
                    var paramStr = m_Continents.Dequeue();
                    var b        = paramStr.Split(':')[1];
                    var a        = paramStr.Split(':')[0];

                    log.InfoFormat("Invoking CotGBrowser_GetRanks({0}, {1}), ...", a, b);
                    DoProgress(string.Format("Invoking CotGBrowser_GetRanks({0}, {1}), ...", a, b));

                    m_Browser.ExecuteScriptAsync("CotGBrowser_GetRanks", a, b);
                }
                else
                {
                    log.Info("All jobs finished.");
                    DoProgress("All jobs finished.");
                    m_CurrentStep = m_TotalSteps;
                    DoJobFinished();
                }
            }
            catch (Exception e)
            {
                log.Error(e.Message, e);
                DoProgress(e.Message);
            }
        }