Пример #1
0
        /// <summary>
        /// When an error is logged, check if user has chosen to upload logs or not
        /// </summary>
        protected override void Append(LoggingEvent loggingEvent)
        {
            if (errorOccurred)
            {
                return;
            }
            errorOccurred = true;
            String configSetting = null;

            if (Settings.IsLoaded)
            {
                configSetting = Settings.Instance.CloudLogging.ToString();
            }
            else
            {
                configSetting = XMLManager.ImportElement("CloudLogging", Settings.ConfigFile);
            }

            if (!string.IsNullOrEmpty(configSetting))
            {
                if (configSetting == "true" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "ALL")
                {
                    GoogleOgcs.ErrorReporting.SetThreshold(true);
                    replayLogs();
                }
                else if (configSetting == "false" && GoogleOgcs.ErrorReporting.GetThreshold().ToString().ToUpper() != "OFF")
                {
                    GoogleOgcs.ErrorReporting.SetThreshold(false);
                }
                return;
            }

            //Cloud logging value not set yet - let's ask the user
            Forms.ErrorReporting frm = new Forms.ErrorReporting();
            DialogResult         dr  = frm.ShowDialog();

            if (dr == DialogResult.Cancel)
            {
                errorOccurred = false;
                return;
            }
            Boolean confirmative = dr == DialogResult.Yes;

            if (Settings.IsLoaded)
            {
                Settings.Instance.CloudLogging = confirmative;
            }
            else
            {
                XMLManager.ExportElement("CloudLogging", confirmative, Settings.ConfigFile);
            }
            Analytics.Send(Analytics.Category.ogcs, Analytics.Action.setting, "CloudLogging=" + confirmative.ToString());

            try {
                Forms.Main.Instance.SetControlPropertyThreadSafe(Forms.Main.Instance.cbCloudLogging, "Checked", confirmative);
            } catch { }

            if (confirmative)
            {
                replayLogs();
            }
        }