public ActionResult Create(Guid id) { ApplicationUser userTable = _AccountService.FirstOrDefault(x => x.UserName == User.Identity.Name); if (userTable == null) { return(HttpNotFound()); } EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == userTable.Id); if (emplTable == null) { return(HttpNotFound()); } ProcessView process = _ProcessService.FindView(id); var viewModel = new DocumentComposite(); viewModel.ProcessView = process; viewModel.docData = _DocumentService.RouteCustomModelView(process.TableName); viewModel.fileId = Guid.NewGuid(); return(View(viewModel)); }
private void EmplUpdateIntegration(string _firstname, string _secondname, string _middlename, Guid _company, string _managerUserId) { IEmplService _EmplService = DependencyResolver.Current.GetService <IEmplService>(); Guid? manageId = null; if (_managerUserId != String.Empty) { if (_EmplService.Contains(x => x.CompanyTableId == _company && x.ApplicationUserId == _managerUserId)) { manageId = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company && x.ApplicationUserId == _managerUserId).Id; if (_EmplService.Contains(x => x.CompanyTableId == _company && x.FirstName == _firstname && x.MiddleName == _middlename && x.SecondName == _secondname)) { EmplTable empl = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company && x.FirstName == _firstname && x.MiddleName == _middlename && x.SecondName == _secondname); empl.ManageId = manageId; _EmplService.SaveDomain(empl, "Admin"); } } } }
public WFUserFunctionResult WFMatchingUpManager(Guid documentId, string currentUserName, int level = 1, string profileName = "") { bool skip = false; var documentTable = _DocumentService.Find(documentId); List <WFTrackerUsersTable> userList = new List <WFTrackerUsersTable>(); EmplTable currentEmplUser = _EmplService.FirstOrDefault(x => x.ApplicationUserId == documentTable.ApplicationUserCreatedId); EmplTable manager = WFMatchingUpManagerFinder(currentEmplUser, level, currentUserName, profileName); if (manager != null) { userList.Add(new WFTrackerUsersTable { UserId = manager.ApplicationUserId }); } if (!String.IsNullOrEmpty(profileName) && !String.IsNullOrWhiteSpace(profileName)) { if (userList.Count == 0) { skip = true; } else { skip = checkSkipStep(userList, documentTable.ApplicationUserCreatedId); } } return(new WFUserFunctionResult { Users = userList, Skip = skip }); }
private void EmplIntegration(string _firstname, string _secondname, string _middlename, string _workphone, string _mobilephone, string _userId, Guid _departmentId, Guid _titleId, Guid _company, string _managerUserId) { IEmplService _EmplService = DependencyResolver.Current.GetService <IEmplService>(); IWorkScheduleService _WorkScheduleService = DependencyResolver.Current.GetService <IWorkScheduleService>(); Guid?manageId = null; if (_managerUserId != String.Empty) { if (_EmplService.Contains(x => x.CompanyTableId == _company && x.ApplicationUserId == _managerUserId)) { manageId = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company && x.ApplicationUserId == _managerUserId).Id; } } if (!_EmplService.Contains(x => x.CompanyTableId == _company && x.FirstName == _firstname && x.MiddleName == _middlename && x.SecondName == _secondname)) { _EmplService.SaveDomain(new EmplTable() { isIntegratedLDAP = true, FirstName = _firstname, SecondName = _secondname, MiddleName = _middlename, ApplicationUserId = _userId, DepartmentTableId = _departmentId, TitleTableId = _titleId, CompanyTableId = _company, WorkScheduleTableId = _WorkScheduleService.FirstOrDefault(x => x.Id != null).Id, ManageId = manageId }, "Admin"); } else { EmplTable empl = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company && x.FirstName == _firstname && x.MiddleName == _middlename && x.SecondName == _secondname); empl.FirstName = _firstname; empl.SecondName = _secondname; empl.MiddleName = _middlename; empl.DepartmentTableId = _departmentId; empl.TitleTableId = _titleId; empl.isIntegratedLDAP = true; empl.ManageId = manageId; _EmplService.SaveDomain(empl, "Admin"); } }
public ActionResult ShowDocument(Guid id, string approveDoc, string rejectDoc, IDictionary <string, object> documentData, string lastComment = "") { DocumentTable docuTable = _DocumentService.Find(id); if (docuTable == null) { return(HttpNotFound()); } if (lastComment != "") { _CommentService.SaveDomain(new CommentTable { Comment = lastComment, DocumentTableId = id }); } if (rejectDoc != String.Empty) { ApplicationUser userTable = _AccountService.FirstOrDefault(x => x.UserName == User.Identity.Name); if (userTable == null) { return(HttpNotFound()); } DateTime checkRejectDate = DateTime.UtcNow.AddMinutes(-5); if (!_CommentService.Contains(x => x.ApplicationUserCreatedId == userTable.Id && x.DocumentTableId == id && x.CreatedDate >= checkRejectDate)) { EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == docuTable.ApplicationUserCreatedId); ProcessView process = _ProcessService.FindView(docuTable.ProcessTableId); object viewModel = InitialViewShowDocument(id, process, docuTable, userTable, emplTable); ModelState.AddModelError(string.Empty, UIElementRes.UIElement.RejectReason); return(View("~/Views/Document/ShowDocument.cshtml", viewModel)); } } ProcessTable processTable = docuTable.ProcessTable; if (_DocumentService.isSignDocument(id, processTable.Id)) { if (approveDoc != String.Empty) { _WorkflowService.AgreementWorkflowApprove(id, processTable.TableName, documentData); } else if (rejectDoc != String.Empty) { _WorkflowService.AgreementWorkflowReject(id, processTable.TableName, documentData); } } return(RedirectToAction("Index", "Home")); }
public void Save(EmplView viewTable) { if (viewTable.Id == null) { var domainTable = new EmplTable(); Mapper.Map(viewTable, domainTable); SaveDomain(domainTable); } else { var domainTable = Find(viewTable.Id); Mapper.Map(viewTable, domainTable); SaveDomain(domainTable); } }
private EmplTable WFMatchingUpManagerFinder(EmplTable emplTable, int level, string currentUserName, string profileName = "") { if ((level == 0 && profileName == null) || (emplTable.ProfileName == profileName || emplTable.TitleTable.ProfileName == profileName)) { return(emplTable); } EmplTable manager = _EmplService.Find(emplTable.ManageId, currentUserName); if (manager == null) { return(null); } level--; return(WFMatchingUpManagerFinder(manager, level, currentUserName, profileName)); }
public ActionResult Index() { ApplicationUser userTable = _AccountService.FirstOrDefault(x => x.UserName == User.Identity.Name); if (userTable == null) { ModelState.AddModelError(string.Empty, String.Format(ValidationRes.ValidationResource.ErrorUserNotFound, User.Identity.Name)); } EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == userTable.Id); if (emplTable == null) { ModelState.AddModelError(string.Empty, String.Format(ValidationRes.ValidationResource.ErrorEmplNotFound, User.Identity.Name)); } return(View(_GroupProcessService.GetPartialView(x => x.GroupProcessParentId == null))); }
public Guid SaveDocument(dynamic viewTable, string tableName, Guid processId, Guid fileId, string currentUserName = "") { string localUserName = getCurrentUserName(currentUserName); var docuTable = new DocumentTable(); docuTable.ProcessTableId = processId; docuTable.CreatedDate = DateTime.UtcNow; docuTable.ModifiedDate = docuTable.CreatedDate; docuTable.DocumentState = DocumentState.Created; docuTable.FileId = fileId; ApplicationUser user = _AccountService.FirstOrDefault(x => x.UserName == localUserName); docuTable.CompanyTableId = user.CompanyTableId; docuTable.ApplicationUserCreatedId = user.Id; docuTable.ApplicationUserModifiedId = user.Id; EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == user.Id); docuTable.EmplTableId = emplTable.Id; Guid numberSeqId = _ProcessService.Find(processId).GroupProcessTable.NumberSeriesTableId ?? Guid.Empty; docuTable.DocumentNum = _NumberSeqService.GetDocumentNum(numberSeqId); _uow.GetRepository <DocumentTable>().Add(docuTable); _uow.Save(); var domainTable = RouteCustomModelDomain(tableName); Mapper.Map(viewTable, domainTable); domainTable.DocumentTableId = docuTable.Id; domainTable.CreatedDate = DateTime.UtcNow; domainTable.ModifiedDate = domainTable.CreatedDate; RouteCustomRepository(tableName).Add(domainTable); _uow.Save(); docuTable.RefDocumentId = domainTable.Id; _uow.GetRepository <DocumentTable>().Update(docuTable); _uow.Save(); return(docuTable.Id); }
public ActionResult ShowDocument(Guid id, bool isAfterView = false) { var previousModelState = TempData["ModelState"] as ModelStateDictionary; if (previousModelState != null) { foreach (KeyValuePair <string, ModelState> kvp in previousModelState) { if (!ModelState.ContainsKey(kvp.Key)) { ModelState.Add(kvp.Key, kvp.Value); } } } DocumentTable docuTable = _DocumentService.Find(id); ProcessView process = _ProcessService.FindView(docuTable.ProcessTableId); if (docuTable == null || process == null || docuTable.isShow(isAfterView) == false) { return(RedirectToAction("PageNotFound", "Error")); } _ReviewDocLogService.SaveDomain(new ReviewDocLogTable { DocumentTableId = id }); EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == docuTable.ApplicationUserCreatedId); ApplicationUser userTable = _AccountService.Find(docuTable.ApplicationUserCreatedId); if (emplTable == null || userTable == null) { return(HttpNotFound()); } object viewModel = InitialViewShowDocument(id, process, docuTable, userTable, emplTable); return(View(viewModel)); }
public void SaveDomain(EmplTable domainTable, string currentUserName = "") { string localUserName = getCurrentUserName(currentUserName); ApplicationUser user = _AccountService.FirstOrDefault(x => x.UserName == localUserName); if (domainTable.Id == Guid.Empty) { domainTable.Id = Guid.NewGuid(); domainTable.CreatedDate = DateTime.UtcNow; domainTable.ModifiedDate = domainTable.CreatedDate; domainTable.CompanyTableId = user.CompanyTableId; domainTable.ApplicationUserCreatedId = user.Id; domainTable.ApplicationUserModifiedId = user.Id; repo.Add(domainTable); } else { domainTable.ModifiedDate = DateTime.UtcNow; domainTable.ApplicationUserModifiedId = user.Id; repo.Update(domainTable); } _uow.Save(); }
private object InitialViewShowDocument(Guid id, ProcessView process, DocumentTable docuTable, ApplicationUser userTable, EmplTable emplTable) { var viewModel = new DocumentComposite(); viewModel.ProcessView = process; viewModel.DocumentTable = docuTable; viewModel.docData = _DocumentService.GetDocumentView(id); viewModel.fileId = docuTable.FileId; viewModel.WFTrackerItems = _WorkflowTrackerService.GetPartialView(x => x.DocumentTableId == id); ViewBag.CreatedDate = _SystemService.ConvertDateTimeToLocal(userTable, docuTable.CreatedDate); if (emplTable != null) { ViewBag.Initiator = emplTable.ApplicationUserId != null ? emplTable.FullName : docuTable.ApplicationUserCreatedId; ViewBag.TitleName = emplTable.TitleTableId != null ? emplTable.TitleTable.TitleName : String.Empty; ViewBag.DepartmentName = emplTable.DepartmentTableId != null ? emplTable.DepartmentTable.DepartmentName : String.Empty; ViewBag.CompanyName = emplTable.CompanyTableId != null ? emplTable.CompanyTable.AliasCompanyName : String.Empty; } else { ViewBag.Initiator = String.Empty; ViewBag.TitleName = String.Empty; ViewBag.DepartmentName = String.Empty; ViewBag.CompanyName = String.Empty; } return(viewModel); }