コード例 #1
0
        public bool UpdateVerificationStatus(UserBankAccountRequest request)
        {
            if (SimpleAesUtil.DecryptAES(request.AccountNumber, EwalletConstant.keyAES).IndexOf(EwalletConstant.strWord) == -1)
            {
                return(false);
            }
            WalletTransactionUow WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities());

            try
            {
                WalletTransactionUnitOfWork.BeginTransaction();
                var UserBankAcc = WalletTransactionUnitOfWork.GetBankAccByID(request.ID);
                UserBankAcc.Comments    = request.Comments;
                UserBankAcc.Verify      = request.Verify;
                UserBankAcc.Update_date = DateTime.Now;
                WalletTransactionUnitOfWork.DoUpdate(UserBankAcc).SaveAndContinue();
                WalletTransactionUnitOfWork.EndTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""));
                return(false);
            }
        }
コード例 #2
0
        public string GenerateNewTransaction_Interest_Snapshot(WalletEntities newWalletEntities, string Tran_ID, decimal Interest_Amount, string AccID, decimal totalamount, string remarks)
        {
            try
            {
                var Tran_interest = new Transaction_Interest_Snapshot();
                Tran_interest.ID              = Guid.NewGuid().ToString();
                Tran_interest.Account_ID      = AccID;
                Tran_interest.Tran_ID         = Tran_ID;
                Tran_interest.Interest_Amount = ConvertUtility.RoundToTwoDecimalPlaces(Interest_Amount);
                Tran_interest.Total_Amount    = ConvertUtility.RoundToTwoDecimalPlaces(totalamount);
                Tran_interest.Createdate      = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
                                                             DateTime.Now.Minute, DateTime.Now.Second);
                Tran_interest.Remark           = remarks;
                Tran_interest.CheckSumInterest = BuildCheckSum_SnapshotInterest(Tran_interest);
                using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(newWalletEntities))
                {
                    eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(Tran_interest).EndTransaction();
                }

                return(Tran_interest.ID);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                logWallet.Log(MethodBase.GetCurrentMethod(), Tran_ID, ex, "");
                return("");
            }
        }
コード例 #3
0
        public decimal UpdateRewardByAccIDForPaymentWithoutTownbus(WalletTransactionUow eWalletTransactionUnitOfWork, Wallet_Account_Reward RewardAcc, decimal CalReward, string remarks)
        {
            decimal realReward = 0;

            try
            {
                if (CalReward >= RewardAcc.Reward_Amount)
                {
                    realReward = RewardAcc.Reward_Amount;
                    RewardAcc.Reward_Amount = 0;
                }
                else if (CalReward < RewardAcc.Reward_Amount)
                {
                    realReward = CalReward;
                    RewardAcc.Reward_Amount = RewardAcc.Reward_Amount - CalReward;
                }

                RewardAcc.Updatedate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
                                                    DateTime.Now.Minute, DateTime.Now.Second);
                RewardAcc.CheckSumReward = BuildCheckSum_Reward(RewardAcc);
                RewardAcc.Remark         = remarks;
                eWalletTransactionUnitOfWork.DoUpdate(RewardAcc).SaveAndContinue();

                return(realReward);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                logWallet.Log(MethodBase.GetCurrentMethod(), RewardAcc.ID, ex, "");
                return(-1);
            }
        }
コード例 #4
0
        public void Log(MethodBase method, object inputParameters, Exception ex, string error, int returnCode, int status)
        {
            try
            {
                var WalletLog = new Wallet_Logs
                {
                    ApiCallerType = "api",
                    ApiMethod     = $"{method.ReflectedType.Name}.{method.Name}",
                    AspNetUserId  = "",
                    Exception     = (ex != null) ? JsonConvert.SerializeObject(ex) : error,
                    Request       = JsonConvert.SerializeObject(inputParameters),
                    Status        = (status == 1)? true:false,
                    ReturnCode    = returnCode,
                    CreateDate    = DateTime.Now,
                    ProductId     = 12
                };

                using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
                {
                    eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(WalletLog).EndTransaction();
                }
            }
            catch (Exception exe)
            {
                throw exe;
            }
        }
コード例 #5
0
        public bool UpdateRewardByAccIDForTopup(WalletTransactionUow eWalletTransactionUnitOfWork, string AccID, decimal rewardamount, string remarks)
        {
            var logWallet = new LogWallet();

            try
            {
                var RewardAcc = eWalletTransactionUnitOfWork.GetRewardByAccID(AccID);
                if (RewardAcc == null)
                {
                    logWallet.Log(MethodBase.GetCurrentMethod(), "Could not find Reward Account by AccID: " + AccID, null, "");
                    return(false);
                }
                RewardAcc.Reward_Amount = RewardAcc.Reward_Amount + rewardamount;
                RewardAcc.Updatedate    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
                                                       DateTime.Now.Minute, DateTime.Now.Second);
                RewardAcc.CheckSumReward = BuildCheckSum_Reward(RewardAcc);
                RewardAcc.Remark         = remarks;
                eWalletTransactionUnitOfWork.DoUpdate(RewardAcc).SaveAndContinue();
                return(true);
            }
            catch (Exception ex)
            {
                logWallet.Log(MethodBase.GetCurrentMethod(), AccID, ex, "");
                return(false);
            }
        }
コード例 #6
0
        public TokenTownBusResponse GetAccessTokenTownBus(TokenRequestTownBus requestParams)
        {
            TokenTownBusResponse tokenTownBus = new TokenTownBusResponse();
            var  townBusEntity = new TownBusEntities();
            bool isExistToken  = false;
            WalletTransactionUow WalletTransactionUnitOfWork = null;

            try
            {
                var strCredencial = SimpleAesUtil.DecryptAES(requestParams.Credential, EwalletConstant.keyAES).Split(';');
                var isExists      = new WalletUserTownbusQueryBuilder(new TownBusEntities()).GetUserByLoginIdnPassword(strCredencial.First(), strCredencial.Last()).FirstOrDefault();
                if (isExists != null)
                {
                    var branch = new WalletBranchTownBusQueryBuilder(new TownBusEntities()).HasBranchId(isExists.Branch_ID).FirstOrDefault();
                    if (branch != null)
                    {
                        tokenTownBus.CompanyID = branch.Company_ID;
                    }
                    tokenTownBus.AccessToken = SimpleAesUtil.EncryptAES(isExists.User_ID + isExists.Password + DateTime.Now.ToString("yyyy-MM-dd hh:00:00"), EwalletConstant.keyAES);
                    tokenTownBus.UserID      = isExists.User_ID;
                    //save notificateToken to config
                    if (string.IsNullOrWhiteSpace(requestParams.NotificationToken))
                    {
                        isExistToken = new TownBusNotificationQueryBuilder(townBusEntity).HasNotificationUniqueId(requestParams.CarPlate, tokenTownBus.CompanyID, requestParams.NotificationUniqueId.Trim());
                    }
                    else
                    {
                        isExistToken = new TownBusNotificationQueryBuilder(townBusEntity).HasNotifcationToken(requestParams.CarPlate, tokenTownBus.CompanyID, requestParams.NotificationToken.Trim());
                    }

                    if (!isExistToken)
                    {
                        // var busType = new TownBusTypeQueryBuilder(townBusEntity).GetBusIdByCompanyIdnBusNo(tokenTownBus.CompanyID, requestParams.CarPlate).FirstOrDefault();
                        using (WalletTransactionUnitOfWork = new WalletTransactionUow(townBusEntity))
                        {
                            TownBusNotification townBusNotification = new TownBusNotification();
                            townBusNotification.CarPlate  = requestParams.CarPlate;
                            townBusNotification.CompanyID = tokenTownBus.CompanyID;
                            //townBusNotification.BusID = busType.Bus_ID;
                            townBusNotification.NotificationToken    = requestParams.NotificationToken.Trim();
                            townBusNotification.NotificationUniqueId = requestParams.NotificationUniqueId.Trim();
                            WalletTransactionUnitOfWork.BeginTransaction(System.Data.IsolationLevel.RepeatableRead)
                            .DoInsert(townBusNotification)
                            .EndTransaction();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                logWallet.Log(MethodBase.GetCurrentMethod(), requestParams.Credential, ex, "");
                return(tokenTownBus);
            }
            return(tokenTownBus);
        }
コード例 #7
0
 public bool InsertTransactionRewards(Wallet_Account_Reward record)
 {
     try
     {
         using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
         {
             eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(record).EndTransaction();
             return(true);
         }
     }
     catch (Exception ex)
     {
         var logWallet = new LogWallet();
         logWallet.Log(MethodBase.GetCurrentMethod(), record.ID, ex, "");
         return(false);
     }
 }
コード例 #8
0
 public bool InsertUserCard(User_Card record)
 {
     try
     {
         using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
         {
             eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(record).EndTransaction();
         }
         return(true);
     }
     catch (Exception ex)
     {
         var logWallet = new LogWallet();
         Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), record.User_ID, ex, ""));
         return(false);
     }
 }
コード例 #9
0
 public string InsertUserRecord(User record)
 {
     try
     {
         using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
         {
             record.User_ID = SecurityLogic.GenerateKey(30);
             eWalletTransactionUnitOfWork.BeginTransaction().DoInsert(record).EndTransaction();
         }
         return(record.User_ID);
     }
     catch (Exception ex)
     {
         var logWallet = new LogWallet();
         Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), record.User_ID, ex, ""));
         return("");
     }
 }
コード例 #10
0
 public bool DeleteUserBankAcc(string IDBankAcc)
 {
     try
     {
         using (var eWalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
         {
             eWalletTransactionUnitOfWork.BeginTransaction();
             var UserBankAcc = new UserBankAccountQueryBuilder(new WalletEntities()).HasID(IDBankAcc).FirstOrDefault();
             eWalletTransactionUnitOfWork.DoDelete(UserBankAcc);
             eWalletTransactionUnitOfWork.EndTransaction();
         }
         return(true);
     }
     catch (Exception ex)
     {
         var logWallet = new LogWallet();
         Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), IDBankAcc, ex, ""));
         return(false);
     }
 }
コード例 #11
0
        public bool UpdateAllCheckSumWalletAccountWithEmptyCS(string FromDate, string ToDate)
        {
            var lstWalletAccount = new List <Wallet_Account>();
            var userLogic        = new WalletUserLogic(true);
            var logWallet        = new LogWallet();

            try
            {
                WalletTransactionUow WalletTransactionUnitOfWork = null;
                using (WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
                {
                    var startDate = new DateTime(int.Parse(FromDate.Split('-')[0]), int.Parse(FromDate.Split('-')[1]), int.Parse(FromDate.Split('-')[2]));
                    var toDate    = new DateTime(int.Parse(ToDate.Split('-')[0]), int.Parse(ToDate.Split('-')[1]), int.Parse(ToDate.Split('-')[2]));
                    var diffDate  = toDate.Subtract(startDate).TotalDays;
                    logWallet.Log(MethodBase.GetCurrentMethod(), "Start UpdateAllCheckSumWalletAccountWithEmptyCS", null, "");

                    for (int i = 0; i <= diffDate; i++)
                    {
                        var date = startDate.AddDays(i);
                        lstWalletAccount = WalletTransactionUnitOfWork.GetAllWalletAccountByDateWithoutCS(date);

                        foreach (Wallet_Account walletAcc in lstWalletAccount)
                        {
                            walletAcc.ChecksumAvailable1 = BuildCheckSumAvailable1(walletAcc);
                            walletAcc.ChecksumAvailable2 = BuildCheckSumAvailable2(walletAcc);
                            walletAcc.ChecksumTotal1     = BuildCheckSumTotal1(walletAcc);
                            walletAcc.ChecksumTotal2     = BuildCheckSumTotal2(walletAcc);
                        }
                        WalletTransactionUnitOfWork.DoUpdateMany(lstWalletAccount);
                        logWallet.Log(MethodBase.GetCurrentMethod(), date, null, date.ToString("yyyy-MM-dd") + ": " + lstWalletAccount.Count);
                    }
                    logWallet.Log(MethodBase.GetCurrentMethod(), "End UpdateAllCheckSumWalletAccountWithEmptyCS", null, "");
                }
                return(true);
            }
            catch (Exception ex)
            {
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""));
                return(false);
            }
        }
コード例 #12
0
        public bool UpdateCheckSumSnapshot(string pChecksum)
        {
            var lstSnapshots = new List <Wallet_Snapshot>();
            var userLogic    = new WalletUserLogic(true);

            try
            {
                var logWallet = new LogWallet();
                WalletTransactionUow WalletTransactionUnitOfWork = null;
                using (WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
                {
                    lstSnapshots = WalletTransactionUnitOfWork.GetSnapshotByCheckSum(pChecksum);
                    logWallet.Log(MethodBase.GetCurrentMethod(), "Log here 1: " + pChecksum + "|" + lstSnapshots.Count, null, "");
                    var S1 = "";
                    foreach (Wallet_Snapshot walletSnapShot in lstSnapshots)
                    {
                        walletSnapShot.Checksum = BuildCheckSum(walletSnapShot);
                        S1 += (walletSnapShot.ID + walletSnapShot.Account_ID + ConvertUtility.RoundToTwoDecimalPlaces(walletSnapShot.Balance) + walletSnapShot.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") + walletSnapShot.Currency_Code + walletSnapShot.Checksum);
                    }
                    logWallet.Log(MethodBase.GetCurrentMethod(), "Log here 2", null, "");
                    var S1Hash = SecurityLogic.GetSha1Hash(S1);
                    logWallet.Log(MethodBase.GetCurrentMethod(), "Log here 3" + S1Hash, null, "");
                    foreach (Wallet_Snapshot Wallet_Snapshot in lstSnapshots)
                    {
                        Wallet_Snapshot.Snapshot = S1Hash;
                    }

                    WalletTransactionUnitOfWork.DoUpdateMany(lstSnapshots).EndTransaction();

                    logWallet.Log(MethodBase.GetCurrentMethod(), "Finish Update UpdateCheckSumSnapshot", null, "");
                }

                return(true);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""));
                return(false);
            }
        }
コード例 #13
0
        public bool UpdateAllCheckSumWalletAccountByUserID(string pUserID)
        {
            var lstWalletAccount = new List <Wallet_Account>();
            var userLogic        = new WalletUserLogic(true);

            try
            {
                var logWallet = new LogWallet();
                WalletTransactionUow WalletTransactionUnitOfWork = null;
                using (WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
                {
                    lstWalletAccount = WalletTransactionUnitOfWork.GetWalletAccountByUserID(pUserID);
                    var flg = false;
                    foreach (Wallet_Account walletAcc in lstWalletAccount)
                    {
                        //if (walletAcc.ChecksumAvailable2 == walletAcc.ChecksumAvailable1)
                        //{
                        walletAcc.ChecksumAvailable1 = BuildCheckSumAvailable1(walletAcc);
                        walletAcc.ChecksumAvailable2 = BuildCheckSumAvailable2(walletAcc);
                        walletAcc.ChecksumTotal1     = BuildCheckSumTotal1(walletAcc);
                        walletAcc.ChecksumTotal2     = BuildCheckSumTotal2(walletAcc);
                        flg = true;
                        //}
                    }
                    if (flg)
                    {
                        WalletTransactionUnitOfWork.DoUpdateMany(lstWalletAccount);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""));
                return(false);
            }
        }
コード例 #14
0
        public bool InsertVerificationStatus(UserBankAccountRequest request)
        {
            try
            {
                var BankAcc = SimpleAesUtil.DecryptAES(request.AccountNumber, EwalletConstant.keyAES);
                BankAcc = BankAcc.Replace(EwalletConstant.strWord, "").Replace(" ", "").Replace("-", "");
                double Num;
                bool   isNum = double.TryParse(BankAcc, out Num);

                if (!isNum || BankAcc.Length < 8 || BankAcc.Length > 20)
                {
                    var logWallet = new LogWallet();
                    logWallet.Log(MethodBase.GetCurrentMethod(), "BankAcc: " + BankAcc, null, "Issue for BankACC");
                    return(false);
                }

                byte[] bytes = Convert.FromBase64String(request.urlBankAcc);
                request.FileNameBankAcc = "BankAcc_" + DateTime.Now.Ticks + request.FileNameBankAcc.Substring(request.FileNameBankAcc.LastIndexOf('.'), 4);
                var pathFileNameBankAcc = Path.Combine(EwalletConstant.EWalletPathPictureUpload, request.FileNameBankAcc);
                using (Image image = Image.FromStream(new MemoryStream(bytes)))
                {
                    image.Save(pathFileNameBankAcc);
                }

                bytes = Convert.FromBase64String(request.urlPassIC);
                request.FileNamePasIC = "BankPasIC_" + DateTime.Now.Ticks + request.FileNamePasIC.Substring(request.FileNamePasIC.LastIndexOf('.'), 4);
                var pathFileNamePasIC = Path.Combine(EwalletConstant.EWalletPathPictureUpload, request.FileNamePasIC);
                using (Image image = Image.FromStream(new MemoryStream(bytes)))
                {
                    image.Save(pathFileNamePasIC);
                }

                var userBankAccount = new User_Bank_Account
                {
                    ID            = SecurityLogic.GenerateKey(30),
                    BankCurrency  = request.BankCurrency,
                    CountryBank   = request.CountryBank,
                    BankName      = request.BankName,
                    AccountName   = request.AccountName,
                    AccountNumber = request.AccountNumber,
                    Verify        = "Pending",
                    urlBankAcc    = pathFileNameBankAcc,
                    urlPassIC     = pathFileNamePasIC,
                    User_ID       = request.User_ID,
                    BankCity      = request.BankCity,
                    BranchCode    = request.BranchCode,
                    BranchName    = request.BranchName,
                    Comments      = request.Comments,
                    Create_date   = DateTime.Now,
                    Update_date   = DateTime.Now,
                };


                WalletTransactionUow WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities());

                WalletTransactionUnitOfWork.BeginTransaction();
                WalletTransactionUnitOfWork.DoInsert(userBankAccount).SaveAndContinue();
                WalletTransactionUnitOfWork.EndTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), request, ex, ""));
                return(false);
            }
        }
コード例 #15
0
        public string GenerateNewWalletAccount(string pUserID, string pUserCreate)
        {
            var lstWalletAccount = new List <Wallet_Account>();
            var lstWalletRule    = new List <Wallet_Rule>();
            //var lstInterestSnapshot = new List<Transaction_Interest_Snapshot>();
            var lstRewards     = new List <Wallet_Account_Reward>();
            var New_WalletUser = new Wallet_User();

            New_WalletUser.User_ID   = pUserID;
            New_WalletUser.Wallet_ID = SecurityLogic.GenerateKey(30);
            var curDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
                                       DateTime.Now.Minute, DateTime.Now.Second);
            WalletTransactionUow WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities());

            try
            {
                WalletTransactionUnitOfWork.BeginTransaction();
                WalletTransactionUnitOfWork.DoInsert(New_WalletUser).SaveAndContinue();

                using (var CurrenciesQueryBuilder = new CurrenciesQueryBuilder(new WalletEntities()))
                {
                    foreach (var CurrencyCode in CurrenciesQueryBuilder.ToList())
                    {
                        #region New Wallet Acc
                        Random random        = new Random();
                        var    New_walletAcc = new Wallet_Account();
                        New_walletAcc.ID                 = SecurityLogic.GenerateKey(30);
                        New_walletAcc.Wallet_ID          = New_WalletUser.Wallet_ID;
                        New_walletAcc.User_ID            = pUserID;
                        New_walletAcc.Available_Balance  = ConvertUtility.RoundToTwoDecimalPlaces(0);
                        New_walletAcc.Total_Balance      = ConvertUtility.RoundToTwoDecimalPlaces(0);
                        New_walletAcc.Currency_Code      = CurrencyCode.Currency_Code;
                        New_walletAcc.CreateDate         = curDate;
                        New_walletAcc.CreateUser         = pUserCreate;
                        New_walletAcc.UpdateDate         = curDate;
                        New_walletAcc.UpdateUser         = pUserCreate;
                        New_walletAcc.ChecksumAvailable1 = BuildCheckSumAvailable1(New_walletAcc);

                        var strCheckSum2 = BuildCheckSumAvailable2(New_walletAcc);
                        if (strCheckSum2 != "")
                        {
                            New_walletAcc.ChecksumAvailable2 = strCheckSum2;
                        }
                        else
                        {
                            var logWallet = new LogWallet();
                            Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), New_WalletUser.Wallet_ID, null, "Can not build checksum2"));
                            return("Failed");
                        }

                        New_walletAcc.ChecksumTotal1 = BuildCheckSumTotal1(New_walletAcc);
                        New_walletAcc.ChecksumTotal2 = BuildCheckSumTotal2(New_walletAcc);
                        lstWalletAccount.Add(New_walletAcc);
                        #endregion

                        #region New Wallet Rule
                        var New_WalletRule = new Wallet_Rule();
                        New_WalletRule.ID         = SecurityLogic.GenerateKey(30);
                        New_WalletRule.Account_ID = New_walletAcc.ID;

                        switch (CurrencyCode.Currency_Code)
                        {
                        case "VND":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_VND;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_VND;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_VND;
                            break;

                        case "USD":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_USD;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_USD;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_USD;
                            break;

                        case "SGD":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_SGN;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_SGN;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_SGN;
                            break;

                        case "MYR":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_MYR;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_MYR;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_MYR;
                            break;

                        case "THB":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_THB;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_THB;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_THB;
                            break;

                        case "CNY":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_CNY;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_CNY;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_CNY;
                            break;

                        case "KHR":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_KHR;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_KHR;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_KHR;
                            break;

                        case "MMK":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_MMK;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_MMK;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_MMK;
                            break;

                        case "Rp":
                            New_WalletRule.Maximum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupAmount_Rp;
                            New_WalletRule.Maximum_Withdraw_Amount = EwalletConstant.EWallet_LimitWithdrawAmount_Rp;
                            New_WalletRule.Minimum_Topup_Amount    = EwalletConstant.EWallet_LimitTopupMinimumAmount_Rp;
                            break;
                        }
                        New_WalletRule.CreateDate    = curDate;
                        New_WalletRule.UpdateDate    = curDate;
                        New_WalletRule.Currency_Code = CurrencyCode.Currency_Code;
                        lstWalletRule.Add(New_WalletRule);

                        #endregion

                        //#region New Interest Snapshot
                        //var TransactionInterest = new WalletInterestLogic();
                        //var Tran_interest = new Transaction_Interest_Snapshot();
                        //Tran_interest.ID = Guid.NewGuid().ToString();
                        //Tran_interest.Account_ID = New_walletAcc.ID;
                        //Tran_interest.Tran_ID = Guid.NewGuid().ToString();
                        //Tran_interest.Interest_Amount = 0;
                        //Tran_interest.Total_Amount = 0;
                        //Tran_interest.Createdate = DateTime.Now;
                        //Tran_interest.Remark = "";
                        //var TransactionLogic = new WalletTransactionLogic(true);
                        //Tran_interest.CheckSumInterest = TransactionInterest.BuildCheckSum_SnapshotInterest(Tran_interest);
                        //lstInterestSnapshot.Add(Tran_interest);
                        //#endregion

                        #region New Reward Account

                        var Transaction_Reward = new Wallet_Account_Reward();
                        Transaction_Reward.ID            = New_walletAcc.ID;
                        Transaction_Reward.Wallet_ID     = New_walletAcc.Wallet_ID;
                        Transaction_Reward.Reward_Amount = 0;
                        Transaction_Reward.Createdate    = curDate;
                        Transaction_Reward.Updatedate    = curDate;
                        Transaction_Reward.Remark        = "";
                        var TransactionRewardLogic = new WalletRewardLogic();
                        Transaction_Reward.CheckSumReward = TransactionRewardLogic.BuildCheckSum_Reward(Transaction_Reward);
                        lstRewards.Add(Transaction_Reward);
                        #endregion
                    }
                }

                WalletTransactionUnitOfWork.DoInsertMany(lstWalletAccount);
                WalletTransactionUnitOfWork.DoInsertMany(lstWalletRule);
                //WalletTransactionUnitOfWork.DoInsertMany(lstInterestSnapshot);
                WalletTransactionUnitOfWork.DoInsertMany(lstRewards);
                WalletTransactionUnitOfWork.EndTransaction();

                return(New_WalletUser.Wallet_ID);
            }
            catch (Exception ex)
            {
                WalletTransactionUnitOfWork.RollBack();
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), New_WalletUser.Wallet_ID, ex, ""));
                return("Failed");
            }
        }
コード例 #16
0
        public bool InsertSnapshot(string now)
        {
            var lstRewardAcc      = new List <Wallet_Account_Reward>();
            var lstWalletSnapshot = new List <Wallet_Snapshot>();
            var userLogic         = new WalletUserLogic(true);

            try
            {
                var DateSnapshot = new WalletSnapshotQueryBuilder(new WalletEntities()).GetLatestDateSnapshot().FirstOrDefault().CreateDateSnapshot;
                if (DateSnapshot.Year == int.Parse(now.Split('-')[0]) && DateSnapshot.Month == int.Parse(now.Split('-')[1]) && DateSnapshot.Day == int.Parse(now.Split('-')[2]))
                {
                    return(true);
                }
                WalletTransactionUow WalletTransactionUnitOfWork = null;
                using (WalletTransactionUnitOfWork = new WalletTransactionUow(new WalletEntities()))
                {
                    WalletTransactionUnitOfWork.BeginTransaction();
                    var lstWalletAccount = WalletTransactionUnitOfWork.GetAllWalletAccount().OrderBy(wa => wa.ID);
                    lstRewardAcc = WalletTransactionUnitOfWork.GetAllRewardAccount();
                    string S1 = "";
                    foreach (Wallet_Account walletAcc in lstWalletAccount)
                    {
                        var walletSnapShot = new Wallet_Snapshot();
                        walletSnapShot.ID         = Guid.NewGuid().ToString();
                        walletSnapShot.Account_ID = walletAcc.ID;
                        walletSnapShot.Balance    = walletAcc.Available_Balance;
                        if (lstRewardAcc != null)
                        {
                            var rewardACC = lstRewardAcc.Find(p => p.ID == walletAcc.ID);
                            if (rewardACC != null)
                            {
                                walletSnapShot.Reward_Amount = rewardACC.Reward_Amount;
                            }
                            else
                            {
                                walletSnapShot.Reward_Amount = 0;
                            }
                        }
                        else
                        {
                            walletSnapShot.Reward_Amount = 0;
                        }
                        walletSnapShot.CreateDate         = walletAcc.CreateDate;
                        walletSnapShot.UpdateDate         = walletAcc.UpdateDate;
                        walletSnapShot.CreateDateSnapshot = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
                                                                         DateTime.Now.Minute, DateTime.Now.Second);
                        walletSnapShot.Currency_Code = walletAcc.Currency_Code;
                        walletSnapShot.Checksum      = BuildCheckSum(walletSnapShot);
                        lstWalletSnapshot.Add(walletSnapShot);
                        S1 += walletSnapShot.ID + walletSnapShot.Account_ID + ConvertUtility.RoundToTwoDecimalPlaces(walletSnapShot.Balance) + ConvertUtility.RoundToTwoDecimalPlaces(walletSnapShot.Reward_Amount) + walletSnapShot.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") + walletSnapShot.Currency_Code + walletSnapShot.Checksum;
                    }
                    var S1Hash = SecurityLogic.GetSha1Hash(S1);
                    foreach (Wallet_Snapshot Wallet_Snapshot in lstWalletSnapshot)
                    {
                        Wallet_Snapshot.Snapshot = S1Hash;
                    }

                    WalletTransactionUnitOfWork.DoInsertMany(lstWalletSnapshot).EndTransaction();
                }
                return(true);
            }
            catch (Exception ex)
            {
                var logWallet = new LogWallet();
                Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""));
                return(false);
            }
        }