public ReportManifestFactory() { var reportXmls = Directory.GetFiles(ReportFolder, "*.xml"); var temp = new List <ReportManifest>(); var logger = ServiceLocator.Current.GetInstance <ILogWriter>(); reportXmls.ToList().ForEach(reportXml => { try { var fileInfo = new FileInfo(reportXml); var xml = File.ReadAllText(reportXml); var manifest = ReportManifest.Deserialize(xml); manifest.FileLastModifiedDate = fileInfo.LastWriteTime == DateTime.MinValue ? new DateTime(2016, 01, 01) : fileInfo.LastWriteTime; if (!temp.Any(t => t.Name.EqualsIgnoreCase(manifest.Name))) { temp.Add(manifest); } } catch (Exception exc) { var excToUse = exc.InnerException ?? exc; var errMessage = string.Format( "An exception occurred when loading report manifests. Please see below for error.{0}Message: {1}{0}Stack Trace: {2}", Environment.NewLine, excToUse.Message, excToUse.StackTrace); logger.Write(exc, "Error loading report manifest from file {0}", reportXml); } }); InstalledManifests = temp; }
public void AssignFrom(ReportManifest manifest) { //Filters = new List<Filter>(); Columns = Columns ?? new List <ReportColumn>(); WebsitePages = WebsitePages ?? new List <ReportWebsitePage>(); ComparisonKeyIcons = ComparisonKeyIcons ?? new List <ComparisonKeyIconSet>(); _rptfilters = _rptfilters ?? new List <RptFilter>(); Audiences = Audiences ?? new List <Audience>(); Columns.Clear(); WebsitePages.Clear(); ComparisonKeyIcons.Clear(); _rptfilters.Clear(); Audiences.Clear(); ComparisonKeyIcons.AddRange(manifest.ToComparisonKeyIconSet(manifest.IconSets, this).ToList()); Audiences.AddRange(manifest.Audiences.Select(a => a.AudienceType).ToList()); Category = manifest.Category; IsTrending = manifest.IsTrending; Datasets = manifest.Datasets.Select(d => d.Name).ToList(); manifest.Columns.ForEach(col => new ReportColumn(this, col.Name) { IsMeasure = col.IsMeasure, MeasureCode = col.MeasureCode, IsIncluded = true }); manifest.WebsitePages.ForEach(wp => new ReportWebsitePage(this, wp)); Name = manifest.Name; ReportAttributes = manifest.ReportAttributes; SourceTemplate = manifest; Description = !string.IsNullOrWhiteSpace(manifest.Description) ? manifest.Description.TrimStart().TrimEnd() : null; Filter = CandidateFilters.ToReportFilter(); RequiresCmsProviderId = manifest.RequiresCmsProviderId; RequiresCostToChargeRatio = manifest.RequiresCostToChargeRatio; ReportType = manifest.Name; ShowInterpretationText = manifest.ShowInterpretationText; InterpretationText = !string.IsNullOrWhiteSpace(manifest.InterpretationText) ? manifest.InterpretationText.TrimStart().TrimEnd() : null; Footnote = !string.IsNullOrWhiteSpace(manifest.Footer) ? manifest.Footer.TrimStart().TrimEnd() : null; ReportOutputSql = !string.IsNullOrWhiteSpace(manifest.ReportOutputSql) ? manifest.ReportOutputSql.TrimStart().TrimEnd() : null; OutputFileName = !string.IsNullOrWhiteSpace(manifest.OutputFileName) ? manifest.OutputFileName.TrimStart().TrimEnd() : null; OutputJsNamespace = !string.IsNullOrWhiteSpace(manifest.OutputJsNamespace) ? manifest.OutputJsNamespace.TrimStart().TrimEnd() : null; _rptfilters.AddRange(RptFilter.FromFilterList(manifest.Filters, this).ToList()); LastReportManifestUpdate = manifest.FileLastModifiedDate; }
public static XmlDocument Serialize(ReportManifest manifest) { var manifestXml = new XmlDocument(); using (var memstream = new MemoryStream()) { //Create a XmlWriter and point it at the stringbuilder for the location to write the serialized Xml using (var xw = XmlWriter.Create(memstream)) { var ser = new XmlSerializer(typeof(ReportManifest)); //Serialize the object into Xml and write the Xml to the in memory stringbuilder ser.Serialize(xw, manifest); memstream.Position = 0; //Load the Xml from memory to the XmlDocument and return manifestXml.Load(memstream); return(manifestXml); } } }
/// <summary> /// Initializes a new instance of the <see cref="ReportColumn"/> class. /// </summary> /// <param name="report">The report.</param> /// <param name="name">The name.</param> public RptManifestColumn(ReportManifest report, string name) { Name = name; report.AddColumn(this); }
/// <summary> /// Initializes a new instance of the <see cref="Report"/> class. /// </summary> /// <param name="manifest">The manifest.</param> public Report(ReportManifest manifest) : this() { AssignFrom(manifest); }