示例#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);
                }
            }
        }
示例#2
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();
        }