Exemplo n.º 1
0
        public ActionResult SendExpertiseDocumentToAgreement(Guid docId, string documentType, Guid?executorId = null, string taskType = null)
        {
            taskType = string.IsNullOrEmpty(taskType) ? null : taskType;
            var db              = new ncelsEntities();
            var repository      = new DrugDeclarationRepository();
            var stageRepo       = new ExpertiseStageRepository();
            var activityManager = new ActivityManager();

            switch (documentType)
            {
            case Dictionary.ExpAgreedDocType.EXP_DrugFinalDocument:
                var declarationInfo      = db.EXP_ExpertiseStageDosage.FirstOrDefault(e => e.Id == docId);
                var finalDocExecutorsIds = stageRepo.GetExecutorsByDicStageId(declarationInfo.EXP_ExpertiseStage.StageId,
                                                                              declarationInfo.EXP_ExpertiseStage.EXP_DrugDeclaration.TypeId)
                                           .Select(e => e.Id).ToArray();
                activityManager.SendToExecution(Dictionary.ExpActivityType.FinalDocAgreement, docId,
                                                Dictionary.ExpAgreedDocType.EXP_DrugFinalDocument, taskType ?? Dictionary.ExpTaskType.Agreement,
                                                declarationInfo.EXP_DrugDosage.RegNumber, declarationInfo.EXP_DrugDosage.EXP_DrugDeclaration.CreatedDate, finalDocExecutorsIds);
                var primaryDocStatus = repository.GetPrimaryFinalDocumentStatus(docId);
                return(Json(primaryDocStatus.Name, JsonRequestBehavior.AllowGet));

            case Dictionary.ExpAgreedDocType.Letter:
                var  primaryRepo = new DrugPrimaryRepository();
                bool isSigning   = taskType == Dictionary.ExpTaskType.Signing;
                var  letter      = primaryRepo.GetCorespondence(docId.ToString());
                if (isSigning)
                {
                    var stageSupervisor = stageRepo.GetStageSupervisor(letter.StageId, letter.EXP_DrugDeclaration.TypeId);
                    activityManager.SendToExecution(Dictionary.ExpActivityType.ExpertiseLetterSigning, docId,
                                                    Dictionary.ExpAgreedDocType.Letter, Dictionary.ExpTaskType.Signing,
                                                    letter.NumberLetter, letter.DateCreate, stageSupervisor.Id);
                    return(Json(
                               DictionaryHelper.GetDicItemByCode(CodeConstManager.STATUS_ONSIGNING,
                                                                 CodeConstManager.STATUS_ONSIGNING).Name, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var letterExecutorsIds = stageRepo.GetExecutorsByDicStageId(letter.StageId, letter.EXP_DrugDeclaration.TypeId).Select(e => e.Id).ToArray();
                    activityManager.SendToExecution(Dictionary.ExpActivityType.ExpertiseLetterAgreement, docId,
                                                    Dictionary.ExpAgreedDocType.Letter, Dictionary.ExpTaskType.Agreement,
                                                    letter.NumberLetter, letter.DateCreate, letterExecutorsIds);
                    return(Json(
                               DictionaryHelper.GetDicItemByCode(CodeConstManager.STATUS_ONAGREEMENT,
                                                                 CodeConstManager.STATUS_ONAGREEMENT).Name, JsonRequestBehavior.AllowGet));
                }

            case Dictionary.ExpAgreedDocType.CertificateOfCompletion:
                var coc = db.EXP_CertificateOfCompletion.FirstOrDefault(e => e.Id == docId);
                if (coc != null)
                {
                    var certExecutorsIds = stageRepo.GetExecutorsByDicStageId(coc.DicStageId.Value, coc.EXP_DrugDeclaration.TypeId).Select(e => e.Id).ToArray();
                    activityManager.SendToExecution(Dictionary.ExpActivityType.CertificateOfComplitionAgreement, docId,
                                                    Dictionary.ExpAgreedDocType.CertificateOfCompletion, taskType ?? Dictionary.ExpTaskType.Agreement,
                                                    string.Empty, coc.CreateDate, certExecutorsIds);
                }
                return(Json(DictionaryHelper.GetDicItemByCode(CodeConstManager.STATUS_ONAGREEMENT,
                                                              CodeConstManager.STATUS_ONAGREEMENT).Name, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Exemplo n.º 2
0
        public ActionResult SendTranslateOnAgreement(Guid docId, string documentType, Guid?executorId = null, string taskType = null)
        {
            var activityManager = new ActivityManager();
            var file            = new UploadRepository().GetFileLinkById(docId);
            var declaration     = GetDrugDeclarationById(file.DocumentId.ToString());
            var stageRepo       = new ExpertiseStageRepository();
            var stage           = stageRepo.GetStageByCode(EXP_DIC_Stage.Translate);
            var executors       = stageRepo.GetExecutorsByDicStageId(stage.Id, declaration.TypeId)
                                  .Select(e => e.Id).ToArray();

            switch (documentType)
            {
            case "1":     // Согласование документа на перевод
            {
                activityManager.SendToExecution(Dictionary.ExpActivityType.TranslateDocAgreement, docId,
                                                Dictionary.ExpAgreedDocType.TranslateFile, taskType ?? Dictionary.ExpTaskType.Agreement,
                                                declaration.Number, declaration.CreatedDate, executors);
                break;
            }

            case "2":     // Согласование макета
            {
                activityManager.SendToExecution(Dictionary.ExpActivityType.MaketDocAgreement, docId,
                                                Dictionary.ExpAgreedDocType.MaketFile, taskType ?? Dictionary.ExpTaskType.Agreement,
                                                declaration.Number, declaration.CreatedDate, executors);
                break;
            }
            }
            var primaryDocStatus = new UploadRepository().GetFileLinkById(docId).DIC_FileLinkStatus;

            return(Json(primaryDocStatus.NameRu, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public Object DeclarationStepsNew(string id)
        {
            try
            {
                var id2 = Guid.Parse(id);
                ViewBag.DeclarationId = id;
                var steps          = new List <DeclarationStepsModel>();
                int priorityInList = 0;
                using (var db = new ncelsEntities())
                {
                    var currentEmployeeGuid = UserHelper.GetCurrentEmployee().Id;
                    var stages      = db.EXP_ExpertiseStage.Where(x => x.DeclarationId == id2);
                    var expStageRep = new ExpertiseStageRepository();
                    foreach (var item in stages.OrderBy(x => x.EXP_DIC_Stage.Code))
                    {
                        var isEndedStage      = item.FactEndDate.HasValue;
                        var dbStatus          = item.EXP_DIC_StageStatus;
                        var statusCode        = dbStatus.Code;
                        var statucCorrectText = GetCostilStatusByStageCode(statusCode);

                        //kostil dlya nachalnikov
                        var executeLeader    = expStageRep.GetExecutorsByDicStageId(item.StageId, item.EXP_DrugDeclaration.TypeId).FirstOrDefault();
                        var currentStageCode = item.EXP_DIC_Stage.Code;



                        var leaderStep = new DeclarationStepsModel();
                        leaderStep.ExecutorShortName = executeLeader.ShortName;
                        leaderStep.StepName          = item.EXP_DIC_Stage.NameRu;
                        leaderStep.IsLeaderStep      = true;
                        leaderStep.Status            = statucCorrectText;
                        leaderStep.StageCode         = currentStageCode;
                        leaderStep.NeedWorkers       = (statusCode == "inQueue");
                        leaderStep.PriorityInList    = priorityInList;
                        priorityInList++;
                        leaderStep.DateStart = item.StartDate.HasValue ? item.StartDate.Value.ToShortDateString() : "";
                        steps.Add(leaderStep);

                        if (currentStageCode != EXP_DIC_Stage.ProcCenter)
                        {
                            var step = new DeclarationStepsModel();
                            step.Id = item.Id;
                            step.AllowAddWorkers = (currentEmployeeGuid == executeLeader.Id);
                            step.StageId         = item.StageId;
                            step.StepName        = item.EXP_DIC_Stage.NameRu;
                            step.NeedWorkers     = (statusCode == "inQueue");
                            step.StageCode       = currentStageCode;
                            step.PriorityInList  = priorityInList;
                            priorityInList++;
                            step.Status            = statucCorrectText;
                            step.ExecutorShortName = item.EXP_ExpertiseStageExecutors.Select(x => x.Employee.ShortName)
                                                     .Aggregate((i, j) => i + Environment.NewLine + j);
                            if (item.StartDate != null && item.EndDate != null)
                            {
                                var dayDiff = (item.EndDate.Value - item.StartDate.Value).TotalDays;
                                step.DueToAllDays = (int)dayDiff;
                                step.DateStart    = item.StartDate.Value.ToShortDateString();
                                if (isEndedStage)
                                {
                                    step.DateEnd = item.FactEndDate.Value.ToShortDateString();
                                }
                                step.ControlDate = item.EndDate.Value.ToShortDateString();
                                var daysLeave = (item.EndDate.Value - DateTime.Now.Date).TotalDays;
                                step.DueToEndDays = (int)daysLeave;
                                step.StepIsEnded  = isEndedStage;
                                int?totalDaysOverdue = null;
                                if (isEndedStage)
                                {
                                    totalDaysOverdue = (int)(item.FactEndDate.Value - item.EndDate.Value).TotalDays;
                                }
                                else
                                {
                                    totalDaysOverdue = (int)(DateTime.Now.Date - item.EndDate.Value).TotalDays;
                                }
                                var isOverdue = isEndedStage && totalDaysOverdue > 0;
                                step.StepIsOverdue = isOverdue;
                                step.OverdueDays   = totalDaysOverdue;
                            }
                            steps.Add(step);
                        }
                    }
                }
                var model = new DeclarationStepsViewModel();
                model.Steps         = steps.OrderBy(x => x.PriorityInList).ToList();
                model.DeclarationId = id2;
                var views = RenderRazorViewToString(View("DeclarationStepsNew").ViewName, model, ViewData, TempData,
                                                    ControllerContext);
                return(views);
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("DeclarationSteps ex:" + ex.Message + " \r\nstack:" + ex.StackTrace);
                throw;
            }
        }