WriteEvent() public static method

Writes an event to the logger. This method will do nothing if Init() is not called first.
public static WriteEvent ( string message ) : void
message string
return void
示例#1
0
        public void OnPropertyChanged(string name)
        {
            CheckDisposed();

            switch (name)
            {
            default:
                break;

            /* remember, what XCore thinks of as a "Content Control", is what this AreaManager sees as a "tool".
             * with that in mind, this case is invoked when the user chooses a different tool.
             * the purpose of this code is to then store the name of that tool so that
             * next time we come back to this area, we can remember to use this same tool.
             */
            case "currentContentControlObject":
                string toolName = m_mediator.PropertyTable.GetStringProperty("currentContentControl", "");
                var    c        = (IxCoreContentControl)m_mediator.PropertyTable.GetValue("currentContentControlObject");
                m_mediator.PropertyTable.SetProperty("ToolForAreaNamed_" + c.AreaName, toolName);
                Logger.WriteEvent("Switched to " + toolName);
                // Should we report a tool change?
                if (m_lastToolChange.Date != DateTime.Now.Date)
                {
                    // new day has dawned (or just started up). Reset tool reporting.
                    m_toolsReportedToday.Clear();
                    m_lastToolChange = DateTime.Now;
                }
                string areaNameForReport = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
                if (!string.IsNullOrWhiteSpace(areaNameForReport) && !m_toolsReportedToday.Contains(toolName))
                {
                    m_toolsReportedToday.Add(toolName);
                    UsageReporter.SendNavigationNotice("SwitchToTool/{0}/{1}", areaNameForReport, toolName);
                }
                break;

            case "areaChoice":
                string areaName = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);

                if (string.IsNullOrEmpty(areaName))
                {
                    break;                            //this can happen when we use this property very early in the initialization
                }
                //for next startup
                m_mediator.PropertyTable.SetProperty("InitialArea", areaName);

                ActivateToolForArea(areaName);
                break;
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="WelcomeToFieldWorksDlg"/> class.
        /// </summary>
        /// <param name="helpTopicProvider">Help topic provider</param>
        /// <param name="appAbbrev">Standard application abbreviation.</param>
        /// <param name="exception">Exception that was thrown if the previously requested
        /// project could not be opened.</param>
        /// <param name="showReportingRow">True (usually only on the first run) when we want to show the first-time warning about
        /// sending google analytics information</param>
        /// ------------------------------------------------------------------------------------
        public WelcomeToFieldWorksDlg(IHelpTopicProvider helpTopicProvider, string appAbbrev, StartupException exception, bool showReportingRow)
        {
            m_appAbbrev = appAbbrev;
            InitializeComponent();
            AccessibleName = GetType().Name;
            var fullAppName = AppIsFlex ? Properties.Resources.kstidFLEx : Properties.Resources.kstidTE;

            SetCheckboxText = fullAppName;              // Setter uses the app name in a format string.

            if (exception == null || !exception.ReportToUser)
            {
                Text = fullAppName;
                Logger.WriteEvent("Opening 'Welcome to FieldWorks' dialog");
            }
            else
            {
                m_helpTopic = "khtpUnableToOpenProject";
                Text        = Properties.Resources.kstidUnableToOpenProjectCaption;
                m_lblProjectLoadError.Text = exception.Message;
                Logger.WriteEvent("Opening 'Unable to Open Project' dialog");
            }

            if (!showReportingRow)
            {
                reportingInfoLayout.Visible = false;
            }

            m_helpTopicProvider        = helpTopicProvider;
            helpProvider               = new HelpProvider();
            helpProvider.HelpNamespace = FwDirectoryFinder.CodeDirectory + m_helpTopicProvider.GetHelpString("UserHelpFile");
            helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            receiveButton.Enabled =
                ClientServerServices.Current.Local.DefaultBackendType != FDOBackendProviderType.kDb4oClientServer &&
                FLExBridgeHelper.IsFlexBridgeInstalled();
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the error.
        /// </summary>
        /// <param name="applicationKey">The application registry key.</param>
        /// <param name="error">the exception you want to report</param>
        /// <param name="parent">the parent form that this error belongs to (i.e. the form
        /// show modally on)</param>
        /// ------------------------------------------------------------------------------------
        private void HandleError(RegistryKey applicationKey, Exception error, Form parent)
        {
            CheckDisposed();
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // These 2 lines can be deleted after the problems with mailto have been resolved.
            radEmail.Enabled = false;
            radSelf.Checked  = true;

            if (m_emailAddress == null)
            {
                radEmail.Enabled = false;
                radSelf.Checked  = true;
            }
            else
            {
                // Add the e-mail address to the dialog.
                emailLabel.Text = String.Format(emailLabel.Text, m_emailAddress);
            }

            if (!m_isLethal)
            {
                btnClose.Text            = ReportingStrings.ks_Ok;
                BackColor                = Color.FromArgb(255, 255, 192); //yellow
                m_notification.BackColor = BackColor;
                UpdateCrashCount(applicationKey, "NumberOfAnnoyingCrashes");
            }
            else
            {
                UpdateCrashCount(applicationKey, "NumberOfSeriousCrashes");
            }
            UpdateAppRuntime(applicationKey);

            StringBuilder detailsText = new StringBuilder();
            Exception     innerMostException;

            detailsText.AppendLine(ExceptionHelper.GetHiearchicalExceptionInfo(error, out innerMostException));

            // if the exception had inner exceptions, show the inner-most exception first, since
            // that is usually the one we want the developer to read.
            if (innerMostException != null)
            {
                StringBuilder innerException = new StringBuilder();
                innerException.AppendLine("Inner most exception:");
                innerException.AppendLine(ExceptionHelper.GetExceptionText(innerMostException));
                innerException.AppendLine();
                innerException.AppendLine("Full, hierarchical exception contents:");
                detailsText.Insert(0, innerException.ToString());
            }

            detailsText.AppendLine("Error Reporting Properties:");
            foreach (string label in s_properties.Keys)
            {
                detailsText.AppendLine(label + ": " + s_properties[label]);
            }

            if (innerMostException != null)
            {
                error = innerMostException;
            }
            Logger.WriteEvent("Got exception " + error.GetType().Name);

            detailsText.AppendLine(Logger.LogText);
            Debug.WriteLine(detailsText.ToString());
            m_details.Text = detailsText.ToString();

            if (s_isOkToInteractWithUser)
            {
                s_fIgnoreReport = true;
                ShowDialog((parent != null && !parent.IsDisposed) ? parent : null);
                s_fIgnoreReport = false;
            }
            else                //the test environment already prohibits dialogs but will save the contents of assertions in some log.
            {
                Debug.Fail(m_details.Text);
            }
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Log the dialog result
 /// </summary>
 /// <param name="e"></param>
 /// ------------------------------------------------------------------------------------
 protected override void OnClosing(CancelEventArgs e)
 {
     Logger.WriteEvent("Closing dialog: " + m_dlgResult);
     base.OnClosing(e);
 }
示例#5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void btnClose_Click(object sender, System.EventArgs e)
        {
            var body = GatherData();

            if (radEmail.Checked)
            {
                var emailProvider = EmailProviderFactory.PreferredEmailProvider();
                var emailMessage  = emailProvider.CreateMessage();
                emailMessage.To.Add(m_emailAddress);
                var emailSubject = s_emailSubject;
                if (m_fReportDuplicateGuidsASAP)
                {
                    emailSubject = "Duplicate GUIDs Error Report:";
                }
                else if (m_fSuggestion)
                {
                    emailSubject = "Suggested Improvement to FLEx:";
                }
                else if (m_fUserReport)
                {
                    emailSubject = "Manual Error Report:";
                }
                emailMessage.Subject = emailSubject;
                emailMessage.Body    = body;
                if (!emailMessage.Send(emailProvider))
                {
                    MessageBox.Show(this, ReportingStrings.kstidSendFailed, ReportingStrings.kstidSendFailedCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    radSelf.Checked = true;
                    return;
                }
            }
            else if (radSelf.Checked)
            {
                if (m_emailAddress != null)
                {
                    if (m_fUserReport)
                    {
                        body = string.Format(ReportingStrings.kstidPleaseEmailThisTo0WithASuitableSubject,
                                             m_emailAddress, body);
                    }
                    else
                    {
                        body = string.Format(ReportingStrings.ksPleaseEMailThisTo0WithThisExactSubject12,
                                             m_emailAddress, s_emailSubject, body);
                    }
                }
                // Copying to the clipboard works only if thread is STA which is not the case if
                // called from the Finalizer thread
                if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
                {
#if __MonoCS__
                    // Workaround for Xamarin bug #4959. I had a mono fix for that bug
                    // but that doesn't work with FW - I couldn't figure out why not.
                    // This is a dirty hack but at least works :-)
                    var clipboardAtom = gdk_atom_intern("CLIPBOARD", true);
                    var clipboard     = gtk_clipboard_get(clipboardAtom);
                    if (clipboard != IntPtr.Zero)
                    {
                        gtk_clipboard_set_text(clipboard, body, -1);
                        gtk_clipboard_store(clipboard);
                    }
#else
                    ClipboardUtils.SetDataObject(body, true);
#endif
                }
                else
                {
                    Logger.WriteEvent(body);
                }
            }

            if (!m_isLethal || ModifierKeys.Equals(Keys.Shift))
            {
                Logger.WriteEvent("Continuing...");
                Close();
                return;
            }

            m_userChoseToExit = true;
            Logger.WriteEvent("Exiting...");
            Application.Exit();
        }
示例#6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows the dialog (handles the error, if it is one).
        /// </summary>
        /// <param name="applicationKey">The application registry key.</param>
        /// <param name="error">the exception you want to report</param>
        /// <param name="parent">the parent form that this error belongs to (i.e. the form
        /// show modally on)</param>
        /// ------------------------------------------------------------------------------------
        private void ShowDialog(RegistryKey applicationKey, Exception error, Form parent)
        {
            CheckDisposed();
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            SetDialogStringsSoLocatilizationWorks();

            m_viewDetailsOriginalText      = viewDetailsLink.Text;
            m_originalHeightWithoutDetails = Height - m_details.Height - 10;
            m_originalHeight  = Height;
            m_originalMinSize = MinimumSize;

            if (m_fUserReport)
            {
                ControlBox           = true;
                cancelButton.Visible = true;
                btnClose.Size        = cancelButton.Size;
                btnClose.Left        = cancelButton.Left - btnClose.Width - 15;
                if (m_fSuggestion)
                {
                    Text = ReportingStrings.kstidMakeSuggestionCaption;
                    m_notification.Text = ReportingStrings.kstidMakeSuggestionNotification;
                    m_stepsLabel.Text   = ReportingStrings.kstidGoalAndSuggestion;
                    m_reproduce.Text    = ReportingStrings.kstidSampleSuggestion;
                }
                else
                {
                    Text = ReportingStrings.kstidReportProblemCaption;
                    m_notification.Text = ReportingStrings.kstidReportProblemNotification;
                    m_stepsLabel.Text   = ReportingStrings.kstidProblemAndSteps;
                    m_reproduce.Text    = ReportingStrings.ksSampleProblemReport;
                }
                // Do this AFTER filling in the sample...it is disabled until they change something.
                btnClose.Enabled = false;
            }

            s_showDetails = true;             // the resource-file state of the dialog is showing.

            if (m_emailAddress == null)
            {
                radEmail.Enabled = false;
                radSelf.Checked  = true;
            }
            else
            {
                // Add the e-mail address to the dialog.
                lbl_EmailReport.Text = String.Format(lbl_EmailReport.Text, m_emailAddress);
            }

            if (!m_isLethal)
            {
                btnClose.Text = ReportingStrings.ks_Ok;
                BackColor     = m_fSuggestion
                                        ? Color.FromKnownColor(KnownColor.Control) // standard dialog background
                                        : Color.FromArgb(255, 255, 192);           //yellow
                m_notification.BackColor = BackColor;
                UpdateCrashCount(applicationKey, "NumberOfAnnoyingCrashes");
            }
            else
            {
                UpdateCrashCount(applicationKey, "NumberOfSeriousCrashes");
            }
            UpdateAppRuntime(applicationKey);

            StringBuilder detailsText        = new StringBuilder();
            Exception     innerMostException = null;

            if (error != null)
            {
                detailsText.AppendLine(ExceptionHelper.GetHiearchicalExceptionInfo(error, out innerMostException));

                // if the exception had inner exceptions, show the inner-most exception first, since
                // that is usually the one we want the developer to read.
                if (innerMostException != null)
                {
                    StringBuilder innerException = new StringBuilder();
                    innerException.AppendLine("Inner most exception:");
                    innerException.AppendLine(ExceptionHelper.GetExceptionText(innerMostException));
                    innerException.AppendLine();
                    innerException.AppendLine("Full, hierarchical exception contents:");
                    detailsText.Insert(0, innerException.ToString());
                }
            }

            detailsText.AppendLine("Additional information about the computer and project:");
            foreach (string label in s_properties.Keys)
            {
                detailsText.AppendLine(label + ": " + s_properties[label]);
            }

            if (innerMostException != null)
            {
                error = innerMostException;
            }
            if (error != null)
            {
                Logger.WriteEvent("Got exception " + error.GetType().Name);
            }

            detailsText.AppendLine(Logger.LogText);
            Debug.WriteLine(detailsText.ToString());
            m_details.Text = detailsText.ToString();

            if (m_fUserReport)
            {
                // show modeless, so they can use the program while filling in details.
                // Don't set the Ignore flag, a real crash might happen while trying to report a lesser problem.
                Show(parent);
                return;
            }
            if (s_isOkToInteractWithUser)
            {
                s_fIgnoreReport = true;
                ShowDialog((parent != null && !parent.IsDisposed) ? parent : null);
                s_fIgnoreReport = false;
            }
            else                //the test environment already prohibits dialogs but will save the contents of assertions in some log.
            {
                Debug.Fail(m_details.Text);
            }
        }