ActionResult ExportXmlReport(ReportInfo ri) { if (ri.XmlSchemaPathes == null) { throw new RequestModelException("The xml-schemes are not specified"); } foreach (var path in ri.XmlSchemaPathes) { if (!System.IO.File.Exists(path)) { throw new RequestModelException($"File not found '{path}'"); } } if (String.IsNullOrEmpty(ri.Encoding)) { throw new RequestModelException("The xml encoding is not specified"); } var xmlCreator = new XmlCreator(ri.XmlSchemaPathes, ri.DataModel, ri.Encoding) { Validate = ri.Validate }; var bytes = xmlCreator.CreateXml(); if (xmlCreator.HasErrors) { throw new Exception(xmlCreator.ErrorMessage); } return(File(bytes, "text/xml", $"{ri.Name}.xml")); }
private XmlDocument CreateXmlDoc() { var doc = XmlCreator.CreateXml( Constants.Saml.AuthResponseId, elementId, "id486364ad7bf040b0a3b6f35cc39c1ceb", "localhost:44388", "*****@*****.**", "https://localhost:44300", "https://localhost:44300/identity/AuthServices/Acs"); return(doc); }
async Task ExecuteXmlCommand(RequestCommand cmd, ExpandoObject dataToExec, HttpResponseBase response) { List <String> xmlSchemaPathes = null; if (cmd.xmlSchemas != null) { xmlSchemaPathes = new List <String>(); foreach (var schema in cmd.xmlSchemas) { xmlSchemaPathes.Add(Host.MakeFullPath(false, cmd.Path, schema + ".xsd")); } } if (xmlSchemaPathes == null) { throw new RequestModelException("The xml-schemes are not specified"); } foreach (var path in xmlSchemaPathes) { if (!System.IO.File.Exists(path)) { throw new RequestModelException($"File not found '{path}'"); } } IDataModel dm = await DbContext.LoadModelAsync(cmd.CurrentSource, cmd.XmlProcedure, dataToExec); var xmlCreator = new XmlCreator(xmlSchemaPathes, dm, "UTF-8") { Validate = cmd.validate }; var bytes = xmlCreator.CreateXml(); response.ContentType = "text/xml"; var chars = Encoding.UTF8.GetString(bytes).ToCharArray(); response.Write(chars, 0, chars.Length); }
public async Task <ServerCommandResult> Execute(RequestCommand cmd, ExpandoObject dataToExec) { List <String> xmlSchemaPathes = null; if (cmd.xmlSchemas != null) { xmlSchemaPathes = new List <String>(); foreach (var schema in cmd.xmlSchemas) { xmlSchemaPathes.Add(_host.ApplicationReader.MakeFullPath(cmd.Path, schema + ".xsd")); } } if (xmlSchemaPathes == null) { throw new RequestModelException("The xml-schemes are not specified"); } foreach (var path in xmlSchemaPathes) { if (!_host.ApplicationReader.FileExists(path)) { throw new RequestModelException($"File not found '{path}'"); } } IDataModel dm = await _dbContext.LoadModelAsync(cmd.CurrentSource, cmd.XmlProcedure, dataToExec); var xmlCreator = new XmlCreator(xmlSchemaPathes, dm, "UTF-8") { Validate = cmd.validate }; var bytes = xmlCreator.CreateXml(); return(new ServerCommandResult(Encoding.UTF8.GetString(bytes)) { ConentType = "text/xml" }); }
public IEETResponse SendRequest(IEETHeader header, IEETData data, string certificatePath = null, string certificatePassword = null) { certificatePath = certificatePath ?? ConfigurationManager.AppSettings["eet.net.certificatePath"]; certificatePassword = certificatePassword ?? ConfigurationManager.AppSettings["eet.net.certificatePass"]; var signatureManager = new EETSignature(certificatePath, certificatePassword); var xmlCreator = new XmlCreator(signatureManager); var request = new WebRequestProvider(); var serviceInfo = ServiceInfo.GetServiceInfo(); var pkp = signatureManager.CreatePKP(data); var bkp = signatureManager.CreateBKP(pkp); var control = new EETControl { PKP = new PkpElement { Text = new string[] { pkp } }, BKP = new BkpElement { Text = new string[] { bkp } } }; EETResponse eetResponse; try { var xml = xmlCreator.CreateXml(data, header, control, serviceInfo.ServiceNamespace); var response = request.CallWebService(ConfigurationManager.AppSettings["eet.net.url"], serviceInfo.Action, xml); eetResponse = new EETResponse { Response = response, Request = xml, BKP = bkp, PKP = pkp }; var confirm = response.XmlDeserializeFromString <EETResponseModel>(); if (confirm == null) { eetResponse.Message = "Nevalidní zpráva ze serveru"; eetResponse.HasError = true; } else { eetResponse.ResponseModel = confirm; if (confirm.Body.Odpoved.Chyba == null) { eetResponse.HasError = false; eetResponse.Fik = confirm.Body.Odpoved.Potvrzeni.fik; eetResponse.EETDate = confirm.Body.Odpoved.Hlavicka.dat_prij; eetResponse.Message = string.Format("FIK {0}, BKP {1}, PKP {2}", eetResponse.Fik, eetResponse.BKP, eetResponse.PKP); } else { eetResponse.HasError = true; eetResponse.Message = string.Format("{0} ({1})", confirm.Body.Odpoved.Chyba.Value, confirm.Body.Odpoved.Chyba.kod); } if (confirm.Body.Odpoved.Varovani != null) { eetResponse.Warning = string.Format("{0} ({1})", confirm.Body.Odpoved.Varovani.Value, confirm.Body.Odpoved.Varovani.kod_varov); } } } catch (WebException ex) { Trace.WriteLine(ex.ToString()); eetResponse = new EETResponse(); eetResponse.HasError = true; eetResponse.Message = "Nepodařilo se připojit k serveru"; } catch (Exception ex) { eetResponse = new EETResponse(); eetResponse.HasError = true; eetResponse.Message = "Chyba při zpracování odpovědi. " + ex.Message; } return(eetResponse); }