示例#1
0
        public static ReportStorage Restore(string path)
        {
            var storage = new ReportStorage(path);

            if (File.Exists(path))
            {
                foreach (var r in File.ReadAllLines(path, Encoding.UTF8).Select(JsonConvert.DeserializeObject <Report>))
                {
                    storage.storage[r.Sid] = r;
                }
            }

            return(storage);
        }
示例#2
0
文件: Main.cs 项目: ysemerikov/Tools
        private static void AnalyzeResult(ReportStorage reportStorage)
        {
            var allReports = reportStorage.GetAllReports()
                             .Where(x => x.ErrorType == ErrorType.CallWasntConnected)
                             .DistinctBy(x => x.CallSid)
                             .Select(TenantLogic.GetTenant)
                             .Where(x => x != null)
                             //.Where(x => !x.Tenant.StartsWith("id-") && x.Tenant != "tulsa" && x.Tenant != "okc")
                             .GroupBy(x => x)
                             .Select(x => $"{x.Key},{x.Count()}")
                             .OrderBy(x => x)
                             .ToList();

            File.AppendAllLines(@"C:\servicetitan\report.csv", allReports);
        }
示例#3
0
文件: Main.cs 项目: ysemerikov/Tools
        public async Task Do()
        {
            var client = new TwilioRestClient(Secrets.Twilio.ProductionUsername, Secrets.Twilio.ProductionPassword);

            var reportStorage = ReportStorage.Restore(@"C:\servicetitan\tw-report-storage.bin");
            var data          = (await GetAllNotifications(client))
                                .Where(x => new DateTime(2019, 12, 16, 20, 0, 0) < x.DateCreated &&
                                       x.DateCreated < new DateTime(2019, 12, 16, 22, 0, 0));

            var counter = 0;

            foreach (var @event in data.Where(x => !reportStorage.Has(x)))
            {
                if (@event.CallSid.StartsWith("MM") ||
                    @event.CallSid.StartsWith("SM")
                    )
                {
                    continue;
                }

                var report = await TwilioLogic.GetReport(@event, client);

                if (report == null || report.ErrorType == ErrorType.Unknown)
                {
                    Console.WriteLine();
                    Console.WriteLine(JsonConvert.SerializeObject(@event));
                    break;
                }

                await reportStorage.Add(report);

                Console.Write($"\r        \r{++counter}");
            }

            AnalyzeResult(reportStorage);
        }