public CombatStatus GuildBossRefreshStatus() { if (CombatStatus != CombatStatus.NoStart && CombatStatus != CombatStatus.Over) { var cacheSet = new ShareCacheStruct <GameActive>(); DateTime currTime = DateTime.Now; GameActive active = cacheSet.FindKey(ActiveID); if (active != null) { if (GuildBossInfo != null) { BeginTime = GuildBossInfo.EnablePeriod.ToDateTime(DateTime.MinValue); EndTime = BeginTime.AddMinutes(active.Minutes); if (BeginTime > currTime) { lock (this) { CombatStatus = CombatStatus.NoStart; } } else if (EndTime < currTime) { lock (this) { CombatStatus = CombatStatus.Over; } } } } } return(CombatStatus); }
public Token(Setting settings) { try { GetHttpClient.Get().DefaultRequestHeaders.Clear(); FormUrlEncodedContent content = new FormUrlEncodedContent(settings.Data); using (var response = GetHttpClient.Get().PostAsync(settings.TokenAddress, content).Result) { if (response.IsSuccessStatusCode) { string answer = response.Content.ReadAsStringAsync().Result; logger.Info("TOKEN: " + answer); TokenResponse tokenResponse = JsonConvert.DeserializeObject <TokenResponse>(answer); Value = $"{tokenResponse.TokenType} {tokenResponse.AccessToken}"; BeginTime = DateTime.Now; EndTime = BeginTime.AddMinutes(tokenResponse.ExpiresIn / 60 - 1); Duration = BeginTime.ToString() + " - " + EndTime.ToString(); StatusCode = response.StatusCode.ToString(); } else { throw new Exception(response.Content.ReadAsStringAsync().Result + "\n\n" + response.ToString()); } } } catch (Exception exc) { logger.Error("TOKENERROR: " + exc.ToString()); Value = $"No {settings.Zone} token!!!"; Error = exc.ToString(); StatusCode = "exception"; } }