コード例 #1
0
        public HttpResponseMessage AddCashInIso20022(HttpRequestMessage reqObject)
        {
            string result        = string.Empty;
            int    result_result = 0;
            string result_msg    = "information hasn't been added";
            var    requestedData = reqObject.Content.ReadAsStringAsync().Result;

            mTaka.Utility.ISO20022.Pacs008.Document obj = new mTaka.Utility.ISO20022.Pacs008.Document();
            Exception ex;
            var       deserializestatus = Utility.ISO20022.Pacs008.Document.Deserialize(requestedData, out obj, out ex);

            if (!deserializestatus)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
            }
            var responseDoucment = new mTaka.Utility.ISO20022.Camt054.Document();

            var cdtTrxInf = obj?.FIToFICstmrCdtTrf.CdtTrfTxInf.FirstOrDefault();

            if (cdtTrxInf?.IntrBkSttlmAmt.Value != null)
            {
                var creditorAccount = cdtTrxInf?.CdtrAcct.Id.Item as GenericAccountIdentification1;
                var debitorAccount  = cdtTrxInf?.DbtrAcct.Id.Item as GenericAccountIdentification1;
                _UserTransaction = new UserTransaction()
                {
                    FromSystemAccountNo = debitorAccount?.Id,
                    ToSystemAccountNo   = creditorAccount?.Id,
                    DefineServiceId     = "003",
                    FunctionId          = "090107003",
                    FunctionName        = "CashIn",
                    Amount    = (decimal)cdtTrxInf?.IntrBkSttlmAmt.Value,
                    Narration = "Cashout",
                    MakeBy    = "Prova"
                };

                bool IsValid = ModelValidation.TryValidateModel(_UserTransaction, out _modelErrorMsg);
                if (IsValid)
                {
                    result = _ICashInService.AddCashIn(_UserTransaction, out responseDoucment);
                    var split = result.ToString().Split(':');
                    result_result = Convert.ToInt32(split[0]);
                    result_msg    = split[1];
                }
            }
            if (result_result == 1)
            {
                var ntfctn = responseDoucment.BkToCstmrDbtCdtNtfctn.Ntfctn.FirstOrDefault() ?? new AccountNotification15();
                var ntry   = ntfctn.Ntry.FirstOrDefault() ?? new ReportEntry9();
                ntry.CdtDbtInd = CreditDebitCode.CRDT;
            }

            var responseString = responseDoucment.Serialize(new UTF8Encoding());

            return(_IDataManipulation.CreateHttpResponseXml(responseString));

            if (!string.IsNullOrWhiteSpace(_modelErrorMsg))
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result_result, _modelErrorMsg);
            }
            else
            {
                _serviceResponse = _IDataManipulation.SetResponseObject(result_result, result_msg);
            }
            _response = _IDataManipulation.CreateResponse(_serviceResponse, reqObject);
            return(_response);
        }
コード例 #2
0
        public string AddCashIn(UserTransaction _UserTransaction, out mTaka.Utility.ISO20022.Camt054.Document document)
        {
            document = new Document();
            var grpHdr = document.BkToCstmrDbtCdtNtfctn.GrpHdr;

            grpHdr.MsgId   = mTaka.Utility.ISO.ISOHelper.RandomString();
            grpHdr.CreDtTm = DateTime.Now;
            var ntfctn = document.BkToCstmrDbtCdtNtfctn.Ntfctn.FirstOrDefault();
            var ntry   = ntfctn?.Ntry.FirstOrDefault();

            if (ntry != null)
            {
                ntry.Amt = new ActiveOrHistoricCurrencyAndAmount()
                {
                    Ccy = "BDT", Value = _UserTransaction.Amount
                };
                ntry.CdtDbtInd = CreditDebitCode.DBIT;
                ntry.Sts       = new EntryStatus1Choice()
                {
                    Item = "Other", ItemElementName = ItemChoiceType9.Prtry
                };
            }

            grpHdr.MsgPgntn.LastPgInd = true;
            grpHdr.MsgPgntn.PgNb      = "1";
            int result = 0;

            _UserTransaction.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 = _UserTransaction.FromSystemAccountNo;
                _AccInfo_Post.ToSystemAccountNo   = _UserTransaction.ToSystemAccountNo;
                _AccInfo_Post.FunctionId          = _UserTransaction.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..";
                    grpHdr.AddtlInf = "Account No. not valid..";


                    return(split_result);
                }
                #endregion

                #region Check StatusWiseService
                _StatusWiseService.ToSystemAccountNo = _AccInfo_Get.ToSystemAccountNo;
                _StatusWiseService.DefineServiceId   = _UserTransaction.DefineServiceId;
                CheckStatusWiseService = _StatusWiseServiceService.CheckStatusWiseService(_StatusWiseService);
                if (CheckStatusWiseService == 0)
                {
                    split_result    = result + ":" + "Account No. is not active for this transaction..";
                    grpHdr.AddtlInf = "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     = _UserTransaction.DefineServiceId;
                CheckTransactionRules = _TransactionRulesService.CheckTransactionRules(_TransactionRules);
                if (CheckTransactionRules == 0)
                {
                    split_result    = result + ":" + "Transaction is not allowed..";
                    grpHdr.AddtlInf = "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     = _UserTransaction.DefineServiceId;
                _AccLimitSetup.Amount  = _UserTransaction.Amount;
                _AccLimitSetup.TransDT = _UserTransaction.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 <UserTransaction>().GetMaxValue(x => x.SerialId) + 1;
                    _UserTransaction.SerialId            = _max.ToString().PadLeft(3, '0');
                    _UserTransaction.AuthStatusId        = "U";
                    _UserTransaction.LastAction          = "ADD";
                    _UserTransaction.MakeDT              = System.DateTime.Now;
                    _UserTransaction.MakeBy              = "prova";
                    _UserTransaction.FromSystemAccountNo = _AccInfo_Get.FromSystemAccountNo;
                    _UserTransaction.ToSystemAccountNo   = _AccInfo_Get.ToSystemAccountNo;
                    result = _IUoW.Repository <UserTransaction>().Add(_UserTransaction);

                    #region Auth Log
                    if (result == 1)
                    {
                        string url = ConfigurationManager.AppSettings["LgurdaService_server"] + "/GetAuthPermissionByFunctionId/" + _UserTransaction.FunctionId + "/" + _UserTransaction.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, _UserTransaction, "ADD", "0001", _UserTransaction.FunctionId, 1, "CashIn", "MTK_USER_TXN", "SerialId", _UserTransaction.SerialId, "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    = _UserTransaction.FunctionId;
                            _ObjAuthLog.TablePkColVal = _UserTransaction.SerialId;
                            result = _IAuthLogService.SetTableObject_FT <UserTransaction>(_IUoW, _ObjAuthLog, _UserTransaction);
                        }
                    }
                    #endregion

                    if (result == 1)
                    {
                        _IUoW.Commit();

                        split_result    = result + ":" + "Saved Successfully";
                        grpHdr.AddtlInf = "Saved Successfully";
                    }
                    else
                    {
                        split_result    = result + ":" + "information hasn't been added";
                        grpHdr.AddtlInf = "information hasn't been added";
                    }
                }
            }
            catch (Exception ex)
            {
                _ObjErrorLogService = new ErrorLogService();
                _ObjErrorLogService.AddErrorLog(ex, string.Empty, "AddCashIn(obj)", string.Empty);
                split_result    = result + ":" + "";
                grpHdr.AddtlInf = "";
            }
            return(split_result);
        }