private void Producer() { EtzbkDataContext db = new EtzbkDataContext(); List <E_TRANSACTION> etzTrx = db.E_TRANSACTION.Where(a => a.TRANS_CODE == "P" && (a.PROCESS_STATUS == "0" || a.PROCESS_STATUS == null)).Take(Settings.number_of_record_perround).ToList(); try { Parallel.ForEach(etzTrx, item => { bool successful = DataManupulation.CheckTransactionStatusOnTMC(item.UNIQUE_TRANSID, item.TRANS_CODE); if (successful) { enqueData.Add(item); Console.WriteLine("Equeued Payment Data " + item.UNIQUE_TRANSID); } else { itemsToRemove.Add(item); } }); } catch (Exception ex) { Logger logger = new Logger(); Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex)); logger.LogInfoMessage(nameof(PaymentProducer) + " " + ExceptionExtensions.GetFullMessage(ex)); } enqueData.CompleteAdding(); DataManupulation.RemoveTransactionFromSettlement(itemsToRemove); DataManupulation.UpdateTransactionAsProcccessed(etzTrx); }
private void Producer() { using (EtzbkDataContext db = new EtzbkDataContext()) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { List <E_TRANSACTION> etzTrx = db.E_TRANSACTION.Where(a => a.PROCESS_STATUS == "0" || a.PROCESS_STATUS == null).ToList(); Parallel.ForEach(etzTrx, new ParallelOptions { MaxDegreeOfParallelism = Settings.settlementThreadNumber }, item => { SettleOption successful = DataManupulation.CheckTransactionStatusOnTMC(item.UNIQUE_TRANSID, item.TRANS_CODE); if (successful.Equals(SettleOption.Valid)) { enqueData.Add(item); Console.WriteLine("Equeued Data " + item.UNIQUE_TRANSID); logger.LogInfoMessage("Equeued Data " + item.UNIQUE_TRANSID); } else if (successful.Equals(SettleOption.Invalid)) { itemsToRemove.Add(item); } }); enqueData.CompleteAdding(); DataManupulation.RemoveTransactionFromSettlement(itemsToRemove); //DataManupulation.UpdateTransactionAsProcccessed(etzTrx); } catch (Exception ex) { Logger logger = new Logger(); Console.WriteLine("Exception from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex)); logger.LogInfoMessage("Exception from Run TaskProducerConsumer Procuder Method" + ExceptionExtensions.GetFullMessage(ex)); } stopwatch.Stop(); Console.WriteLine("Round completed in " + stopwatch.Elapsed); Console.ReadLine(); } }
private void Producer() { using (EtzbkDataContext db = new EtzbkDataContext()) { try { List <E_TRANSACTION> etzTrx = db.E_TRANSACTION.Where(a => a.TRANS_CODE == "T" && (a.PROCESS_STATUS == "0" || a.PROCESS_STATUS == null)).Take(Settings.number_of_record_perround).ToList(); Parallel.ForEach(etzTrx, item => { bool successful = DataManupulation.CheckTransactionStatusOnTMC(item.UNIQUE_TRANSID, item.TRANS_CODE); if (successful) { enqueData.Add(item); Console.WriteLine("Equeued Data" + item.UNIQUE_TRANSID); } else { itemsToRemove.Add(item); logger.LogInfoMessage(nameof(TransferProducer) + " round saved to database "); } }); enqueData.CompleteAdding(); DataManupulation.RemoveTransactionFromSettlement(itemsToRemove); DataManupulation.UpdateTransactionAsProcccessed(etzTrx); } catch (Exception ex) { Logger logger = new Logger(); Console.WriteLine("Exception from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex)); logger.LogInfoMessage("Exception from Run " + nameof(TransferProducer) + " " + ExceptionExtensions.GetFullMessage(ex)); } } }