// Initialize our class variables from EvilTwins.exe.config. // Returns true if variables were successfully initialized, false otherwise. // ConfigurationErrorsException caught and logged in // %LOCALAPPDATA%\AcTools\Logs\EvilTwins-YYYY-MM-DD.log on initialization failure. private static bool initAppConfigData() { bool ret = true; // assume success try { _twinsExcludeFile = AcQuery.getAppConfigSetting <string>("TwinsExcludeFile").Trim(); DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection; if (depotsConfigSection == null) { AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection"); ret = false; } else { _selDepots = depotsConfigSection.Depots; } } catch (ConfigurationErrorsException exc) { Process currentProcess = Process.GetCurrentProcess(); ProcessModule pm = currentProcess.MainModule; AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}"); ret = false; } return(ret); }
// Initialize our class variables with values from LatestPromotions.exe.config. Returns true if all values // successfully read and class variables initialized, false otherwise. ConfigurationErrorsException caught // and logged in %LOCALAPPDATA%\AcTools\Logs\LatestPromotions-YYYY-MM-DD.log on initialization failure. private static bool initAppConfigData() { bool ret = true; // assume success try { _fromHoursAgo = AcQuery.getAppConfigSetting <int>("FromHoursAgo"); _outputFile = AcQuery.getAppConfigSetting <string>("OutputFile").Trim(); ADSection adSection = ConfigurationManager.GetSection("activeDir") as ADSection; if (adSection == null) { AcDebug.Log("Error in Program.initAppConfigData creating ADSection"); ret = false; } else { _domains = adSection.Domains; _properties = adSection.Props; } DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection; if (depotsConfigSection == null) { AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection"); ret = false; } else { _selDepots = depotsConfigSection.Depots; } StreamsSection streamsConfigSection = ConfigurationManager.GetSection("Streams") as StreamsSection; if (streamsConfigSection == null) { AcDebug.Log("Error in Program.initAppConfigData creating StreamsSection"); ret = false; } else { _selStreams = streamsConfigSection.Streams; } } catch (ConfigurationErrorsException exc) { Process currentProcess = Process.GetCurrentProcess(); ProcessModule pm = currentProcess.MainModule; AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}"); ret = false; } return(ret); }
// Initialize our class variables from LatestTransactions.exe.config. Returns true if class variables // initialized successfully, false otherwise. ConfigurationErrorsException caught and logged in // %LOCALAPPDATA%\AcTools\Logs\LatestTransactions-YYYY-MM-DD.log on initialization failure. private static bool initAppConfigData() { bool ret = false; // assume failure try { _fileName = AcQuery.getAppConfigSetting <string>("FileName").Trim(); _fileLocation = AcQuery.getAppConfigSetting <string>("FileLocation").Trim(); ret = true; } catch (ConfigurationErrorsException exc) { Process currentProcess = Process.GetCurrentProcess(); ProcessModule pm = currentProcess.MainModule; AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}"); } return(ret); }
// General program startup initialization. Returns true if the operation succeeded, false otherwise. private static bool init() { try { // ensure we're logged into AccuRev Task<string> prncpl = AcQuery.getPrincipalAsync(); if (String.IsNullOrEmpty(prncpl.Result)) { Console.WriteLine($"Not logged into AccuRev.{Environment.NewLine}Please login and try again."); return false; } if (!isCurrDirInWSpace()) { Console.WriteLine($"No workspace found for location {Environment.CurrentDirectory}"); return false; } char[] sep = new char[] { }; string temp = AcQuery.getAppConfigSetting<string>("SkipOver").Trim(); if (!String.IsNullOrEmpty(temp)) _skipOver = temp.Split(sep); else _skipOver = new string[] { }; } catch (ConfigurationErrorsException exc) { Process currentProcess = Process.GetCurrentProcess(); ProcessModule pm = currentProcess.MainModule; Console.WriteLine($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}"); } catch (Exception ecx) { Console.WriteLine($"Exception caught in Program.init{Environment.NewLine}{ecx.Message}"); } return true; }
// Initialize our ElementType array class variable with values from XLinked.exe.config. // Returns true if successfully read and initialized, false otherwise. ConfigurationErrorsException // caught and logged in %LOCALAPPDATA%\AcTools\Logs\XLinked-YYYY-MM-DD.log on initialization failure. private static bool initAppConfigData() { bool ret = false; // assume failure try { string[] arr = AcQuery.getAppConfigSetting <string>("ElementTypes") .Split(',').Select(s => s.Trim()).ToArray(); _etypes = Array.ConvertAll(arr, new Converter <string, ElementType>(n => (ElementType)Enum.Parse(typeof(ElementType), n))); ret = true; } catch (ConfigurationErrorsException exc) { Process currentProcess = Process.GetCurrentProcess(); ProcessModule pm = currentProcess.MainModule; AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}"); } return(ret); }