public override void ProcessComplited(Guid documentId, EXP_Activities activity) { var letter = _context.EXP_DrugCorespondence.FirstOrDefault(e => e.Id == documentId); var positiveStatus = DictionaryHelper.GetDicIdByCode(Dictionary.ExpActivityStatus.DicCode, Dictionary.ExpActivityStatus.Executed); if (activity.StatusId == positiveStatus) { //letter.StatusId = DictionaryHelper.GetDicIdByCode(CodeConstManager.STATUS_AGREED, CodeConstManager.STATUS_AGREED); var stageRepo = new ExpertiseStageRepository(_context); var stageSupervisor = stageRepo.GetStageSupervisor(letter.StageId, letter.EXP_DrugDeclaration.TypeId); var activityManager = new ActivityManager(_context); activityManager.SendToExecution(Dictionary.ExpActivityType.ExpertiseLetterSigning, letter.Id, Dictionary.ExpAgreedDocType.Letter, Dictionary.ExpTaskType.Signing, letter.NumberLetter, letter.DateCreate, stageSupervisor.Id); } else { letter.StatusId = DictionaryHelper.GetDicIdByCode(CodeConstManager.STATUS_REJECTED, CodeConstManager.STATUS_REJECTED); if (letter.EXP_DIC_CorespondenceSubject.Code == EXP_DIC_CorespondenceSubject.RefuseByPayment) { var declaration = _context.EXP_DrugDeclaration.FirstOrDefault(e => e.Id == letter.DrugDeclarationId); declaration.StatusId = CodeConstManager.STATUS_EXP_SEND_ID; } } }
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); }