Exemplo n.º 1
0
        public ActionResult GetContractFactory(Guid contractId)
        {
            var repo   = new OBKContractRepository();
            var result = repo.GetContractFactories(contractId);

            return(Json(result));
        }
Exemplo n.º 2
0
        public ActionResult GetContractTemplatePdf(Guid id)
        {
            var       db     = new ncelsEntities();
            string    name   = "Договор_на_проведение_оценки_безопасности_и_качества.pdf";
            StiReport report = new StiReport();

            try
            {
                report.Load(obkRepo.GetContractTemplatePath(id));//(Server.MapPath("~/Reports/Mrts/OBK/ObkContractDec.mrt"));
                foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
                {
                    data.ConnectionString = UserHelper.GetCnString();
                }

                report.Dictionary.Variables["ContractId"].ValueObject = id;

                var price = new OBKContractRepository().GetPriceCount(id);
                report.Dictionary.Variables["PriceCount"].ValueObject = price;

                var priceText = RuDateAndMoneyConverter.ToTextTenge(Convert.ToDouble(price), false);
                report.Dictionary.Variables["PriceCountName"].ValueObject = priceText;

                report.Render(false);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace);
            }

            Stream stream = new MemoryStream();

            report.ExportDocument(StiExportFormat.Word2007, stream);
            stream.Position = 0;

            Aspose.Words.Document doc = new Aspose.Words.Document(stream);

            try
            {
                var signData = db.OBK_ContractSignedDatas.Where(x => x.ContractId == id).FirstOrDefault();
                if (signData != null && signData.ApplicantSign != null && signData.CeoSign != null)
                {
                    doc.InserQrCodesToEnd("ApplicantSign", signData.ApplicantSign);
                    doc.InserQrCodesToEnd("CeoSign", signData.CeoSign);
                }
            }
            catch (Exception ex)
            {
            }

            var file = new MemoryStream();

            doc.Save(file, Aspose.Words.SaveFormat.Pdf);
            file.Position = 0;

            //return new FileStreamResult(stream, "application/pdf");
            return(File(file, "application/pdf", name));
        }
Exemplo n.º 3
0
 public OBKContractController()
 {
     obkRepo = new OBKContractRepository();
 }