Пример #1
0
        public DialogResult ReportException(IWin32Window ownerWindow, Exception e, string buildDesc)
        {
            string excString = ITNExceptionSubmitter.FilterExceptionString(e.ToString());

            if (_excludedExceptions.ContainsKey(excString))
            {
                AttachLog = false;
                return(DialogResult.None);
            }

            _errorText.Text = e.ToString();
            _errorText.Select(0, 0);
            _exception = e;
            _buildDesc = buildDesc;
            DialogResult dlgResult = ownerWindow == null?ShowDialog() : ShowDialog(ownerWindow);

            if (dlgResult == DialogResult.OK && _chkDontShowAgain.Checked)
            {
                string filterStr = ITNExceptionSubmitter.FilterExceptionString(_exception.ToString());
                if (!_excludedExceptions.ContainsKey(filterStr))
                {
                    _excludedExceptions.Add(filterStr, true);
                }
            }
            return(dlgResult);
        }
Пример #2
0
        public SubmissionResult SubmitException(string excString, string excMessage, string excStackTrace, string description, string itnUserName, string itnPassword, int buildNumber, string osVersion, IWebProxy proxy)
        {
            string           md5Hash     = ITNExceptionSubmitter.GetExceptionHash(excString);
            ErrorReportProxy reportProxy = new ErrorReportProxy(proxy, myNeedProcessEvents);

            try
            {
                OnSubmitProgress("Checking...");
                int             itnThread   = -1;
                ExceptionStruct es          = new ExceptionStruct();
                bool            checkFailed = reportProxy.CheckException(md5Hash, ref es);

                if (!checkFailed)
                {
                    itnThread = es.exceptionItnThread;
                }

                OnSubmitProgress("Posting...");
                bool isComment = true;

                string errDescription = (description.Length == 0)
                    ? excString
                    : description + "\n" + excString;

                IJiraService service = (IJiraService)XmlRpcProxyGen.Create(typeof(IJiraService));

                string token;

                if (myDefaultUserName != null && myDefaultPassword != null)
                {
                    try
                    {
                        token = service.login(itnUserName, itnPassword);
                    }
                    catch (XmlRpcFaultException)
                    {
                        token       = service.login(myDefaultUserName, myDefaultPassword);
                        itnUserName = myDefaultUserName;
                        itnPassword = myDefaultPassword;
                    }
                }
                else
                {
                    token = service.login(itnUserName, itnPassword);
                }

                XmlRpcStruct[] statuses    = service.getStatuses(token);
                XmlRpcStruct[] resolutions = service.getResolutions(token);

                XmlRpcStruct issue = new XmlRpcStruct();
                if (itnThread == -1)
                {
                    isComment = false;
                    XmlRpcStruct[] components = service.getComponents(token, myJiraProjectKey);
                    XmlRpcStruct[] issueTypes = service.getIssueTypes(token);
                    XmlRpcStruct[] priorities = service.getPriorities(token);

                    issue["project"] = myJiraProjectKey;
                    if (myComponent != null)
                    {
                        foreach (XmlRpcStruct component in components)
                        {
                            if ((string)component["name"] == myComponent)
                            {
                                issue["components"] = new XmlRpcStruct[] { component }
                            }
                            ;
                        }
                    }
                    MapNameToId(issue, issueTypes, "type", "Exception");
                    MapNameToId(issue, priorities, "priority", "Major");

                    issue["summary"]     = ITNExceptionSubmitter.GetExceptionTitle(excMessage, excStackTrace);
                    issue["description"] = errDescription;

                    issue = service.createIssue(token, issue);
                    string issueKey = (string)issue["key"];
                    itnThread = Int32.Parse(issueKey.Substring(issueKey.IndexOf("-") + 1));

                    if (myStatus != null)
                    {
                        foreach (XmlRpcStruct status in statuses)
                        {
                            if ((string)status["name"] == myStatus)
                            {
                                service.setIssueStatus(itnUserName, itnPassword, issueKey, (string)status["id"], "");
                                break;
                            }
                        }

                        service.setIssueStatus(itnUserName, itnPassword, issueKey, myStatus, "");
                    }
                }
                else
                {
                    string issueKey = myJiraProjectKey + "-" + itnThread;
                    service.addIssueComment(itnUserName, itnPassword, issueKey,
                                            errDescription);
                    issue = service.getIssue(token, issueKey);
                }

                XmlDocument requestDescription = new XmlDocument();
                requestDescription.LoadXml("<scr/>");
                requestDescription.DocumentElement.SetAttribute("url",
                                                                "http://www.jetbrains.net/jira/browse/" + issue["key"]);
                requestDescription.DocumentElement.SetAttribute("state",
                                                                MapIdToName(issue, statuses, "status"));
                requestDescription.DocumentElement.SetAttribute("resolution",
                                                                MapIdToName(issue, resolutions, "resolution"));

                XmlElement fixVersionNodes = requestDescription.CreateElement("fixVersions");
                requestDescription.DocumentElement.AppendChild(fixVersionNodes);

                object[] fixVersions = (object[])issue ["fixVersions"];
                foreach (object fixVersionObj in fixVersions)
                {
                    XmlRpcStruct fixVersion     = (XmlRpcStruct)fixVersionObj;
                    XmlElement   fixVersionNode = requestDescription.CreateElement("version");
                    fixVersionNode.SetAttribute("name", (string)fixVersion ["name"]);
                    fixVersionNodes.AppendChild(fixVersionNode);
                }

                if (!checkFailed)
                {
                    if (!isComment)
                    {
                        es = new ExceptionStruct();
                        es.exceptionHash        = md5Hash;
                        es.exceptionMessage     = excString;
                        es.exceptionDate        = DateTime.Now;
                        es.exceptionStack       = excStackTrace == null ? String.Empty : excStackTrace;
                        es.exceptionItnThread   = itnThread;
                        es.exceptionBuildNumber = buildNumber.ToString();
                        es.exceptionProductCode = myProduct;
                        es.exceptionScrambled   = false;
                    }

                    OnSubmitProgress("Submitting...");
                    reportProxy.SubmitException(itnUserName, es, excString, isComment);
                }
                return(new SubmissionResult(itnThread, isComment, requestDescription));
            }
            finally
            {
                OnSubmitProgress("");
            }
        }