Example #1
0
        /// <summary>
        /// The main method launched after starting the program.
        /// The program retrieves issues from a Jira sprint and fills in fields to prioritize them according to the defined settings.
        /// </summary>
        /// <param name="args">Arguments from the command line. None are accepted.</param>
        static void Main(string[] args)
        {
            string logPath = PrepareLogPath();

            MirrorConsole(logPath);

            // Writer for both a log file and the console output.
            using (FileAndConsoleWriter writer = new FileAndConsoleWriter(logPath))
            {
                if (writer.Stream == null || writer.Writer == null)
                {
                    Console.ReadLine();
                    Environment.Exit(1);
                }

                writer.WriteLine("The log file is located at: {0}", logPath);

                try
                {
                    // Continues with further processing of the Jira issues.
                    ProcessIssuesAsync(writer).Wait();
                }
                catch (Exception ex)
                {
                    // Writes the exception message to both the console output and log file.
                    writer.WriteLine(ex.Message);
                    writer.WriteLine(ex.StackTrace);

                    Environment.Exit(1);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="connector">Connector to the Atlassian services that keeps the connection with the program.</param>
 /// <param name="writer">Instance of the log writer.</param>
 /// <param name="sprintId">Jira sprint ID.</param>
 /// <param name="emailFrom">Email address from which notification emails are sent. Also, the username for signing in.</param>
 /// <param name="emailTo">Email address to which notification emails are sent.</param>
 /// <param name="emailFromPassword">Password to the user account specified by the <see cref="EmailTo"/></param>
 public JiraManager(AtlassianConnector connector, FileAndConsoleWriter writer, int sprintId, string emailFrom, string emailTo, string emailFromPassword)
 {
     Connector         = connector;
     Writer            = writer;
     SprintId          = sprintId;
     EmailFrom         = emailFrom;
     EmailTo           = emailTo;
     EmailFromPassword = emailFromPassword;
 }
Example #3
0
        /// <summary>
        /// Processes retrieving of Jira issues based on the given parametes and the consecutive filling in the values according to the specified formula.
        /// </summary>
        /// <param name="writer">Instance of the log writer.</param>
        static async Task ProcessIssuesAsync(FileAndConsoleWriter writer)
        {
            string[] requiredAppSettings            = requiredAppSettingsBasic.Union(requiredAppSettingsConnection).Union(requiredAppSettingsPrioritization).ToArray();
            Dictionary <string, string> appSettings = new Dictionary <string, string>();

            foreach (string requiredAppSettingKey in requiredAppSettings)
            {
                string requiredAppSettingValue = ConfigurationManager.AppSettings[requiredAppSettingKey];

                if (String.IsNullOrEmpty(requiredAppSettingValue))
                {
                    writer.WriteLine($"The required {requiredAppSettingKey} app.config key is missing. Terminating the prioritization.");
                    return;
                }
                else
                {
                    appSettings.Add(requiredAppSettingKey, requiredAppSettingValue);
                }
            }

            // Creates a connection with the REST services of the Atlassian products and signs in.
            AtlassianConnector connector = new AtlassianConnector(new Uri(appSettings["RestBaseServiceUrl"]), new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{appSettings["JiraUsername"]}:{appSettings["JiraUserApiKey"]}"))));

            // Converts sprint ID to a number.
            if (!Int32.TryParse(appSettings["SprintId"], out int sprintId))
            {
                Console.WriteLine("The sprint ID is not a number.");
                Console.ReadLine();
                Environment.Exit(1);
            }

            // Initializes a manager that prioritizes the backlog.
            JiraManager manager = new JiraManager(connector, writer, sprintId, appSettings["EmailFrom"], appSettings["EmailTo"], appSettings["EmailFromPassword"]);

            // Prioritizes the backlog.
            await manager.PrioritizeBacklogAsync();
        }