Example #1
0
        /*
         * public string AddCashIn(CashIn _CashIn)
         * {
         *  int result = 0;
         *  _CashIn.TransDT = Convert.ToDateTime(System.DateTime.Now.ToString("dd/MM/yyyy"));
         *  string split_result = string.Empty;
         *  string MainAuthFlag = string.Empty;
         *  AccMasterService _AccInfoService = new AccMasterService();
         *  AccMaster _AccInfo_Post = new AccMaster();
         *  AccMaster _AccInfo_Get = new AccMaster();
         *
         *  StatusWiseServiceService _StatusWiseServiceService = new StatusWiseServiceService();
         *  StatusWiseService _StatusWiseService= new StatusWiseService();
         *  int CheckStatusWiseService = 0;
         *
         *  TransactionRulesService _TransactionRulesService = new TransactionRulesService();
         *  TransactionRules _TransactionRules = new TransactionRules();
         *  int CheckTransactionRules = 0;
         *
         *  AccLimitSetupService _AccLimitSetupService = new AccLimitSetupService();
         *  AccLimitSetup _AccLimitSetup = new AccLimitSetup();
         *  string CheckAccLimit = string.Empty;
         *  try
         *  {
         #region Get SystemAccountNo by WalletAccountNo
         *      _AccInfo_Post.FromSystemAccountNo = _CashIn.FromSystemAccountNo;
         *      _AccInfo_Post.ToSystemAccountNo = _CashIn.ToSystemAccountNo;
         *      _AccInfo_Post.FunctionId = _CashIn.FunctionId;
         *      _AccInfo_Get = _AccInfoService.GetAccInfo(_AccInfo_Post);
         *      if (_AccInfo_Get == null || _AccInfo_Get.FromSystemAccountNo == null || _AccInfo_Get.ToSystemAccountNo == null)
         *      {
         *          split_result = result + ":" + "Account No. not valid..";
         *          return split_result;
         *      }
         #endregion
         *
         #region Check StatusWiseService
         *      _StatusWiseService.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
         *      _StatusWiseService.DefineServiceId = _CashIn.DefineServiceId;
         *      CheckStatusWiseService = _StatusWiseServiceService.CheckStatusWiseService(_StatusWiseService);
         *      if (CheckStatusWiseService == 0)
         *      {
         *          split_result = result + ":" + "Account No. is not active for this transaction..";
         *          return split_result;
         *      }
         #endregion
         *
         #region Check TransactionRules
         *      _TransactionRules.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
         *      _TransactionRules.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
         *      _TransactionRules.DefineServiceId = _CashIn.DefineServiceId;
         *      CheckTransactionRules = _TransactionRulesService.CheckTransactionRules(_TransactionRules);
         *      if (CheckTransactionRules == 0)
         *      {
         *          split_result = result + ":" + "Transaction is not allowed..";
         *          return split_result;
         *      }
         #endregion
         *
         #region Check Limit
         *      _AccLimitSetup.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
         *      _AccLimitSetup.FromAccType = _AccInfo_Get.FromAccType;
         *      _AccLimitSetup.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
         *      _AccLimitSetup.ToAccType = _AccInfo_Get.ToAccType;
         *      _AccLimitSetup.DefineServiceId = _CashIn.DefineServiceId;
         *      _AccLimitSetup.Amount = _CashIn.Amount;
         *      _AccLimitSetup.TransDT = _CashIn.TransDT;
         *      CheckAccLimit = _AccLimitSetupService.CheckAccLimit(_AccLimitSetup);
         *      if (CheckAccLimit != "true")
         *      {
         *          split_result = result + ":" + CheckAccLimit;
         *          return split_result;
         *      }
         #endregion
         *
         *      if (_AccInfo_Get.FromSystemAccountNo != null && _AccInfo_Get.ToSystemAccountNo != null && CheckStatusWiseService != 0 && CheckTransactionRules != 0 && CheckAccLimit == "true")
         *      {
         *          var _max = _IUoW.Repository<CashIn>().GetMaxValue(x => x.CashInId) + 1;
         *          _CashIn.CashInId = _max.ToString().PadLeft(3, '0');
         *          _CashIn.AuthStatusId = "U";
         *          _CashIn.LastAction = "ADD";
         *          _CashIn.MakeDT = System.DateTime.Now;
         *          _CashIn.MakeBy = "prova";
         *          _CashIn.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
         *          _CashIn.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
         *          result = _IUoW.Repository<CashIn>().Add(_CashIn);
         *
         #region Auth Log
         *          if (result == 1)
         *          {
         *              string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + _CashIn.FunctionId + "/" + _CashIn.FunctionName + "?format=json";
         *              using (WebClient wc = new WebClient())
         *              {
         *                  TransactionRules OBJ_TransactionRules = new TransactionRules();
         *                  var json = wc.DownloadString(url);
         *                  OBJ_TransactionRules = JsonConvert.DeserializeObject<TransactionRules>(json);
         *                  MainAuthFlag = OBJ_TransactionRules.GetAuthPermissionByFunctionIdResult;
         *              }
         *              if (MainAuthFlag == "1")
         *              {
         *                  _IAuthLogService = new AuthLogService();
         *                  long _outMaxSlAuthLogDtl = 0;
         *                  result = _IAuthLogService.AddAuthLog(_IUoW, null, _CashIn, "ADD", "0001", _CashIn.FunctionId, 1, "CashIn", "MTK_USER_TXN", "CashInId", _CashIn.CashInId, "prova", _outMaxSlAuthLogDtl, out _outMaxSlAuthLogDtl);
         *              }
         *              if (MainAuthFlag == "0")
         *              {
         *                  _IAuthLogService = new AuthLogService();
         *                  FTAuthLog _ObjAuthLog = new FTAuthLog();
         *                  _ObjAuthLog.TableNm = "MTK_USER_TXN";
         *                  _ObjAuthLog.AuthStatusId = "A";
         *                  _ObjAuthLog.LastAction = "ADD";
         *                  _ObjAuthLog.FunctionId = _CashIn.FunctionId;
         *                  _ObjAuthLog.TablePkColVal = _CashIn.CashInId;
         *                  result = _IAuthLogService.SetTableObject_FT<CashIn>(_IUoW, _ObjAuthLog, _CashIn);
         *              }
         *          }
         #endregion
         *
         *          if (result == 1)
         *          {
         *              _IUoW.Commit();
         *              split_result = result + ":" + "Saved Successfully";
         *          }
         *          else
         *          {
         *              split_result = result + ":" + "information hasn't been added";
         *          }
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      _ObjErrorLogService = new ErrorLogService();
         *      _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddCashIn(obj)", string.Empty);
         *      split_result = result + ":" + "";
         *  }
         *  return split_result;
         * }
         */

        public async Task <string> AddCashIn(UserTransaction _UserTransaction)
        {
            string txn_id     = string.Empty;
            int    count      = 0;
            int    countTxnId = 0;
            await Task.Run(() =>
            {
                //Parallel.For(0, _UserTransaction.NumberOfCashIn, i =>
                //{
                using (mTakaDbContext _dbContext = new mTakaDbContext())
                {
                    //using (_dbContext.Database.BeginTransaction(IsolationLevel.ReadCommitted))
                    //{
                    try
                    {
                        //_dbContext.Database.BeginTransaction(IsolationLevel.ReadCommitted);
                        count++;
                        var param = new OracleParameter("PWALLET_ACC_NO_F", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.FromSystemAccountNo
                        };
                        var param1 = new OracleParameter("PWALLET_ACC_NO_T", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.ToSystemAccountNo
                        };
                        var param2 = new OracleParameter("PDEFINE_SERVICE_ID", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.DefineServiceId
                        };
                        var param3 = new OracleParameter("PAMOUNT", OracleDbType.Decimal, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.Amount
                        };
                        var param4 = new OracleParameter("PFUNCTIONID", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.FunctionId
                        };
                        var param5 = new OracleParameter("PNARRATION", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.Narration
                        };
                        var param6 = new OracleParameter("PMAKE_BY", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = _UserTransaction.MakeBy
                        };
                        var param7 = new OracleParameter("PTXN_ID", OracleDbType.NVarchar2, ParameterDirection.Output)
                        {
                            Size = 100
                        };
                        var param8 = new OracleParameter("pSL", OracleDbType.NVarchar2, ParameterDirection.Input)
                        {
                            Value = count
                        };


                        //var newId = DbContext.Database.SqlQuery<int>("EXEC dbo.MyProc @MyID = {0}", parm).First()

                        string commandText = "BEGIN MTK_TXN.CREATE_TRANS(:PWALLET_ACC_NO_F,:PWALLET_ACC_NO_T,:PDEFINE_SERVICE_ID,:PAMOUNT,:PFUNCTIONID,:PNARRATION,:PMAKE_BY,:PTXN_ID,:pSL); end;";
                        _dbContext.Database.SqlQuery <string>(commandText, param, param1, param2, param3, param4, param5, param6, param7, param8).ToListAsync();
                        //dbContextTransaction.Commit();
                        txn_id = param7.Value.ToString();
                        if (txn_id != null && txn_id != "")
                        {
                            countTxnId++;
                        }
                    }

                    catch (Exception ex)
                    {
                        //dbContextTransaction.Rollback();
                    }
                    //}

                    //Log.Info("Thread Id is-->" + Thread.CurrentThread.ManagedThreadId);
                }
                //});
            });

            return(txn_id + " - " + count + " -- " + countTxnId);
        }
Example #2
0
        //#region Index
        //public List<FundOut> GetAllFundOut()
        //{
        //    try
        //    {
        //        List<FundOut> OBJ_LIST_FundOut = new List<FundOut>();
        //        foreach (var item in _IUoW.Repository<FundOut>().GetAll())
        //        {
        //            FundOut OBJ_FundOut = new FundOut();
        //            BranchInfoService OBJ_BranchInfoService = new BranchInfoService();

        //            OBJ_FundOut.FundOutId = item.FundOutId;
        //            OBJ_FundOut.ToAccountNo = item.ToAccountNo;
        //            OBJ_FundOut.ToBranchId = item.ToBranchId;
        //            foreach (var item1 in OBJ_BranchInfoService.GetBranchInfoForDD())
        //            {
        //                if (item1.Value == OBJ_FundOut.ToBranchId)
        //                {
        //                    OBJ_FundOut.ToBranchNm = item1.Text;
        //                }
        //            }
        //            OBJ_FundOut.ToAccountBalance = item.ToAccountBalance;
        //            OBJ_FundOut.Amount = item.Amount;
        //            OBJ_FundOut.Narration = item.Narration;
        //            OBJ_FundOut.FromAccountNo = item.FromAccountNo;
        //            OBJ_FundOut.FromBranchId = item.FromBranchId;
        //            foreach (var item1 in OBJ_BranchInfoService.GetBranchInfoForDD())
        //            {
        //                if (item1.Value == OBJ_FundOut.FromBranchId)
        //                {
        //                    OBJ_FundOut.FromBranchNm = item1.Text;
        //                }
        //            }
        //            OBJ_FundOut.AuthStatusId = item.AuthStatusId;
        //            OBJ_FundOut.LastAction = item.LastAction;
        //            OBJ_FundOut.LastUpdateDT = item.LastUpdateDT;
        //            OBJ_FundOut.MakeBy = item.MakeBy;
        //            OBJ_FundOut.MakeDT = System.DateTime.Now;
        //            OBJ_FundOut.TransDT = item.TransDT;
        //            OBJ_LIST_FundOut.Add(OBJ_FundOut);
        //        }
        //        return OBJ_LIST_FundOut;

        //        //var fundout = _IUoW.Repository<FundOut>().GetBy(x => x.AuthStatusId == "A" &&
        //        //                                                 x.LastAction != "DEL", n => new { n.FundOutId, n.ToAccountNo, n.ToBranchId, n.ToAccountBalance, n.Amount, n.Narration, n.FromAccountNo, n.FromBranchId });
        //        //var branch = _IUoW.Repository<BranchInfo>().GetBy(x => x.AuthStatusId == "A" &&
        //        //                                                             x.LastAction != "DEL", n => new { n.BranchId, n.BranchNm });

        //        //List<FundOut> OBJ_LIST_FundOut = fundout
        //        //    .Join(branch, f => f.ToBranchId, b => b.BranchId, (f, b) => new { f, b })
        //        //    .Join(branch, f1 => f1.f.FromBranchId, b1 => b1.BranchId, (f1, b1) => new { f1, b1 })
        //        //.Select(m => new FundOut
        //        //{
        //        //    FundOutId = m.f1.f.FundOutId,
        //        //    ToAccountNo = m.f1.f.ToAccountNo,
        //        //    ToBranchId = m.f1.f.ToBranchId,
        //        //    ToBranchNm = m.f1.b.BranchNm,
        //        //    ToAccountBalance = m.f1.f.ToAccountBalance,
        //        //    Amount = m.f1.f.Amount,
        //        //    Narration = m.f1.f.Narration,
        //        //    FromAccountNo = m.f1.f.FromAccountNo,
        //        //    FromBranchId = m.f1.f.FromBranchId,
        //        //    FromBranchNm = m.b1.BranchNm
        //        //}).ToList();
        //        //return OBJ_LIST_FundOut;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        //public FundOut GetFundOutById(string _FundOutId)
        //{
        //    try
        //    {
        //        return _IUoW.Repository<FundOut>().GetById(_FundOutId);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        //public FundOut GetFundOutBy(FundOut _FundOut)
        //{
        //    try
        //    {
        //        if (_FundOut == null)
        //        {
        //            return _FundOut;
        //        }
        //        return _IUoW.Repository<FundOut>().GetBy(x => x.FundOutId == _FundOut.FundOutId &&
        //                                                           x.AuthStatusId == "A" &&
        //                                                           x.LastAction != "DEL");
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        //#endregion

        #region Add
        public async Task <string> AddFundOut(FundOut _FundOut)
        {
            string txn_id = string.Empty;
            await Task.Run(() =>
            {
                using (mTakaDbContext _dbContext = new mTakaDbContext())
                {
                    using (var dbContextTransaction = _dbContext.Database.BeginTransaction(IsolationLevel.ReadCommitted))
                    {
                        try
                        {
                            var param = new OracleParameter("PWALLET_ACC_NO_F", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.FromSystemAccountNo
                            };
                            var param1 = new OracleParameter("PWALLET_ACC_NO_T", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.ToSystemAccountNo
                            };
                            var param2 = new OracleParameter("PDEFINE_SERVICE_ID", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.DefineServiceId
                            };
                            var param3 = new OracleParameter("PAMOUNT", OracleDbType.Decimal, ParameterDirection.Input)
                            {
                                Value = _FundOut.Amount
                            };
                            var param4 = new OracleParameter("PFUNCTIONID", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.FunctionId
                            };
                            var param5 = new OracleParameter("PNARRATION", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.Narration
                            };
                            var param6 = new OracleParameter("PMAKE_BY", OracleDbType.NVarchar2, ParameterDirection.Input)
                            {
                                Value = _FundOut.MakeBy
                            };
                            var param7 = new OracleParameter("PTXN_ID", OracleDbType.NVarchar2, ParameterDirection.Output)
                            {
                                Size = 100
                            };

                            string commandText = "BEGIN MTK_TXN.CREATE_TRANS(:PWALLET_ACC_NO_F,:PWALLET_ACC_NO_T,:PDEFINE_SERVICE_ID,:PAMOUNT,:PFUNCTIONID,:PNARRATION,:PMAKE_BY,:PTXN_ID); end;";
                            _dbContext.Database.SqlQuery <string>(commandText, param, param1, param2, param3, param4, param5, param6, param7).FirstAsync();
                            dbContextTransaction.Commit();
                            txn_id = param7.Value.ToString();
                        }

                        catch (Exception ex)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }

                    //Log.Info("Thread Id is-->" + Thread.CurrentThread.ManagedThreadId);
                }
            });

            return(txn_id);
        }