private void BuildResponseDocuments() { if (responseDocument == null) { // Metadata request returns two documents, a display version of the metadata result, and processable version. // Summary query requests returns two documents if necessary, the query result and the style document. responseDocument = new Document[IsMetadataRequest || hasCellCountAlert ? 2 : 1]; responseDocument[0] = new Document("0", "x-application/lpp-dns-table", "SummaryQueryResponse.xml"); responseDocument[0].IsViewable = true; responseDocument[0].Size = viewableResultDataset.GetXml().Length; if (hasCellCountAlert) { ViewableDocumentStyle style = new ViewableDocumentStyle { Css = ".StyledRows { background-color: yellow; color: red }", StyledRows = SummaryQueryUtil.FindLowCellCountsInQueryResult(viewableResultDataset.Tables[0], CellThreshHold) }; XmlSerializer serializer = new XmlSerializer(typeof(ViewableDocumentStyle)); using (StringWriter sw = new StringWriter()) { using (XmlWriter xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings { OmitXmlDeclaration = true })) { serializer.Serialize(xmlWriter, style, null); styleXml = sw.ToString(); } } responseDocument[1] = new Document("1", "application/xml", "ViewableDocumentStyle.xml"); responseDocument[1].IsViewable = false; responseDocument[1].Size = styleXml.Length; } else if (IsMetadataRequest) { responseDocument[1] = new Document("1", "application/xml", "RefreshDatesResponse.xml"); responseDocument[1].IsViewable = false; responseDocument[1].Size = metadataResultDataset == null ? 0 : metadataResultDataset.GetXml().Length; } } }
private void BuildResponseDocuments() { if (responseDocument == null) { var documents = new List <Document>(); if (resultDataset != null) { documents.Add(BuildDocument(RESPONSE_XML_DOCUMENTID, resultDataset, "ESPResponse.xml", true, true)); documents.Add(BuildDocument(RESPONSE_JSON_DOCUMENTID, resultDataset, "ESPResponse.json", false, false)); } if (resultDemoDataset != null) { documents.Add(BuildDocument(DEMOGRAPHIC_XML_DOCUMENTID, resultDemoDataset, "ESPDemographicResponse.xml", false, true)); documents.Add(BuildDocument(DEMOGRAPHIC_JSON_DOCUMENTID, resultDemoDataset, "ESPDemographicResponse.json", false, false)); } if (hasCellCountAlert) { ViewableDocumentStyle style = new ViewableDocumentStyle { Css = ".StyledRows { background-color: yellow; color: red }", StyledRows = FindLowCellCountsInQueryResult(resultDataset.Tables[0], CellThreshHold) }; XmlSerializer serializer = new XmlSerializer(typeof(ViewableDocumentStyle)); using (StringWriter sw = new StringWriter()) { using (XmlWriter xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings { OmitXmlDeclaration = true })) { serializer.Serialize(xmlWriter, style, null); styleXml = sw.ToString(); } } Document styleDoc = new Document(RESPONSE_STYLE_DOCUMENTID, "application/xml", "ViewableDocumentStyle.xml"); styleDoc.IsViewable = false; styleDoc.Size = styleXml.Length; documents.Add(styleDoc); } responseDocument = documents.ToArray(); } }