public async Task Stats2([Remainder] string x) { var forbidden = APIHelper.DiscordAPI.GetConfigForbiddenPublicChannels(); if (forbidden.Any() && forbidden.Contains(Context.Channel.Id)) { return; } try { if (x == "newday") { return; //only auto check allowed for this } await ContinuousCheckModule.Stats(Context, x); } catch (Exception ex) { await LogHelper.LogEx("stat", ex); await Task.FromException(ex); } }
private static async Task Async_Tick(object stateInfo) { _asyncNow = DateTime.Now; // _asyncToday = DateTime.Today; try { if ((_asyncNow - _lastOnlineCheck).TotalSeconds > 5) { _lastOnlineCheck = _asyncNow; if (!await APIHelper.ESIAPI.IsServerOnline("General")) { if (IsConnected) { await LogHelper.LogWarning("EVE server is offline or there is a connection problem!", LogCat.ESI); await LogHelper.LogWarning("Waiting for connection....", LogCat.ESI); } IsNoConnection = true; } else { if (IsNoConnection) { IsNoConnection = false; await LogHelper.LogWarning("EVE server is ONLINE or connection has been restored!", LogCat.ESI, true, false); } } } await ContinuousCheckModule.OneSec_TQStatusPost(_asyncNow); if (IsNoConnection) { return; } Parallel.ForEach(Modules, module => module.Run(null)); } catch (Exception ex) { await LogHelper.LogEx(ex.Message, ex, LogCat.Tick); } finally { _running = false; } }
public async Task Stats2() { var forbidden = APIHelper.DiscordAPI.GetConfigForbiddenPublicChannels(); if (forbidden.Any() && forbidden.Contains(Context.Channel.Id)) { return; } try { await ContinuousCheckModule.Stats(Context, "m"); } catch (Exception ex) { await LogHelper.LogEx("stat", ex); await Task.FromException(ex); } }
public static async void Tick(object stateInfo) { if (_running || !APIHelper.DiscordAPI.IsAvailable) { return; } _running = true; _asyncNow = DateTime.Now; try { if (!_isModulesLoaded) { await LoadModules(); _isModulesLoaded = true; } #region ONLINE CHECK if ((_asyncNow - _lastOnlineCheck).TotalSeconds > 5) { _lastOnlineCheck = _asyncNow; var onlineType = await APIHelper.ESIAPI.IsServerOnlineEx("General"); IsESIUnreachable = onlineType == -1; if (onlineType != 1) { if (IsConnected) { if (onlineType == 0) { await LogHelper.LogWarning("EVE server is offline!", LogCat.ESI); } if (onlineType == -1) { await LogHelper.LogWarning("EVE ESI API is unreachable!", LogCat.ESI); } await LogHelper.LogWarning("Waiting for connection....", LogCat.ESI); } IsNoConnection = true; } else { if (IsNoConnection) { IsNoConnection = false; await LogHelper.LogWarning("EVE server is ONLINE or connection has been restored!", LogCat.ESI, true, false); } } } #endregion await ContinuousCheckModule.OneSec_TQStatusPost(_asyncNow); if (IsNoConnection || IsESIUnreachable) { return; } await Modules.ParallelForEachAsync(async module => { await module.Run(null); }, SettingsManager.MaxConcurrentThreads); } catch (Exception ex) { await LogHelper.LogEx(ex.Message, ex, LogCat.Tick); } finally { _running = false; } }