Esempio n. 1
0
        private void WriteExcelRow(Excel.Worksheet oSheet, int index, reviewData rv, versionedLineCommentData vlcd, 
            JiraSoapServiceService jss, string token)
        {
            int column = 1;
            rp(String.Format("[{0}] Processing comment [{1}] from [{2}]",CommentCount,
                vlcd.permaId.id ,vlcd.user.displayName));
            CommentCount++;

            Excel.Range rng = (Excel.Range)(oSheet.Cells[index, 1]);
            rng.EntireRow.Font.Size = 9;
            rng.EntireRow.WrapText = true;

            oSheet.Cells[index, column++] = rv.author.userName;
            oSheet.Cells[index, column++] = rv.author.displayName;
            oSheet.Cells[index, column++] = bf(rv.closeDate);
            oSheet.Cells[index, column++] = bf(rv.createDate);
            oSheet.Cells[index, column++] = rv.creator.userName;
            oSheet.Cells[index, column++] = rv.creator.displayName;
            oSheet.Cells[index, column++] = rv.description;
            oSheet.Cells[index, column++] = bf(rv.dueDate);
            oSheet.Cells[index, column++] = rv.jiraIssueKey;
            if (rv.jiraIssueKey != null && rv.jiraIssueKey != "")
            {
                RemoteIssue issue = GetIssue(jss, token, rv.jiraIssueKey);
                oSheet.Cells[index, column++] = verToString(issue.affectsVersions);
                oSheet.Cells[index, column++] = GetCvValue(issue, Properties.Settings.Default.JiraAddlCustomField);
            }
            else
            {
                column++;
                column++;
            }
            oSheet.Cells[index, column++] = rv.moderator.userName;
            oSheet.Cells[index, column++] = rv.moderator.displayName;
            oSheet.Cells[index, column++] = rv.name;
            oSheet.Cells[index, column++] = rv.permaId.id;
            oSheet.Cells[index, column++] = rv.projectKey;
            oSheet.Cells[index, column++] = rv.state.ToString();
            oSheet.Cells[index, column++] = rv.summary;
            oSheet.Cells[index, column++] = vlcd.fromLineRange;
            oSheet.Cells[index, column++] = vlcd.toLineRange;
            if (vlcd.lineRanges != null)
            {
                string lineRanges = "";
                foreach (lineRangeDetail lr in vlcd.lineRanges)
                {
                    lineRanges += lr.revision + "-" + lr.range + "\r\n";
                }
                oSheet.Cells[index, column++] = lineRanges;
            }
            else
            {
                column++;
            }
            oSheet.Cells[index, column++] = bf(vlcd.createDate);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.defectRaised);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.deleted);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.draft);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.message);
            oSheet.Cells[index, column++] = vlcd.user.userName;
            oSheet.Cells[index, column++] = vlcd.user.displayName;
            accepted = false;
            if (vlcd.replies.Any != null)
            {
                oSheet.Cells[index, column++] = ProcessReplies(vlcd.replies.Any, 1);
            }
            else
            {
                column++;
            }
            
            oSheet.Cells[index, column++] = Convert.ToString(accepted);
        }
Esempio n. 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...");
        }
Esempio n. 3
0
 private RemoteIssue GetIssue(JiraSoapServiceService jss, string token, string jiraId)
 {
     if (loadedJiraItems.ContainsKey(jiraId))
     {
         return (RemoteIssue)(loadedJiraItems[jiraId]);
     }
     else
     {
         try
         {
             RemoteIssue issue = jss.getIssue(token, jiraId);
             loadedJiraItems[jiraId] = issue;
             return issue;
         }
         catch(Exception exp)
         {
             rp("Loading Jira issue failed..." + exp.Message);
             return null;
         }
     }
 }