Exemplo n.º 1
0
 /// <summary>
 ///     Reports a single activity
 /// </summary>
 /// <param name="report"></param>
 /// <param name="activity"></param>
 private void reportActivity(ERTMSAcademyReport report, Activity activity)
 {
     report.AddTable(new string[] { "Added on " + activity.Date }, new int[] { 20, 120 });
     report.AddRow("Author", activity.User + "(" + activity.Email + ")");
     report.AddRow("Comment", activity.Comment);
     report.AddRow("Statistics", activity.getStatistics());
     report.AddParagraph("");
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates a report on the model, according to user's choices
        /// </summary>
        /// <returns>The document created, or null</returns>
        public override Document BuildDocument()
        {
            Document retVal = new Document();

            retVal.Info.Title   = "ERTMS Academy report";
            retVal.Info.Author  = "ERTMS Solutions";
            retVal.Info.Subject = "ERTMS Academy report";

            ERTMSAcademyReport report = new ERTMSAcademyReport(retVal);

            // Make sure the repository is available
            if (Repository == null)
            {
                report.AddSubParagraph("Configuration");
                report.AddParagraph("Invalid git configuration : cannot access git repository");
                report.CloseSubParagraph();
            }
            else
            {
                List <Activity> ModelActivity = new List <Activity>();
                List <Activity> TestActivity  = new List <Activity>();
                foreach (Commit commit in Repository.Commits)
                {
                    TimeSpan span = DateTime.Now - commit.Author.When;
                    if (span.Days > SinceHowManyDays)
                    {
                        break;
                    }

                    if (commit.Author.Email == GitLogin)
                    {
                        if (commit.Message.Contains("EA_MODEL") || commit.Message.Contains("EA_TEST"))
                        {
                            Activity activity = new Activity(commit.Author.Name, commit.Author.Email, commit.Author.When,
                                                             commit.Message);
                            foreach (Commit other in commit.Parents)
                            {
                                TreeChanges changes = Repository.Diff.Compare(other.Tree, commit.Tree);
                                foreach (TreeEntryChanges change in changes.Modified)
                                {
                                    string path = Path.GetFileName(change.Path);
                                    activity.Statistics.Add(new Statistics(path, change.LinesAdded, change.LinesDeleted));
                                }
                            }

                            if (commit.Message.Contains("EA_MODEL"))
                            {
                                ModelActivity.Add(activity);
                            }
                            else
                            {
                                TestActivity.Add(activity);
                            }
                        }
                    }
                }

                // Create the report
                if (ModelActivity.Count > 0)
                {
                    report.AddSubParagraph("Implementation activity by " + User);

                    foreach (Activity activity in ModelActivity)
                    {
                        reportActivity(report, activity);
                    }
                }

                if (TestActivity.Count > 0)
                {
                    report.AddSubParagraph("Testing activity by " + User);

                    foreach (Activity activity in TestActivity)
                    {
                        reportActivity(report, activity);
                    }
                }
            }

            return(retVal);
        }