/// <summary> /// Handles the Click event of the buttonReportXML control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void buttonReportXML_Click(object sender, EventArgs e) { // theReports.GetReportbyID(int.Parse(HReport_ID.Value)); DateTime dateFrom = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateTime dateTo = new DateTime(DateTime.Now.Year, DateTime.Now.Month + 1, 1).AddDays(-1); int cd4Baseline = int.Parse(hCutOffCD4.Value); // int cd4CutOff = (textCD4.Text == "") ? cd4Baseline : int.Parse(textCD4.Text); //DataTable theDT = theQueries.ExecQuery(queryID, dateFrom, dateTo, cd4CutOff); theReports.RunReport(int.Parse(HReport_ID.Value), dateFrom, dateTo, cd4Baseline); string strTemplate = theReports.GetReportData(); byte[] toBytes = System.Text.Encoding.UTF8.GetBytes(strTemplate); IQWebUtils Util = new IQWebUtils(); Util.ExportDocument(toBytes, "text/xml", theReports.ReportName + ".xml", Response); }
protected void Page_Load(object sender, EventArgs e) { if (Session["AppLocation"] == null || Session.Count == 0 || Session["AppUserID"].ToString() == "") { IQCareMsgBox.Show("SessionExpired", this); Response.Redirect("~/frmlogin.aspx", true); } XmlDocument xmlDoc = null; // Get the ID of the action if (base.Session["PRINT_REPORT_ID"] != null) { try { strReport_ID = base.Session["PRINT_REPORT_ID"].ToString(); datefrom = Convert.ToDateTime(base.Session["REPOR_DATE_RANGE_FROM"]); dateTo = Convert.ToDateTime(base.Session["REPOR_DATE_RANGE_TO"]); cd4CutOff = Convert.ToInt32(base.Session["REPORT_CD4_CUTOFF"]); theReports.RunReport(Convert.ToInt16(strReport_ID), datefrom, dateTo, cd4CutOff); xmlDoc = new XmlDocument(); xmlDoc.LoadXml(theReports.GetReportData()); // XmlSchemaInference inference = new XmlSchemaInference(); // MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xmlDoc.OuterXml.ToString())); //XmlTextReader reader = new XmlTextReader(stream); //XmlSchemaSet schemaSet = inference.InferSchema(reader); ////XmlSchema schema = // IEnumerator en = schemaSet.Schemas().GetEnumerator(); // en.MoveNext(); // XmlSchema schema = (XmlSchema)en.Current; // FileStream file = new FileStream(Server.MapPath("new.xsd"), FileMode.Create, FileAccess.ReadWrite); // XmlTextWriter xwriter = new XmlTextWriter(file, new UTF8Encoding()); // xwriter.Formatting = Formatting.Indented; // schema.Write(xwriter); xslDoc = new XmlDocument(); xslDoc.LoadXml(theReports.ReportXslTemplate); // xslDoc.Save(Server.MapPath("\\" + strReport_ID.ToString() + "xsl.xml")); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xslDoc.NameTable); nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform"); XPathNavigator xslNav = xslDoc.CreateNavigator(); XslCompiledTransform trans = new XslCompiledTransform(); Response.Clear(); Response.ContentType = "text/html; charset=windows-1252"; XsltSettings xslSessings = new XsltSettings(); xslSessings.EnableScript = true; trans.Load(xslNav, xslSessings, new XmlUrlResolver()); trans.Transform(xmlDoc.CreateNavigator(), null, Response.OutputStream); Response.Flush(); } catch (Exception exp) { MsgBuilder theBuilder = new MsgBuilder(); theBuilder.DataElements["MessageText"] = "Please verify the IQTools connection. Please make sure you have IQTools configured properly."; IQCareMsgBox.Show("#C1", theBuilder, this); } } else { return; } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { // Get the ID of the action if (base.Session["PRINT_REPORT_ID"] != null) { strReport_ID = base.Session["PRINT_REPORT_ID"].ToString(); datefrom = Convert.ToDateTime(base.Session["REPOR_DATE_RANGE_FROM"]); dateTo = Convert.ToDateTime(base.Session["REPOR_DATE_RANGE_TO"]); cd4CutOff = Convert.ToInt32(base.Session["REPORT_CD4_CUTOFF"]); theReports.RunReport(Convert.ToInt16(strReport_ID), datefrom, dateTo, cd4CutOff); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(theReports.GetReportData()); // XmlSchemaInference inference = new XmlSchemaInference(); // MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xmlDoc.OuterXml.ToString())); //XmlTextReader reader = new XmlTextReader(stream); //XmlSchemaSet schemaSet = inference.InferSchema(reader); ////XmlSchema schema = // IEnumerator en = schemaSet.Schemas().GetEnumerator(); // en.MoveNext(); // XmlSchema schema = (XmlSchema)en.Current; // FileStream file = new FileStream(Server.MapPath("new.xsd"), FileMode.Create, FileAccess.ReadWrite); // XmlTextWriter xwriter = new XmlTextWriter(file, new UTF8Encoding()); // xwriter.Formatting = Formatting.Indented; // schema.Write(xwriter); xslDoc = new XmlDocument(); xslDoc.LoadXml(theReports.ReportXslTemplate); // xslDoc.Save(Server.MapPath("\\" + strReport_ID.ToString() + "xsl.xml")); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xslDoc.NameTable); nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform"); XPathNavigator xslNav = xslDoc.CreateNavigator(); XslCompiledTransform trans = new XslCompiledTransform(); Response.Clear(); Response.ContentType = "text/html; charset=windows-1252"; XsltSettings xslSessings = new XsltSettings(); xslSessings.EnableScript = true; trans.Load(xslNav, xslSessings, new XmlUrlResolver()); trans.Transform(xmlDoc.CreateNavigator(), null, Response.OutputStream); Response.Flush(); } else { return; } }