Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void RemoveTransactionFromSettlement(List <E_TRANSACTION> itemsToRemove)
        {
            using (EtzbkDataContext etz = new EtzbkDataContext())
            {
                etz.E_TRANSACTION.AddRange(itemsToRemove);
                //etz.Entry(itemsToRemove).State = System.Data.Entity.EntityState.Deleted;
                itemsToRemove.ForEach(p => etz.Entry(p).State = EntityState.Deleted);
                etz.E_TRANSACTION.RemoveRange(itemsToRemove);

                bool saveFailed;
                do
                {
                    saveFailed = false;
                    try
                    {
                        etz.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException ex)
                    {
                        saveFailed = true;
                        ex.Entries.Single().Reload();

                        Console.WriteLine(nameof(DataManupulation) + " " + ExceptionExtensions.GetFullMessage(ex));
                        logger.LogInfoMessage(nameof(DataManupulation) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    }
                } while (saveFailed);
            }
        }
Ejemplo n.º 3
0
        public static void UpdateTMCProcccessedTransaction(string[] uniqueIDs)
        {
            updateSemaphore.WaitOne();

            using (var db = new TmcDataContext())
            {
                try
                {
                    var    paramVal = string.Join("','", uniqueIDs);
                    string sql      = "UPDATE E_TMCREQUEST SET STATUS ='1' WHERE TRANS_DATA IN ('" + paramVal + "')";

                    Console.WriteLine(sql);

                    db.Database.ExecuteSqlCommand(sql);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(nameof(DataManupulation) + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage(nameof(DataManupulation) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                }
                finally
                {
                    updateSemaphore.Release();
                }
            }
        }
Ejemplo n.º 4
0
        public List <E_TRANSACTION> NonEtzCard1()
        {
            List <E_TRANSACTION> e_Transaction = new List <E_TRANSACTION>();

            using (TmcDataContext db = new TmcDataContext())
            {
                try
                {
                    var query = from A in db.E_TMCREQUEST
                                join B in db.E_TMCNODE
                                on A.TRANS_SEQ equals B.INCON_NAME into jointData
                                from joinRecord in jointData.DefaultIfEmpty()
                                where (A.TRANS_DATE > Settings.startdate && A.STATUS == "0" && (A.TERMINAL_ID.StartsWith("4505") || A.TERMINAL_ID.StartsWith("2030")) && A.RESPONSE_CODE == "00" && A.MTI == "0200" && A.PRO_CODE.StartsWith("00"))
                                select new EtransactionViewModel
                    {
                        TRANS_CODE       = "P",
                        CARD_NUM         = A.PAN,
                        TRANSID          = A.STAN,
                        MERCHANT_CODE    = A.CARD_ACC_ID,
                        TRANS_DESCR      = "Payment to " + A.CARD_ACC_ID + " - " + A.TRANS_DATA.Substring(A.TRANS_DATA.IndexOf("#") + 1),
                        RESPONSE_CODE    = A.RESPONSE_CODE,
                        TRANS_AMOUNT     = A.AMOUNT,
                        TRANS_DATE       = A.TRANS_DATE,
                        CHANNELID        = A.TRANS_DATA.Substring(0, 2),
                        TRANS_TYPE       = "1",
                        EXTERNAL_TRANSID = A.SWITCH_KEY,
                        FEE            = A.FEE,
                        CURRENCY       = A.CURRENCY,
                        REVERSAL_KEY   = A.TRANS_KEY,
                        TRANS_NO       = A.TRANS_SEQ,
                        UNIQUE_TRANSID = A.TRANS_DATA,            //.Substring(0, A.TRANS_DATA.IndexOf("#")),
                        BANK_CODE      = A.TARGET == "NIBBS_TMS" && A.PAN.Substring(1, 1) != "4" ? "032" : joinRecord.AQISSUER_CODE
                    };


                    var tmcreq = query.ToList().Take(Settings.number_of_record_perround);


                    e_Transaction = Mapper.Map <List <E_TRANSACTION> >(tmcreq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage(nameof(NonEtzCardTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            Console.WriteLine("NonEtzCard1 Completed");
            logger.LogInfoMessage(nameof(NonEtzCardTransaction) + " NonEtzCard1 Completed ");

            return(e_Transaction);
        }
Ejemplo n.º 5
0
        //   private static TmcDataContext db = new TmcDataContext();

        public static SettleOption CheckTransactionStatusOnTMC(string UNIQUE_TRANSID, string TRANS_CODE)
        {
            Logger logger = new Logger();

            try
            {
                checkSemaphore.WaitOne();

                Console.WriteLine("Checking Transaction" + UNIQUE_TRANSID);

                using (TmcDataContext tmcData = new TmcDataContext())
                {
                    var reversed = tmcData.E_TMCREQUEST.Where(a => a.TRANS_DATA == UNIQUE_TRANSID && a.MTI == "0420").FirstOrDefault();
                    if (reversed != null)
                    {
                        return(SettleOption.Invalid);
                    }

                    var requestResp = tmcData.E_REQUESTLOG.Where(a => a.transid == UNIQUE_TRANSID).FirstOrDefault();
                    if (requestResp != null)
                    {
                        if (requestResp.response_code != "00" && requestResp.response_code != "0")
                        {
                            return(SettleOption.Invalid);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(nameof(DataManupulation) + " " + ExceptionExtensions.GetFullMessage(ex));
                logger.LogInfoMessage(nameof(DataManupulation) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                return(SettleOption.Valid);
            }

            finally
            {
                checkSemaphore.Release();
            }


            return(SettleOption.Valid);
        }
Ejemplo n.º 6
0
        public static void LoadSettings()
        {
            using (EtzbkDataContext etzTrx = new EtzbkDataContext())
            {
                try
                {
                    // var etzTrx = db.E_CARDLOAD_COMMISSION_SPLIT.ToList();
                    List <E_CARDLOAD_COMMISSION_SPLIT> cardLoadSplitList = new List <E_CARDLOAD_COMMISSION_SPLIT>()
                    {
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "011", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 40, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "011", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 60, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "033", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 30, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission", COMM_SUSPENCE = "033PAYABLE"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "033", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 70, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission", COMM_SUSPENCE = "033PAYABLE"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "033", CREATED = DateTime.Now, MAIN_FLAG = "1", RATIO = 0, SPLIT_CARD = "0447777567", SPLIT_DESCR = "Bank Commission", COMM_SUSPENCE = "033PAYABLE"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "000", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 50, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_CARDLOAD_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "000", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 50, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission"
                        }
                    };

                    //EtzbkDataContext etzTrx = new EtzbkDataContext();
                    // var etzTrx = db.E_CARDLOAD_COMMISSION_SPLIT.ToList();
                    List <E_TRANSFER_COMMISSION_SPLIT> transferSplitList = new List <E_TRANSFER_COMMISSION_SPLIT>()
                    {
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "011", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 40, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "011", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 60, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "033", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 30, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission", COMM_SUSPENCE = "033PAYABLE"
                        },
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "033", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 70, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission", COMM_SUSPENCE = "033PAYABLE"
                        },
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "000", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 50, SPLIT_CARD = "%9999", SPLIT_DESCR = "Bank Commission"
                        },
                        new E_TRANSFER_COMMISSION_SPLIT()
                        {
                            BANK_CODE = "000", CREATED = DateTime.Now, MAIN_FLAG = "0", RATIO = 50, SPLIT_CARD = "0441234567", SPLIT_DESCR = "Bank Commission"
                        }
                    };

                    //            EtzbkDataContext etzTrx = new EtzbkDataContext();
                    List <E_FUNDGATE_COMMISSION_SPLIT> fundGateSplitList = etzTrx.E_FUNDGATE_COMMISSION_SPLIT.ToList();

                    CachingProvider.AddItem("CardLoad", cardLoadSplitList);
                    CachingProvider.AddItem("Transfer", transferSplitList);
                    CachingProvider.AddItem("FundGate", fundGateSplitList);
                }
                catch (Exception ex)
                {
                    Logger logger = new Logger();
                    Console.WriteLine("Exception loading settings" + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage("Exception loading settings " + nameof(Settings) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
        }
Ejemplo n.º 7
0
        private void Consumer()

        {
            List <E_CARDLOAD_COMMISSION_SPLIT> splitFormular = CachingProvider.GetCachedData <List <E_CARDLOAD_COMMISSION_SPLIT> >("CardLoad");

            List <CommissionMapViewModel> commission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(splitFormular);


            using (EtzbkDataContext etzbk = new EtzbkDataContext())
            {
                etzbk.Configuration.AutoDetectChangesEnabled = false;

                try
                {
                    int i = 0;
                    foreach (var item in enqueData.GetConsumingEnumerable())
                    {
                        List <E_FEE_DETAIL_BK> feeDetailList = new List <E_FEE_DETAIL_BK>();
                        feeDetailList = FeeProcessing.ProcessCardloadSplit(item, commission);
                        etzbk.E_FEE_DETAIL_BK.AddRange(feeDetailList);

                        E_SETTLEMENT_DOWNLOAD_BK e_settlement = AutoMapper.Mapper.Map <E_SETTLEMENT_DOWNLOAD_BK>(item);
                        decimal bankFee = feeDetailList.Where(fee => fee.MERCHANT_CODE.EndsWith("9999")).Select(FEE => FEE.FEE).FirstOrDefault();
                        e_settlement.BANK_FEE = bankFee;
                        etzbk.E_SETTLEMENT_DOWNLOAD_BK.Add(e_settlement);


                        if (i % 50 == 0)
                        {
                            etzbk.SaveChanges();
                            logger.LogInfoMessage(nameof(CardloadProducer) + " round saved to database ");
                        }
                        i++;
                    }
                    etzbk.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage("Exception from Run " + nameof(CardloadProducer) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
        }
Ejemplo n.º 8
0
        internal static void ProcessTransferSettlement(E_TRANSACTION item)
        {
            List <E_TRANSFER_COMMISSION_SPLIT> splitFormular         = CachingProvider.GetCachedData <List <E_TRANSFER_COMMISSION_SPLIT> >("Transfer");
            List <E_FUNDGATE_COMMISSION_SPLIT> fundGatesplitFormular = CachingProvider.GetCachedData <List <E_FUNDGATE_COMMISSION_SPLIT> >("FundGate");

            List <CommissionMapViewModel> commission         = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(splitFormular);
            List <CommissionMapViewModel> fundGatecommission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(fundGatesplitFormular);

            using (EtzbkDataContext etzbk = new EtzbkDataContext())
            {
                try
                {
                    List <E_FEE_DETAIL_BK> feeDetailList = new List <E_FEE_DETAIL_BK>();
                    if (item.CHANNELID == "09")
                    {
                        feeDetailList = FeeProcessing.ProcessCardloadSplit(item, fundGatecommission);
                    }
                    else
                    {
                        feeDetailList = FeeProcessing.ProcessCardloadSplit(item, commission);
                    }

                    var e_Fee_detail = RemoveSettledFeeDetails(feeDetailList);
                    etzbk.E_FEE_DETAIL_BK.AddRange(e_Fee_detail);

                    E_SETTLEMENT_DOWNLOAD_BK e_settlement = AutoMapper.Mapper.Map <E_SETTLEMENT_DOWNLOAD_BK>(item);
                    decimal bankFee = feeDetailList.Where(fee => fee.MERCHANT_CODE.EndsWith("9999")).Select(FEE => FEE.FEE).FirstOrDefault();
                    e_settlement.BANK_FEE = bankFee;

                    if (!CheckSettledFee(e_settlement))
                    {
                        etzbk.E_SETTLEMENT_DOWNLOAD_BK.Add(e_settlement);
                    }

                    item.PROCESS_STATUS = "1";
                    etzbk.E_TRANSACTION.Add(item);
                    etzbk.Entry(item).State = System.Data.Entity.EntityState.Modified;

                    etzbk.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + nameof(Settlement) + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage("Exception from Run " + nameof(Settlement) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
        }
Ejemplo n.º 9
0
        public static ResponseViewModel ProcessPaymentSettlement(E_TRANSACTION item)
        {
            ResponseViewModel response = new ResponseViewModel();


            using (EtzbkDataContext etzbk = new EtzbkDataContext())
            {
                //item = etzbk.E_TRANSACTION.Where(a => a.UNIQUE_TRANSID == "0327002364000289256353").FirstOrDefault();
                if (item.UNIQUE_TRANSID.Contains("#"))
                {
                    item.UNIQUE_TRANSID = item.UNIQUE_TRANSID.Substring(0, item.UNIQUE_TRANSID.IndexOf("#"));
                }
                try
                {
                    var merchantIntercept = etzbk.E_MERCHANT_CODE_INTERCEPT.Where(a => a.INITIATOR_CODE == item.CARD_NUM.Substring(0, 3) && a.MERCHANT_CODE == item.MERCHANT_CODE && a.CHANNELID == item.CHANNELID && a.TRANS_CODE == item.TRANS_CODE && a.INTERCEPT_STATUS == "1").FirstOrDefault();

                    if (merchantIntercept != null)
                    {
                        if (merchantIntercept.INTERCEPT_MERCHANT_CODE != null || merchantIntercept.INTERCEPT_MERCHANT_CODE.Trim() != "")
                        {
                            item.MERCHANT_CODE = merchantIntercept.INTERCEPT_MERCHANT_CODE;
                        }
                        if (merchantIntercept.CARD_NUM != null || merchantIntercept.CARD_NUM.Trim() != "")
                        {
                            item.CARD_NUM = merchantIntercept.CARD_NUM;
                        }
                    }

                    if (item.CHANNELID == "09")
                    {
                        using (FundGateDataContext fundGate = new FundGateDataContext())
                        {
                            var fundGateQuery = from A in fundGate.FUNDGATE_RESPONSE
                                                join B in fundGate.FUNDGATE_REQUEST
                                                on new { X = A.clientRef, Y = A.terminal } equals new { X = B.clientRef, Y = B.terminal } into jointData
                            from joinRecord in jointData.DefaultIfEmpty()
                            where (joinRecord.action == "VT" && A.etzRef == item.UNIQUE_TRANSID)
                            select new
                            {
                                joinRecord.lineType
                            };

                            var fundGateTrx = fundGateQuery.FirstOrDefault();
                            if (fundGateTrx != null)
                            {
                                var swicthData = etzbk.E_SWITCHIT_TRANSFORMER.Where(a => a.CARD_NUM == item.CARD_NUM && a.PROVIDER_ID == fundGateTrx.lineType).FirstOrDefault();
                                if (swicthData != null)
                                {
                                    item.CARD_NUM      = swicthData.TRANSFORM_CARD;
                                    item.MERCHANT_CODE = swicthData.MERCHANT_CODE;
                                }
                            }
                        }
                    }
                    string merchantCode = item.MERCHANT_CODE;
                    List <E_FEE_DETAIL_BK>   feeDetailList = new List <E_FEE_DETAIL_BK>();
                    E_SETTLEMENT_DOWNLOAD_BK e_settlement  = AutoMapper.Mapper.Map <E_SETTLEMENT_DOWNLOAD_BK>(item);

                    var merchantScaleQuery = from A in etzbk.E_MERCHANT
                                             join B in etzbk.E_CATSCALE
                                             on new { X = A.CAT_ID } equals new { X = B.CAT_ID } into jointData
                    from joinRecord in jointData.DefaultIfEmpty()
                    where (A.MERCHANT_CODE == merchantCode)
                    select new
                    {
                        A.FEE_STATUS,
                        A.SPECIAL_SPLIT,
                        A.MERCHANT_NAME,
                        joinRecord.SCALE_VALUE,
                        joinRecord.SCALE_TYPE,
                        joinRecord.CAT_ID
                    };

                    var merchantScale = merchantScaleQuery.FirstOrDefault();
                    if (merchantScale == null)
                    {
                        response = new ResponseViewModel()
                        {
                            ErrorType = ErrorType.NoMerchantCode, MerchantCode = merchantCode, Response = false
                        };

                        //return response;

                        ///Write Code to handle No Merchant Code or Split category configured
                    }
                    else
                    {
                        List <CommissionMapViewModel> commission = new List <CommissionMapViewModel>();
                        if (merchantScale.SPECIAL_SPLIT == "0")
                        {
                            // Check If Fee is Charged if not, ignore and comparee value
                            if (merchantScale.SCALE_TYPE == "1" & item.FEE == 0)
                            {
                                item.FEE = FeeProcessing.CalculateFeeBeneficiary(merchantScale.SCALE_VALUE, item.TRANS_AMOUNT);
                            }
                            var query = from A in etzbk.E_MERCHANT_COMMISSION_SPLIT
                                        where (A.MERCHANT_CODE == item.MERCHANT_CODE)
                                        select new CommissionMapViewModel
                            {
                                AGENT         = "",
                                MAIN_FLAG     = A.MAIN_FLAG,
                                SPLIT_CARD    = A.SPLIT_CARD,
                                RATIO         = A.RATIO,
                                SPLIT_DESCR   = A.SPLIT_DESCR,
                                COMM_SUSPENCE = item.MERCHANT_CODE
                            };
                            commission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(query.ToList());
                        }
                        else if (merchantScale.SPECIAL_SPLIT == "1")
                        {
                            var query = from A in etzbk.E_MERCHANT_SPECIAL_SPLIT
                                        where (A.MERCHANT_CODE == item.MERCHANT_CODE)
                                        select new CommissionMapViewModel
                            {
                                AGENT         = "",
                                MAIN_FLAG     = A.MAIN_FLAG,
                                SPLIT_CARD    = A.SPLIT_CARD,
                                RATIO         = A.SVALUE,
                                SPLIT_DESCR   = A.SPLIT_DESCR,
                                COMM_SUSPENCE = item.MERCHANT_CODE
                            };
                            commission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(query.ToList());
                        }
                        else
                        {
                            response = new ResponseViewModel()
                            {
                                ErrorType = ErrorType.InvalidSplitType, MerchantCode = merchantCode, Response = false
                            };
                            // return response;
                        }

                        if (merchantScale.SPECIAL_SPLIT == "1" || merchantScale.SPECIAL_SPLIT == "0")
                        {
                            feeDetailList = FeeProcessing.ProcessRatioPaymentSplit(item, commission);

                            var e_Fee_detail = RemoveSettledFeeDetails(feeDetailList);
                            etzbk.E_FEE_DETAIL_BK.AddRange(e_Fee_detail);

                            decimal bankFee = feeDetailList.Where(fee => fee.MERCHANT_CODE.EndsWith("9999")).Select(FEE => FEE.FEE).FirstOrDefault();
                            e_settlement.BANK_FEE = bankFee;
                        }
                    }


                    if (!CheckSettledFee(e_settlement))
                    {
                        etzbk.E_SETTLEMENT_DOWNLOAD_BK.Add(e_settlement);
                    }

                    item.PROCESS_STATUS = "1";
                    etzbk.E_TRANSACTION.Add(item);
                    etzbk.Entry(item).State = System.Data.Entity.EntityState.Modified;


                    etzbk.SaveChanges();
                    // Console.WriteLine(nameof(PaymentProducer) + " Final round saved to database ");
                    return(new ResponseViewModel()
                    {
                        ErrorType = ErrorType.Valid, MerchantCode = merchantCode, Response = true
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + nameof(Settlement) + " " + ExceptionExtensions.GetFullMessage(ex) + item.UNIQUE_TRANSID);
                    logger.LogInfoMessage("Exception from Run " + nameof(Settlement) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex) + item.UNIQUE_TRANSID);
                    return(new ResponseViewModel()
                    {
                        ErrorType = ErrorType.Exception, MerchantCode = item.UNIQUE_TRANSID, Message = ex.Message, Response = false
                    });
                }
            }
        }
        public List <E_TRANSACTION> Channel1()
        {
            List <E_TRANSACTION> e_Transaction = new List <E_TRANSACTION>();

            using (TmcDataContext db = new TmcDataContext())
            {
                try
                {
                    var query = from A in db.E_TMCREQUEST
                                join B in db.E_TMCHOST_RESP
                                on new { X = A.TRANS_DATA, Y = A.TRANS_SEQ } equals new { X = B.TRANS_DATA, Y = B.SWITCH_REF } into jointData
                    from joinRecord in jointData.DefaultIfEmpty()
                    where (A.TRANS_DATE > Settings.startdate && A.STATUS == "0" && A.PRO_CODE.StartsWith("13") && Settings.successKeys.Contains(A.RESPONSE_CODE) && A.MTI == "0200" && Settings.targets.Contains(A.TARGET))
                    select new EtransactionViewModel
                    {
                        TRANS_CODE       = "P",
                        CARD_NUM         = A.PAN,
                        TRANSID          = A.STAN,
                        MERCHANT_CODE    = A.CARD_ACC_ID,
                        TRANS_DESCR      = A.CARD_ACC_NAME,
                        RESPONSE_CODE    = A.RESPONSE_CODE,
                        TRANS_AMOUNT     = A.AMOUNT,
                        TRANS_DATE       = A.TRANS_DATE,
                        CHANNELID        = A.TRANS_DATA.Substring(0, 2),
                        TRANS_TYPE       = "1",
                        EXTERNAL_TRANSID = A.TRANS_DATA,
                        UNIQUE_TRANSID   = A.TRANS_DATA,
                        FEE                = A.FEE,
                        CURRENCY           = A.CURRENCY,
                        REVERSAL_KEY       = A.TRANS_KEY,
                        TRANS_NO           = A.TRANS_SEQ,
                        TERMINAL_ID        = A.TERMINAL_ID,
                        CARD_SCHEME        = A.CARD_SCHEME,
                        REFERENCE          = joinRecord.REFERENCE,
                        RESP_RESPONSE_CODE = joinRecord.RESPONSE_CODE
                    };

                    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                    stopwatch.Start();

                    var tmcreq = query.ToList().Take(Settings.number_of_record_perround);

                    stopwatch.Stop();
                    Console.WriteLine("Inspectingtime for channel 1 completed in " + stopwatch.Elapsed);

                    e_Transaction = Mapper.Map <List <E_TRANSACTION> >(tmcreq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage(nameof(EtranzactChannelTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            Console.WriteLine("Channel1 Completed");
            logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " Channel1 Completed ");

            return(e_Transaction);
        }
Ejemplo n.º 11
0
        public void Run()
        {
            logger = new Logger();


            Task <List <E_TRANSACTION> > t1 = Task.Factory.StartNew(MastercardTrx1);
            Task <List <E_TRANSACTION> > t2 = Task.Factory.StartNew(MastercardTrx2);
            Task <List <E_TRANSACTION> > t3 = Task.Factory.StartNew(MastercardTrx3);

            Console.WriteLine("  MastercardTransactions waiting for Merging ");

            List <Task> taskList = new List <Task> {
                t1, t2, t3
            };

            Task.WaitAll(taskList.ToArray());
            Console.WriteLine("  MastercardTransactions Merged");

            using (EtzbkDataContext db = new EtzbkDataContext())
            {
                try
                {
                    var allTmcData = DataManupulation.MergeEntityList(new List <List <E_TRANSACTION> >()
                    {
                        t1.Result.ToList(), t2.Result.ToList(), t3.Result.ToList()
                    });


                    //PROCESS DATA

                    Console.WriteLine(" Merge All Data Spooled... Removing Duplicate record");


                    var uniqueIDs     = allTmcData.Select(u => u.UNIQUE_TRANSID).Distinct().ToArray();
                    var uniqueIDsOnDB = db.E_TRANSACTION.Where(u => uniqueIDs.Contains(u.UNIQUE_TRANSID)).Select(u => u.UNIQUE_TRANSID).ToArray();
                    var etrxData      = allTmcData.Where(u => !uniqueIDsOnDB.Contains(u.UNIQUE_TRANSID));
                    Console.WriteLine(uniqueIDsOnDB.Count() + " Duplicate record removed--NonEtzCardTransaction");

                    logger.LogInfoMessage(nameof(MastercardTransactions) + " " + etrxData.Count() + " Record ready to be Inserted");
                    db.E_TRANSACTION.AddRange(etrxData);
                    db.SaveChanges();

                    logger.LogInfoMessage(nameof(MastercardTransactions) + " " + etrxData.Count() + " Record Inserted for Settlement");

                    Console.WriteLine(etrxData.Count() + " Record Inserted for Settlement");
                    Console.WriteLine("Marking Transaction as spooled transaction");
                    if (uniqueIDs.Count() > 0)
                    {
                        DataManupulation.UpdateTMCProcccessedTransaction(uniqueIDs);
                    }
                    Console.WriteLine("Spooled transactions Marked");
                    Console.WriteLine("Spooled transactions Marked");
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("SQLException from MastercardTransactions Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage("SQLException from Run " + nameof(MastercardTransactions) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage("Exception from Run " + nameof(MastercardTransactions) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            logger.LogInfoMessage(nameof(MastercardTransactions) + " Merged ");



            Console.WriteLine("MastercardTransactions Transaction spool Completed");
        }
Ejemplo n.º 12
0
        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));
                }
            }
        }
Ejemplo n.º 13
0
        public void Run()
        {
            logger.LogInfoMessage("Welcome to Task Producer Consure Runmethod");


            //Thread t1 = new Thread(Producer);
            //Thread t2 = new Thread(Consumer);
            //t1.Start();
            //t2.Start();

            //t1.Join();
            //t2.Join();

            enqueData = new BlockingCollection <E_TRANSACTION>();
            Task t2 = Task.Factory.StartNew(Consumer);
            Task t1 = Task.Factory.StartNew(Producer);

            List <Task> taskList = new List <Task> {
                t1, t2
            };

            //Task[] tasksArray = taskList.Where(t => t != null).ToArray();
            //if (tasksArray.Length > 0) Task.WaitAll(tasksArray);

            try
            {
                Task.WaitAll(taskList.ToArray());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception from TaskProducerConsumer Run " + ExceptionExtensions.GetFullMessage(ex));
                logger.LogInfoMessage("Exception from Run TaskProducerConsumer RUN Method" + ExceptionExtensions.GetFullMessage(ex));

                return;
            }
            List <ErrorType> itemsList = responseList.Select(s => s.ErrorType).Distinct().ToList();

            foreach (var item in itemsList)
            {
                List <string> list = responseList.Where(a => a.ErrorType == item).Select(a => a.MerchantCode).ToList();
                if (item == ErrorType.Exception)
                {
                    if (list.Count > 0)
                    {
                        string table = MapTables(list);
                        MailMessanger.SendMail(Settings.mailsettlementsupport, "*****@*****.**", "Exception On While processing round", "");
                    }
                }
                else if (item == ErrorType.InvalidSplitType)
                {
                    if (list.Count > 0)
                    {
                        string table = MapTables(list);
                        MailMessanger.SendMail(Settings.mailTrxProcessing, Settings.mailTrxProcessing, "Invalid Split on Type on e_Merchant", MailTemplate("The split type setup for the merchant Code(s) in the table below is/are wrong <p>" + table));
                    }
                }
                else if (item == ErrorType.NoMerchantCode)
                {
                    if (list.Count > 0)
                    {
                        string table = MapTables(list);
                        MailMessanger.SendMail(Settings.mailTrxProcessing, Settings.mailpayoutlet, "Merchant Code not available on e_Merchant", MailTemplate("The following merchant Code(s) are not setup on E_MERCHANT table <p>" + table));
                    }
                }
                else if (item == ErrorType.NoSplitOnMerchant)
                {
                    if (list.Count > 0)
                    {
                        string table = MapTables(list);
                        MailMessanger.SendMail(Settings.mailTrxProcessing, Settings.mailpayoutlet, "Split Not Setup", MailTemplate("Split is not setip for the following merchant Code(s) <p>" + table));
                    }
                }
            }

            Console.WriteLine("TaskProducerConsumer Round Complete");
        }
Ejemplo n.º 14
0
        private void Consumer()

        {
            List <E_TRANSFER_COMMISSION_SPLIT> splitFormular         = CachingProvider.GetCachedData <List <E_TRANSFER_COMMISSION_SPLIT> >("Transfer");
            List <E_FUNDGATE_COMMISSION_SPLIT> fundGatesplitFormular = CachingProvider.GetCachedData <List <E_FUNDGATE_COMMISSION_SPLIT> >("FundGate");

            List <CommissionMapViewModel> commission         = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(splitFormular);
            List <CommissionMapViewModel> fundGatecommission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(fundGatesplitFormular);



            Parallel.ForEach(enqueData.GetConsumingEnumerable(), new ParallelOptions {
                MaxDegreeOfParallelism = Settings.settlementThreadNumber
            }, item =>
            {
                logger.LogInfoMessage("Parallel produced word");
                try
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

                    switch (item.TRANS_CODE)
                    {
                    case "P":
                        var response = Settlement.ProcessPaymentSettlement(item);
                        if (response.Response == false)
                        {
                            //object obj = new object();
                            lock (responseList)
                            {
                                if (responseList.Where(res => res.MerchantCode == response.MerchantCode).ToList().Count == 0)
                                {
                                    responseList.Add(response);
                                }
                            }
                        }
                        break;

                    case "T":
                        Settlement.ProcessTransferSettlement(item);
                        break;

                    case "D":
                        Settlement.ProcessCardLoadSettlement(item);
                        break;

                    case "W":

                        // Settlement.ProcessCardLoadSettlement(item);

                        break;
                    }

                    stopwatch.Stop();
                    logger.LogInfoMessage(item.UNIQUE_TRANSID + "Round Parallel Consumert in " + stopwatch.Elapsed);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from TaskProducerConsumer Consumer Method " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage("Exception from Run TaskProducerConsumer Consumer Method " + ExceptionExtensions.GetFullMessage(ex));
                }
            });
            logger.LogInfoMessage("Parrallel exit with first");
        }
Ejemplo n.º 15
0
        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();
            }
        }
Ejemplo n.º 16
0
        public static List <E_FEE_DETAIL_BK> ProcessRatioPaymentSplit(E_TRANSACTION e_transaction, List <CommissionMapViewModel> splitFormular)
        {
            List <E_FEE_DETAIL_BK> feeDetailList = new List <E_FEE_DETAIL_BK>();

            if (e_transaction == null)
            {
                throw new ArgumentNullException(nameof(e_transaction));
                //return feeDetailList;
            }
            else
            {
                int i = 1;
                //string bankCode = e_transaction.CARD_NUM.Substring(0, 3);
                decimal trans_amount = e_transaction.TRANS_AMOUNT;

                foreach (var item in splitFormular.OrderBy(a => a.MAIN_FLAG))
                {
                    decimal fee = 0;
                    try
                    {
                        if (e_transaction.FEE > 0)
                        {
                            fee = CalculateFeeBeneficiary(item.RATIO, e_transaction.FEE);
                        }
                        else
                        {
                            fee = item.RATIO;
                        }

                        if (trans_amount < 0)
                        {
                            return(new List <E_FEE_DETAIL_BK>());
                        }

                        trans_amount = trans_amount - fee;
                        if (fee == 0)
                        {
                            fee = trans_amount;
                        }

                        E_FEE_DETAIL_BK feeDetail = new E_FEE_DETAIL_BK()
                        {
                            CARD_NUM         = item.COMM_SUSPENCE,
                            CHANNELID        = e_transaction.CHANNELID,
                            CLOSED           = "1",
                            CURRENCY         = e_transaction.CURRENCY,
                            EXTERNAL_TRANSID = e_transaction.UNIQUE_TRANSID,
                            UNIQUE_TRANSID   = "C" + i.ToString() + e_transaction.UNIQUE_TRANSID,
                            FEE            = 0,
                            FEE_BATCH      = e_transaction.FEE_BATCH,
                            GFLAG          = item.MAIN_FLAG.ToString(),
                            INTSTATUS      = "2",
                            ISSUER_CODE    = e_transaction.CARD_NUM.Substring(0, 3),
                            MERCHANT_CODE  = item.SPLIT_CARD.Contains("%") ? e_transaction.CARD_NUM.Substring(0, 3) + TransactionAlias.GetChannelAlias(e_transaction.CHANNELID.ToString()) + item.SPLIT_CARD.Substring(item.SPLIT_CARD.IndexOf("%") + 1) : item.SPLIT_CARD,
                            PROCESS_STATUS = "1",
                            SUB_CODE       = e_transaction.CARD_NUM.Substring(3, 3),
                            SERVICEID      = e_transaction.CARD_NUM.Substring(0, 6),
                            SETTLE_BATCH   = e_transaction.SETTLE_BATCH,
                            TRANSID        = e_transaction.TRANSID,
                            TRANS_AMOUNT   = fee,
                            TRANS_CODE     = "C",
                            TRANS_DATE     = DateTime.Now,
                            TRANS_DESCR    = "SETTLEMENT:;" + item.SPLIT_DESCR,
                            TRANS_NO       = e_transaction.TRANS_NO,
                            TRANS_REF      = e_transaction.MERCHANT_CODE,
                            TRANS_TYPE     = "1"
                        };

                        Console.WriteLine("Split transaction Trans_Code=" + e_transaction.TRANS_CODE + "  Merchant_Code : " + feeDetail.MERCHANT_CODE + " Card_num: " + feeDetail.CARD_NUM + " Descr " + feeDetail.TRANS_DESCR + " isssuer" + feeDetail.ISSUER_CODE + " unique_trans: " + feeDetail.UNIQUE_TRANSID + " Value: " + feeDetail.TRANS_AMOUNT);
                        i++;

                        feeDetailList.Add(feeDetail);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + nameof(Settlement) + " " + ExceptionExtensions.GetFullMessage(ex));
                        //logger.LogInfoMessage("Exception from Run " + nameof(Settlement) + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex) + item.UNIQUE_TRANSID);
                        return(feeDetailList);
                    }
                }


                return(feeDetailList);
            }
        }
        public List <E_TRANSACTION> Channel5()
        {
            List <E_TRANSACTION> e_Transaction = new List <E_TRANSACTION>();

            using (TmcDataContext db = new TmcDataContext())
            {
                try
                {
                    var query = from A in db.E_TMCREQUEST
                                join B in db.E_TMCNODE
                                on A.SRC_NODE equals B.INCON_ID into jointData
                                from joinRecord in jointData.DefaultIfEmpty()
                                where (A.TRANS_DATE > Settings.startdate && A.STATUS == "0" && /* A.card_acc_id LIKE: Bank_Code AND */ A.PRO_CODE.StartsWith("01") && Settings.successKeys.Contains(A.RESPONSE_CODE) && A.MTI == "0200" && Settings.targets.Contains(A.TARGET))
                                select new EtransactionViewModel
                    {
                        TRANS_CODE       = "W",
                        CARD_NUM         = A.CARD_SCHEME + "XXXXXX" + A.PAN.Substring(A.PAN.Length - 4),
                        TRANSID          = A.STAN,
                        MERCHANT_CODE    = joinRecord.AQISSUER_CODE + "ATMWHDR",
                        TRANS_DESCR      = "WITHDRAWAL: " + A.STAN + "000000 :" + A.TERMINAL_ID + ":" + A.CARD_ACC_NAME,
                        RESPONSE_CODE    = A.RESPONSE_CODE,
                        TRANS_AMOUNT     = A.AMOUNT,
                        TRANS_DATE       = A.TRANS_DATE,
                        CHANNELID        = A.TRANS_DATA.Substring(0, 2),
                        TRANS_TYPE       = "1",
                        EXTERNAL_TRANSID = A.REVERSAL_KEY,
                        UNIQUE_TRANSID   = A.TRANS_DATA,
                        FEE                = A.FEE,
                        CURRENCY           = A.CURRENCY,
                        REVERSAL_KEY       = A.TRANS_KEY,
                        TRANS_NO           = A.TRANS_SEQ,
                        TERMINAL_ID        = A.TERMINAL_ID,
                        CARD_SCHEME        = A.CARD_SCHEME,
                        REFERENCE          = A.REFERENCE,
                        RESP_RESPONSE_CODE = ""
                    };
                    var tmcreq = query.ToList().Take(Settings.number_of_record_perround);

                    e_Transaction = Mapper.Map <List <E_TRANSACTION> >(tmcreq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage(nameof(EtranzactChannelTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            Console.WriteLine("Channel5 Completed");
            logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " Channel5 Completed ");

            return(e_Transaction);
        }
Ejemplo n.º 18
0
        private void Consumer()
        {
            List <string> McNoSplit = new List <string>();

            using (EtzbkDataContext etzbk = new EtzbkDataContext())
            {
                try
                {
                    etzbk.Configuration.AutoDetectChangesEnabled = false;
                    int i = 0;
                    foreach (var item in enqueData.GetConsumingEnumerable())
                    {
                        string Merchant_Code = item.MERCHANT_CODE;
                        List <E_FEE_DETAIL_BK> feeDetailList = new List <E_FEE_DETAIL_BK>();

                        var merchantScaleQuery = from A in etzbk.E_MERCHANT
                                                 join B in etzbk.E_CATSCALE
                                                 on new { X = A.CAT_ID } equals new { X = B.CAT_ID } into jointData
                        from joinRecord in jointData.DefaultIfEmpty()
                        where (A.MERCHANT_CODE == Merchant_Code)
                        select new
                        {
                            A.FEE_STATUS,
                            A.SPECIAL_SPLIT,
                            joinRecord.SCALE_VALUE,
                            joinRecord.SCALE_TYPE,
                            joinRecord.CAT_ID
                        };

                        var merchantScale = merchantScaleQuery.FirstOrDefault();
                        if (merchantScale == null)
                        {
                            if (!McNoSplit.Contains(Merchant_Code))
                            {
                                McNoSplit.Add(Merchant_Code);
                            }
                            continue;
                            ///Write Code to handle No Merchant Code or Split category configured
                        }
                        if (merchantScale.SPECIAL_SPLIT == "0")
                        {
                            // Check If Fee is Charged if not, ignore and comparee value
                            if (merchantScale.SCALE_TYPE == "1" & item.FEE == 0)
                            {
                                item.FEE = FeeProcessing.CalculateFeeBeneficiary(merchantScale.SCALE_VALUE, item.TRANS_AMOUNT);
                            }
                            var query = from A in etzbk.E_MERCHANT_COMMISSION_SPLIT
                                        where (A.MERCHANT_CODE == item.MERCHANT_CODE)
                                        select new CommissionMapViewModel
                            {
                                AGENT         = "",
                                MAIN_FLAG     = A.MAIN_FLAG,
                                SPLIT_CARD    = A.SPLIT_CARD,
                                RATIO         = A.RATIO,
                                SPLIT_DESCR   = A.SPLIT_DESCR,
                                COMM_SUSPENCE = item.MERCHANT_CODE
                            };
                            List <CommissionMapViewModel> commission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(query.ToList());

                            var e_settlement = AutoMapper.Mapper.Map <E_SETTLEMENT_DOWNLOAD_BK>(item);

                            feeDetailList = FeeProcessing.ProcessRatioPaymentSplit(item, commission);
                            decimal bankFee = feeDetailList.Where(fee => fee.MERCHANT_CODE.EndsWith("9999")).Select(FEE => FEE.TRANS_AMOUNT).FirstOrDefault();
                            e_settlement.BANK_FEE = bankFee;
                            etzbk.E_SETTLEMENT_DOWNLOAD_BK.Add(e_settlement);
                        }
                        else
                        {
                            var query = from A in etzbk.E_MERCHANT_SPECIAL_SPLIT
                                        where (A.MERCHANT_CODE == item.MERCHANT_CODE)
                                        select new CommissionMapViewModel
                            {
                                AGENT         = "",
                                MAIN_FLAG     = A.MAIN_FLAG,
                                SPLIT_CARD    = A.SPLIT_CARD,
                                RATIO         = A.SVALUE,
                                SPLIT_DESCR   = A.SPLIT_DESCR,
                                COMM_SUSPENCE = item.MERCHANT_CODE
                            };

                            List <CommissionMapViewModel> commission = AutoMapper.Mapper.Map <List <CommissionMapViewModel> >(query.ToList());

                            E_SETTLEMENT_DOWNLOAD_BK e_settlement = AutoMapper.Mapper.Map <E_SETTLEMENT_DOWNLOAD_BK>(item);

                            feeDetailList = FeeProcessing.ProcessRatioPaymentSplit(item, commission);

                            decimal bankFee = feeDetailList.Where(fee => fee.MERCHANT_CODE.EndsWith("9999")).Select(FEE => FEE.FEE).FirstOrDefault();
                            e_settlement.BANK_FEE = bankFee;
                            etzbk.E_SETTLEMENT_DOWNLOAD_BK.Add(e_settlement);
                        }



                        // feeDetailList = FeeProcessing.ProcessCardloadSplit(item, commission);
                        etzbk.E_FEE_DETAIL_BK.AddRange(feeDetailList);
                        if (i % 50 == 0)
                        {
                            //var uniqueIDs = feeDetailList.Select(u => u.UNIQUE_TRANSID).Distinct().ToArray();
                            //var uniqueIDsOnDB = etzbk.E_TRANSACTION.Where(u => uniqueIDs.Contains(u.UNIQUE_TRANSID)).Select(u => u.UNIQUE_TRANSID).ToArray();
                            //var feeForDBata = feeDetailList.Where(u => !uniqueIDsOnDB.Contains(u.UNIQUE_TRANSID));

                            etzbk.SaveChanges();
                            logger.LogInfoMessage(nameof(PaymentProducer) + " round saved to database ");
                        }
                        i++;
                    }


                    etzbk.SaveChanges();
                    logger.LogInfoMessage(nameof(PaymentProducer) + " FInal round saved to database ");
                }
                catch (Exception ex)
                {
                    Logger logger = new Logger();
                    Console.WriteLine("Exception from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogInfoMessage("Exception from Run " + nameof(PaymentProducer) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
                //Act on MC without Split

                Console.WriteLine("List of MC without split");
                foreach (string item in McNoSplit)
                {
                    Console.WriteLine(item);
                }
            }
        }
        public List <E_TRANSACTION> Channel7()
        {
            List <E_TRANSACTION> e_Transaction = new List <E_TRANSACTION>();

            using (TmcDataContext db = new TmcDataContext())
            {
                try
                {
                    var query = from A in db.E_TMCREQUEST
                                join B in db.E_TMCHOST_RESP
                                on new { X = A.TRANS_DATA, Y = A.TRANS_SEQ } equals new { X = B.TRANS_DATA, Y = B.SWITCH_REF } into jointData
                    from joinRecord in jointData.DefaultIfEmpty()
                    where (A.TRANS_DATE > Settings.startdate && A.STATUS == "0" && /* A.card_acc_id LIKE: Bank_Code AND */ A.PRO_CODE.StartsWith("40") && Settings.successKeys.Contains(joinRecord.RESPONSE_CODE) && A.MTI == "0220" && A.CARD_ACC_ID.Trim().Length > 11 && Settings.targets.Contains(A.TARGET))
                    select new EtransactionViewModel
                    {
                        TRANS_CODE       = A.CARD_ACC_ID.EndsWith("D") ? "D" : "U",
                        CARD_NUM         = A.CARD_ACC_ID.EndsWith("D") ? A.PAN : A.BILLER_ID.Substring(A.BILLER_ID.Length - DbFunctions.Reverse(A.BILLER_ID).IndexOf("#")),
                        TRANSID          = A.REFERENCE,
                        MERCHANT_CODE    = A.CARD_ACC_ID.EndsWith("D") ? A.BILLER_ID.Substring(A.BILLER_ID.Length - DbFunctions.Reverse(A.BILLER_ID).IndexOf("#")) : A.PAN,
                        TRANS_DESCR      = A.CARD_ACC_NAME,
                        RESPONSE_CODE    = A.RESPONSE_CODE,
                        TRANS_AMOUNT     = A.AMOUNT,
                        TRANS_DATE       = A.TRANS_DATE,
                        CHANNELID        = A.TRANS_DATA.Substring(0, 2),
                        TRANS_TYPE       = "1",
                        EXTERNAL_TRANSID = A.TRANS_DATA.Substring(3, A.TRANS_DATA.Length / 2),
                        UNIQUE_TRANSID   = A.TRANS_DATA,
                        FEE                = A.FEE,
                        CURRENCY           = A.CURRENCY,
                        REVERSAL_KEY       = A.TRANS_KEY,
                        TRANS_NO           = A.BILLER_ID.Substring(A.BILLER_ID.IndexOf("#"), A.BILLER_ID.Length - DbFunctions.Reverse(A.BILLER_ID).IndexOf("#")),
                        TERMINAL_ID        = A.TERMINAL_ID,
                        CARD_SCHEME        = A.CARD_SCHEME,
                        REFERENCE          = joinRecord.REFERENCE,
                        RESP_RESPONSE_CODE = joinRecord.RESPONSE_CODE
                    };
                    var tmcreq = query.ToList().Take(Settings.number_of_record_perround);
                    e_Transaction = Mapper.Map <List <E_TRANSACTION> >(tmcreq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage(nameof(EtranzactChannelTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            logger.LogInfoMessage(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            Console.WriteLine("Channel7 Completed");
            logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " Channel7 Completed ");

            return(e_Transaction);
        }
Ejemplo n.º 20
0
        public List <E_TRANSACTION> MastercardTrx1()
        {
            var src_node_value = new int[] { 210000059, 510000059 };

            List <E_TRANSACTION> e_Transaction = new List <E_TRANSACTION>();

            using (TmcDataContext db = new TmcDataContext())
            {
                try
                {
                    var query = from A in db.E_TMCREQUEST
                                join B in db.E_TMCHOST_RESP
                                on new { X = A.TRANS_DATA, Y = A.TRANS_SEQ } equals new { X = B.TRANS_DATA, Y = B.SWITCH_REF } into jointData
                    from joinRecord in jointData.DefaultIfEmpty()
                    join C in db.E_TMCNODE
                    on A.TARGET_NODE equals C.INCON_ID into jointData2
                    from joinRecord2 in jointData2.DefaultIfEmpty()
                    where (A.TRANS_DATE > Settings.startdate && A.STATUS == "0" && src_node_value.Contains(A.SRC_NODE) && A.TARGET_NODE == 210000049 && Settings.successKeys.Contains(joinRecord.RESPONSE_CODE) && A.MTI == "0200" && A.AMOUNT > 0 && A.REVERSAL_KEY == "" && A.TRANS_DATA != "")

                    select new EtransactionViewModel
                    {
                        TRANS_CODE       = "F",
                        CARD_NUM         = joinRecord2.ISSUER_CODE + A.PAN,
                        TRANSID          = joinRecord.REFERENCE,
                        TRANS_NO         = joinRecord.STAN,
                        MERCHANT_CODE    = A.CARD_ACC_ID,
                        TRANS_DESCR      = A.CARD_ACC_NAME,
                        RESPONSE_CODE    = A.RESPONSE_CODE,
                        TRANS_AMOUNT     = A.AMOUNT,
                        TRANS_DATE       = A.TRANS_DATE,
                        CHANNELID        = A.TRANS_DATA.Substring(0, 2),
                        TRANS_TYPE       = "1",
                        EXTERNAL_TRANSID = A.SWITCH_KEY,
                        UNIQUE_TRANSID   = A.TRANS_DATA,
                        FEE                = A.FEE,
                        FEE2               = joinRecord.FEE,
                        CURRENCY           = A.CURRENCY,
                        REVERSAL_KEY       = A.ACCT_ID1,
                        TERMINAL_ID        = A.TERMINAL_ID,
                        CARD_SCHEME        = A.PRO_CODE,
                        RESP_RESPONSE_CODE = joinRecord.RESPONSE_CODE,
                    };


                    var tmcreq = query.ToList().Take(Settings.number_of_record_perround);

                    foreach (EtransactionViewModel item in tmcreq)
                    {
                        if (item.CARD_SCHEME.Substring(0, 2) == "00")
                        {
                            item.TRANS_DESCR = "POS:" + item.REVERSAL_KEY + ':' + item.TRANSID + ':' + item.TERMINAL_ID + ':' + item.TRANS_DESCR;

                            item.MERCHANT_CODE = "044MSTHLD4";
                            item.TRANS_CODE    = "P";
                            item.CHANNELID     = "03";
                        }
                        else if (item.CARD_SCHEME.Substring(0, 2) == "01")
                        {
                            item.TRANS_DESCR = "ATM WTHDRWL:" + item.REVERSAL_KEY + ':' + item.TRANSID + ':' + item.TERMINAL_ID + ':' + item.TRANS_DESCR;

                            if (item.MERCHANT_CODE == "044MSTHLD1")
                            {
                                item.MERCHANT_CODE = "044MSTHLD3";
                                item.TRANS_CODE    = "P";
                                item.CHANNELID     = "04";
                            }
                            else if (item.MERCHANT_CODE != "044MSTHLD1" && item.TERMINAL_ID.Substring(0, 4) == "1044")
                            {
                                item.MERCHANT_CODE = "0443241211";
                                item.TRANS_CODE    = "W";
                                item.CHANNELID     = "04";
                            }

                            else if (item.MERCHANT_CODE != "044MSTHLD1" && item.TERMINAL_ID.Substring(0, 4) != "1044")
                            {
                                item.MERCHANT_CODE = "044MSTHLD3";
                                item.TRANS_CODE    = "P";
                                item.CHANNELID     = "04";
                            }

                            item.FEE = int.Parse(item.FEE2.Substring(1)) / 100;
                        }
                    }

                    e_Transaction = Mapper.Map <List <E_TRANSACTION> >(tmcreq);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from " + System.Reflection.MethodBase.GetCurrentMethod().Name + " " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage(nameof(MastercardTransactions) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
            }
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + e_Transaction.Count());
            Console.WriteLine("Channel4 Completed");
            logger.LogInfoMessage(nameof(MastercardTransactions) + " Channel4 Completed ");

            return(e_Transaction);
        }
        public void Run()
        {
            logger = new Logger();

            logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " Starting  EtranzactChannelTransaction ");

            Task <List <E_TRANSACTION> > t1 = Task.Factory.StartNew(Channel1);
            Task <List <E_TRANSACTION> > t2 = Task.Factory.StartNew(Channel2);
            Task <List <E_TRANSACTION> > t3 = Task.Factory.StartNew(Channel3);
            Task <List <E_TRANSACTION> > t4 = Task.Factory.StartNew(Channel4);
            Task <List <E_TRANSACTION> > t5 = Task.Factory.StartNew(Channel5);
            Task <List <E_TRANSACTION> > t6 = Task.Factory.StartNew(Channel6);
            Task <List <E_TRANSACTION> > t7 = Task.Factory.StartNew(Channel7);
            Task <List <E_TRANSACTION> > t8 = Task.Factory.StartNew(Channel8);


            logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + "  EtranzactChannelTransaction waiting for Merging ");
            Console.WriteLine("  EtranzactChannelTransaction waiting for Merging ");
            using (EtzbkDataContext db = new EtzbkDataContext())
            {
                try
                {
                    List <Task> taskList = new List <Task> {
                        t1, t2, t3, t4, t5, t6, t7, t8
                    };
                    Task.WaitAll(taskList.ToArray());
                    Console.WriteLine("  EtranzactChannelTransaction Merged");

                    //Merge All Data Spooled
                    var allTmcData = DataManupulation.MergeEntityList(new List <List <E_TRANSACTION> >()
                    {
                        t1.Result.ToList(), t2.Result.ToList(), t3.Result.ToList(), t4.Result.ToList(), t5.Result.ToList(), t6.Result.ToList(), t7.Result.ToList(), t8.Result.ToList()
                    });

                    Console.WriteLine(" Merge All Data Spooled... Removing Duplicate record");

                    //Remove duplicate value
                    var uniqueIDs     = allTmcData.Select(u => u.UNIQUE_TRANSID).Distinct().ToArray();
                    var uniqueIDsOnDB = db.E_TRANSACTION.Where(u => uniqueIDs.Contains(u.UNIQUE_TRANSID)).Select(u => u.UNIQUE_TRANSID).ToArray();
                    var etrxData      = allTmcData.Where(u => !uniqueIDsOnDB.Contains(u.UNIQUE_TRANSID));

                    Console.WriteLine(uniqueIDsOnDB.Count() + " Duplicate record removed--NonEtzCardTransaction");

                    logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " " + etrxData.Count() + " Record ready to be Inserted");

                    db.E_TRANSACTION.AddRange(etrxData);
                    db.SaveChanges();

                    logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " " + etrxData.Count() + " Record Inserted for Settlement");

                    Console.WriteLine(etrxData.Count() + " Record Inserted for Settlement");
                    Console.WriteLine("Marking Transaction as spooled transaction");
                    if (uniqueIDs.Count() > 0)
                    {
                        DataManupulation.UpdateTMCProcccessedTransaction(uniqueIDs);
                    }
                    Console.WriteLine("Spooled transactions Marked");
                }
                catch (SqlException ex)
                {
                    Console.WriteLine("SQLException from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage("SQLException from Run " + nameof(EtranzactChannelTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from EtranzactChannelTransaction Run " + ExceptionExtensions.GetFullMessage(ex));
                    logger.LogDebugMessage("Exception from Run " + nameof(EtranzactChannelTransaction) + " " + ExceptionExtensions.GetFullMessage(ex));
                }

                logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " Merged ");


                Console.WriteLine("ETZ Channel Transaction Completed");

                logger.LogInfoMessage(nameof(EtranzactChannelTransaction) + " ETZ Channel  Transaction Completed ");
            }
        }