public SummonerUpdateResult(AccountIdJob job)
        {
            switch (job.Result)
            {
                case JobQueryResult.Success:
                    Result = "Success";
                    break;

                case JobQueryResult.NotFound:
                    Result = "NotFound";
                    break;

                case JobQueryResult.Timeout:
                    Result = "Timeout";
                    break;
            }
        }
Exemple #2
0
 void PerformAutomaticUpdates()
 {
     while (true)
     {
         Thread.Sleep(ServiceConfiguration.AutomaticUpdateInterval * 1000);
         lock (AutomaticUpdateJobs)
         {
             if (AutomaticUpdateJobs.Count == 0)
             {
                 using (NpgsqlConnection database = DatabaseProvider.GetConnection())
                 {
                     SQLCommand command = new SQLCommand("select account_id from summoner where region = cast(:region as region_type) and update_automatically = true", database);
                     command.Set("region", GetRegionEnum());
                     using (NpgsqlDataReader reader = command.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             int accountId = (int)reader[0];
                             AccountIdJob job = new AccountIdJob(accountId);
                             AutomaticUpdateJobs.Enqueue(job);
                         }
                     }
                 }
                 if (AutomaticUpdateJobs.Count > 0)
                 {
                     ActivateWorkers();
                     WriteLine("Performing automatic updates for {0} summoner(s)", AutomaticUpdateJobs.Count);
                 }
                 else
                     WriteLine("There are no automatic updates to be performed");
             }
             else
                 WriteLine("There are still automatic updates in progress, not adding any new ones");
         }
     }
 }
Exemple #3
0
 void ProcessAccountIdJob(AccountIdJob job)
 {
     SQLCommand nameLookup = Command("select id, account_id, summoner_name from summoner where region = cast(:region as region_type) and account_id = :account_id");
     nameLookup.SetEnum("region", RegionProfile.RegionEnum);
     nameLookup.Set("account_id", job.AccountId);
     using (NpgsqlDataReader nameReader = nameLookup.ExecuteReader())
     {
         if (nameReader.Read())
         {
             int id = (int)nameReader[0];
             int accountId = (int)nameReader[1];
             string name = (string)nameReader[2];
             UpdateSummoner(new SummonerDescription(name, id, accountId), false);
             job.ProvideResult(JobQueryResult.Success);
         }
         else
         {
             //The account isn't in the database yet, add it
             AllPublicSummonerDataDTO publicSummonerData = RPC.GetAllPublicSummonerDataByAccount(job.AccountId);
             if (publicSummonerData != null)
             {
                 var summoner = publicSummonerData.summoner;
                 int id = InsertNewSummoner(summoner.acctId, summoner.sumId, summoner.name, summoner.internalName, publicSummonerData.summonerLevel.summonerLevel, summoner.profileIconId);
                 UpdateSummoner(new SummonerDescription(summoner.name, id, summoner.acctId), false);
                 job.ProvideResult(JobQueryResult.Success);
             }
             else
             {
                 //No such summoner
                 job.ProvideResult(JobQueryResult.NotFound);
             }
         }
     }
 }
Exemple #4
0
 public AccountIdJob PerformManualSummonerUpdate(int accountId)
 {
     AccountIdJob job = new AccountIdJob(accountId);
     lock (ManualUpdateJobs)
         ManualUpdateJobs.Enqueue(job);
     ActivateWorkers();
     job.Execute();
     return job;
 }