Exemple #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;
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public void ThenTheTicketShouldDisplayTheCorrectServiceRequestDataOfType(string ticketType, Table table)
        {
            ServiceRequestData srData = (ServiceRequestData)ModuleDataSwitch.CreateSRModuleDataObject(ticketType, table);

            if (data == null)
            {
                Assert.Fail("Data was not found");
                log.Error("data was not found");
            }
            VerifyFieldValuesSwitch.VerifySRFieldValues(ticketType, srData);
        }
Exemple #4
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);
        }
Exemple #5
0
        private ServiceRequestData GetServiceRequest(string operation, XmlElement argument, CallContext callContext)
        {
            ServiceRequestData request = new ServiceRequestData
            {
                Operation          = operation,
                Argument           = argument,
                CallContext        = callContext,
                CitizenEGN         = null,
                EmployeeEGN        = null,
                ReturnAccessMatrix = false,
                SignResult         = true,
                CallbackURL        = null,
                EIDToken           = null
            };

            return(request);
        }
Exemple #6
0
        private static bool VerifyHierarchyField(ServiceRequestData data, string fieldID)
        {
            string location      = "";
            string locationXPath = "";

            if (fieldID == "CurrentLocation")
            {
                location      = data.CurrentLocation;
                locationXPath = ID.currentLocationValue;
            }
            else if (fieldID == "NewLocation")
            {
                location      = data.NewLocation;
                locationXPath = ID.newLocationValue;
            }
            else
            {
                log.Info("From the VerifyHierarchyField method of the ServiceRequestPage.cs file. Incorrect parameter passed: " +
                         fieldID);
                Assert.Fail("From the VerifyHierarchyField method of the ServiceRequestPage.cs file. Incorrect parameter passed: " +
                            fieldID);
                return(false);
            }

            //Verify if  is correct
            string[] typeHierarchyListExpected = location.Split(':');
            string[] typeHierarchyListActual   = (GeneralPage.ExtractValueFromElement(locationXPath)).Split(':');
            bool     numTypeLevelsMatch        = (typeHierarchyListActual.Count() == typeHierarchyListExpected.Count());

            bool typeLevelMatch = true;

            if (numTypeLevelsMatch)
            {
                for (int i = 0; i < typeHierarchyListExpected.Count(); i++)
                {
                    typeLevelMatch &= typeHierarchyListActual[i].Contains(typeHierarchyListExpected[i]);
                }
            }
            else
            {
                typeLevelMatch &= numTypeLevelsMatch;
                log.Error("Type levels do not match. Check the Service request feature file for errors");
            }

            return(typeLevelMatch);
        }
Exemple #7
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);
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        /// <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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        /// <summary>
        /// Справка по сериен номер на въздухоплавателно средство за вписани в регистъра обстоятелства (Регистър на гражданските въздухоплавателни средства на Република България/ГВА)
        /// </summary>
        /// <returns></returns>
        private ServiceRequestData GetAircraftsByMSNRequest(string propertyIdentifier, RegiXReportModel report)
        {
            CallContext callContext = GetCallContext();

            // TODO: build xml
            XmlDocument doc = new XmlDocument();
            string      xml = @"<AircraftsByMSNRequest 
                        xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" 
                        xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" 
                        xmlns=""http://egov.bg/RegiX/GVA/AircraftsByMSNRequest"">
                        <MSN>" + propertyIdentifier + @"</MSN>
                      </AircraftsByMSNRequest>";

            doc.LoadXml(xml);
            XmlElement argument = doc.DocumentElement;

            string             operation = report.Operation;
            ServiceRequestData request   = GetServiceRequest(operation, argument, callContext);

            return(request);
        }
Exemple #12
0
        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 async Task <RegiXResponse> CallAsync(RegiXEntryPointClient client, ServiceRequestData request)
        {
            Guid callId;
            //string rawResponse;
            ServiceResultData result;

            RawMessage rawRequestMessage  = new RawMessage();
            RawMessage rawResponseMessage = new RawMessage();

            try
            {
                callId = RegiXMessageInspector.BeforeCall();

                if (client == null)
                {
                    client = new RegiXEntryPointClient();
                }
                await client.OpenAsync();

                result = await client.ExecuteSynchronousAsync(request);

                await client.CloseAsync();
            }
            catch (Exception ex)
            {
                client.Abort();
                throw ex;
            }
            finally
            {
                //rawResponse = RegiXMessageInspector.AfterCall(callId);
                RegiXMessageInspector.AfterCallAll(callId, ref rawRequestMessage, ref rawResponseMessage);
            }

            return(new RegiXResponse(result, rawRequestMessage, rawResponseMessage));
        }
Exemple #14
0
        public static void VerifyTicketFieldValues(string ticketType, ServiceRequestData data)
        {
            log.Info("Verifying if " + ticketType + " values are correct...");
            bool valuesMatch = true;
            var  dictionary  = new Dictionary <string, bool>();

            dictionary.Add("Requester", (data.Requester == GeneralPage.ExtractValueFromElement(ID.requesterValue)));
            dictionary.Add("Summary", (data.Summary == GeneralPage.ExtractValueFromElement(ID.Summary)));

            //string[] typeHierarchyListExpected = (data.Type).Split(':');
            //string[] typeHierarchyListActual = (GeneralPage.ExtractValueFromElement(ID.TicketTypeValue)).Split(':');
            //bool numTypeLevelsMatch = (typeHierarchyListActual.Count() == typeHierarchyListExpected.Count());
            //valuesMatch &= numTypeLevelsMatch;
            //bool typeLevelMatch = true;
            //if (numTypeLevelsMatch)
            //{
            //    for (int i = 0; i < typeHierarchyListExpected.Count(); i++)
            //    {
            //        typeLevelMatch &= typeHierarchyListActual[i].Contains(typeHierarchyListExpected[i]);
            //    }
            //}
            //else
            //    log.Info("Type levels do not match");

            //dictionary.Add("Type", typeLevelMatch);
            if (ticketType == "Move Request")
            {
                dictionary.Add("Employee Name", (data.EmployeeName == GeneralPage.ExtractValueFromElement(ID.employeeName)));
                dictionary.Add("Employee Type", (((ServiceRequestData)data).EmployeeType == GeneralPage.ExtractValueFromElement(ID.employeeType)));
                dictionary.Add("Position", (((ServiceRequestData)data).Position == GeneralPage.ExtractValueFromElement(ID.position)));
                dictionary.Add("Current Cube or Office", (((ServiceRequestData)data).CurrentCubeOrOffice == GeneralPage.ExtractValueFromElement(ID.currentCubeOffice)));
                dictionary.Add("New Cube or Office", (((ServiceRequestData)data).NewCubeOrOffice == GeneralPage.ExtractValueFromElement(ID.newCubeOffice)));
                dictionary.Add("Current Phone Ext", (((ServiceRequestData)data).CurrentPhoneExt == GeneralPage.ExtractValueFromElement(ID.currentPhoneExt)));
                dictionary.Add("New Phone Ext", (((ServiceRequestData)data).NewPhoneExt == GeneralPage.ExtractValueFromElement(ID.newPhoneExt)));
                dictionary.Add("Current Location", VerifyHierarchyField(data, "CurrentLocation"));
                dictionary.Add("New Location", VerifyHierarchyField(data, "NewLocation"));
            }
            else
            {
                switch (ticketType)
                {
                case "Access Request":
                {
                    dictionary.Add("System", ((ServiceRequestData)data).System == GeneralPage.ExtractTextFromElement(ID.systemValue));
                    dictionary.Add("Access Level", ((ServiceRequestData)data).AccessLevel == GeneralPage.ExtractTextFromElement(ID.accessLevelValue));
                    dictionary.Add("Access Location", ((ServiceRequestData)data).AccessLocation == GeneralPage.ExtractTextFromElement(ID.accessLocationValue));
                    break;
                }

                case "General Request":
                {
                    break;
                }

                case "Hardware Request":
                {
                    dictionary.Add("Hardware Type", ((ServiceRequestData)data).HardwareType == GeneralPage.ExtractTextFromElement(ID.hardwareTypeValue));
                    dictionary.Add("Operating System", ((ServiceRequestData)data).OperatingSystem == GeneralPage.ExtractTextFromElement(ID.operatingSystemValue));
                    break;
                }

                case "Software Request":
                {
                    dictionary.Add("Requested Software", ((ServiceRequestData)data).RequestedSoftware == GeneralPage.ExtractTextFromElement(ID.requestedSoftwareValue));
                    dictionary.Add("Operating System", ((ServiceRequestData)data).OperatingSystem == GeneralPage.ExtractTextFromElement(ID.operatingSystemValue));
                    break;
                }

                case "Training Request":
                {
                    dictionary.Add("Course Name", data.CourseName == GeneralPage.ExtractValueFromElement(ID.coursenameTextbox));
                    dictionary.Add("Program Type", data.ProgramType == GeneralPage.ExtractTextFromElement(ID.programTypeValue));
                    dictionary.Add("Training Level", data.TrainingLevel == GeneralPage.ExtractTextFromElement(ID.trainingLevelValue));
                    dictionary.Add("Course Cost", data.CourseCost == GeneralPage.ExtractValueFromElement(ID.courseCostTextbox));
                    break;
                }

                default:
                {
                    log.Info("Unrecognized Service request type. Check the feature file for errors.");
                    Assert.Fail("Unrecognized Service request type. Check the feature file for errors.");
                    break;
                }
                }
                dictionary.Add("Impact", (data.Impact == GeneralPage.ExtractTextFromElement(ID.impactValue)));
                dictionary.Add("Urgency", (data.Urgency == GeneralPage.ExtractTextFromElement(ID.urgencyValue)));
                dictionary.Add("Priority", (data.Priority == GeneralPage.ExtractTextFromElement(ID.priorityValue)));
            }

            foreach (KeyValuePair <string, bool> entry in dictionary)
            {
                log.Info(entry.Key + ": " + entry.Value);
                valuesMatch &= entry.Value;
            }

            if (!valuesMatch)
            {
                log.Error("One or more field values do not match. Check the logs above to see which field is incorrect");
            }

            Assert.IsTrue(valuesMatch);
        }
 public ServiceResultData ExecuteSynchronous(ServiceRequestData request)
 {
     return(base.Channel.ExecuteSynchronous(request));
 }
 public ServiceExecuteResult Execute(ServiceRequestData request)
 {
     return(base.Channel.Execute(request));
 }
Exemple #17
0
 public static void VerifySRFieldValues(string ticketType, ServiceRequestData data)
 {
     ServiceRequestPage.VerifyTicketFieldValues(ticketType, data);
 }