/// <summary> /// Изпълнение на заявка към Regix сървис /// </summary> /// <param name="xml">Параметри на справката</param> /// <param name="operation">Адрес на справката</param> /// <returns></returns> public static string GetRegixData(System.Xml.XmlElement xml, string operation) { string res = string.Empty; WSHttpBinding bind = new WSHttpBinding(); bind.Security.Mode = SecurityMode.Transport; bind.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; bind.MaxReceivedMessageSize = 200000; bind.OpenTimeout = new TimeSpan(0, 5, 0); bind.SendTimeout = new TimeSpan(0, 5, 0); bind.ReceiveTimeout = new TimeSpan(0, 5, 0); bind.CloseTimeout = new TimeSpan(0, 5, 0); SLog.log("START Regix: { " + operation + " }"); try { EndpointAddress endp = new EndpointAddress(RegixUtils.RegixURL); RegiXEntryPointClient rgx_srv = new RegiXEntryPointClient(bind, endp); RegixUtils.BindCertificates(rgx_srv, RegixUtils.CertSerialNumber); RegixUtils.ConfirmCertificate(); ServiceRequestData rd = new ServiceRequestData(); rd.CallContext = new CallContext(); rd.CallContext.LawReason = "Закон за правната помощ"; rd.CallContext.ServiceURI = string.Empty; rd.CallContext.Remark = string.Empty; rd.CallContext.ServiceType = "2"; rd.CallContext.AdministrationName = "Национално Бюро за Правна Помощ"; rd.CallbackURL = string.Empty; rd.EIDToken = string.Empty; rd.EmployeeEGN = string.Empty; rd.Argument = xml; rd.Operation = operation; if (RegixUtils.IsDebug) { RegixUtils.SeriliazeForDebug(rd); } ServiceResultData all_data = rgx_srv.ExecuteSynchronous(rd); if (all_data == null) { return(RegixUtils.GetErrorString("Няма данни")); } else if (all_data.HasError) { SLog.log(all_data.Error); return(RegixUtils.GetErrorString(all_data.Error)); } else { if (RegixUtils.IsDebug) { RegixUtils.SeriliazeForDebugResult(all_data); } if (all_data.Data != null && all_data.Data.Response != null) { res = all_data.Data.Response.Any.OuterXml; } } } catch (Exception exIn) { SLog.log("ERROR Regix:"); SLog.log(exIn); res = RegixUtils.GetErrorString("Няма връзка с услугата"); } SLog.log("END Regix: { " + operation + " }"); return(res); }
/// <summary> /// Изпълнява списък от справки и връща резултат в предварително дефиниран HTML формат /// </summary> /// <param name="req">списък на желаните за изпълнение справки и нужните критерии за тях</param> /// <returns>резултатът от всички поискани справки, обединени в един общ HTML. Резултатът е HTML стринг, представен като Stream с UTF-8 енкодинг.</returns> public Stream GetRegixReport(RequestReport[] req) { Log.SLog.log("GetRegixReport -> Count: " + req.Length); Dictionary <string, string> resp = new Dictionary <string, string>(); if (req != null) { foreach (var r in req) { switch (r.RequestOperation) { case ("TechnoLogica.RegiX.ASPSocialAdapter.APIService.IASPSocialAPI.GetSocialServicesDecisions"): { System.Xml.XmlElement xmlRequest = RegixClass.ASP.ASPReport.SocialServicesDecisions(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.ASP.ASPReport.GetHTMLString(res, "1")); break; } case ("TechnoLogica.RegiX.ASPSocialAdapter.APIService.IASPSocialAPI.GetMonthlySocialBenefits"): { System.Xml.XmlElement xmlRequest = RegixClass.ASP.ASPReport.GetMonthlySocialBenefits(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.ASP.ASPReport.GetHTMLString(res, "2")); break; } case ("TechnoLogica.RegiX.ASPSocialAdapter.APIService.IASPSocialAPI.GetBenefitsForHeating"): { System.Xml.XmlElement xmlRequest = RegixClass.ASP.ASPReport.GetBenefitsForHeating(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.ASP.ASPReport.GetHTMLString(res, "3")); break; } case ("TechnoLogica.RegiX.NoiRPAdapter.APIService.IRPAPI.GetPensionRightInfoReport"): { System.Xml.XmlElement xmlRequest = RegixClass.NOI.NOIReport.GetPensionRightRequest(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.NOI.NOIReport.GetHTMLString(res, "1")); break; } case ("TechnoLogica.RegiX.NoiRPAdapter.APIService.IRPAPI.GetPensionTypeAndAmountReport"): { System.Xml.XmlElement xmlRequest = RegixClass.NOI.NOIReport.GetUP7(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.NOI.NOIReport.GetHTMLString(res, "2")); break; } case ("TechnoLogica.RegiX.NoiRPAdapter.APIService.IRPAPI.GetPensionIncomeAmountReport"): { System.Xml.XmlElement xmlRequest = RegixClass.NOI.NOIReport.GetUP8(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.NOI.NOIReport.GetHTMLString(res, "3")); break; } case ("TechnoLogica.RegiX.GraoBRAdapter.APIService.IBRAPI.MaritalStatusSearch"): { System.Xml.XmlElement xmlRequest = RegixClass.BR.BRReport.MaritalStatusRequest(r.RequestID, r.RequestIdType); string res = RegixUtils.GetRegixData(xmlRequest, r.RequestOperation); resp.Add(r.RequestOperation, RegixClass.BR.BRReport.GetHTMLString(res, "1")); break; } default: { break; } } } } StringBuilder sb = new StringBuilder(); foreach (string s in resp.Values) { sb.AppendLine(s); } byte[] resultBytes = Encoding.UTF8.GetBytes(sb.ToString()); WebOperationContext.Current.OutgoingResponse.ContentType = "text/html;charset=utf-8"; return(new MemoryStream(resultBytes)); }