public static void Main(string[] args) { try { /// ///@get List<Payments> /// Payments payments = new Payments(); string FileNamePayments = "Payments.json"; List <Payments> paymentsList = payments.ReadPaymentsFromFile(FileNamePayments); /// ///@get List<Prices> /// Prices prices = new Prices(); string FileNamePrices = "Prices.xml"; List <Prices> pricesList = prices.ReadPricesFromFile(FileNamePrices); /// ///@get List<Purchases> /// Purchases purchases = new Purchases(); string FileNamePurchases = "Purchases.dat"; List <Purchases> purchaseList = purchases.ReadPurchasesFromFile(FileNamePurchases); /// ///@get List<PaymentsNotMatched> /// PaymentsNotMatched paymentsNotMatched = new PaymentsNotMatched(); List <PaymentsNotMatched> paymentsNotMatchedList = paymentsNotMatched.ReadPaymentsNotMatchedList(paymentsList, purchaseList, pricesList); /// ///@write List<PaymentsNotMatched> /// paymentsNotMatched.WritePaymentsToFileJson(paymentsNotMatchedList); paymentsNotMatched.WritePaymentsToFileCsv(paymentsNotMatchedList); Console.WriteLine("Press one key to exit"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("Ex:{0}", ex.Message); } }
/// <summary> /// Main Method /// </summary> public async Task GetPayments() { await Task.Run(async() => { //Reads from Purchasess.dat Console.WriteLine("Reads from Purchasess.dat"); await MyLogger.WriteLog("Reads from Purchasess.dat"); PurchasesList = await Purchases.GetPurchases(); Console.WriteLine("Ok"); await MyLogger.WriteLog("Done"); //Reads fom Pricess XML Console.WriteLine("Reads from Pices.xml"); await MyLogger.WriteLog("Reads from Pices.xml"); PricesList = await ItemPricesList.GetItemPricesList(); Console.WriteLine("Ok"); await MyLogger.WriteLog("Done"); //Reads from Payments Json Console.WriteLine("Reads from Payments.json"); await MyLogger.WriteLog("Reads from Payments.json"); PaymentsList = await Payment.GetPaiments(); Console.WriteLine("Ok"); await MyLogger.WriteLog("Done"); Console.WriteLine("Start the PaymentsNotMatched Loop"); await MyLogger.WriteLog("Start the PaymentsNotMatched Loop"); foreach (var p in PurchasesList) { PaymentsNotMatched n = new PaymentsNotMatched(); n.Customer = p.Customer; n.Month = p.Month; n.Year = p.Year; n.AmountPaid = await GetAmoutPayd(p); foreach (var i in p.Item) { //Sum the price to total to pay. n.Amount += await GetPriceForProductAsync(i.Id); } // Get the Due value n.AmountDue = n.AmountPaid - n.Amount; //include only unmatched payments if (n.AmountDue != 0) { paymentsNotMatched.Add(n); } } Console.WriteLine("Done"); await MyLogger.WriteLog("Done"); // Free the memmory PaymentsList.Clear(); PurchasesList.Clear(); //Sort the list List <PaymentsNotMatched> payments = paymentsNotMatched.OrderByDescending(x => x.AmountDue).ToList(); // Free the memmory paymentsNotMatched.Clear(); //Save a json File in Data Folder. Console.WriteLine("Save PaymentsNotMatched.json File in the Data Folder."); await FileUtillities.WriteJasonToFile(payments, AppPath + @"\PaymentsNotMatched.json"); Console.WriteLine("Done"); await MyLogger.WriteLog("Done"); //Save Jason File for the WebApp in the dta Folder for the Web Application Console.WriteLine("Save Jason File for the WebApp in the dta Folder for the Web Application."); await FileUtillities.WriteJasonToFile(payments, JsonPath + @"\PaymentsNotMatched.json"); Console.WriteLine("Done"); await MyLogger.WriteLog("Done"); //Save a csv File Console.WriteLine("Save PaymentsNotMatched.csv File in the Data Folder."); await FileUtillities.CreateCSVFromGenericList(payments, AppPath + @"\PaymentsNotMatched.csv"); Console.WriteLine("Done"); await MyLogger.WriteLog("Done"); //Display the data in a Web Page in WebApp }); }