private void ListViewReportDistributionLog_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.ListViewReportDistributionLog.SelectedItems.Count != 0) { DistributionLog distributionLog = (DistributionLog)this.ListViewReportDistributionLog.SelectedItem; string fileName = distributionLog.GetXPSFilePath(); JObject jsonRequest = APIRequestHelper.GetCaseDocumentMessage(fileName); APIResult apiResult = APIRequestHelper.SubmitAPIRequestMessage(jsonRequest); if (apiResult.Status != "ERROR") { int count = apiResult.JSONResult["result"]["message"]["data"].Count(); byte[] buffer = new byte[count]; for (int i = 0; i < count; i++) { buffer[i] = (byte)Convert.ToInt32(apiResult.JSONResult["result"]["message"]["data"][i].ToString()); } if (this.m_CurrentPackageUri != null) { PackageStore.RemovePackage(this.m_CurrentPackageUri); } this.m_CurrentPackageUri = new Uri("memorystream://20-1234.S"); MemoryStream memoryStream = new MemoryStream(); memoryStream.Write(buffer, 0, buffer.Length); Package package = Package.Open(memoryStream); PackageStore.AddPackage(this.m_CurrentPackageUri, package); XpsDocument document = new XpsDocument(package, CompressionOption.Maximum, this.m_CurrentPackageUri.ToString()); FixedDocumentSequence fixedDocumentSequence = document.GetFixedDocumentSequence(); this.Viewer.Document = fixedDocumentSequence as IDocumentPaginatorSource; } else { MessageBox.Show("The result document for this patient has not been published yet."); } } }