public ActionResult ScanOriginalDocuments(ScanOriginalDocumentsModel model) { string error = String.Empty; string SPPath = AuthenticationService.CurrentUser.Id.ToString(); if (model.DeleteAttachmentId != 0) { if (((AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager) && !EmploymentBl.IsUnlimitedEditAvailable()) || AuthenticationService.CurrentUser.UserRole == UserRole.ConsultantOutsourcing) { ModelState.AddModelError("ErrorMessage", "У вас нет прав для редактирования данных!"); model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); } else { DeleteAttacmentModel modelDel = new DeleteAttacmentModel { Id = model.DeleteAttachmentId }; EmploymentBl.DeleteAttachment(modelDel); model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); ModelState.AddModelError("ErrorMessage", "Файл удален!"); } } else { ModelState.Clear(); //кадровик не может менять список документов после выгрузки кандидата в 1С if (model.SendTo1C.HasValue) { //model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); ModelState.AddModelError("ErrorMessage", "Кандидат выгружен в 1С! Любые изменения на данной страницы не возможны!"); } else { if (AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager && !EmploymentBl.IsUnlimitedEditAvailable()) { //model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); ModelState.AddModelError("ErrorMessage", "У вас нет прав для редактирования данных!"); } else { if (ValidateModel(model)) { string str = model.IsAgree ? "Данные сохранены!" : "Файл загружен!"; EmploymentBl.SaveScanOriginalDocumentsModelAttachments(model, out error); //model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); ModelState.AddModelError("ErrorMessage", string.IsNullOrEmpty(error) ? str : error); } else { //так как при использования вкладок, страницу приходится перезагружать с потерей данных, то передаем модель с библиотекой ошибок через переменную сессии //model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); } } } model = EmploymentBl.GetScanOriginalDocumentsModel(model.UserId); } if (Session["ScanOriginalDocumentsM" + SPPath] != null) Session.Remove("ScanOriginalDocumentsM" + SPPath); if (Session["ScanOriginalDocumentsM" + SPPath] == null) Session.Add("ScanOriginalDocumentsM" + SPPath, model); if (Session["ScanOriginalDocumentsMS" + SPPath] != null) Session.Remove("ScanOriginalDocumentsMS" + SPPath); if (Session["ScanOriginalDocumentsMS" + SPPath] == null) { ModelStateDictionary mst = ModelState; Session.Add("ScanOriginalDocumentsMS" + SPPath, mst); } if ((AuthenticationService.CurrentUser.UserRole & UserRole.PersonnelManager) > 0 && EmploymentBl.IsUnlimitedEditAvailable()) return Redirect("PersonnelInfo?id=" + model.UserId + "&IsCandidateInfoAvailable=true&IsBackgroundCheckAvailable=true&IsManagersAvailable=true&IsPersonalManagersAvailable=true&TabIndex=0"); else return model.IsFinal && !EmploymentBl.IsUnlimitedEditAvailable() ? View("ScanOriginalDocumentsReadOnly", model) : View(model); }
public JsonResult DeleteAttachment(int id) { bool saveResult; string error; try { DeleteAttacmentModel model = new DeleteAttacmentModel { Id = id }; saveResult = EmploymentBl.DeleteAttachment(model); error = model.Error; } catch (Exception ex) { Log.Error("Exception on DeleteAttachment:", ex); error = ex.GetBaseException().Message; saveResult = false; } return Json(new { Error = error, Result = saveResult }); }
public ContentResult DeleteVersion(int id) { bool saveResult = false; string error; try { if (AuthenticationService.CurrentUser.UserRole == UserRole.Admin) { DeleteAttacmentModel model = new DeleteAttacmentModel {Id = id}; saveResult = HelpBl.DeleteVersion(model); error = model.Error; } else error = StrCannotDeleteTemplate; } catch (Exception ex) { Log.Error("Exception on DeleteVersion:", ex); error = ex.GetBaseException().Message; saveResult = false; } JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); var jsonString = jsonSerializer.Serialize(new SaveTypeResult { Error = error, Result = saveResult }); return Content(jsonString); }
public ActionResult BackgroundCheck(BackgroundCheckModel model, IEnumerable<HttpPostedFileBase> files) { string error = String.Empty; string SPPath = AuthenticationService.CurrentUser.Id.ToString(); if (model.DeleteAttachmentId == 0) { if (model.RowID == 0) { if (ValidateModel(model)) { model.IsDraft = model.IsBGDraft; EmploymentBl.ProcessSaving<BackgroundCheckModel, BackgroundCheck>(model, out error); model = EmploymentBl.GetBackgroundCheckModel(model.UserId); ModelState.AddModelError("IsValidate", string.IsNullOrEmpty(error) ? "Данные сохранены!" : error); //ViewBag.Error = error; } else { //так как при использования вкладок, страницу приходится перезагружать с потерей данных, то передаем модель с библиотекой ошибок через переменную сессии model = EmploymentBl.GetBackgroundCheckModel(model); if (Session["BackgroundCheckM" + SPPath] != null) Session.Remove("BackgroundCheckM" + SPPath); if (Session["BackgroundCheckM" + SPPath] == null) Session.Add("BackgroundCheckM" + SPPath, model); } if (Session["BackgroundCheckMS" + SPPath] != null) Session.Remove("BackgroundCheckMS" + SPPath); if (Session["BackgroundCheckMS" + SPPath] == null) { ModelStateDictionary mst = ModelState; Session.Add("BackgroundCheckMS" + SPPath, mst); } } else { EmploymentBl.DeleteBackgroundRow(model); model = EmploymentBl.GetBackgroundCheckModel(model.UserId); } } else { if (AuthenticationService.CurrentUser.UserRole == UserRole.PersonnelManager && !EmploymentBl.IsUnlimitedEditAvailable()) { ModelState.AddModelError("IsValidate", "У вас нет прав для редактирования данных!"); model = EmploymentBl.GetBackgroundCheckModel(model.UserId); } else { DeleteAttacmentModel modelDel = new DeleteAttacmentModel { Id = model.DeleteAttachmentId }; EmploymentBl.DeleteAttachment(modelDel); model = EmploymentBl.GetBackgroundCheckModel(model.UserId); ModelState.AddModelError("IsValidate", "Файл удален!"); } if (Session["BackgroundCheckMS" + SPPath] != null) Session.Remove("BackgroundCheckMS" + SPPath); if (Session["BackgroundCheckMS" + SPPath] == null) { ModelStateDictionary mst = ModelState; Session.Add("BackgroundCheckMS" + SPPath, mst); } } if ((AuthenticationService.CurrentUser.UserRole & UserRole.PersonnelManager) > 0 || (AuthenticationService.CurrentUser.UserRole & UserRole.Security) > 0) return Redirect("PersonnelInfo?id=" + model.UserId + "&IsCandidateInfoAvailable=true&IsBackgroundCheckAvailable=true&IsManagersAvailable=true&IsPersonalManagersAvailable=true&TabIndex=8"); else return model.IsFinal && !EmploymentBl.IsUnlimitedEditAvailable() ? View("BackgroundCheckReadOnly", model) : View(model); }
public ContentResult DeleteTemplate(int id) { bool saveResult; string error; try { DeleteAttacmentModel model = new DeleteAttacmentModel { Id = id }; saveResult = RequestBl.DeleteAttachment(model); error = model.Error; } catch (Exception ex) { Log.Error("Exception on DeleteTemplate:", ex); error = ex.GetBaseException().Message; saveResult = false; } JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); var jsonString = jsonSerializer.Serialize(new SaveTypeResult { Error = error, Result = saveResult }); return Content(jsonString); }
public bool DeleteAttachment(DeleteAttacmentModel model) { RequestAttachmentDao.Delete(model.Id); return true; }
public bool DeleteVersion(DeleteAttacmentModel model) { if (AuthenticationService.CurrentUser.UserRole != UserRole.Admin) { model.Error = StrCannotDeleteVersion; return false; } helpVersionDao.DeleteAndFlush(model.Id); return true; }
public bool ConvertAttachments(DeleteAttacmentModel model) { Log.Debug("Begin convert attachments"); int beforeId = Int32.MaxValue; bool hasError = false; //int i = 0; while (true) { List<RequestAttachment> list = RequestAttachmentDao.FindOldEntities(beforeId);//RequestAttachmentDao.FindOld(beforeId).ToList();) if (list.Count() == 0) break; Log.DebugFormat("After FindOld beforeId {0}", beforeId); //RequestAttachmentDao.BeginTran(); foreach (RequestAttachment entity in list) { try { //RequestAttachmentDao.UpdateAttachement(entity.Id,entity.Context); RequestAttachmentDao.SaveAndFlush(entity); RequestAttachmentDao.Evict(entity); } catch (Exception ex) { Log.Error(string.Format("Исключение при конвертации аттачмента {0}", entity.Id), ex); hasError = true; } } RequestAttachmentDao.CommitTran(); RequestAttachmentDao.BeginTran(); beforeId = list.Last().Id; //i++; //if(i > 2) // break; } if (hasError) model.Error = "Были ошибки при конвертации.Подробности - в лог файле."; Log.Debug("End convert attachments"); return true; }
public ContentResult ConvertAttachments() { bool saveResult = true; string error; try { DeleteAttacmentModel model = new DeleteAttacmentModel {Error = string.Empty}; saveResult = AdminBl.ConvertAttachments(model); error = model.Error; } catch (Exception ex) { Log.Error("Exception on ConvertAttachments:", ex); error = ex.GetBaseException().Message; saveResult = false; } JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); var jsonString = jsonSerializer.Serialize(new SaveTypeResult { Error = error, Result = saveResult }); return Content(jsonString); }