Пример #1
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);
        }
Пример #2
0
        static int Main()
        {
            bool           ret = false; // assume failure
            StreamsSection streamsConfigSection = ConfigurationManager.GetSection("Streams") as StreamsSection;

            if (streamsConfigSection == null)
            {
                Console.WriteLine("Error creating StreamsSection");
            }
            else
            {
                _selStreams = streamsConfigSection.Streams;
                Task <bool> pini = promoRightsAsync();
                ret = pini.Result;
            }

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