public ActionResult SendToApplicant(Guid stageId)
        {
            var repo       = new ExpertiseStageRepository();
            var stage      = repo.GetStage(stageId);
            var repository = new DrugDeclarationRepository();
            var declaraion = repository.GetById(stage.DeclarationId.ToString());

            if (declaraion == null)
            {
                return(Json(new
                {
                    isSuccess = false,
                }));
            }
            declaraion.DesignDate = DateTime.Now;
            declaraion.StatusId   = CodeConstManager.STATUS_EXP_SEND_INSTRUCTION_ID;
            new DrugDeclarationRepository().Update(declaraion);
            var history = new EXP_DrugDeclarationHistory()
            {
                DateCreate        = DateTime.Now,
                DrugDeclarationId = declaraion.Id,
                StatusId          = declaraion.StatusId,
                UserId            = UserHelper.GetCurrentEmployee().Id,
                Note = "Инструкция для согласования"
            };

            new DrugDeclarationRepository().SaveHisotry(history, UserHelper.GetCurrentEmployee().Id);
            var status = new ReadOnlyDictionaryRepository().GetDicStatusById(CodeConstManager.STATUS_EXP_SEND_INSTRUCTION_ID);

            return(Json(new
            {
                isSuccess = true,
                statusName = status.NameRu
            }));
        }
        public ActionResult UpdateTmcUseOff([DataSourceRequest] DataSourceRequest request, TmcUseOffView model)
        {
            string           expertiseNumber = null;
            TmcOffRepository repository      = new TmcOffRepository();

            if (model.RefExtertiseStatement != null)
            {
                DrugDeclarationRepository ddRepo = new DrugDeclarationRepository();
                var exp = ddRepo.GetById(model.RefExtertiseStatement.Value);

                if (exp != null)
                {
                    expertiseNumber = exp.Number;
                }
            }

            var tmcOff = repository.GetAsQuarable(toff => toff.Id == model.Id).FirstOrDefault();

            if (tmcOff != null)
            {
                tmcOff.Count = model.Count;
                tmcOff.Note  = model.Note;
                tmcOff.ExpertiseStatementNumber = expertiseNumber;
                tmcOff.ExpertiseStatementId     = model.RefExtertiseStatement;
            }

            repository.Update(tmcOff);
            repository.Save();

            return(Json(new[] { tmcOff }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult CreateTmcUseOff([DataSourceRequest] DataSourceRequest request, TmcUseOffView model)
        {
            string           expertiseNumber = null;
            TmcOffRepository repository      = new TmcOffRepository();

            if (model.RefExtertiseStatement != null)
            {
                DrugDeclarationRepository ddRepo = new DrugDeclarationRepository();
                var exp = ddRepo.GetById(model.RefExtertiseStatement.Value);

                if (exp != null)
                {
                    expertiseNumber = exp.Number;
                }
            }

            TmcOff tmc = new TmcOff()
            {
                Id                       = Guid.NewGuid(),
                StateType                = model.StateType,
                CreatedDate              = DateTime.Now,
                CreatedEmployeeId        = UserHelper.GetCurrentEmployee().Id,
                Count                    = model.Count,
                Note                     = model.Note,
                TmcOutId                 = model.TmcOutId,
                TmcId                    = model.TmcId,
                ExpertiseStatementId     = model.RefExtertiseStatement,
                ExpertiseStatementNumber = expertiseNumber
            };

            repository.Insert(tmc);
            repository.Save();

            return(Json(new[] { tmc }.ToDataSourceResult(request, ModelState)));
        }
Exemple #4
0
        public EXP_DrugDeclaration GetDrugDeclarationById(string id)
        {
            var repository = new DrugDeclarationRepository();
            var model      = repository.GetById(id);

            model.IsExist = true;
            FillDeclarationControl(model);
            return(model);
        }
        public ActionResult SignForm(string preambleId, string xmlAuditForm)
        {
            var success    = true;
            var repository = new DrugDeclarationRepository();
            var model      = repository.GetById(preambleId);

            new SignDocumentRepository().SaveSignDocument(UserHelper.GetCurrentEmployee().Id, xmlAuditForm, model);

            if (model.StatusId == CodeConstManager.STATUS_DRAFT_ID)
            {
                model.FirstSendDate = DateTime.Now;
            }

            model.StatusId = CodeConstManager.STATUS_SEND_ID;
            model.SendDate = DateTime.Now;
            model.IsSigned = true;
            var history = new EXP_DrugDeclarationHistory()
            {
                DateCreate        = DateTime.Now,
                DrugDeclarationId = model.Id,
                XmlSign           = xmlAuditForm,
                StatusId          = CodeConstManager.STATUS_SEND_ID,
                UserId            = UserHelper.GetCurrentEmployee().Id,
                Note = "Отчет предоставлен. Дата отправки:" + DateTime.Now
            };

            if (string.IsNullOrEmpty(model.Number))
            {
                //   model.Number = repository.GetAppNumber();
            }
            var indexWrapping = 1;

            foreach (var expDrugDosage in model.EXP_DrugDosage)
            {
                if (string.IsNullOrEmpty(expDrugDosage.RegNumber))
                {
                    expDrugDosage.RegNumber = model.Number + "." + indexWrapping;
                    indexWrapping++;
                }
            }
            repository.SaveOrUpdate(model, UserHelper.GetCurrentEmployee().Id);
            repository.SaveHisotry(history, UserHelper.GetCurrentEmployee().Id);
            // Set Status Sended
            return(Json(new
            {
                success
            }, JsonRequestBehavior.AllowGet));
        }
        public virtual ActionResult SendNotSign(string modelId)
        {
            var repository = new DrugDeclarationRepository();
            var model      = repository.GetById(modelId);

            if (model.StatusId == CodeConstManager.STATUS_DRAFT_ID)
            {
                model.FirstSendDate = DateTime.Now;
            }

            model.StatusId = CodeConstManager.STATUS_SEND_ID;
            model.SendDate = DateTime.Now;
            model.IsSigned = false;
            var history = new EXP_DrugDeclarationHistory()
            {
                DateCreate        = DateTime.Now,
                DrugDeclarationId = model.Id,
                StatusId          = CodeConstManager.STATUS_SEND_ID,
                UserId            = UserHelper.GetCurrentEmployee().Id,
                Note = "Отчет предоставлен без подписи. Дата отправки:" + DateTime.Now
            };

            if (string.IsNullOrEmpty(model.Number))
            {
                //  model.Number = repository.GetAppNumber();
            }
            var indexWrapping = 1;

            foreach (var expDrugDosage in model.EXP_DrugDosage)
            {
                if (string.IsNullOrEmpty(expDrugDosage.RegNumber))
                {
                    expDrugDosage.RegNumber = model.Number + "." + indexWrapping;
                    indexWrapping++;
                }
            }
            repository.SaveOrUpdate(model, UserHelper.GetCurrentEmployee().Id);
            repository.SaveHisotry(history, UserHelper.GetCurrentEmployee().Id);
            return(Json(new
            {
                isSuccess = true
            }));
        }
        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"));
        }