Exemple #1
0
        private CardInfoResponseModel GetResponse <T>(T response)
        {
            CardInfoResponseModel responseModel = new CardInfoResponseModel();

            if (typeof(T).Equals(typeof(CheckCardByCIDResponse)))
            {
                var vResp = (CheckCardByCIDResponse)(object)response;
                responseModel.Code         = vResp.Body.CheckCardByCIDResult.Code;
                responseModel.Desc         = vResp.Body.CheckCardByCIDResult.Desc;
                responseModel.ErrorMessage = vResp.Body.CheckCardByCIDResult.ErrorMessage;
                responseModel.IsError      = vResp.Body.CheckCardByCIDResult.IsError;
            }
            else if (typeof(T).Equals(typeof(CheckCardByLaserResponse)))
            {
                var vResp = (CheckCardByLaserResponse)(object)response;
                responseModel.Code         = vResp.Body.CheckCardByLaserResult.Code;
                responseModel.Desc         = vResp.Body.CheckCardByLaserResult.Desc;
                responseModel.ErrorMessage = vResp.Body.CheckCardByLaserResult.ErrorMessage;
                responseModel.IsError      = vResp.Body.CheckCardByLaserResult.IsError;
            }
            else
            {
                throw new NotSupportedException(typeof(T).Name + " not support");
            }

            return(responseModel);
        }
Exemple #2
0
        public async Task <CardInfoResponseModel> ByCID(SmartCardInfo smartCardInfo)
        {
            CheckCardModel cardModel = new CheckCardModel
            {
                ReferenceNo  = "DO100120200707161630123", // Todo Fix Ref between system
                BranchNumber = "889",
                TerminalId   = "T15000015",
                PID          = smartCardInfo.PID,
                CID          = smartCardInfo.CID,
                Bp1No        = smartCardInfo.Bp1No,
                NameTh       = smartCardInfo.NameTh,
                SurenameTh   = smartCardInfo.SurenameTh,
                DateOfBirth  = smartCardInfo.DateOfBirth,
                LaserNo      = smartCardInfo.LaserNo
            };
            CardInfoResponseModel resTxKey = new CardInfoResponseModel();

            try
            {
                var           client  = clientFactory.CreateClient();
                StringContent content = new StringContent(JsonConvert.SerializeObject(cardModel), Encoding.UTF8, "application/json");
                using var response = await client.PostAsync("http://w2wasdho126:9090/api/checkcardstatus/bycid", content);

                string apiResponse = await response.Content.ReadAsStringAsync();

                resTxKey = JsonConvert.DeserializeObject <CardInfoResponseModel>(apiResponse);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(resTxKey);
        }
Exemple #3
0
        public async Task <EkycTxKeyModel> CheckCardStatus(SmartCardInfo smartCardInfo)
        {
            CardInfoResponseModel cardInfoResponse = new CardInfoResponseModel();

            // Call Dopa WsService
            // Select mode: 3 => Dipship, 5=> Non-Dipship
            switch (smartCardInfo.Mode)
            {
            case "3":
                // Call ByCID
                cardInfoResponse = await checkCardStatusService.ByCID(smartCardInfo);

                break;

            case "5":
                // Call ByLaser
                cardInfoResponse = await checkCardStatusService.ByLaser(smartCardInfo);

                break;
            }

            EkycTxKeyModel txKeyModel = new EkycTxKeyModel
            {
                applicationNo     = "2020051900010001",
                serviceType       = "Account Opening",
                mode              = cardInfoResponse.Data.Mode,
                subMode           = "Y",
                idCard            = smartCardInfo.PID,
                titleNameTh       = smartCardInfo.PrefixNameTh,
                firstNameTh       = smartCardInfo.NameTh,
                middleNameTh      = smartCardInfo.MiddlenameTh,
                lastNameTh        = smartCardInfo.SurenameTh,
                titleNameEn       = smartCardInfo.PrefixNameEn,
                firstNameEn       = smartCardInfo.NameEn,
                middleNameEn      = smartCardInfo.MiddlenameEn,
                lastNameEn        = smartCardInfo.SurenameEn,
                chipImage         = Convert.ToBase64String(smartCardInfo.Image),
                staffId           = "P5170",
                staffName         = "Pornchai",
                overrideStaffId   = "",
                overrideStaffName = "",
                branchCode        = "889",
                branceName        = "สาทร",
                remark            = "",
                dopaResultCode    = cardInfoResponse.Data.StatusCode,
                dopaResultDesc    = cardInfoResponse.Data.Desc
            };

            return(txKeyModel);
        }
Exemple #4
0
        public async Task <CardInfoResponseModel> ByLaser(SmartCardInfo smartCardInfo)
        {
            CardInfoResponseModel resModel = new CardInfoResponseModel();

            try
            {
                var           client  = clientFactory.CreateClient();
                StringContent content = new StringContent(JsonConvert.SerializeObject(smartCardInfo), Encoding.UTF8, "application/json");
                using var response = await client.PostAsync("http://172.20.6.226:8080/ekyc-app/api/ekyc-result", content);

                string apiResponse = await response.Content.ReadAsStringAsync();

                resModel = JsonConvert.DeserializeObject <CardInfoResponseModel>(apiResponse);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(resModel);
        }
        public async Task <IActionResult> GetCardInfo()
        {
            try
            {
                var tasks = await _db.Tasks.ToListAsync();

                var cardResponse = new CardInfoResponseModel
                {
                    PlantCount   = await _db.Plants.CountAsync(),
                    AlertCount   = tasks.Count(x => !x.Status),
                    SuccessCount = tasks.Count(x => x.Status),
                    UserCount    = await _db.Users.CountAsync(),
                };

                return(Ok(cardResponse));
            }
            catch (Exception ex)
            {
                const string error = "Error Was generated GetCardInfo Method";
                _logger.Error($"Unable to Preload Card Info'{error}'.");
                _logger.Error($"Error Message => '{ex.Message}'.");
                return(BadRequest());
            }
        }