/// <summary> /// Will check for Twitter Keys and Secrets in appsettings.json file, if not found, user is prompted for input in the terminal. /// </summary> private static void _getConfigKeys() { logBlue("\nReading Configuration values from appsettings.json ..."); // see if the user has input the values into appsettings.json and use those as defaults consumerApiKey = ConfigValueProvider.Get("ConsumerApiKey"); consumerApiSecretKey = ConfigValueProvider.Get("ConsumerSecretKey"); accessToken = ConfigValueProvider.Get("AccessToken"); accessTokenSecret = ConfigValueProvider.Get("AccessTokenSecret"); if (String.IsNullOrEmpty(consumerApiKey)) { logBlue("\nWhat is your Consumer API Key?"); consumerApiKey = Console.ReadLine(); } if (String.IsNullOrEmpty(consumerApiSecretKey)) { logBlue("\nWhat is your Consumer API Secret Key?"); consumerApiSecretKey = Console.ReadLine(); } if (String.IsNullOrEmpty(accessToken)) { logBlue("\nWhat is your Access Token?"); accessToken = Console.ReadLine(); } if (String.IsNullOrEmpty(accessTokenSecret)) { logBlue("\nWhat is your Access Token Secret?"); accessTokenSecret = Console.ReadLine(); } cLog("\nThe values for your Twitter configuration are:"); cLog("Consumer Api Key = " + consumerApiKey); cLog("Consumer Api Secret Key = " + consumerApiSecretKey); cLog("Access Token = " + accessToken); cLog("Access Token Secret = " + accessTokenSecret); cLog("\n"); // if any value is null, print message and exit since they are required to use the Twitter API. if ( String.IsNullOrEmpty(consumerApiKey) || String.IsNullOrEmpty(consumerApiSecretKey) || String.IsNullOrEmpty(accessToken) || String.IsNullOrEmpty(accessTokenSecret) ) { logRed("\nAll of the Twitter Api Keys and Secrets are required to communicate with the Twitter API. \nDeletus-Tweetus is now exiting."); Environment.Exit(0); return; } }
public static void Run() { //get folder to watch path from appsettings.json var FSWSource = ConfigValueProvider.Get("FSW:FSWSource"); //get file types from appsettings.json List <string> fileTypes = ConfigValueProvider.GetArray("FSW:FileTypes"); //register our events FilesWatcher.OnFileReady += OnFileReady; FilesWatcher.OnNewMessage += OnNewMessage; FilesWatcher.Instance.Watch(FSWSource, fileTypes); }
void ReadAllSettings() { try { LogFileReadyEvents = bool.Parse(ConfigValueProvider.Get("FSW:LogFileReadyEvents")); LogFSWEvents = bool.Parse(ConfigValueProvider.Get("FSW:LogFSWEvents")); FSWUseRegex = bool.Parse(ConfigValueProvider.Get("FSW:FSWUseRegex")); FSWRegex = ConfigValueProvider.Get("FSW:FSWRegex"); WatchKinds = ConfigValueProvider.GetArray("FSW:WatchKinds"); if (LogFSWEvents) { Log.Information($"[Event] Time: (DateTime.Now.TimeOfDay)\t LogFileReadyEvents:[{ LogFileReadyEvents}],LogFSWEvents:[{LogFSWEvents}]"); } } catch (Exception ex) { Log.Error(ex, "FileWatchExecutor.ReadAllSettings()"); } }
void ReadAllSettings() { try { initialTimerInterval = int.Parse(ConfigValueProvider.Get("FSW:initialTimerInterval")); delayedTimerIntervalAddition = int.Parse(ConfigValueProvider.Get("FSW:delayedTimerAddition")); permittedIntervalBetweenFiles = int.Parse(ConfigValueProvider.Get("FSW:permittedSecondsBetweenReadyEvents")); LogFileReadyEvents = bool.Parse(ConfigValueProvider.Get("FSW:LogFileReadyEvents")); LogFSWEvents = bool.Parse(ConfigValueProvider.Get("FSW:LogFSWEvents")); FSWUseRegex = bool.Parse(ConfigValueProvider.Get("FSW:FSWUseRegex")); FSWRegex = ConfigValueProvider.Get("FSW:FSWRegex"); Console.WriteLine($"initialTimerInterval:[{initialTimerInterval}], delayedTimerIntervalAddition:[{delayedTimerIntervalAddition}], permittedIntervalBetweenEvents:[{permittedIntervalBetweenFiles}]"); Console.WriteLine($"LogFileReadyEvents:[{LogFileReadyEvents}], LogFSWEvents:[{LogFSWEvents}]"); } catch (Exception e) { Console.Error.WriteLine($"Error reading R2NETFSWSettings settings(setting defaults...), Message: {e.Message}", true); } }
private int GetDifficulty() { int difficulty = int.TryParse(ConfigValueProvider.Get("BlockDifficulty"), out int intDifficulty) ? intDifficulty : 0; return(difficulty); }