public ReleaseNotesGenerator(NamedLookup settings, bool silent)
		{
			this.settings = settings;
			CheckRequiredFields();
			this.TFS = TFSAccessor.TFSAccessorFactory(settings["Team Project Path"], settings["Project Name"], settings["Iteration"], settings["Project Subpath"]);
			this.logger = new Logger();
			this.silent = silent;
		}
Esempio n. 2
0
 /// <summary>
 /// Generates a word instance
 /// </summary>
 /// <param name="settings"></param>
 private WordGenerator(NamedLookup settings, bool silent) : base(settings, silent)
 {
     app = new Word.Application();
     app.Visible = !this.silent;
     document = app.Documents.Add(Type.Missing, Type.Missing,
     Word.WdNewDocumentType.wdNewBlankDocument, !this.silent);
     document.UserControl = !this.silent;
 }
Esempio n. 3
0
        public override void CreateHorizontalTable(NamedLookup data, int splits, bool header)
        {
            // create table start
            this.htmlString += "<table>";
            // 2 splits = 4 columns
            int currentColumnCount = 2 * splits;

            // if header needed
            if (header) CreateHeader(data.GetName());

            // get a list of the keys
            List<string> tableKeys = data.GetLookup().Keys.ToList();

            // determine the optimal number of rows for the table
            int optimalRowNumber = (tableKeys.Count() / splits) + (tableKeys.Count() % splits);

            int counter = 0;

            for (int i = 1; i <= optimalRowNumber; i++)
            {
                this.htmlString += "<tr>";
                for (int j = 1; j <= currentColumnCount; j++)
                {
                    this.htmlString += "<td>";
                    string currentKey = "";
                    if (counter != tableKeys.Count())
                        currentKey = tableKeys.ElementAt(counter);

                    if (j % 2 != 0)
                    {
                        this.htmlString += currentKey;
                    }
                    else
                    {
                        if (counter != tableKeys.Count())
                        {
                            if (currentKey.Equals("Source"))
                            {
                                this.htmlString += settings["Team Project Path"] + "/" + settings["Project Name"] + "/_workitems" + Environment.NewLine + data[currentKey];
                            }
                            else
                            {
                                this.htmlString += data[currentKey];
                            }
                            counter++;
                        }
                        else
                        {
                            this.htmlString += "";
                        }
                    }
                    this.htmlString += "</td>";
                }
                this.htmlString += "</tr>";
            }

            this.htmlString += "</table>";
        }
Esempio n. 4
0
 /// <summary>
 /// Generates an excel instance
 /// </summary>
 /// <param name="settings"></param>
 private ExcelGenerator(NamedLookup settings, bool silent) : base(settings, silent)
 {
     app = new Excel.Application();
     app.Visible = !this.silent;
     app.UserControl = !this.silent;
     workbook = (Excel.Workbook)app.Workbooks.Add();
     worksheet = (Excel.Worksheet)workbook.ActiveSheet;
     worksheet.Name = "Release Notes";
     app.ActiveWindow.DisplayGridlines = false;
 }
 /// <summary>
 /// Generates an excel instance
 /// </summary>
 /// <param name="settings"></param>
 private ExcelServerGenerator(NamedLookup settings, bool silent)
     : base(settings, silent)
 {
     ms = new MemoryStream();
     app = new ExcelPackage(ms);
     workbook = app.Workbook;
     app.Workbook.Worksheets.Add("Release Notes");
     app.Workbook.Worksheets.MoveToStart("Release Notes");
     worksheet = app.Workbook.Worksheets[1];
     worksheet.Name = "Release Notes";
     worksheet.View.ShowGridLines = false;
 }
Esempio n. 6
0
 /// <summary>
 /// Generates a word instance
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 public static WordGenerator WordGeneratorFactory(NamedLookup settings, bool silent)
 {
     try
     {
         return new WordGenerator(settings, silent);
     }
     catch (COMException e)
     {
         (new Logger())
             .SetLoggingType(Logger.Type.Error)
             .SetMessage(e.Message).Display();
         throw;
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Generates an Excel instance
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 public static ExcelGenerator ExcelGeneratorFactory(NamedLookup settings, bool silent)
 {
     try
     {
         return new ExcelGenerator(settings, silent);
     }
     catch (COMException e)
     {
         (new Logger())
             .SetLoggingType(Logger.Type.Error)
             .SetMessage(e.Message + "Excel not initialized. \n Are you trying to run this server-side?...")
             .Display();
         throw;
     }
 }
Esempio n. 8
0
        // output a class library instead
        /*
        static void Main(string[] args)
        {
            programStart(args);
        }*/

        public static void programStart(string[] args)
        {
            // silent mode is true by default -
			// it's faster and quieter.
			bool silent = true;

			#if DEBUG
				silent = false;
			#endif
			
			// program header
			printProgramHeader();

			// create logger
			Logger logger = new Logger()
				.SetLoggingType(Logger.Type.Message);

			// try to generate the notes
			try
			{
				// arguments
				if (args.Length == 0) throw new Exception("Settings.json file path argument missing.");

				// create release notes generator
				ReleaseNotesGenerator generator = null;

				// set vars from args
				var configuration = (SaveFile.CreateSaveFileFromPath(args[0])).GetInternalObject();
				string generatorType = configuration.GetValue("Generator Type").ToString();

				var settings = new NamedLookup("Settings");
				settings["Team Project Path"] = configuration.GetValue("Team Project Path").ToString();
				settings["Project Name"] = configuration.GetValue("Project Name").ToString();
				settings["Project Subpath"] = configuration.GetValue("Project Subpath").ToString();
				settings["Iteration"] = configuration.GetValue("Iteration").ToString();
				settings["Database"] = configuration.GetValue("Database").ToString();
				settings["Database Server"] = configuration.GetValue("Database Server").ToString();
				settings["Web Server"] = configuration.GetValue("Web Server").ToString();
				settings["Doc Type"] = "APPLICATION BUILD/RELEASE NOTES\n";
				settings["Web Location"] = configuration.GetValue("Web Location").ToString();

				switch (generatorType.ToLowerInvariant())
				{
					case "excel":
						generator = ExcelGenerator.ExcelGeneratorFactory(settings, silent);
						break;
					case "server":
						generator = ExcelServerGenerator.ExcelServerGeneratorFactory(settings, silent);
						break;
					case "word":
						generator = WordGenerator.WordGeneratorFactory(settings, silent);
						break;
					case "html":
						throw new NotImplementedException("Not implemented generator type");
					default:
						throw new Exception("Invalid generator type specified");
				}

				// generate
				generator.GenerateReleaseNotes();
			}
			catch (Exception e)
			{
				// display error
				logger
					.SetLoggingType(Logger.Type.Error)
					.SetMessage(e.Message)
					.Display();
				Thread.Sleep(1000);
			}

			if (!silent) //if we're in silent mode, the program exits. The file has been saved.
			{
				// wait for exit
				logger.SetLoggingType(Logger.Type.General)
					.SetMessage("Press any key to exit.")
					.Display();

				// wait for key
				Console.ReadKey();
			}
        }
Esempio n. 9
0
 public override void CreateNamedSection(string headername, string text, string hyperlink)
 {
     NamedLookup namedSectionData = new NamedLookup(headername);
     namedSectionData[text] = hyperlink;
     CreateHorizontalTable(namedSectionData, 1, true);
 }
Esempio n. 10
0
 /// <summary>
 /// HTML generator factory
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="silent"></param>
 /// <returns></returns>
 public static HTMLGenerator HTMLGeneratorFactory(NamedLookup settings, bool silent)
 {
     return new HTMLGenerator(settings, silent);
 }
		/// <summary>
		/// Creates some default executive summary details
		/// </summary>
		/// <returns></returns>
		public NamedLookup GetDefaultExecutiveSummary()
		{
			NamedLookup executiveSummary = new NamedLookup("Executive Summary");
			executiveSummary["Application"] = settings["Project Name"];
			executiveSummary["Release Date"] = DateTime.Now.ToShortDateString();            
			executiveSummary["Release (Sprint)"] = settings["Iteration"];
			string buildNumber = TFS.GetLatestBuildNumber();
			if (buildNumber != null)
			{
				executiveSummary["Build #"] = buildNumber;
			}            
			return executiveSummary;
		}
Esempio n. 12
0
 private HTMLGenerator(NamedLookup settings, bool silent)
     : base(settings, silent)
 {
     this.settings = settings;
     this.silent = silent;
 }
        /// <summary>
        /// Creates a horizontal data table in Excel
        /// </summary>
        /// <param name="data"></param>
        /// <param name="splits"></param>
        /// <param name="header"></param>
        public override void CreateHorizontalTable(NamedLookup data, int splits, bool header)
        {
            // 2 splits = 4 columns
            this.currentColumnCount = 2 * splits;
            this.starterRow = this.currentRow + 1;

            // if header needed
            if (header)
                CreateHeader(data.GetName());

            // get a list of the keys
            List<string> tableKeys = data.GetLookup().Keys.ToList();

            // determine the optimal number of rows for the table
            int optimalRowNumber = (tableKeys.Count() / splits) + (tableKeys.Count() % splits);

            // counter variable
            int counter = 0;

            for (int i = 1; i <= optimalRowNumber; i++)
            {
                for (int j = 1; j <= this.currentColumnCount; j++)
                {
                    ExcelRange cellRange = GetSingleCellRange(worksheet, j + currentColumnOffset - 1, currentRow);

                    string currentKey = "";
                    if (counter != tableKeys.Count())
                        currentKey = tableKeys.ElementAt(counter);

                    worksheet.Row(i).Height = 18;
                    cellRange.Style.Fill.PatternType = ExcelFillStyle.Solid;
                    cellRange.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                    cellRange.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                    cellRange.Style.Font.Bold = true;
                    cellRange.Style.Font.Size = 10;
                    cellRange.Style.Font.Name = "Arial";

                    if (j % 2 != 0)
                    {
                        cellRange.Style.Fill.BackgroundColor.SetColor(Color.LightGray);
                        cellRange.Value = currentKey;
                    }
                    else
                    {
                        if (counter != tableKeys.Count())
                        {
                            cellRange.Style.Font.Color.SetColor(Color.FromArgb(0, 112, 192));
                            if (currentKey.Equals("Source"))
                            {
                                // hyperlink
                                cellRange.Style.Font.Name = "Arial";
                                cellRange.Style.Font.Size = 10;
                                cellRange.Style.Font.Bold = true;
								cellRange.Value = settings["Team Project Path"] + "/" + settings["Project Name"] + "/_versionControl" + Environment.NewLine + data[currentKey];
								string address = settings["Team Project Path"] + "/" + settings["Project Name"] + "/_versionControl";
                                cellRange.Hyperlink = new Uri(address);
                            }
                            else
                            {
                                cellRange.Value = data[currentKey];
                            }
                            counter++;
                        }
                        else
                        {
                            cellRange.Value = "";
                        }
                        cellRange.Style.Fill.BackgroundColor.SetColor(Color.White);
                    }
                }

                if (i == optimalRowNumber)
                {
                    // style with basic theme
                    SetBasicTheme(true);
                }
                AdvanceRow(0);
            }

            // insert final table split
            AdvanceRow();
        }
		public virtual void CreateHorizontalTable(NamedLookup data, int splits, bool header) 
		{
			// Contract.Requires<ArgumentNullException>(splits > 0, "At least 1 table split must be specified");
		}
		/// <summary>
		/// Creates some default details you can choose 
		/// </summary>
		/// <returns></returns>
		public NamedLookup GetDefaultDetails()
		{
			NamedLookup sourceServerInformation = new NamedLookup("Details");
			sourceServerInformation["Web Server"] = settings["Web Server"];
			sourceServerInformation["Database Server"] = settings["Database Server"];
			sourceServerInformation["Database"] = settings["Database"];
			sourceServerInformation["Source"] = "(Changeset: " + TFS.GetLatestChangesetNumber() + ")";
			return sourceServerInformation;
		}
Esempio n. 16
0
        /// <summary>
        /// Creates a gorizontal stacked table in Word
        /// </summary>
        /// <param name="data"></param>
        /// <param name="splits"></param>
        /// <param name="header"></param>
        public override void CreateHorizontalTable(NamedLookup data, int splits, bool header)
        {
            // test preconditions
            base.CreateHorizontalTable(data, splits, header);

            // if header needed
            if (header)
                CreateHeader(data.GetName());

            // add another paragraph
            Word.Paragraph paragraph = document.Paragraphs.Add();
            Word.Range range = paragraph.Range;

            // 2 splits = 4 columns
            int numberOfColumns = 2 * splits;

            // get a list of the keys
            List<string> tableKeys = data.GetLookup().Keys.ToList();

            // determine the optimal number of rows for the table
            int optimalNumberOfRows = (tableKeys.Count() / splits) + (tableKeys.Count() % splits);

            // create the entire table with styling
            Word.Table table = document.Tables.Add(range, optimalNumberOfRows, numberOfColumns,
                Word.WdDefaultTableBehavior.wdWord9TableBehavior, Word.WdAutoFitBehavior.wdAutoFitFixed);
            table.PreferredWidth = app.InchesToPoints(6.0F);
            table.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;

            // goto first cell
            Word.Cell tableCell = table.Cell(1, 1);

            // counter variable
            int counter = 0;

            // style the entire table
            table.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            table.Borders.InsideLineWidth = Word.WdLineWidth.wdLineWidth100pt;
            table.Borders.InsideColor = Word.WdColor.wdColorGray45;
            table.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            table.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth150pt;
            table.Borders.OutsideColor = Word.WdColor.wdColorGray55;

            // set styling for horizontal columns
            for (int i = 1; i <= optimalNumberOfRows; i++)
            {
                for (int j = 1; j <= numberOfColumns; j++)
                {
                    tableCell = table.Cell(i, j);
                    string currentKey = "";
                    if (counter != tableKeys.Count())
                        currentKey = tableKeys.ElementAt(counter);

                    tableCell.Height = 18;
                    tableCell.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
                    tableCell.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                    tableCell.Range.Bold = 1;
                    tableCell.Range.Font.Size = 8;
                    tableCell.Range.Font.Name = "Arial";

                    if (j % 2 != 0)
                    {
                        tableCell.Shading.BackgroundPatternColor = Word.WdColor.wdColorGray10;
                        tableCell.Range.Text = currentKey;
                    }
                    else
                    {
                        tableCell.Range.Font.TextColor.RGB = ColorTranslator.ToOle(Color.FromArgb(0, 112, 192));
                        if (counter != tableKeys.Count())
                        {
                            if (currentKey.Equals("Source"))
                            {
                                tableCell.Range.Hyperlinks.Add(document.Range(tableCell.Range.Start, tableCell.Range.End), data[currentKey], Type.Missing,
                                    "Source Control", data[currentKey], Type.Missing);
                                tableCell.Range.Font.Name = "Arial";
                                tableCell.Range.Font.Size = 8;
                            }
                            else
                            {
                                tableCell.Range.Text = data[currentKey];
                            }
                            counter++;
                        }
                        else
                        {
                            tableCell.Range.Text = "";
                        }
                    }
                }
            }

            // split
            InsertTableSplit(paragraph);
        }
Esempio n. 17
0
        /// <summary>
        /// Creates a horizontal data table in Excel
        /// </summary>
        /// <param name="data"></param>
        /// <param name="splits"></param>
        /// <param name="header"></param>
        public override void CreateHorizontalTable(NamedLookup data, int splits, bool header)
        {
            // 2 splits = 4 columns
            this.currentColumnCount = 2 * splits;
            this.starterRow = this.currentRow + 1;

            // if header needed
            if (header)
                CreateHeader(data.GetName());

            // get a list of the keys
            List<string> tableKeys = data.GetLookup().Keys.ToList();

            // determine the optimal number of rows for the table
            int optimalRowNumber = (tableKeys.Count() / splits) + (tableKeys.Count() % splits);

            // counter variable
            int counter = 0;

            for (int i = 1; i <= optimalRowNumber; i++)
            {
                for (int j = 1; j <= this.currentColumnCount; j++)
                {
                    Excel.Range cellRange = GetSingleCellRange(worksheet, j + currentColumnOffset - 1, currentRow);

                    string currentKey = "";
                    if (counter != tableKeys.Count())
                        currentKey = tableKeys.ElementAt(counter);

                    cellRange.RowHeight = 18;
                    cellRange.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
                    cellRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
                    cellRange.Font.Bold = 1;
                    cellRange.Font.Size = 10;
                    cellRange.Font.Name = "Arial";

                    if (j % 2 != 0)
                    {
                        cellRange.Interior.Color = Excel.XlRgbColor.rgbLightGrey;
                        cellRange.Value = currentKey;
                    }
                    else
                    {
                        if (counter != tableKeys.Count())
                        {
                            cellRange.Font.Color = ColorTranslator.ToOle(Color.FromArgb(0, 112, 192));
                            if (currentKey.Equals("Source"))
                            {
                                // hyperlink
                                cellRange.Font.Name = "Arial";
                                cellRange.Font.Size = 10;
                                cellRange.Font.Bold = 1;
                                cellRange.Hyperlinks.Add(cellRange, settings["Team Project Path"] + "/" + settings["Project Name"] + "/_workitems", Type.Missing, "Work Items",
                                    settings["Team Project Path"] + "/" + settings["Project Name"] + "/_workitems" + Environment.NewLine + data[currentKey]);
                            }
                            else
                            {
                                cellRange.Value = data[currentKey];
                            }
                            counter++;
                        }
                        else
                        {
                            cellRange.Value = "";
                        }
                    }
                }

                if (i == optimalRowNumber)
                {
                    // style with basic theme
                    SetBasicTheme(true);
                }
                AdvanceRow(0);
            }

            // insert final table split
            AdvanceRow();
        }