コード例 #1
0
ファイル: Jira.cs プロジェクト: vishalishere/Logira
        public static RemoteVersion GetVersion(string projectKey, string versionName)
        {
            if (!IsConfigured)
            {
                throw new InvalidOperationException("JIRA is not configured");
            }

            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat("Getting version: {0} -> {1}", projectKey, versionName);
            }

            var remoteVersion = Service.getVersions(GetToken(), projectKey); //TODO: add some caching

            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat("Response:\n{0}", remoteVersion.ToJson());
            }

            return(remoteVersion.FirstOrDefault(version => string.Compare(version.name, versionName, StringComparison.InvariantCultureIgnoreCase) == 0));
        }
コード例 #2
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                CommentCount = 1;

                rp("Logging in into Crucible...");

                Stream auth = getHttpStream(
                    String.Format(Properties.Settings.Default.CrucibleLoginUrl, Properties.Settings.Default.CrucibleUserName,
                                  Properties.Settings.Default.CruciblePassword));
                XmlSerializer asr = new XmlSerializer(typeof(loginResult));
                loginResult   lr  = (loginResult)asr.Deserialize(auth);

                rp("Login complete...");

                rp("Fetching reviews...");
                Stream rvs = getHttpStream(String.Format(Properties.Settings.Default.CrucibleReviewsUrl,
                                                         Properties.Settings.Default.CrucibleProject, lr.token));

                XmlSerializer rsr     = new XmlSerializer(typeof(reviews));
                reviews       reviews = (reviews)rsr.Deserialize(rvs);

                rp("Opening Excel...");

                Excel.Application oXL      = new Excel.Application();
                Excel.Workbook    workBook = oXL.Workbooks.Add(System.Reflection.Missing.Value);

                rp("Preparing the workbook...");

                PrepareExcelWorkbook(workBook);
                Excel.Worksheet workSheet = (Excel.Worksheet)workBook.Sheets[1];

                rp("Logging in into Jira...");
                JiraSoapServiceService jss = new JiraSoapServiceService();

                string token = jss.login(Properties.Settings.Default.CrucibleUserName,
                                         Properties.Settings.Default.CruciblePassword);

                rp("Loading Jira versions");
                foreach (RemoteVersion ver in jss.getVersions(token, Properties.Settings.Default.JiraProjectName))
                {
                    revHash[ver.id] = ver.name;
                    log(String.Format("Adding [{0}] : [{1}] to hash", ver.name, ver.id));
                }

                rp("Populating data into workbook...");
                int rowIndex = 2;

                foreach (reviewData rv in reviews.reviewData)
                {
                    if (
                        (Properties.Settings.Default.CrucibleFetchAllReviews == false) &&
                        (rv.state != state.Closed)
                        )
                    {
                        log("Incomplete review, skipping " + rv.permaId.id);
                        continue;
                    }
                    else
                    {
                        rp("Processing " + rv.permaId.id);

                        Stream cms = getHttpStream(String.Format(Properties.Settings.Default.CrucibleCommentUrl, rv.permaId.id, lr.token));

                        XmlSerializer cmr       = new XmlSerializer(typeof(comments));
                        comments      rcomments = (comments)cmr.Deserialize(cms);
                        if (rcomments.Any != null)
                        {
                            foreach (System.Xml.XmlElement elem in rcomments.Any)
                            {
                                XmlSerializer            vlcdr = new XmlSerializer(typeof(versionedLineCommentData));
                                versionedLineCommentData vlcd  = (versionedLineCommentData)vlcdr.Deserialize(new StringReader(
                                                                                                                 decorate(elem.InnerXml, "versionedLineCommentData")));
                                WriteExcelRow(workSheet, rowIndex, rv, vlcd, jss, token);
                                rowIndex++;
                            }
                        }
                        else
                        {
                            rp("Skipping " + rv.permaId.id + ". No review comments detected.");
                        }
                    }
                }
                oXL.Visible     = true;
                oXL.UserControl = true;
            }
            catch (Exception exp)
            {
                rp("Sorry, exception occured, after all this is software and there is no CI for this :)\r\n" +
                   exp.Message + "\r\n" + exp.StackTrace);
            }
            rp("Completed...");
        }
コード例 #3
0
        public string createIssue(JiraIssue issue)
        {
#if PLVS_133_WORKAROUND
            object[] issuesTable = service.getIssuesFromTextSearch(Token, "<<<<<<<<<<<<<IHOPETHEREISNOSUCHTEXT>>>>>>>>>>>>>>");

            Type   issueObjectType = issuesTable.GetType().GetElementType();
            object ri = issueObjectType.GetConstructor(new Type[] {}).Invoke(new object[] {});
            setObjectProperty(ri, "project", issue.ProjectKey);
            setObjectProperty(ri, "type", issue.IssueTypeId.ToString());
            setObjectProperty(ri, "priority", issue.PriorityId.ToString());
            setObjectProperty(ri, "summary", issue.Summary);
            setObjectProperty(ri, "description", issue.Description);

            if (issue.Assignee != null)
            {
                setObjectProperty(ri, "assignee", issue.Assignee);
            }

            if (issue.Components != null && issue.Components.Count > 0)
            {
                object[] components = service.getComponents(Token, issue.ProjectKey);
                setObjectTablePropertyFromObjectList(ri, "components", issue.Components, components);
            }

            object[] versions = service.getVersions(Token, issue.ProjectKey);

            if (issue.Versions != null && issue.Versions.Count > 0)
            {
                setObjectTablePropertyFromObjectList(ri, "affectsVersions", issue.Versions, versions);
            }

            if (issue.FixVersions != null && issue.FixVersions.Count > 0)
            {
                setObjectTablePropertyFromObjectList(ri, "fixVersions", issue.FixVersions, versions);
            }

            object createdIssue = service.createIssue(Token, ri);
            return((string)createdIssue.GetType().GetProperty("key").GetValue(createdIssue, null));
#else
            RemoteIssue ri = new RemoteIssue
            {
                project     = issue.ProjectKey,
                type        = issue.IssueTypeId.ToString(),
                priority    = issue.PriorityId.ToString(),
                summary     = issue.Summary,
                description = issue.Description,
            };
            if (issue.Assignee != null)
            {
                ri.assignee = issue.Assignee;
            }

            if (issue.Components != null && issue.Components.Count > 0)
            {
                IEnumerable <JiraNamedEntity> components = getComponents(issue.ProjectKey);
//                RemoteComponent[] objects = service.getComponents(Token, issue.ProjectKey);
                List <RemoteComponent> comps = new List <RemoteComponent>();
                foreach (string t in issue.Components)
                {
                    // fixme: a bit problematic part. What if two objects have the same name?
                    // I suppose JiraIssue class has to be fixed, but that would require more problematic
                    // construction of it during server query
                    string tCopy = t;
                    foreach (JiraNamedEntity component in components.Where(component => component.Name.Equals(tCopy)))
                    {
                        comps.Add(new RemoteComponent {
                            id = component.Id.ToString(), name = component.Name
                        });
                        break;
                    }
                }
                ri.components = comps.ToArray();
            }

            List <JiraNamedEntity> versions = getVersions(issue.ProjectKey);
//            RemoteVersion[] versions = service.getVersions(Token, issue.ProjectKey);

            if (issue.Versions != null && issue.Versions.Count > 0)
            {
                List <RemoteVersion> vers = new List <RemoteVersion>();
                foreach (string t in issue.Versions)
                {
                    // fixme: a bit problematic part. same as for objects
                    string tCopy = t;
                    foreach (JiraNamedEntity version in versions.Where(version => version.Name.Equals(tCopy)))
                    {
                        vers.Add(new RemoteVersion {
                            id = version.Id.ToString(), name = version.Name
                        });
                        break;
                    }
                }
                ri.affectsVersions = vers.ToArray();
            }

            if (issue.FixVersions != null && issue.FixVersions.Count > 0)
            {
                List <RemoteVersion> vers = new List <RemoteVersion>();
                foreach (string t in issue.FixVersions)
                {
                    // fixme: a bit problematic part. same as for objects
                    string tCopy = t;
                    foreach (JiraNamedEntity version in versions.Where(version => version.Name.Equals(tCopy)))
                    {
                        vers.Add(new RemoteVersion {
                            id = version.Id.ToString(), name = version.Name
                        });
                        break;
                    }
                }
                ri.fixVersions = vers.ToArray();
            }

            RemoteIssue createdIssue = service.createIssue(Token, ri);
            return(createdIssue.key);
#endif
        }
コード例 #4
0
 public List <JiraNamedEntity> getVersions(JiraProject project)
 {
     return(createEntityList(service.getVersions(token, project.Key)));
 }
 private List <JiraNamedEntity> getVersions(string projectKey)
 {
     return(createEntityList(service.getVersions(Token, projectKey)));
 }