/// <summary> /// Creates the report. /// </summary> public string CreateReportXAML(string serverUrl, ReportConfig config) { if (config.StaticXAMLReport != null) return config.StaticXAMLReport; // load the xslt template System.Xml.Xsl.XslCompiledTransform xslt = new System.Xml.Xsl.XslCompiledTransform(); try { LoadTemplate(xslt, serverUrl, config.ReportGroup, config.ReportTemplate); } catch (System.Exception) { throw new ScrumFactory.Exceptions.ScrumFactoryException("Error_reading_report_template"); } // creates a buffer stream to write the report context in XML System.IO.BufferedStream xmlBuffer = new System.IO.BufferedStream(new System.IO.MemoryStream()); System.Xml.XmlWriterSettings writerSettings = new System.Xml.XmlWriterSettings(); writerSettings.CheckCharacters = false; writerSettings.OmitXmlDeclaration = true; System.Xml.XmlWriter reportDataStream = System.Xml.XmlWriter.Create(xmlBuffer, writerSettings); // write XML start tag reportDataStream.WriteStartDocument(); reportDataStream.WriteStartElement("ReportData"); // create report context in XML CreateDefaultXMLContext(reportDataStream, writerSettings, serverUrl, config); // finish XML document reportDataStream.WriteEndDocument(); reportDataStream.Flush(); xmlBuffer.Seek(0, System.IO.SeekOrigin.Begin); // debug //System.IO.StreamReader s = new System.IO.StreamReader(xmlBuffer); //string ss = s.ReadToEnd(); System.Xml.XmlReaderSettings readerSettings = new System.Xml.XmlReaderSettings(); readerSettings.CheckCharacters = false; System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(xmlBuffer, readerSettings); // creates a buffer stream to write the XAML flow document System.IO.StringWriter xamlBuffer = new System.IO.StringWriter(); System.Xml.XmlWriter xamlWriter = System.Xml.XmlWriter.Create(xamlBuffer, writerSettings); // creates the flow document XMAL xslt.Transform(xmlReader, xamlWriter); // sets the flow document at the view return xamlBuffer.ToString(); }
/// <summary> /// Creates the report. /// </summary> public string CreateReportXAML(string serverUrl, ReportConfig config, bool toUseAsHtml = false) { if (config.StaticXAMLReport != null) { return(config.StaticXAMLReport); } // load the xslt template System.Xml.Xsl.XslCompiledTransform xslt = new System.Xml.Xsl.XslCompiledTransform(); try { LoadTemplate(xslt, serverUrl, config.ReportGroup, config.ReportTemplate); } catch (System.Exception ex) { throw new ScrumFactory.Exceptions.ScrumFactoryException("Error_reading_report_template\n" + ex.Message); } // creates a buffer stream to write the report context in XML System.IO.BufferedStream xmlBuffer = new System.IO.BufferedStream(new System.IO.MemoryStream()); System.Xml.XmlWriterSettings writerSettings = new System.Xml.XmlWriterSettings(); writerSettings.CheckCharacters = false; writerSettings.OmitXmlDeclaration = true; System.Xml.XmlWriter reportDataStream = System.Xml.XmlWriter.Create(xmlBuffer, writerSettings); // write XML start tag reportDataStream.WriteStartDocument(); reportDataStream.WriteStartElement("ReportData"); // create report context in XML CreateDefaultXMLContext(reportDataStream, writerSettings, serverUrl, config); // finish XML document reportDataStream.WriteEndDocument(); reportDataStream.Flush(); xmlBuffer.Seek(0, System.IO.SeekOrigin.Begin); // debug //System.IO.StreamReader s = new System.IO.StreamReader(xmlBuffer); //string ss = s.ReadToEnd(); System.Xml.XmlReaderSettings readerSettings = new System.Xml.XmlReaderSettings(); readerSettings.CheckCharacters = false; System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(xmlBuffer, readerSettings); // creates a buffer stream to write the XAML flow document System.IO.StringWriter xamlBuffer = new System.IO.StringWriter(); System.Xml.XmlWriter xamlWriter = System.Xml.XmlWriter.Create(xamlBuffer, writerSettings); // creates the flow document XMAL xslt.Transform(xmlReader, xamlWriter); // sets the flow document at the view var xaml = xamlBuffer.ToString(); if (toUseAsHtml) { xaml = MDParser.ConvertToHTML(xaml); } else { xaml = MDParser.ConvertToXAML(xaml); } return(xaml); }
private void CreateDefaultXMLContext(System.Xml.XmlWriter reportDataStream, System.Xml.XmlWriterSettings writerSettings, string serverUrl, ReportConfig config) { reportDataStream.WriteElementString("Today", System.DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); reportDataStream.WriteElementString("ServerUrl", serverUrl); foreach (string key in config.ReportVars.Keys) { reportDataStream.WriteElementString(key, config.ReportVars[key]); } foreach (object o in config.ReportObjects) { SerializeObjectToXML(reportDataStream, writerSettings, o); } }
private void CreateDefaultXMLContext(System.Xml.XmlWriter reportDataStream, System.Xml.XmlWriterSettings writerSettings, string serverUrl, ReportConfig config) { reportDataStream.WriteElementString("Today", System.DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); reportDataStream.WriteElementString("ServerUrl", serverUrl); foreach (string key in config.ReportVars.Keys) reportDataStream.WriteElementString(key, config.ReportVars[key]); foreach (object o in config.ReportObjects) SerializeObjectToXML(reportDataStream, writerSettings, o); }
private void ShowSprintStackReport() { ReportConfig reportConfig = new ReportConfig("DeliveryReport", "SprintStackReport", Properties.Resources.Schedule_report); PrepareReport(reportConfig); aggregator.Publish<ReportConfig>(ScrumFactoryEvent.ShowReport, reportConfig); }
private void PrepareReport(ReportConfig reportConfig) { ICollection<BacklogItem> backlog = backlogService.GetBacklog(Project.ProjectUId, null, (short)ScrumFactory.Services.BacklogFiltersMode.ALL); ICollection<BacklogItemGroup> groups = backlogService.GetBacklogItemGroups(Project.ProjectUId); foreach (BacklogItem item in backlog) { item.ValidPlannedHours = item.GetValidPlannedHours(); int? firstSprint = item.ValidPlannedHours.Min(h => h.SprintNumber); item.FirstSprintWorked = firstSprint.HasValue ? firstSprint.Value : Project.LastSprint.SprintNumber; int? lastSprint = item.ValidPlannedHours.Max(h => h.SprintNumber); item.LastSprintWorked = lastSprint.HasValue ? lastSprint.Value : Project.LastSprint.SprintNumber; if (item.FirstSprintWorked < Project.CurrentValidSprint.SprintNumber) item.OrderSprintWorked = item.LastSprintWorked; else item.OrderSprintWorked = item.FirstSprintWorked; item.Group = groups.SingleOrDefault(g => g.GroupUId == item.GroupUId); } reportConfig.ReportObjects.Add(Project); reportConfig.ReportObjects.Add(backlog); reportConfig.ReportObjects.Add(groups); if (Project.CurrentValidSprint != null) reportConfig.ReportVars.Add("ProjectCurrentSprintNumber", Project.CurrentValidSprint.SprintNumber.ToString()); }