Example #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}.");
            }
        }
        public static SettlementHistory Parse(string filename)
        {
            SettlementHistoryParser parser = new SettlementHistoryParser(
                filename, GetSettlementIdFromFile(filename));
            SettlementHistory settlement = parser.Parse();

            return(settlement);
        }
Example #3
0
        private bool SaveFileToDatabase(string filename, SettlementHistory settlement)
        {
            SettlementHistory parsedSettlement = SettlementHistoryParser.Parse(filename);

            if (parsedSettlement != null)
            {
                settlement.Credits    = parsedSettlement.Credits;
                settlement.Deductions = parsedSettlement.Deductions;

                repository.SaveSettlementHistoryAsync(settlement).Wait();
                System.Console.WriteLine($"Saved {settlement.SettlementId} to db.");
                return(true);
            }
            else
            {
                System.Console.WriteLine($"Unable to parse {filename}.");
                return(false);
            }
        }
Example #4
0
 private string GetSettlementId(ZamzarResult result)
 {
     return(SettlementHistoryParser.GetSettlementIdFromFile(
                result.target_files[0].name));
 }