Beispiel #1
0
        private static void ProcessDownloaded(PantherClient panther, string convertApiKey)
        {
            System.Console.WriteLine("Processing local converted xlsx files.");

            List <SettlementHistory> settlementHeaders     = null;
            List <SettlementHistory> downloadedSettlements = null;
            var getSettlementHeaders = Task.Run(async() => {
                settlementHeaders = await panther.GetSettlementsAsync();
            });
            var parseLocalFiles = Task.Run(() =>
                                           downloadedSettlements = SettlementHistoryParser.ParseLocalFiles(panther.Company));

            Task.WaitAll(getSettlementHeaders, parseLocalFiles);

            if (downloadedSettlements.Count > 0)
            {
                System.Console.WriteLine($"Found {downloadedSettlements.Count} to process.");
                List <SettlementHistory> mergedSettlements =
                    MergeSettlements(settlementHeaders, downloadedSettlements).ToList();
                System.Console.WriteLine($"Merged {mergedSettlements.Count}.");

                if (mergedSettlements.Count > 0)
                {
                    SettlementRepository repository = new SettlementRepository();
                    repository.SaveSettlements(mergedSettlements);
                }
            }
            else
            {
                System.Console.WriteLine($"No settlements found for company {panther.Company}.");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Forces an update on all settlements.  This is normally used to update the serialized
        /// object after a schema change.
        /// </summary>
        public string[] UpdateAll()
        {
            System.Console.WriteLine($"Updating all settlements.");
            List <SettlementHistory> savedSettlements = null;

            var task = Task.Run(async() =>
            {
                SettlementRepository repository = new SettlementRepository();
                savedSettlements = await repository.GetSettlementsAsync();
                repository.SaveSettlements(savedSettlements);
            });

            task.Wait();

            string[] settlementIds = savedSettlements?.Select(s => s.SettlementId).ToArray();
            return(settlementIds);
        }
Beispiel #3
0
        public string[] UpdateHeadersFromPanther(PantherClient panther)
        {
            System.Console.WriteLine($"Updating settlements for company: {panther.Company}.");
            List <SettlementHistory> settlementsToUpdate = null;

            var task = Task.Run(async() =>
            {
                List <SettlementHistory> settlements = await panther.GetSettlementsAsync();

                SettlementRepository repository           = new SettlementRepository();
                List <SettlementHistory> savedSettlements = await repository.GetSettlementsAsync();

                settlementsToUpdate =
                    settlements.Intersect(savedSettlements, new SettlementHistoryComparer())
                    .ToList();
                repository.SaveSettlements(settlementsToUpdate);
            });

            task.Wait();

            string[] settlementIds = settlementsToUpdate?.Select(s => s.SettlementId).ToArray();
            return(settlementIds);
        }