Esempio n. 1
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(file, "application/pdf"));
        }
Esempio n. 2
0
        public ActionResult GetContractAdditionalTemplatePdf(Guid id, string contractAdditionTypeCode)
        {
            var       db     = new ncelsEntities();
            string    name   = "Договор_на_проведение_оценки_безопасности_и_качества.pdf";
            StiReport report = new StiReport();

            try
            {
                report.Load(obkRepo.GetContractAdditionalTemplatePath(id, contractAdditionTypeCode));
                foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
                {
                    data.ConnectionString = UserHelper.GetCnString();
                }

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

                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(file, "application/pdf"));
        }
Esempio n. 3
0
        public ActionResult GetPaymentTemplatePdf(Guid id)
        {
            var       payRepo = new OBKPaymentRepository();
            string    name    = "Счет на оплату.pdf";
            StiReport report  = new StiReport();

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

                report.Dictionary.Variables["ContractId"].ValueObject = id;
                //итого
                var totalPriceWithCount = payRepo.GetTotalPriceCount(id);
                report.Dictionary.Variables["TotalPriceWithCount"].ValueObject = totalPriceWithCount;
                //в том числе НДС
                var totalPriceNDS = payRepo.GetTotalPriceNDS(totalPriceWithCount);
                report.Dictionary.Variables["TotalPriceNDS"].ValueObject = totalPriceNDS;
                //прописью
                var priceText = RuDateAndMoneyConverter.CurrencyToTxtTenge(Convert.ToDouble(totalPriceWithCount), false);
                report.Dictionary.Variables["TotalPriceWithCountName"].ValueObject = priceText;
                //report.Dictionary.Variables["ChiefAccountant"].ValueObject = payRepo.GetEmpoloyee(Guid.Parse("E1EE3658-0C35-41EB-99FD-FDDC4D07CEC4"));
                //report.Dictionary.Variables["Executor"].ValueObject = payRepo.GetEmpoloyee(Guid.Parse("55377FAC-A5F0-4093-BBB6-18BD28E53BE1"));
                report.Render(false);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("ex: " + ex.Message + " \r\nstack: " + ex.StackTrace);
            }
            var stream             = new MemoryStream();
            var contractId         = payRepo.GetContractIdGuid(id);
            var directionToPayment = payRepo.GetDirectionToPayments(contractId);
            var signPayment        = payRepo.GetDirectionSignData(directionToPayment.Id);

            if (signPayment.ChiefAccountantSign != null && signPayment.ExecutorSign != null)
            {
                try
                {
                    report.ExportDocument(StiExportFormat.Word2007, stream);
                    stream.Position = 0;
                    Aspose.Words.Document doc = new Aspose.Words.Document(stream);
                    doc.InserQrCodesToEnd("ChiefAccountantSign", signPayment.ChiefAccountantSign);
                    var pdfFile = new MemoryStream();
                    doc.Save(pdfFile, SaveFormat.Pdf);
                    pdfFile.Position = 0;
                    stream.Close();
                    return(new FileStreamResult(pdfFile, "application/pdf"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            report.ExportDocument(StiExportFormat.Pdf, stream);
            stream.Position = 0;
            return(new FileStreamResult(stream, "application/pdf"));
        }
Esempio n. 4
0
        public MemoryStream GetCorespondenceFilePreview(Guid id, string reportPath, out string fileType, out string fileName)
        {
            StiReport report = new StiReport();

            report.Load(reportPath);

            foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
            {
                data.ConnectionString = UserHelper.GetCnString();
            }

            if (report.Dictionary.Variables.Contains("CorespondenceId"))
            {
                report.Dictionary.Variables["CorespondenceId"].ValueObject = id;
            }

            report.Render(false);
            var stream = new MemoryStream();

            report.ExportDocument(StiExportFormat.Word2007, stream);
            stream.Position = 0;
            var signingActivity = AppContext.EXP_Activities.Where(e => e.DocumentId == id &&
                                                                  e.ExpActivityStatus.Code == Dictionary.ExpActivityStatus
                                                                  .Executed &&
                                                                  e.ExpActivityType.Code == Dictionary.ExpActivityType
                                                                  .ExpertiseLetterSigning && e.ExpAgreedDocType.Code ==
                                                                  Dictionary.ExpAgreedDocType.Letter)
                                  .OrderByDescending(e => e.CreatedDate).FirstOrDefault();

            if (signingActivity != null)
            {
                var task = signingActivity.EXP_Tasks.Where(e => e.DigSign != null)
                           .OrderByDescending(e => e.ExecutedDate).FirstOrDefault();
                Aspose.Words.Document docWord = new Aspose.Words.Document(stream);
                docWord.InserQrCodesToEnd("ExecutorSign", task.DigSign);
                var pdfFile = new MemoryStream();
                docWord.Save(pdfFile, SaveFormat.Pdf);
                pdfFile.Position = 0;
                stream.Close();
                fileType = "application/pdf";
                fileName = "Замечания.pdf";
                return(pdfFile);
            }
            fileType = "application/word";
            fileName = "Замечания.doc";
            return(stream);
        }
Esempio n. 5
0
        public ActionResult ExportFilePdf(Guid id)
        {
            var       db     = new ncelsEntities();
            string    name   = "Заявление на проведение экспертизы лс.pdf";
            StiReport report = new StiReport();

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

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

                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;
            var drugDeclaration        = db.EXP_DrugDeclaration.FirstOrDefault(dd => dd.Id == id);
            var drugDeclarationHistory = drugDeclaration.EXP_DrugDeclarationHistory.Where(dh => dh.XmlSign != null)
                                         .OrderByDescending(dh => dh.DateCreate).FirstOrDefault();

            if (drugDeclarationHistory != null)
            {
                Aspose.Words.Document doc = new Aspose.Words.Document(stream);
                doc.InserQrCodesToEnd("ExecutorSign", drugDeclarationHistory.XmlSign);
                var pdfFile = new MemoryStream();
                pdfFile.Position = 0;
                stream.Close();
                return(new FileStreamResult(pdfFile, "application/pdf"));
            }
            return(new FileStreamResult(stream, "application/pdf"));
        }
        public ActionResult ExportFilePdf(Guid id)
        {
            var       db     = new ncelsEntities();
            string    name   = "Заявление на проведение экспертизы лс.pdf";
            StiReport report = new StiReport();

            try
            {
                report.Load(Server.MapPath("~/Reports/Mrts/DrugDeclaration.mrt"));
                foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
                {
                    data.ConnectionString = UserHelper.GetCnString();
                }
                var repository = new DrugDeclarationRepository();
                var model      = repository.GetById(id);
                model.IsExist = true;
                FillDeclarationControl(model);
                var registerNumber       = "";
                var reestrRegDate        = "";
                var reestrExpirationDate = "";
                var numberNd             = "";
                foreach (var modelExpDrugDosage in model.ExpDrugDosages)
                {
                    if (!string.IsNullOrEmpty(modelExpDrugDosage.ReestrNumber))
                    {
                        registerNumber += modelExpDrugDosage.ReestrNumber + "; ";
                    }
                    if (!string.IsNullOrEmpty(modelExpDrugDosage.ReestrRegDate))
                    {
                        reestrRegDate += modelExpDrugDosage.ReestrRegDate + ";";
                    }
                    if (!string.IsNullOrEmpty(modelExpDrugDosage.ReestrExpirationDate))
                    {
                        reestrExpirationDate += modelExpDrugDosage.ReestrExpirationDate + ";";
                    }
                    if (!string.IsNullOrEmpty(modelExpDrugDosage.NumberNd))
                    {
                        numberNd += modelExpDrugDosage.NumberNd + ";";
                    }
                }
                if (model.TypeId == 1)
                {
                    reestrRegDate = model.CreatedDate.ToShortDateString();
                }
                report.Dictionary.Variables["NumberNd"].ValueObject             = numberNd;
                report.Dictionary.Variables["ReestrExpirationDate"].ValueObject = reestrExpirationDate;
                report.Dictionary.Variables["RegisterNumber"].ValueObject       = registerNumber;
                report.Dictionary.Variables["ReestrRegDate"].ValueObject        = reestrRegDate;
                report.Dictionary.Variables["DrugDeclarationId"].ValueObject    = id;

                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;
            var drugDeclaration        = db.EXP_DrugDeclaration.FirstOrDefault(dd => dd.Id == id);
            var drugDeclarationHistory = drugDeclaration.EXP_DrugDeclarationHistory.Where(dh => dh.XmlSign != null)
                                         .OrderByDescending(dh => dh.DateCreate).FirstOrDefault();

            if (drugDeclarationHistory != null)
            {
                Aspose.Words.Document doc = new Aspose.Words.Document(stream);
                doc.InserQrCodesToEnd("ExecutorSign", drugDeclarationHistory.XmlSign);
                var pdfFile = new MemoryStream();
                pdfFile.Position = 0;
                stream.Close();
                return(new FileStreamResult(pdfFile, "application/pdf"));
            }
            return(new FileStreamResult(stream, "application/pdf"));
        }
Esempio n. 7
0
        public MemoryStream GetCorespondenceFilePreview(Guid id, string reportPath, out string fileType, out string fileName)
        {
            StiReport report = new StiReport();

            report.Load(reportPath);
            var corespondent = AppContext.EXP_DrugCorespondence.FirstOrDefault(e => e.Id == id);

            //Данные повестки
            if (corespondent != null)
            {
                if (report.Dictionary.Variables.Contains("DeclarationType"))
                {
                    var regNumber = "";
                    switch (corespondent.EXP_DrugDeclaration.TypeId)
                    {
                    case 1: { regNumber = "регистрации"; break; }

                    case 2: { regNumber = "перерегистрации"; break; }

                    case 3: { regNumber = "внесении изменений в регистрационное досье"; break; }
                    }
                    report.Dictionary.Variables["DeclarationType"].ValueObject = regNumber;
                }
                var commisions = AppContext.CommissionDrugDosages.FirstOrDefault(e => e.EXP_DrugDosage.DrugDeclarationId == corespondent.DrugDeclarationId);
                if (commisions != null)
                {
                    if (report.Dictionary.Variables.Contains("CommissionNumber"))
                    {
                        report.Dictionary.Variables["CommissionNumber"].ValueObject = commisions.Commission.Number;
                    }
                    if (report.Dictionary.Variables.Contains("CommissionDate"))
                    {
                        report.Dictionary.Variables["CommissionDate"].ValueObject =
                            commisions.Commission.Date.ToShortDateString();
                    }
                }
            }
            foreach (var data in report.Dictionary.Databases.Items.OfType <StiSqlDatabase>())
            {
                data.ConnectionString = UserHelper.GetCnString();
            }

            if (report.Dictionary.Variables.Contains("CorespondenceId"))
            {
                report.Dictionary.Variables["CorespondenceId"].ValueObject = id;
            }

            if (report.Dictionary.Variables.Contains("DrugInfo"))
            {
                var drugInfo = new StringBuilder("торговое название ");
                if (corespondent?.EXP_DrugDeclaration != null)
                {
                    var declaration = corespondent?.EXP_DrugDeclaration;
                    drugInfo.Append("(На государственном языке: " + declaration.NameKz + "; На русском языке: " +
                                    declaration.NameRu + "; На английском языке: " + declaration.NameEn + "), ");
                    drugInfo.Append("лекарственная форма");
                    if (declaration.sr_dosage_forms != null)
                    {
                        drugInfo.Append(" (На государственном языке: " + declaration.sr_dosage_forms.name_kz + "; На русском языке: " +
                                        declaration.sr_dosage_forms.name + ")");
                    }
                    drugInfo.Append(", дозировка (");
                    foreach (var expDrugDosage in declaration.EXP_DrugDosage)
                    {
                        drugInfo.Append(expDrugDosage.Dosage);
                        if (expDrugDosage.sr_measures != null)
                        {
                            drugInfo.Append(" " + expDrugDosage.sr_measures.short_name);
                        }
                        drugInfo.Append("; ");
                    }
                    drugInfo.Append("), ");
                }

                report.Dictionary.Variables["DrugInfo"].ValueObject = drugInfo.ToString();
            }


            report.Render(false);
            var stream = new MemoryStream();

            report.ExportDocument(StiExportFormat.Word2007, stream);
            stream.Position = 0;
            var signingActivity = AppContext.EXP_Activities.Where(e => e.DocumentId == id &&
                                                                  e.ExpActivityStatus.Code == Dictionary.ExpActivityStatus
                                                                  .Executed &&
                                                                  e.ExpActivityType.Code == Dictionary.ExpActivityType
                                                                  .ExpertiseLetterSigning && e.ExpAgreedDocType.Code ==
                                                                  Dictionary.ExpAgreedDocType.Letter)
                                  .OrderByDescending(e => e.CreatedDate).FirstOrDefault();

            if (signingActivity != null)
            {
                var task = signingActivity.EXP_Tasks.Where(e => e.DigSign != null)
                           .OrderByDescending(e => e.ExecutedDate).FirstOrDefault();
                Aspose.Words.Document docWord = new Aspose.Words.Document(stream);
                docWord.InserQrCodesToEnd("ExecutorSign", task.DigSign);
                var pdfFile = new MemoryStream();
                docWord.Save(pdfFile, SaveFormat.Pdf);
                pdfFile.Position = 0;
                stream.Close();
                fileType = "application/pdf";
                fileName = "Замечания.pdf";
                return(pdfFile);
            }
            fileType = "application/word";
            fileName = "Замечания.doc";
            return(stream);
        }