public ActionResult ActExportFilePdf(Guid id) { string name = "Акт выполненных работ.pdf"; StiReport report = new StiReport(); try { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletion.mrt")); foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = id; report.Dictionary.Variables["ContractId"].ValueObject = expRepo.GetAssessmentDeclaration(id).ContractId; report.Dictionary.Variables["ValueAddedTax"].ValueObject = expRepo.GetValueAddedTax(); var totalCount = expRepo.GetContractPrice(expRepo.GetAssessmentDeclaration(id).ContractId); report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(File(stream, "application/pdf", name)); }
/// <summary> /// Акт выполненных работ /// </summary> /// <returns></returns> public ActionResult CertOfComplectFilePdf(Guid id) { OBKExpDocumentRepository expRepo = new OBKExpDocumentRepository(); string name = "Акт выполненных работ.pdf"; StiReport report = new StiReport(); try { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletion.mrt")); foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = id; var declaration = expRepo.GetAssessmentDeclaration(id); report.Dictionary.Variables["ContractId"].ValueObject = declaration.ContractId; report.Dictionary.Variables["ValueAddedTax"].ValueObject = expRepo.GetValueAddedTax(); var refType = db.OBK_Ref_Type.FirstOrDefault(o => o.Id == declaration.TypeId); var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.AssessmentDeclarationId == id); decimal totalCount = 0; if (CodeConstManager.OBK_SA_PARTY.Equals(refType.Code) && expDocument.ExpResult == false) { totalCount = expRepo.GetContractPriceMotivationRefuse(expRepo.GetAssessmentDeclaration(id).ContractId); } else { totalCount = expRepo.GetContractPrice(expRepo.GetAssessmentDeclaration(id).ContractId); } report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(new FileStreamResult(stream, "application/pdf")); //return File(stream, "application/pdf", name); }
public ActionResult CertOfComplectFilePdf(Guid zbkCopyId) { OBKExpDocumentRepository expRepo = new OBKExpDocumentRepository(); string name = "Акт выполненных работ.pdf"; var copy = db.OBK_ZBKCopy.FirstOrDefault(o => o.Id == zbkCopyId); var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.Id == copy.OBK_StageExpDocumentId); StiReport report = new StiReport(); try { if (copy.ExpApplication == false) { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletionCopyZbkApplication.mrt")); } else { report.Load(Server.MapPath("~/Reports/Mrts/OBK/1c/ObkCertificateOfCompletionCopyZbk.mrt")); } foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>()) { data.ConnectionString = UserHelper.GetCnString(); } report.Dictionary.Variables["AssessmentDeclarationId"].ValueObject = expDocument.AssessmentDeclarationId; report.Dictionary.Variables["ContractId"].ValueObject = expRepo.GetAssessmentDeclaration((Guid)expDocument.AssessmentDeclarationId).ContractId; var totalCount = payRepo.GetTotalPriceZbkCopy(zbkCopyId); report.Dictionary.Variables["TotalCount"].ValueObject = totalCount; var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalCount), false); report.Dictionary.Variables["TotalCountText"].ValueObject = priceText; report.Dictionary.Variables["ZBKCopyId"].ValueObject = copy.Id; report.Dictionary.Variables["PriceNds"].ValueObject = repository.GetZbkCopyNds(zbkCopyId); report.Render(false); } catch (Exception ex) { LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace); } var stream = new MemoryStream(); report.ExportDocument(StiExportFormat.Pdf, stream); stream.Position = 0; return(new FileStreamResult(stream, "application/pdf")); }