Esempio n. 1
0
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            bool isUserLogedIn = Authnticator.isUserLogedIn();

            if (!isUserLogedIn)
            {
                Login login = new Login();
                login.Show();
            }
            else
            {
                bool isExceptionThrown = ExceptionFinder.isExceptionThrown();
                if (!isExceptionThrown)
                {
                    ErrorService              errorService      = new ErrorService();
                    ErrorListProvider         errorListProvider = new ErrorListProvider(errorService);
                    IEnumerable <IVsTaskItem> list = VsShellUtilities.GetErrorListItems(errorService);
                    int numberOfErrors             = 0;

                    List <string> errorMessages = new List <string>();
                    errorMessages.Clear();
                    foreach (var item in list)
                    {
                        string errortext;
                        item.get_Text(out errortext);
                        errorMessages.Add(errortext);
                        numberOfErrors++;
                    }
                    if (numberOfErrors == 0)
                    {
                        MessageBox.Show("Everything is OK... You are good to Go.");
                    }
                    else
                    {
                        foreach (var item in errorMessages)
                        {
                            MessageBox.Show(item);
                        }
                    }
                }
                else if (isExceptionThrown)
                {
                    DTE2                  dte                   = Package.GetGlobalService(typeof(DTE)) as DTE2;
                    string                filename              = dte.FileName;
                    Solution              solution              = dte.Solution;
                    string                fileName              = dte.ActiveDocument.FullName;
                    EnvExtractor          envExtractor          = new EnvExtractor();
                    string                extionName            = envExtractor.detectEnvironoment(fileName);
                    EnvironomentSpecifier environomentSpecifier = new EnvironomentSpecifier();
                    string                envName               = environomentSpecifier.getEnvNameByFileExtensionName(extionName);
                    OutputWindowPane      outputWindowPane      = dte.ToolWindows.OutputWindow.OutputWindowPanes.Item("Debug");
                    outputWindowPane.TextDocument.Selection.SmartFormat();

                    outputWindowPane.TextDocument.Selection.SelectAll();

                    string newText = outputWindowPane.TextDocument.Selection.Text;

                    string[] buildOrder = newText.Split('\n');

                    int index = 0;
                    int count = 0;

                    foreach (var item in buildOrder)
                    {
                        if (item.Contains("An unhandled"))
                        {
                            index = count;
                        }
                        count++;
                    }
                    exceptionString = buildOrder[index + 1];
                    // process new output in newText
                    exceptionString = exceptionString + " in " + envName;
                    //MessageBox.Show(exceptionString);
                    Home errorDisplay = new Home(exceptionString);
                    errorDisplay.ShowDialog();
                }
            }
        }