Ejemplo n.º 1
0
        public async Task setErrorText(Exception ex)
        {
            if (await VersionInformation.isNewVersionAvailable(CancellationToken.None))
            {
                richTextBoxError.AppendText(Environment.NewLine);
                richTextBoxError.AppendText("NEW VERSION AVAILABLE - ");
                LinkLabel downloadLink = new LinkLabel();
                downloadLink.Text = "DOWNLOAD NOW";
                downloadLink.AutoSize = true;
                downloadLink.LinkColor = Color.FromArgb(0, 102, 204);
                downloadLink.Location = richTextBoxError.GetPositionFromCharIndex(richTextBoxError.TextLength);
                downloadLink.LinkClicked += (openDowloadUrl);
                richTextBoxError.Controls.Add(downloadLink);
                richTextBoxError.AppendText(downloadLink.Text);
                richTextBoxError.AppendText(Environment.NewLine);
                richTextBoxError.AppendText(Environment.NewLine);
                AppendTextWithColor("PLEASE UPDATE TO THE LATEST VERSION!" + Environment.NewLine, Color.Firebrick);
            }

            AppendTextWithColor("FIRST CHECK IF THIS ERROR HAS ALREADY BEEN REPORTED!", Color.Firebrick);
            AppendTextWithColor(Environment.NewLine + "IF THE PROBLEM STILL EXISTS WRITE AN ERROR REPORT ", Color.Firebrick);
            LinkLabel bugsLink = new LinkLabel();
            bugsLink.Text = "HERE!";
            bugsLink.AutoSize = true;
            bugsLink.LinkColor = Color.FromArgb(0, 102, 204);
            bugsLink.Location = richTextBoxError.GetPositionFromCharIndex(richTextBoxError.TextLength);
            bugsLink.LinkClicked += (openBugsUrl);
            richTextBoxError.Controls.Add(bugsLink);

            richTextBoxError.AppendText(Environment.NewLine);
            richTextBoxError.AppendText(Environment.NewLine);

            richTextBoxError.AppendText("GCSM VERSION:    " + VersionInformation.getGCSMVersion().ToString());
            richTextBoxError.AppendText(Environment.NewLine);
            richTextBoxError.AppendText("OUTLOOK VERSION: " + VersionInformation.GetOutlookVersion(Synchronizer.OutlookApplication).ToString() + Environment.NewLine);
            richTextBoxError.AppendText("OS VERSION:      " + VersionInformation.GetWindowsVersion() + Environment.NewLine);
            richTextBoxError.AppendText(Environment.NewLine);
            richTextBoxError.AppendText("ERROR MESAGE:" + Environment.NewLine + Environment.NewLine);
            AppendTextWithColor(ex.Message + Environment.NewLine, Color.Firebrick);
            richTextBoxError.AppendText(Environment.NewLine);
            richTextBoxError.AppendText("ERROR MESAGE STACK TRACE:" + Environment.NewLine + Environment.NewLine);
            if (ex.StackTrace != null)
                AppendTextWithColor(ex.StackTrace, Color.Firebrick);
            else
                AppendTextWithColor("NO STACK TRACE AVAILABLE", Color.Firebrick);

            string message = richTextBoxError.Text.Replace("\n", "\r\n");
            //copy to clipboard
            try
            {
                Thread thread = new Thread(() => System.Windows.Clipboard.SetDataObject(message, true));
                thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
                thread.Start();
                thread.Join();
            }
            catch (Exception e)
            {
                Logger.Log("Message couldn't be copied to clipboard: " + e.Message, EventType.Debug);
            }
        }
Ejemplo n.º 2
0
        private static void CreateOutlookInstance()
        {
            if (OutlookApplication == null || _outlookNamespace == null)
            {
                CreateOutlookApplication();

                if (OutlookApplication == null)
                {
                    throw new NotSupportedException("Could not create instance of 'Microsoft Outlook'. Make sure Outlook 2003 or above version is installed and retry.");
                }

                CreateOutlookNamespace();

                if (_outlookNamespace == null)
                {
                    throw new NotSupportedException("Could not connect to 'Microsoft Outlook'. Make sure Outlook 2003 or above version is installed and retry.");
                }
                else
                {
                    Logger.Log("Connected to Outlook: " + VersionInformation.GetOutlookVersion(OutlookApplication), EventType.Debug);
                }
            }

            //Just try to access the outlookNamespace to check, if it is still accessible, throws COMException, if not reachable
            try
            {
                if (string.IsNullOrEmpty(ContactsSynchronizer.SyncContactsFolder))
                {
                    _outlookNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
                }
                else
                {
                    _outlookNamespace.GetFolderFromID(ContactsSynchronizer.SyncContactsFolder);
                }
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == unchecked ((int)0x80029c4a))
                {
                    Logger.Log(ex, EventType.Debug);
                    throw new NotSupportedException(OutlookRegistryUtils.GetPossibleErrorDiagnosis(), ex);
                }
                else if (ex.ErrorCode == unchecked ((int)0x80040111)) //"The server is not available. Contact your administrator if this condition persists."
                {
                    try
                    {
                        Logger.Log("Trying to logon, 1st try", EventType.Debug);
                        _outlookNamespace.Logon("", "", false, false);
                        Logger.Log("1st try OK", EventType.Debug);
                    }
                    catch (Exception e1)
                    {
                        Logger.Log(e1, EventType.Debug);
                        try
                        {
                            Logger.Log("Trying to logon, 2nd try", EventType.Debug);
                            _outlookNamespace.Logon("", "", true, true);
                            Logger.Log("2nd try OK", EventType.Debug);
                        }
                        catch (Exception e2)
                        {
                            Logger.Log(e2, EventType.Debug);
                            throw new NotSupportedException("Could not connect to 'Microsoft Outlook'. Make sure Outlook 2003 or above version is installed and running.", e2);
                        }
                    }
                }
                else
                {
                    Logger.Log(ex, EventType.Debug);
                    throw new NotSupportedException("Could not connect to 'Microsoft Outlook'. Make sure Outlook 2003 or above version is installed and running.", ex);
                }
            }
        }