// Initialize depots list class variable with select depots from WSpaceTransLevel.exe.config. Returns true
        // if initialization was successful, false otherwise. ConfigurationErrorsException caught and logged in
        // %LOCALAPPDATA%\AcTools\Logs\WSpaceTransLevel-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = false; // assume failure

            try
            {
                DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection;
                if (depotsConfigSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection");
                }
                else
                {
                    _selDepots = depotsConfigSection.Depots;
                    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);
        }
예제 #2
0
        // 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);
        }
        static int Main()
        {
            bool          ret = false; // assume failure
            DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection;

            if (depotsConfigSection == null)
            {
                Console.WriteLine("Error creating DepotsSection");
            }
            else
            {
                _selDepots = depotsConfigSection.Depots;
                Task <bool> wini = showActiveWSpacesAsync();
                ret = wini.Result;
            }

            return((ret) ? 0 : 1);
        }