private DocumentParameter GetOrCreateDocumentParameter(bool shouldSave, Document doc, PrmFactName paramName, string strValue = null, int?intValue = null, float?floatValue = null, DateTime?dateValue = null) { strValue = strValue ?? string.Empty; var docPrm = _db.DocumentParameters.SingleOrDefault(d => d.DocumentId == doc.Id && d.ParameterId == paramName.Id); if (docPrm == null) { docPrm = new DocumentParameter() { DateValue = dateValue, IntValue = intValue, FloatValue = floatValue, StringValue = strValue, DocumentId = doc.Id, ParameterId = paramName.Id }; _db.DocumentParameters.Add(docPrm); } else { docPrm.DateValue = dateValue; docPrm.IntValue = intValue; docPrm.FloatValue = floatValue; docPrm.StringValue = strValue; docPrm.DocumentId = doc.Id; docPrm.ParameterId = paramName.Id; } if (shouldSave) { _db.SaveChanges(); } return(docPrm); }
public async Task <ExportedDocumentContent> ExportReport(int reportId) { // Start report export task var documentParameters = new DocumentParameter[] { new DocumentParameter() { Name = "CustomerID", Value = "CACTU" } }; string exportId = await ExportReport(reportId, GetPdfExportModel(documentParameters)); // Check report export task status TaskStatus status = TaskStatus.InProgress; while (status != TaskStatus.Complete) { if ((status = await GetReportExportTaskStatus(exportId)) == TaskStatus.Fault) { throw new DemoExportServiceException("task failed"); } Thread.Sleep(ExportStatusPollingDelay); } // Download exported report HttpContent exportContent = await GetReportExportContent(exportId); return(new ExportedDocumentContent(await exportContent.ReadAsStreamAsync(), "application/pdf", "report.pdf")); }