/// <summary> /// Passes the response's documents to the View Panel /// </summary> /// <param name="documents"></param> /// <param name="processor"></param> /// <param name="requestId"></param> public void SetResponseDocuments(Document[] documents) { this.documents = documents; var processorStatus = processor.Status(requestId); if (processorStatus.Code == RequestStatus.StatusCode.Error) { ShowErrorMessage(processorStatus.Message); return; } FileListDataSource = documents ?? new Document[0]; // If "documents" is null, then no document is available, show a message. if (documents == null || documents.Length == 0) { ShowView = DisplayType.HTML; DataSource = "<html><body><p style='text-align:center;color:gray;font-family:arial'>No Result Documents Available.</p></body></html>"; return; } Document d = documents.Where(f => f.IsViewable).FirstOrDefault(); if (d != null) { Document s = documents.Where(f => f.Filename == "ViewableDocumentStyle.xml").FirstOrDefault(); Document j = documents.Where(f => f.Filename == "response.json").FirstOrDefault(); Stream contentStream = null; processor.ResponseDocument(requestId, d.DocumentID, out contentStream, 100); ShowMimeType = d.MimeType; if (s != null) { Stream styleStream = null; processor.ResponseDocument(requestId, s.DocumentID, out styleStream, 100); XmlSerializer serializer = new XmlSerializer(typeof(ViewableDocumentStyle)); SetDataSourceStream(contentStream, (ViewableDocumentStyle)serializer.Deserialize(new StreamReader(styleStream))); contentStream.Close(); styleStream.Close(); } else if (j != null) { ShowView = DisplayType.JSON; Stream styleStream = null; processor.ResponseDocument(requestId, j.DocumentID, out styleStream, 100); SetDataSourceStream(contentStream, null); contentStream.Close(); styleStream.Close(); } else { SetDataSourceStream(contentStream); contentStream.Close(); } } else { ShowView = DisplayType.FILELIST; } }