Пример #1
0
        public async Task <MCICRInfoModel> ValidateMCICRAndGetInfoWithOwners(MCICRInfoModelRequest model)
        {
            var isMCICRValidationWork = _rootConfiguration.isMCICRValidationConfiguration.isMCICRValidationWork;

            if (isMCICRValidationWork)
            {
                var service = GetMCICRValidationServiceClient();
                var request = new MCICRValidation11Service.MCICRValidationRq_Type
                {
                    MsgRqHdr = MCICRValidationCRFillHeader()
                };
                request.Body = new MCICRValidation11Service.MCICRValidationRqBody_Type()
                {
                    CommercialRegistrationNumber = model.CommercialRegistrationNumber
                };
                Logger.LogToFile(request, "");
                var result = (await service.MCICRValidationAsync(request))?.MCICRValidationRs;
                Logger.LogToFile(request, result);
                if (result != null && result.Body != null && result.MsgRsHdr.ResponseStatus.StatusCode == ServiceStatusCodes.Success)
                {
                    var commercialRegistrationType = result.Body.CommercialRegistrationType;
                    return(new MCICRInfoModel
                    {
                        Name = result.Body.Name,
                        CommercialRegistrationNameAr = result.Body.Name,
                        AddressDescription = new AddressDescription(result.Body.AddrDesc.AddrLine1),
                        Capital = result.Body.Capital,
                        CityNameAr = result.Body.CityNameAr,
                        CommercialRegistrationStatusInfo = new CommercialRegistrationStatusInfo((int)result.Body.CommercialRegistrationStatusInfo.CommercialRegistrationStatus),
                        CommercialRegistrationType = commercialRegistrationType == CommercialRegistrationType_Type.Main ? CommercialRegistrationType.Main : CommercialRegistrationType.Branch,
                        IssueDateHjri = DateTimeExtensions.ParseHijriDate(result.Body.IssueDtHjr).Value,
                        ExpiryDateHjri = DateTimeExtensions.ParseHijriDate(result.Body.ExpiryDtHjr).Value,
                        LegalTypeAr = result.Body.LegalTypeAr,
                        LegalTypeEn = result.Body.LegalTypeEn,
                        PhoneNumber = result.Body.PhoneNum,
                        FaxNumber = result.Body.FaxNum,
                        CommercialRegistrationActivities = new CommercialRegistrationActivities(result.Body.CommercialRegistrationActivities.Item.ToString() /*CommercialRegistrationActivity*/),
                        CROwnersList = FillCrOwners(result.Body.CROwnersList)
                    });
                }
                throw new WebServiceException(Logger.GetJsonString(request, result));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public async Task <MCICRInfoModel> ValidateMCICRAndGetInfo(MCICRInfoModelRequest model)
        {
            var isMCICRValidationWork = _rootConfiguration.isMCICRValidationConfiguration.isMCICRValidationWork;

            if (isMCICRValidationWork)
            {
                var service = GetMCICRValidationServiceClient();
                var request = new MCICRValidation11Service.MCICRValidationRq_Type
                {
                    MsgRqHdr = MCICRValidationCRFillHeader()
                };
                request.Body = new MCICRValidation11Service.MCICRValidationRqBody_Type()
                {
                    CommercialRegistrationNumber = model.CommercialRegistrationNumber
                };
                Logger.LogToFile(request, "");
                try
                {
                    var result = (await service.MCICRValidationAsync(request))?.MCICRValidationRs;
                    Logger.LogToFile(request, result);
                    if (result != null && result.MsgRsHdr.ResponseStatus.StatusCode == ServiceStatusCodes.Success)
                    {
                        if (result.Body != null)
                        {
                            var commercialRegistrationType = result.Body.CommercialRegistrationType;
                            return(new MCICRInfoModel
                            {
                                Name = result.Body.Name,
                                CommercialRegistrationNameAr = result.Body.Name,
                                AddressDescription = new AddressDescription(result.Body.AddrDesc.AddrLine1),
                                Capital = result.Body.Capital,
                                CityNameAr = result.Body.CityNameAr,
                                CommercialRegistrationStatusInfo = new CommercialRegistrationStatusInfo((int)result.Body.CommercialRegistrationStatusInfo.CommercialRegistrationStatus),
                                CommercialRegistrationType = commercialRegistrationType == CommercialRegistrationType_Type.Main ? CommercialRegistrationType.Main : CommercialRegistrationType.Branch,
                                IssueDateHjri = DateTimeExtensions.ParseHijriDate(result.Body.IssueDtHjr).Value,
                                ExpiryDateHjri = DateTimeExtensions.ParseHijriDate(result.Body.ExpiryDtHjr).Value,
                                LegalTypeAr = result.Body.LegalTypeAr,
                                LegalTypeEn = result.Body.LegalTypeEn,
                                PhoneNumber = result.Body.PhoneNum,
                                FaxNumber = result.Body.FaxNum,
                                ResponseCode = result.MsgRsHdr.ResponseStatus.StatusCode,
                                CommercialRegistrationActivities = new CommercialRegistrationActivities(result.Body.CommercialRegistrationActivities.Item.ToString() /*CommercialRegistrationActivity*/),
                            });
                        }
                        else if (result.MsgRsHdr.ResponseStatus.StatusCode == "E001199")
                        {
                            return(new MCICRInfoModel
                            {
                                statusName = Resources.SharedResources.ErrorMessages.CrExpired,
                                ResponseCode = result.MsgRsHdr.ResponseStatus.StatusCode
                            });
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else if (result != null && result.MsgRsHdr.ResponseStatus.StatusCode == "E001199")
                    {
                        return(new MCICRInfoModel
                        {
                            statusName = Resources.SharedResources.ErrorMessages.CrExpired,
                            ResponseCode = result.MsgRsHdr.ResponseStatus.StatusCode
                        });
                    }
                    else if (result != null && result.MsgRsHdr.ResponseStatus.StatusCode == ServiceStatusCodes.NoRecordsFoundValidateMCICR)
                    {
                        return(null);
                    }
                }
                catch
                {
                    throw new BusinessRuleException("خطأ أثناء جلب البيانات لهذا السجل ");
                }
                throw new BusinessRuleException("خطأ أثناء جلب البيانات لهذا السجل ");
            }
            else
            {
                return(null);
            }
        }