コード例 #1
0
        public async static void UpdateServerKeeper()
        {
            int serversSkipped = 0;
            int y;

            for (y = 0; y < Servers.Count - 1; y++)
            {
                //SServers item = Servers[y];
                KeeperAPI          keeper = new KeeperAPI();
                CustomSnapshotRoot root   = await keeper.getKeeperInfo(Servers[y]._ServerGuid.ToString());

                if (root == null)
                {
                    continue;
                }
                if (Servers[y]._Snapshots == null)
                {
                    Servers[y]._Snapshots = new List <CustomSnapshotRoot>();// new ObservableCollection<CustomSnapshotRoot>();
                    // CLogging.AddLog("null");
                }
                else
                {
                    //CLogging.AddLog("not Null");
                }
                int NumPlayers = root.snapshot.teamInfo.team0.player.Count + root.snapshot.teamInfo.team1.player.Count + root.snapshot.teamInfo.team2.player.Count;
                Servers[y].PlayersPlaying = NumPlayers;
                //CLogging.AddLog(String.Format("{0} players on server", NumPlayers));
                if (root.snapshot.roundTime != 0)
                {
                    Servers[y]._Snapshots.Add(root);
                }
                else
                {
                    serversSkipped++;
                }
                if (Servers[y].Snapshots.Count > 0 && root.snapshot.roundTime == 0)
                {
                    CLogging.AddLog(String.Format("{0} Saved", Servers[y].ServerGuid));
                    string output = JsonConvert.SerializeObject(Servers[y]);
                    FileHandler.Save(output, Servers[y].ServerGuid.ToString());
                    Servers[y].Snapshots.Clear();
                }
                //Servers[y] = item;
            }
            CLogging.AddLog(String.Format("{0} servers updated", y), LogType.Update);
            CheckServersForRemoval();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: xHeinrich/keeperScoreboard
 public async static void UpdateServerKeeper()
 {
      int serversSkipped = 0;
      int y;
      for(y = 0; y < Servers.Count-1; y++)
      {
         //SServers item = Servers[y];
         KeeperAPI keeper = new KeeperAPI();
         CustomSnapshotRoot root = await keeper.getKeeperInfo(Servers[y]._ServerGuid.ToString());
         if (root == null)
             continue;
         if (Servers[y]._Snapshots == null)
         {
             Servers[y]._Snapshots = new List<CustomSnapshotRoot>();// new ObservableCollection<CustomSnapshotRoot>();
            // CLogging.AddLog("null");
         }
         else
         {
             //CLogging.AddLog("not Null");
         }
         int NumPlayers = root.snapshot.teamInfo.team0.player.Count + root.snapshot.teamInfo.team1.player.Count + root.snapshot.teamInfo.team2.player.Count;
         Servers[y].PlayersPlaying = NumPlayers;
         //CLogging.AddLog(String.Format("{0} players on server", NumPlayers));
         if (root.snapshot.roundTime != 0)
         {
             Servers[y]._Snapshots.Add(root);
         }
         else
             serversSkipped++;
         if (Servers[y].Snapshots.Count > 0 && root.snapshot.roundTime == 0)
         {
             CLogging.AddLog(String.Format("{0} Saved", Servers[y].ServerGuid));
             string output = JsonConvert.SerializeObject(Servers[y]);
             FileHandler.Save(output, Servers[y].ServerGuid.ToString());
             Servers[y].Snapshots.Clear();
         }
         //Servers[y] = item;
     }
     CLogging.AddLog(String.Format("{0} servers updated", y), LogType.Update);
     CheckServersForRemoval();
 }