public OBK_AssessmentDeclaration GetSaDeclarationById(string id) { var repository = new SafetyAssessmentRepository(); var model = repository.GetById(id); FillDeclarationControl(model); return(model); }
/// <summary> /// подписание /// </summary> /// <param name="preambleId"></param> /// <param name="xmlAuditForm"></param> /// <returns></returns> public ActionResult SignForm(string preambleId, string xmlAuditForm) { var success = true; var repository = new SafetyAssessmentRepository(); var model = repository.GetById(preambleId); new SignDocumentRepository().SaveSignDocument(UserHelper.GetCurrentEmployee().Id, xmlAuditForm, model); if (model.StatusId == CodeConstManager.STATUS_DRAFT_ID) { model.FirstSendDate = DateTime.Now; } var modelStage = new AssessmentStageRepository().GetByDeclarationId(model.Id.ToString(), CodeConstManager.STAGE_OBK_COZ); if (modelStage != null && modelStage.StageStatusId == new SafetyAssessmentRepository().GetStageStatusByCode(OBK_Ref_StageStatus.InReWork).Id) { modelStage.StageStatusId = new SafetyAssessmentRepository().GetStageStatusByCode(OBK_Ref_StageStatus.InWork).Id; new SafetyAssessmentRepository().SaveStage(modelStage); } model.StatusId = CodeConstManager.STATUS_SEND_ID; model.SendDate = DateTime.Now; model.IsSigned = false; var history = new OBK_AssessmentDeclarationHistory() { DateCreate = DateTime.Now, AssessmentDeclarationId = 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 act = db.OBK_ActReception.FirstOrDefault(o => o.OBK_AssessmentDeclarationId == model.Id); if (act != null) { act.Number = model.Number; db.SaveChanges(); } } repository.SaveOrUpdate(model, UserHelper.GetCurrentEmployee().Id); repository.SaveHisotry(history, UserHelper.GetCurrentEmployee().Id); // new SafetyAssessmentRepository().AddHistory(model.Id, OBK_Ref_StageStatus.New, UserHelper.GetCurrentEmployee().Id); return(Json(new { success }, JsonRequestBehavior.AllowGet)); }
public virtual ActionResult SendNotSign(string modelId) { var repository = new SafetyAssessmentRepository(); var model = repository.GetById(modelId); if (model.StatusId == CodeConstManager.STATUS_DRAFT_ID) { model.FirstSendDate = DateTime.Now; } var modelStage = new AssessmentStageRepository().GetByDeclarationId(modelId, CodeConstManager.STAGE_OBK_COZ); if (modelStage != null && modelStage.StageStatusId == new SafetyAssessmentRepository().GetStageStatusByCode(OBK_Ref_StageStatus.InReWork).Id) { var ex = db.OBK_AssessmentStageExecutors.Where(r => r.AssessmentStageId == modelStage.Id && r.ExecutorType == 2).FirstOrDefault(); modelStage.StageStatusId = new SafetyAssessmentRepository().GetStageStatusByCode(OBK_Ref_StageStatus.InWork).Id; new SafetyAssessmentRepository().SaveStage(modelStage); new SafetyAssessmentRepository().AddHistory(model.Id, OBK_Ref_StageStatus.InWork, ex.ExecutorId); } model.StatusId = CodeConstManager.STATUS_SEND_ID; model.SendDate = DateTime.Now; model.IsSigned = false; var history = new OBK_AssessmentDeclarationHistory() { DateCreate = DateTime.Now, AssessmentDeclarationId = model.Id, StatusId = CodeConstManager.STATUS_SEND_ID, UserId = UserHelper.GetCurrentEmployee().Id, Note = "Отчет предоставлен без подписи. Дата отправки:" + DateTime.Now }; if (string.IsNullOrEmpty(model.Number)) { model.Number = repository.GetAppNumber(); var act = db.OBK_ActReception.FirstOrDefault(o => o.OBK_AssessmentDeclarationId == model.Id); if (act != null) { act.Number = model.Number; db.SaveChanges(); } } repository.SaveOrUpdate(model, UserHelper.GetCurrentEmployee().Id); repository.SaveHisotry(history, UserHelper.GetCurrentEmployee().Id); return(Json(new { isSuccess = true })); }