Пример #1
0
        private static Dictionary <string, LocalIssue> ReadLastReportItems()
        {
            Dictionary <string, LocalIssue> ret = new Dictionary <string, LocalIssue>();

            string fileName = FILENAME;

            if (debug)
            {
                fileName = @"S:\dev\ApplicationServer\SupportRequestNotify\SRs.dat";
            }

            if (File.Exists(fileName))
            {
                foreach (string line in File.ReadAllLines(fileName))
                {
                    // Lines are split into Key|Priority|Status|LastEmailed|Assignee|Summary
                    string[] fields = line.Split(new Char[] { '|' });

                    LocalIssue issue = new LocalIssue();
                    issue.Key      = fields[0];
                    issue.Priority = int.Parse(fields[1]);
                    issue.Status   = int.Parse(fields[2]);

                    DateTime le;
                    if (DateTime.TryParse(fields[3], out le))
                    {
                        issue.LastEmailed = le;
                    }
                    else
                    {
                        Log("Failed to parse DateTime {0}".Args(fields[3]));
                        issue.LastEmailed = DateTime.Now;
                    }
                    issue.AssignedTo = fields[4];
                    issue.Summary    = fields[5];

                    ret.Add(issue.Key, issue);
                }
            }

            return(ret);
        }
Пример #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);
        }