/// <summary> /// 대시보드 테이블 업무 영역을 업데이트한다. (파일 템플릿 ID가 변경되면 이전에 사용 중이던 파일 템플릿은 삭제 처리 된다.) /// </summary> public bool UpdateFormTableSection(FormTableSection formSection, string updaterId) { formSection.ThrowIfNull(nameof(formSection)); string procCommandName = "up_FormTableSection_Update"; try { var command = Connection.GetStoredProcCommand(procCommandName); Connection.AddInParameter(command, "FormID", DbType.Guid, formSection.FormId); Connection.AddInParameter(command, "FormSectionID", DbType.Guid, formSection.FormSectionId); Connection.AddInParameter(command, "FileTemplateID", DbType.Guid, formSection.FileTemplateId); Connection.AddInParameter(command, "Name", DbType.String, formSection.FormSectionName); Connection.AddInParameter(command, "ScriptVariable", DbType.String, formSection.ScriptVariable); Connection.AddInParameter(command, "IsEnabled", DbType.Boolean, formSection.IsEnabled); Connection.AddInParameter(command, "UpdaterID", DbType.String, updaterId); Connection.AddInParameter(command, "UpdatedDate", DbType.DateTimeOffset, formSection.UpdatedDate); return((int)Connection.ExecuteNonQuery(command) > 0); } catch (Exception ex) { throw new DataException($"프로시져 실행 중 예기치 못한 에러가 발생했습니다.\r\n 프로시저: \"{procCommandName}\"", ex); } }
/// <summary> /// 대시보드 테이블 업무 영역을 업데이트한다. /// </summary> public FormTableSection UpdateFormTableSection(FormTableSection formSection, IEnumerable <string> fileSourceUploaders) { formSection.ThrowIfNull(nameof(formSection)); using (var repo = new FormTableRepository()) { var old = repo.SelectFormTableSection(formSection.FormId, formSection.FormSectionId); if (old == null) { throw new ObjectNotFoundException($"업데이트될 업무영역을 찾을 수 없습니다. 업무영역: \"{formSection.FormSectionName}\"" + $"\r\n" + $"업무영역 ID: {formSection.FileSourceId}"); } repo.BeginTransaction(); try { var diff = old.Diff(formSection); if (repo.UpdateFormTableSection(formSection, CurrentUser.UserId)) { repo.InsertFormTableSectionGroupMembers(formSection.FormId, formSection.FormSectionId, fileSourceUploaders, DateTimeOffset.Now); if (old.FileTemplateId != formSection.FileTemplateId) { repo.InsertDateFileTemplate(formSection.FileTemplate); } else { repo.UpdateDateFileTemplate(formSection.FileTemplate); } repo.CommitTransaction(); logger.Info($"업무영역이 업데이트 되었습니다. 업무영역: \"{formSection.FormSectionName}\"" + $"\r\n\r\n" + $"updated: {UpdatedField.Print(diff)}" + $"\r\n\r\n" + $"{formSection}"); return(formSection); } } catch (Exception ex) { logger.Error(ex, $"업무영역 업데이트 중 확인 중 알 수 없는 오류가 발생하였습니다. 업무영역: \"{formSection.FormName}/{formSection.FormSectionName}\"" + $"\r\n\r\n" + $"{formSection}"); try { repo.RollBackTransaction(); } catch (Exception rex) { logger.Fatal(ex, $"업무영역 업데이트 함수에서 롤백 실행중 치명적인 에러가 발생했습니다. 업무영역: \"{formSection.FormName}/{formSection.FormSectionName}\"" + $"\r\n\r\n" + $"{formSection}"); ExceptionDispatchInfo.Capture(rex).Throw(); // not reached } ExceptionDispatchInfo.Capture(ex).Throw(); return(null); // not reached } return(null); } }