Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Properties.Settings setting = Properties.Settings.Default;

            if (args.Length > 0)
            {
                Dictionary <string, bool> values = new Dictionary <string, bool>();
                foreach (string arg in args)
                {
                    values.Add(arg.ToLower(), true);
                }

                // Set args that are there
                if (values.ContainsKey("debug"))
                {
                    debug = true;
                }
                if (values.ContainsKey("log"))
                {
                    logOn = true;
                }
            }

            try {
                Log("============ Starting at {0}".Args(DateTime.Now.ToString("HH:mm:ss")));

                string jUserID   = Maple.Security.Decrypt(Properties.Settings.Default.JiraUser);
                string jPassword = Maple.Security.Decrypt(Properties.Settings.Default.JiraPw);
                string appName   = "";

                appName = Environment.GetCommandLineArgs()[0];
                Console.WriteLine("");
                Console.WriteLine(" {0}. Checking support requests.".Args(appName));
                Console.WriteLine("");

                //string jqlString = "(project = \"Help MSUK\" AND resolution = Unresolved AND status in (Open, \"In Progress\", \"Transferred To IT MSUK\") AND \"Support Team\" = Dev)";
                string jqlString = "(project = \"Help MSUK\" AND resolution = Unresolved AND status in (Open, \"In Progress\", \"Transferred To IT MSUK\") AND \"Support Team\" = Dev)";

                Dictionary <string, LocalIssue> reportedItems = ReadLastReportItems();

                List <Issue> jiraIssues = GetJiraIssues(jqlString, jUserID, jPassword);
                Log("Issues found = {0}".Args(jiraIssues.Count));

                string toEmail = "";
                itemsToWrite = "";
                foreach (Issue iss in jiraIssues)
                {
                    toEmail += ProcessItem(iss, reportedItems);
                }

                if (toEmail != "")
                {
                    toEmail = WrapInTable(toEmail);

                    Notifier.SendEmail(EmailTarget(), "Outstanding SRs", toEmail, true);

                    WriteReportedItems();
                }
            } catch (Exception ex) {
                Notifier.SendEmail(EmailTarget(), "Support Request Notifier Problem", "Error:\r\n\r\n{0}\r\n\r\n{1}".Args(ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 2
0
        private static string ProcessItem(Issue iss, Dictionary <string, LocalIssue> reportedItems)
        {
            string ret = "";

            Properties.Settings setting = Properties.Settings.Default;

            string key = iss.Key.ToString();

            // Has someone picked it up?
            if (iss.Assignee == null)
            {
                LocalIssue liss;

                // Did it exist last time we checked?
                if (reportedItems.ContainsKey(key))
                {
                    liss = reportedItems[key];

                    double minutesSinceEmail = (DateTime.Now - liss.LastEmailed).TotalMinutes;
                    switch (iss.Priority.ToString())
                    {
                    case "1":     // Blocker
                        if (minutesSinceEmail > setting.BlockerMinuteLimit)
                        {
                            liss.Report = true;
                        }
                        break;

                    case "2":     // Critical
                        if (minutesSinceEmail > setting.CriticalMinuteLimit)
                        {
                            liss.Report = true;
                        }
                        break;

                    case "3":     // Major
                        if (minutesSinceEmail > setting.MajorMinuteLimit)
                        {
                            liss.Report = true;
                        }
                        break;

                    default:
                        if (minutesSinceEmail > setting.MinuteLimit)
                        {
                            liss.Report = true;
                        }
                        break;
                    }
                }
                else
                {
                    // not reported before
                    Log("New issue found {0}".Args(iss.Key));

                    liss            = new LocalIssue();
                    liss.Key        = iss.Key.ToString();
                    liss.Summary    = iss.Summary;
                    liss.Status     = int.Parse(iss.Status.ToString());
                    liss.Priority   = int.Parse(iss.Priority.ToString());
                    liss.AssignedTo = iss.Assignee == null ? "Unassigned" : iss.Assignee;
                    liss.Report     = true;
                }

                if (liss.Report)
                {
                    Log("Need to report issue {0}".Args(liss.Key));
                    ret = "<tr><td><a href=\"https://jira.de.maplebank.eu/browse/{0}\">{0}</a></td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>".Args(
                        liss.Key,
                        PriorityName(liss.Priority),
                        StatusName(liss.Status),
                        liss.AssignedTo,
                        liss.Summary);

                    // Lines are split into Key|Priority|Status|LastEmailed|Assignee|Summary
                    itemsToWrite += "{0}|{1}|{2}|{3}|{4}|{5}\r\n".Args(
                        liss.Key,
                        liss.Priority,
                        liss.Status,
                        DateTime.Now.ToString("dd MMM yyyy HH:mm:ss"),
                        liss.AssignedTo,
                        liss.Summary);
                }
            }

            return(ret);
        }