public static void InitializeBg()
        {
            debugLog.Info("[INITIALIZATION] Attempting to load stored configuration");

            string DebugLogging = NUTConfig.GetConfig("Debug");

            if (DebugLogging == null)
            {
                debugLog.Info("[INITIALIZATION] No registry entry exists for debug logging");
            }
            else if (DebugLogging.Equals("true"))
            {
                isLogging = true;
            }


            try
            {
                isSimulated = Convert.ToBoolean(NUTConfig.GetConfig("Simulate"));
            }
            catch
            {
                debugLog.Info("[INITIALIZATION] No simulation setting found, so defaulting to collecting real data");
                isSimulated = false;
            }

            try
            {
                // Checking Registry for settings
                NUTConnectionSettings = NUTConfig.GetConnectionSettings();
                if (NUTConnectionSettings.Item1 == null || NUTConnectionSettings.Item2 == 0 || NUTConnectionSettings.Item3 == 0)
                {
                    debugLog.Info("[INITIALIZATION] Empty values found, starting setup workflow");
                    NeedConfig = true;
                }
            }
            catch (Exception e)
            {
                debugLog.Fatal("[INITIALIZATION] Error occurred: " + e);
            }
            NUTConnectionSettings = NUTConfig.GetConnectionSettings();
        }
Пример #2
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;


#if DEBUG
            LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Debug, LogLevel.Fatal, new StreamingFileTarget());
#else
            LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Error, LogLevel.Fatal, new StreamingFileTarget());
#endif
            Backend.NUTInitialization.debugLog.Info("\n\n\n\n[CORE] Application is starting");

            // Now we start loading the stored configuration, if any
            var InitContainer = new Backend.NUTConfig();
            InitContainer.InitializeContainer();
            Backend.NUTInitialization.InitializeBg();

            // Invokes an instance of NUTPoller and then starts polling
            //Backend.NUTPoller nutPoller = new Backend.NUTPoller();
            //nutPoller.InitializeUPSPolling();
            //Backend.NUTPoller.Poll
        }