Пример #1
0
        private static async Task <int> GenerateStats(StartupParameters startParams)
        {
            try
            {
                var monthsBack = startParams.MonthsBack ?? 6;
                var start      = DateTime.Today.AddMonths(-monthsBack);
                start = DateFunctions.NextFriday(start);
                var startWeekend = DateFunctions.MakeWeekendRange(start);
                Console.WriteLine($"Starting at {startWeekend} for services {startParams.Services}");

                var pagerDutyClient = new PagerDutyClient(startParams);
                var incidentCounter = new IncidentCounter(pagerDutyClient);

                await ReadWeekends(incidentCounter, startWeekend);

                Console.WriteLine("Done");
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Run failed: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(1);
            }
        }
Пример #2
0
        public static int Main(string[] args)
        {
            StartupParameters startParams = new StartupParameters();

            if (!Parser.Default.ParseArguments(args, startParams))
            {
                Console.WriteLine("Missing required arguments, exiting...");
                return(1);
            }

            var task = GenerateStats(startParams);

            task.Wait();
            var result = task.Result;

            //Console.ReadLine();
            return(result);
        }
 public PagerDutyClient(StartupParameters parameters)
 {
     _parameters = parameters;
 }