private async Task <RegiXReportModel> GetRegiXReportForCompanyValidation() { // TODO: configure operation name? RegiXReportModel report = await _context.RegiXreport .Where(x => x.OperationName == "GetValidUICInfo") .Select(x => x.ToModel()) .FirstOrDefaultAsync(); return(report); }
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); }
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); }
private async Task <long> SaveRegiXRequest(ServiceRequestData request, RegiXReportModel report) { RegiXrequest entity = new RegiXrequest { UserId = null, RegiXreportId = report.Id, Argument = request.Argument.OuterXml, CreatedAtUtc = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc) }; await _context.RegiXrequest.AddAsync(entity); await _context.SaveChangesAsync(); long requestId = entity.Id; return(requestId); }
private async Task <RegiXReportModel> GetRegiXReportForPropertyType(Shared.Enums.PropertyType propertyType, PropertySearchRequestModel searchModel) { RegiXreportToPropertyType reportType = await _context.RegiXreportToPropertyType .Where(x => x.RegiXsearchCriteriaTypeCode == searchModel.IdentifierTypeCode.ToUpper() && x.PropertyTypeCode == propertyType.ToString()) .FirstOrDefaultAsync(); if (reportType == null) { return(null); } RegiXReportModel report = await _context.RegiXreport .Where(x => x.Id == reportType.RegiXreportId) .Select(x => x.ToModel()) .FirstOrDefaultAsync(); return(report); }
private ServiceRequestData GetServiceRequestDataForCompany(RegiXReportModel report, string identifier) { CallContext callContext = GetCallContext(); // TODO: build xml XmlDocument doc = new XmlDocument(); string xml = @"<ValidUICRequest xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://egov.bg/RegiX/AV/TR/ValidUICRequest""> <UIC>" + identifier + @"</UIC> </ValidUICRequest>"; doc.LoadXml(xml); XmlElement argument = doc.DocumentElement; string operation = report.Operation; ServiceRequestData request = GetServiceRequest(operation, argument, callContext); return(request); }
private ServiceRequestData GetVesselsByOwnerRequest(string ownerIdentifier, RegiXReportModel report) { CallContext callContext = GetCallContext(); // TODO: build xml XmlDocument doc = new XmlDocument(); string xml = @"<RegistrationInfoByOwnerRequest xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://egov.bg/RegiX/IAMA/RegistrationInfoByOwnerRequest""> <Identifier>" + ownerIdentifier + @"</Identifier> </RegistrationInfoByOwnerRequest> "; doc.LoadXml(xml); XmlElement argument = doc.DocumentElement; string operation = report.Operation; ServiceRequestData request = GetServiceRequest(operation, argument, callContext); return(request); }
public static RegiXReportModel ToModel(this RegiXreport report) { if (report == null) { return(null); } RegiXReportModel model = new RegiXReportModel { Id = report.Id, ProviderName = report.ProviderName, RegisterName = report.RegisterName, ReportName = report.ReportName, AdapterSubdirectory = report.AdapterSubdirectory, OperationName = report.OperationName, RequestXsd = report.RequestXsd, ResponseXsd = report.ResponseXsd, Operation = report.Operation, IsDeleted = report.IsDeleted }; return(model); }
/// <summary> /// Справка по ЕИК/БУЛСТАТ/ЕГН/ЛНЧ за вписани на името на лицето въздухоплавателни средства (Регистър на гражданските въздухоплавателни средства на Република България/ГВА) /// </summary> /// <returns></returns> private ServiceRequestData GetAircraftsByOwnerRequest(string ownerIdentifier, RegiXReportModel report) { CallContext callContext = GetCallContext(); // TODO: build xml XmlDocument doc = new XmlDocument(); string xml = @"<AircraftsByOwnerRequest xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://egov.bg/RegiX/GVA/AircraftsByOwnerRequest""> <OwnerID>" + ownerIdentifier + @"</OwnerID> <DateFrom>2000-01-01</DateFrom> <DateTo>2016-01-01</DateTo> </AircraftsByOwnerRequest>"; doc.LoadXml(xml); XmlElement argument = doc.DocumentElement; string operation = report.Operation; ServiceRequestData request = GetServiceRequest(operation, argument, callContext); return(request); }
/// <summary> /// Разширена справка за МПС по регистрационен номер - V3 (Регистър на моторните превозни средства/МВР) /// </summary> /// <returns></returns> private ServiceRequestData GetMotorVehicleRegistrationInfoV3Request(string propertyIdentifier, RegiXReportModel report) { CallContext callContext = GetCallContext(); // TODO: build xml XmlDocument doc = new XmlDocument(); string xml = ""; string operation = ""; //xml = @"<GetMotorVehicleRegistrationInfoV2Request // xsi:schemaLocation=""http://egov.bg/RegiX/MVR/MPS/GetMotorVehicleRegistrationInfoV2Request GetMotorVehicleRegistrationInfoV2Request.xsd"" // xmlns=""http://egov.bg/RegiX/MVR/MPS/GetMotorVehicleRegistrationInfoV2Request"" // xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> // <Identifier>CA0000CA</Identifier> // </GetMotorVehicleRegistrationInfoV2Request>"; if (_regixCertificateSettings.UseVehicleV3) { xml = @"<GetMotorVehicleRegistrationInfoV3Request xsi:schemaLocation=""http://egov.bg/RegiX/MVR/MPS/GetMotorVehicleRegistrationInfoV3Request GetMotorVehicleRegistrationInfoV3Request.xsd"" xmlns=""http://egov.bg/RegiX/MVR/MPS/GetMotorVehicleRegistrationInfoV3Request"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <Identifier>" + propertyIdentifier + @"</Identifier> </GetMotorVehicleRegistrationInfoV3Request>"; operation = "TechnoLogica.RegiX.MVRMPSAdapter.APIService.IMVRMPSAPI.GetMotorVehicleRegistrationInfoV3"; } else { xml = @"<MotorVehicleRegistrationRequest xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://egov.bg/RegiX/MVR/MPS/MotorVehicleRegistrationRequest""> <Identifier>" + propertyIdentifier + @"</Identifier> </MotorVehicleRegistrationRequest> "; operation = "TechnoLogica.RegiX.MVRMPSAdapter.APIService.IMVRMPSAPI.GetMotorVehicleRegistrationInfo"; } doc.LoadXml(xml); XmlElement argument = doc.DocumentElement; ServiceRequestData request = GetServiceRequest(operation, argument, callContext); return(request); }
private ServiceRequestData GetServiceRequestData(Shared.Enums.PropertyType propertyType, PropertySearchRequestModel model, RegiXReportModel report) { ServiceRequestData request = null; if (propertyType == Shared.Enums.PropertyType.VEHICLE) { request = GetMotorVehicleRegistrationInfoV3Request(model.Identifier, report); } else if (propertyType == Shared.Enums.PropertyType.AIRCRAFT) { if (String.Equals(model.IdentifierTypeCode.ToUpper(), "MSN")) { request = GetAircraftsByMSNRequest(model.Identifier, report); } else if (String.Equals(model.IdentifierTypeCode.ToUpper(), "OWNER")) { request = GetAircraftsByOwnerRequest(model.Identifier, report); } } else if (propertyType == Shared.Enums.PropertyType.VESSEL) { request = GetVesselsByOwnerRequest(model.Identifier, report); } return(request); }