예제 #1
0
        private async Task <RegiXResponse> CallRegiXAsync(CustomCallContext context, ServiceRequestData request)
        {
            try
            {
                RegiXEntryPointClient client = CreateRegiXEntryPointClient();

                // Ако не е подаден сертификат, се използва този от конфигурационния файл.
                X509CertificateInitiatorClientCredential clientCert = client.ClientCredentials.ClientCertificate;
                if (context.Certificate != null)
                {
                    clientCert.Certificate = context.Certificate;
                }
                else if (clientCert.Certificate == null)
                {
                    throw new Exception("Не е указан сертификат за достъп до RegiX.");
                }

                Log.Information($"IntegrationService/CallRegiXAsync - certificate thumbprint: {clientCert.Certificate?.Thumbprint}");

                RegiXResponse response = await RegiXUtility.CallAsync(client, request);

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public async Task <CompanySearchResultModel> GetCompanyFromRegiXAsync(string identifier)
        {
            if (!_integrationSettings.UseRegiX)
            {
                throw new Exception("Integration with RegiX is not configured!");
            }

            if (String.IsNullOrWhiteSpace(identifier))
            {
                throw new Exception("Company identifier is missing");
            }

            RegiXReportModel report = await GetRegiXReportForCompanyValidation();

            if (report == null)
            {
                throw new Exception("RegiX report configuration not found for company validation");
            }

            ServiceRequestData request = GetServiceRequestDataForCompany(report, identifier);

            if (request == null)
            {
                throw new Exception("Company service request was not created");
            }

            // TODO: user, timestamp
            long requestId = await SaveRegiXRequest(request, report);

            // TODO: is context needed for transfering eAuth and certificate info?
            CustomCallContext context  = new CustomCallContext();
            RegiXResponse     response = await CallRegiXAsync(context, request);

            // TODO: errors
            await SaveRegiXResponse(requestId, response, "");

            BaseResponse parsedObject = XsdToObjectUtility.GetResponseObjectFromXsd <ValidUICResponse>(response);


            CompanySearchResultModel resultModel = new CompanySearchResultModel
            {
                CompanyIdentifier = identifier,
                RequestId         = requestId,
                ResponseObject    = parsedObject
            };

            return(resultModel);
        }
예제 #3
0
        private async Task <PropertySearchResultModel> SearchInRegiXAsync(Shared.Enums.PropertyType propertyType, PropertySearchRequestModel searchModel)
        {
            if (!_integrationSettings.UseRegiX)
            {
                throw new Exception("Integration with RegiX is not configured!");
            }

            if (searchModel == null || String.IsNullOrWhiteSpace(searchModel.IdentifierTypeCode) || String.IsNullOrWhiteSpace(searchModel.Identifier))
            {
                throw new Exception("Property search criteria is missing");
            }

            RegiXReportModel report = await GetRegiXReportForPropertyType(propertyType, searchModel);

            if (report == null)
            {
                throw new Exception("RegiX report configuration not found for property type: " + propertyType);
            }

            ServiceRequestData request = GetServiceRequestData(propertyType, searchModel, report);

            if (request == null)
            {
                throw new Exception("Property service request was not created");
            }

            long requestId = await SaveRegiXRequest(request, report);

            // TODO: is context needed for transfering eAuth and certificate info?
            CustomCallContext context  = new CustomCallContext();
            RegiXResponse     response = await CallRegiXAsync(context, request);

            await SaveRegiXResponse(requestId, response, "");

            BaseResponse parsedObject = GetResponseObject(propertyType, response);

            PropertySearchResultModel resultModel = new PropertySearchResultModel
            {
                PropertyIdentifier = searchModel.Identifier,
                RequestId          = requestId,
                ResponseObject     = parsedObject
            };

            return(resultModel);
        }