Esempio n. 1
0
        private static void GetSystemAndCustomIssueFields()
        {
            var repo = JiraUtil.JiraRepo;
            IEnumerable <CustomField> fields = repo.GetJira().Fields.GetCustomFieldsAsync().GetAwaiter().GetResult();

            ConsoleUtil.WriteLine("");
            ConsoleUtil.WriteLine("***** SYSTEM AND CUSTOM ISSUE FIELDS *********", ConsoleColor.White, ConsoleColor.DarkBlue, false);

            var table = new ConsoleTable("Id", "Name", "CustomType", "CustomIdentfier");

            foreach (var field in repo.GetJira().Fields.GetCustomFieldsAsync().GetAwaiter().GetResult())
            {
                table.AddRow(field.Id, field.Name, field.CustomType, field.CustomIdentifier);
            }
            table.Write();

            ConsoleUtil.WriteLine("***** SYSTEM AND CUSTOM ISSUE FIELDS *********", ConsoleColor.White, ConsoleColor.DarkBlue, false);
            ConsoleUtil.PressAnyKeyToContinue();
        }
Esempio n. 2
0
        private static void GetServerInfo()
        {
            var repo = JiraUtil.JiraRepo;

            DateTimeOffset?serverTime = repo.ServerInfo.ServerTime;

            ConsoleUtil.WriteLine("***** SERVER INFO *********", ConsoleColor.White, ConsoleColor.DarkBlue, false);
            var table = new ConsoleTable("Key", "Value");

            table.AddRow("BaseUrl", repo.ServerInfo.BaseUrl);
            table.AddRow("Build", repo.ServerInfo.BuildNumber);
            table.AddRow("Deployment Type", repo.ServerInfo.DeploymentType);
            table.AddRow("Server Time", serverTime.HasValue ? serverTime.Value.DateTime.ToShortTimeString() : "Unknown");
            table.AddRow("Server Title", repo.ServerInfo.ServerTitle);
            table.AddRow("Version", repo.ServerInfo.Version);
            table.Write();
            ConsoleUtil.WriteLine("***** END SERVER INFO *****", ConsoleColor.White, ConsoleColor.DarkBlue, false);
            ConsoleUtil.PressAnyKeyToContinue();
        }
Esempio n. 3
0
        private static bool InitializedMenu()
        {
            ConsoleUtil.BuildInitializedMenu();
            ConsoleUtil.Lines.WriteQueuedLines(true);

            var resp = Console.ReadKey(true);

            if (resp.Key == ConsoleKey.M)
            {
                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Enter 1 or more card keys separated by a space (e.g. POS-123 POS-456 BAM-789), or E to exit.", ConsoleColor.Black, ConsoleColor.White, false);
                var keys = Console.ReadLine().ToUpper();
                if (string.IsNullOrWhiteSpace(keys))
                {
                    return(true);
                }
                if (keys.ToUpper() == "E")
                {
                    return(false);
                }

                string[] arr = keys.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (arr.Length >= 1)
                {
                    ConsoleUtil.WriteLine("Would you like to include changes to card description and comments? (enter Y to include)");
                    resp = Console.ReadKey(true);
                    if (resp.Key == ConsoleKey.Y)
                    {
                        AnalyzeIssues(keys, true);
                    }
                    else
                    {
                        AnalyzeIssues(keys, false);
                    }
                }

                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Press any key to continue.");
                Console.ReadKey(true);
                return(true);
            }
            else if (resp.Key == ConsoleKey.X)
            {
                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Enter or paste JQL then press enter to continue.");
                var jql = Console.ReadLine();
                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine(string.Format("Enter (Y) to use the following JQL?\r\n***** {0}", jql));
                ConsoleUtil.WriteLine("");
                var keys = Console.ReadKey(true);
                if (keys.Key == ConsoleKey.Y)
                {
                    ConsoleUtil.WriteLine("");
                    ConsoleUtil.WriteLine("Enter (Y)es to include card descriptions and comments in the Change History file, otherwise press any key");
                    ConsoleUtil.WriteLine("");
                    var  k = Console.ReadKey(true);
                    bool includeCommentsAndDesc = false;
                    if (k.Key == ConsoleKey.Y)
                    {
                        includeCommentsAndDesc = true;
                    }

                    CreateExtractFiles(jql, includeCommentsAndDesc);
                    ConsoleUtil.WriteLine("");
                    ConsoleUtil.WriteLine("Press any key to continue.");
                    Console.ReadKey(true);
                }
                return(true);
            }
            else if (resp.Key == ConsoleKey.W)
            {
                string jql = GetJQL();

                int startHour = 7;
                int endHour   = 18;

                if (jql != null)
                {
                    var dic = GetBusinessHours();
                    startHour = dic["start"];
                    endHour   = dic["end"];

                    CreateWorkMetricsFile(jql, startHour, endHour);

                    ConsoleUtil.PressAnyKeyToContinue();
                }
                return(true);
            }
            else if (resp.Key == ConsoleKey.A)
            {
                var epicAnalysis = new EpicAnalysis();
                epicAnalysis.Analyze();
                return(true);
            }
            else if (resp.Key == ConsoleKey.I)
            {
                ShowItemStatusConfig();

                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Press any key to continue.");
                Console.ReadKey(true);
                return(true);
            }
            else if (resp.Key == ConsoleKey.J)
            {
                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Enter or paste JQL then press enter to continue.");
                var jql = Console.ReadLine();
                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine(string.Format("Enter (Y) to use the following JQL?\r\n***** {0}", jql));
                var keys = Console.ReadKey(true);
                if (keys.Key == ConsoleKey.Y)
                {
                    ShowJSON(jql);
                    ConsoleUtil.WriteLine("");
                    ConsoleUtil.WriteLine("Press any key to continue.");
                    Console.ReadKey(true);
                }
                return(true);
            }
            else if (resp.Key == ConsoleKey.C)
            {
                while (ConfigMenu())
                {
                }
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        private static void GetIssueTypesForProject()
        {
            ConsoleUtil.WriteLine("");
            ConsoleUtil.WriteLine("***** PROJECTS *********", ConsoleColor.White, ConsoleColor.DarkBlue, false);

            var            projects    = JiraUtil.JiraRepo.GetJira().Projects.GetProjectsAsync().GetAwaiter().GetResult();
            List <Project> projectList = new List <Project>();

            projectList.AddRange(projects);
            projectList = projectList.OrderBy(x => x.Key).ToList();

            var table = new ConsoleTable("Key", "Name", "Id");

            foreach (var p in projectList)
            {
                table.AddRow(p.Key, p.Name, p.Id);
            }
            table.Write();

            ConsoleUtil.WriteLine("***** END PROJECTS *****", ConsoleColor.White, ConsoleColor.DarkBlue, false);
            ConsoleUtil.WriteLine("");
            ConsoleUtil.WriteLine("Would you like to see valid issue types for one or more of the above projects?", ConsoleColor.White, ConsoleColor.DarkMagenta, false);
            ConsoleUtil.WriteLine("Press 'Y' to Enter 1 or more Project Key, otherwise PRESS ANY KEY TO CONTINUE", ConsoleColor.White, ConsoleColor.DarkMagenta, false);
            var key = Console.ReadKey(true);

            if (key.Key == ConsoleKey.Y)
            {
                while (true)
                {
                    ConsoleUtil.WriteLine("Enter 1 or more project keys (listed above) separated by a space (e.g. POS BAM)");
                    var read = Console.ReadLine();
                    if (read != null && read.Length > 0)
                    {
                        string[] keys    = read.ToUpper().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        bool     invalid = false;
                        foreach (var k in keys)
                        {
                            if (projectList.Where(y => y.Key != null && y.Key == k).FirstOrDefault() == null)
                            {
                                invalid = true;
                                ConsoleUtil.WriteLine(string.Format("'{0}' is not a valid project. Try again.", k));
                                ConsoleUtil.PressAnyKeyToContinue();
                            }
                        }
                        if (!invalid)
                        {
                            foreach (var k in keys)
                            {
                                var issueTypes = JiraUtil.JiraRepo.GetIssueTypes(k).OrderBy(x => x.Name);
                                ConsoleUtil.WriteLine("");
                                ConsoleUtil.WriteLine(string.Format("***** PROJECT '{0}' ISSUE TYPES *********", k), ConsoleColor.White, ConsoleColor.DarkBlue, false);

                                table = new ConsoleTable("Proj", "Id", "Name", "Description", "IsSubTask");
                                foreach (var type in issueTypes)
                                {
                                    table.AddRow(string.Format("({0})", k), type.Id, type.Name, type.Description, type.IsSubTask);
                                }
                                table.Write();
                                ConsoleUtil.WriteLine(string.Format("***** END PROJECT '{0}' ISSUE TYPES *****", k), ConsoleColor.White, ConsoleColor.DarkBlue, false);
                                ConsoleUtil.PressAnyKeyToContinue();
                            }
                            break;
                        }
                    }
                }
            }

            ConsoleUtil.PressAnyKeyToContinue();
        }
Esempio n. 5
0
        private static bool Menu()
        {
            BuildMenu();
            ConsoleUtil.Lines.WriteQueuedLines(true);

            //string jql2 = string.Format("project in (BAM,POS) AND parentEpic={0}", epicKey);

            //project in (require 1 or more))

            /*
             * 1.  specify 1 or more projects, space delimited
             * 2.  optional
             *   - ANY search terms found in Summary OR Description
             *   - ALL search terms found in Summary OR Description
             *   -
             *
             *
             *
             */

            var resp = Console.ReadKey(true);

            if (resp.Key == ConsoleKey.K)
            {
                ConsoleUtil.WriteLine("Enter Epic Key (e.g. BAM-1234)");
                var epicKey = Console.ReadLine();
                ConsoleUtil.WriteLine(string.Format("Create time metrics for Epic: {0}? (ENTER 'Y' TO CONTINUE OR PRESS ANOTHER KEY TO RETURN TO MENU", epicKey));
                var read = Console.ReadKey(true);
                if (read.Key != ConsoleKey.Y)
                {
                    return(true);
                }

                var dic       = MainClass.GetBusinessHours();
                int startHour = dic["start"];
                int endHour   = dic["end"];

                MainClass.CreateWorkMetricsFile(BuildJQL_EpicChildren(epicKey), startHour, endHour, epicKey);

                ConsoleUtil.WriteLine("");
                ConsoleUtil.WriteLine("Press any key to continue.");
                Console.ReadKey(true);
            }
            else if (resp.Key == ConsoleKey.F)
            {
                string projects           = string.Empty;
                bool   ANDED              = false;
                bool   SUMMARY_ONLY       = false;
                bool   RETURN_ALL_RESULTS = false;;
                string searchTerms        = string.Empty;

                ConsoleUtil.WriteLine("You are required to enter 1 or more project keys.", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("optionally you can enter search terms to finds Epics by Summary (Title) or Description.", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("ENTER 1 OR MORE PROJECT KEYS, SEPARATED BY SPACES (e.g. BAM POS)", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                projects = Console.ReadLine();
                ConsoleUtil.WriteLine("***** Epic Summary (Title) and Description Search *****", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("***** Choose a search option *****", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("1 - Return epics where Summary or Description contain ANY search terms", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("2 - Return epics where Summary or Description contain ALL search terms", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("3 - Return epics where Summary (Title) contains ANY search terms", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("4 - Return epics where Summary (Title) contains ALL search terms", ConsoleColor.White, ConsoleColor.DarkCyan, false);
                ConsoleUtil.WriteLine("5 - View list of all epics for selected project(s).", ConsoleColor.White, ConsoleColor.DarkCyan, false);

                var    searchOption       = Console.ReadKey(true);
                string searchStrategyDesc = string.Empty;

                if (searchOption.KeyChar.ToString() == "1")
                {
                    ConsoleUtil.WriteLine("Search Option 1 selected", ConsoleColor.White, ConsoleColor.DarkYellow, false);
                    searchStrategyDesc = "Enter 1 or more search terms, separated by spaces. Epics that contain ** ANY ** search terms (Summary or Desc fields) will be returned.";
                    ANDED = false;
                }
                else if (searchOption.KeyChar.ToString() == "2")
                {
                    ConsoleUtil.WriteLine("Search Option 2 selected", ConsoleColor.White, ConsoleColor.DarkYellow, false);
                    searchStrategyDesc = "Enter 1 or more search terms, separated by spaces. Epics that contain ** ALL ** search terms (Summary or Desc fields) will be returned.";
                    ANDED = true;
                }
                else if (searchOption.KeyChar.ToString() == "3")
                {
                    ConsoleUtil.WriteLine("Search Option 3 selected", ConsoleColor.White, ConsoleColor.DarkYellow, false);
                    searchStrategyDesc = "Enter 1 or more search terms, separated by spaces. Epics that contain ** ANY ** search terms (Summary field) will be returned.";
                    ANDED        = false;
                    SUMMARY_ONLY = true;
                }
                else if (searchOption.KeyChar.ToString() == "4")
                {
                    ConsoleUtil.WriteLine("Search Option 4 selected", ConsoleColor.White, ConsoleColor.DarkYellow, false);
                    searchStrategyDesc = "Enter 1 or more search terms, separated by spaces. Epics that contain ** ALL ** search terms (Summary field) will be returned.";
                    ANDED        = true;
                    SUMMARY_ONLY = true;
                }
                else if (searchOption.KeyChar.ToString() == "5")
                {
                    ConsoleUtil.WriteLine("Search Option 5 selected", ConsoleColor.White, ConsoleColor.DarkYellow, false);

                    RETURN_ALL_RESULTS = true;
                }



                if (projects == null || projects.Trim().Length == 0)
                {
                    ConsoleUtil.WriteLine("1 Or More Project Keys is required!  Doh!", ConsoleColor.Red, ConsoleColor.White, false);
                    ConsoleUtil.PressAnyKeyToContinue();
                    return(true);
                }
                if (!RETURN_ALL_RESULTS)
                {
                    ConsoleUtil.WriteLine(searchStrategyDesc, ConsoleColor.White, ConsoleColor.DarkCyan, false);
                    searchTerms = Console.ReadLine();

                    if (searchTerms == null || searchTerms.Trim().Length == 0)
                    {
                        ConsoleUtil.WriteLine("You chose to search for epics based on search terms, but failed to enter any search terms.  Doh!", ConsoleColor.Red, ConsoleColor.Yellow, false);
                        ConsoleUtil.PressAnyKeyToContinue();
                        return(true);
                    }
                }
                string epicSearchJQL = BuildJQL_EpicSearch(projects, searchTerms, ANDED, SUMMARY_ONLY, RETURN_ALL_RESULTS);;
                ConsoleUtil.WriteLine(string.Format("AWESOME -- Please be patient while your results are fetched using the following *** JQL: {0}", epicSearchJQL), ConsoleColor.DarkBlue, ConsoleColor.Gray, false);

                var epics = JiraUtil.JiraRepo.GetIssues(epicSearchJQL);
                ConsoleUtil.WriteLine("***** ***** *****", ConsoleColor.White, ConsoleColor.Black, false);
                ConsoleUtil.WriteLine("***** ***** *****", ConsoleColor.White, ConsoleColor.Black, false);
                ConsoleUtil.WriteLine(string.Format("{0} epics were found matching your search criteria", epics.Count), ConsoleColor.White, ConsoleColor.Black, false);
                ConsoleUtil.WriteLine("***** ***** *****", ConsoleColor.White, ConsoleColor.Black, false);
                ConsoleUtil.WriteLine("***** ***** *****", ConsoleColor.White, ConsoleColor.Black, false);
                ConsoleUtil.PressAnyKeyToContinue();

                if (epics.Count == 0)
                {
                    return(true);
                }
                ConsoleUtil.WriteLine("Please wait while the search results are evaluated", ConsoleColor.DarkBlue, ConsoleColor.Gray, false);
                SortedList <JIssue, List <JIssue> > epicsWithChildren = new SortedList <JIssue, List <JIssue> >();

                string[] projArray       = projects.ToUpper().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string   projSearchItems = projArray.Length == 1 ? projArray[0] : String.Join(",", projArray);

                int epicsEvaluated  = 0;
                int totalEpicsFound = epics.Count;

                foreach (Issue epic in epics)
                {
                    epicsEvaluated += 1;
                    SortedDictionary <string, int> epicIssueBreakdown = new SortedDictionary <string, int>();
                    JIssue jepic = new JIssue(epic);
                    ConsoleUtil.WriteLine(string.Format("Analyzing Epic: {0} ({1}) - {2}", jepic.Key, jepic.StatusName, jepic.Summary), ConsoleColor.DarkBlue, ConsoleColor.Gray, false);

                    string epicIssuesJQL = string.Format("project in({0}) AND parentEpic={1}", projSearchItems, jepic.Key);

                    List <Issue>  epicIssues   = JiraUtil.JiraRepo.GetIssues(epicIssuesJQL);
                    List <JIssue> epicChildren = new List <JIssue>();
                    foreach (Issue epicIssue in epicIssues)
                    {
                        JIssue epicChild = new JIssue(epicIssue);
                        epicChildren.Add(epicChild);
                        if (epicIssueBreakdown.ContainsKey(epicChild.IssueType.ToLower()))
                        {
                            epicIssueBreakdown[epicChild.IssueType.ToLower()] = epicIssueBreakdown[epicChild.IssueType.ToLower()] + 1;
                        }
                        else
                        {
                            epicIssueBreakdown.Add(epicChild.IssueType.ToLower(), 1);
                        }
                    }
                    ConsoleTable table = new ConsoleTable(string.Format("Epic:{0} ({1}/{2} results)", jepic.Key, epicsEvaluated, totalEpicsFound), "ChildType", "Qty");
                    foreach (var kvp in epicIssueBreakdown)
                    {
                        table.AddRow(" ***** ", kvp.Key, kvp.Value);
                    }
                    table.Write();

                    ConsoleUtil.WriteLine(string.Format("Isn't this cool? -- Do you want to generate the Work Time Analytics for this Epic ({0})? (Don't worry, we'll come back here where you left off if you decide to do that!)", jepic.Key), ConsoleColor.DarkBlue, ConsoleColor.Gray, false);
                    ConsoleUtil.WriteLine(string.Format("Press 'Y' to generate the Work Time Analytics file for epic {0}", jepic.Key), ConsoleColor.DarkBlue, ConsoleColor.Gray, false);
                    ConsoleUtil.WriteLine(string.Format("Press 'E' to stop reviewing epic search results", jepic.Key), ConsoleColor.DarkBlue, ConsoleColor.Gray, false);
                    ConsoleUtil.WriteLine(string.Format("Press any other key to continue reviewing epic search results.", jepic.Key), ConsoleColor.DarkBlue, ConsoleColor.Gray, false); var read = Console.ReadKey(true);
                    if (read.Key == ConsoleKey.Y)
                    {
                        MainClass.CreateWorkMetricsFile(epicIssuesJQL, 7, 18, jepic.Key);
                        ConsoleUtil.PressAnyKeyToContinue();
                    }
                    else if (read.Key == ConsoleKey.E)
                    {
                        return(true);
                    }
                }
            }
            else if (resp.Key == ConsoleKey.M)
            {
                return(false);
            }

            return(true);
        }