コード例 #1
0
        public async Task <bool> IsOwnAccount(FundsTransferRequest request)
        {
            bool response = false;

            var oralConnect = new OracleConnection(_protector.Unprotect(_appSettings.TMEConnection));

            try
            {
                using (oralConnect)
                {
                    string query = $@"SELECT A.* FROM {_appSettings.FlexSchema}.STTM_CUST_ACCOUNT A INNER JOIN {_appSettings.FlexSchema}.STTM_CUST_ACCOUNT B ON A.CUST_NO = B.CUST_NO
                                WHERE A.CUST_AC_NO = :dract AND B.CUST_AC_NO = :cract";

                    var r = await oralConnect.QueryAsync <string>(query, new { request.dract, request.cract });

                    response = r != null && r.Count() > 0;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }

            return(response);
        }
コード例 #2
0
        public async Task <FundsTransferResponse> FundsTransfer(FundsTransferRequest request)
        {
            FundsTransferResponse res = new FundsTransferResponse();
            string reqString; string respMsg = string.Empty; string resultContent = string.Empty;
            int    respCode = 0;

            request.is_own_account = true;

            try
            {
                using (var client = new HttpClient())
                {
                    reqString = JsonHelper.toJson(request);
                    var content = new StringContent(reqString, Encoding.UTF8, Constant.CONTENTTYPE);
                    var result  = await client.PostAsync(_settings.baseURL + _settings.peURL, content);

                    respCode      = (int)result.StatusCode;
                    respMsg       = result.ReasonPhrase;
                    resultContent = await result.Content.ReadAsStringAsync();
                };
            }
            catch (TaskCanceledException tex)
            {
                respCode = (int)HttpStatusCode.RequestTimeout;
                res      = new FundsTransferResponse()
                {
                    message = Constant.TIMEOUT_MSG,
                    status  = Constant.TIMEOUT_STATUS
                };

                _logger.LogInformation($"{request.cract} {request.trnrefno} : {tex.ToString()}");
            }
            catch (Exception ex)
            {
                respCode = (int)HttpStatusCode.InternalServerError;
                res      = new FundsTransferResponse()
                {
                    message = ex.Message,
                    status  = Constant.FAILED_STATUS
                };

                _logger.LogInformation($"{request.cract} {request.trnrefno} : {ex.ToString()}");
            }

            if (!string.IsNullOrEmpty(resultContent))
            {
                res = JsonHelper.fromJson <FundsTransferResponse>(resultContent);
            }
            else
            {
                res.message = Constant.UKNOWN_MSG;
                res.status  = Constant.UKNOWN_STATUS;
            }

            return(res);
        }
コード例 #3
0
        public async Task <FundsTransferResponse> ExecuteTransaction(FundsTransferRequest request)
        {
            FundsTransferResponse resp = new FundsTransferResponse();

            string sproc = (request.with_charges) ? (!string.IsNullOrEmpty(request.cract3) && request.trnamt2 > 0)
                ? _appSettings.ChrgsSproc2 : _appSettings.ChrgsSproc : _appSettings.PaytSproc;

            string storeProcedure = $"{_appSettings.FlexSchema}.{sproc}";

            var oralConnect = new OracleConnection(_protector.Unprotect(_appSettings.FlexConnection));

            request.trnrefno = $"{request.branch_code}{request.product}{request.l_acs_ccy}" +
                               $"{Commons.Helpers.Utility.RandomString(6)}";


            var param = new DynamicParameters();

            param.Add("dract", request.dract.Trim());
            param.Add("trnamt", request.trnamt);
            if (request.with_charges)
            {
                param.Add("cract1", request.cract1?.Trim());
                param.Add("cract2", request.cract2?.Trim());
                //param.Add("cract3", request.cract3?.Trim());
                param.Add("trnamt1", request.trnamt1);
                //param.Add("trnamt2", request.trnamt2);
            }
            else
            {
                param.Add("cract", request.cract?.Trim());
            }
            if (!string.IsNullOrEmpty(request.cract3))
            {
                param.Add("cract3", request.cract3?.Trim());
            }
            if (request.trnamt2 > 0)
            {
                param.Add("trnamt2", request.trnamt2);
            }
            param.Add("trnrefno", request.trnrefno.Trim());
            param.Add("l_acs_ccy", request.l_acs_ccy);
            param.Add("txnnarra", request.txnnarra);
            param.Add("product", request.product.Trim());
            param.Add("instr_code", request.instr_code.Trim());
            param.Add("branch_code", request.branch_code.Trim());
            param.Add("user_name", request.user_name);
            param.Add("response_code", direction: ParameterDirection.Output, size: 100);
            param.Add("response_msg", direction: ParameterDirection.Output, size: 300);
            param.Add("actualtrnamt", direction: ParameterDirection.Output, size: 300);
            param.Add("rate", direction: ParameterDirection.Output, size: 300);

            using (oralConnect)
            {
                oralConnect.Open();
                await oralConnect.ExecuteAsync(storeProcedure, param, commandType : CommandType.StoredProcedure);

                resp.status       = param.Get <string>("response_code");
                resp.message      = param.Get <string>("response_msg");
                resp.actualtrnamt = param.Get <string>("actualtrnamt");
                resp.rate         = param.Get <string>("rate");
                resp.trnrefno     = request.trnrefno;
                resp.status       = resp.status.Trim();
            }

            return(resp);
        }