private bool internalValidOwner(string target_status_mnemonic) { string current_status = null; if (LatestInstance == null) { return(true); } if (target_status_mnemonic.Equals(STATUS_INIT) == false) { current_status = LatestInstance.task_status; } User requestor = null; switch (target_status_mnemonic) { case STATUS_INIT: if (internalCheckTaskAccessibility()) { return(true); } break; case STATUS_APPROVAL: case STATUS_REJECT: //Get Submit Persons if (IsSelfApproveEnable == false) { requestor = User.GetUser(LatestInstance.entry_author); if (requestor.IsValid && requestor.Equals(CurrentUser)) { return(false); } } foreach (Models.TaskSubmitInformation taskSubmitInformation in GyomuDataAccess.SelectTaskSubmitInformation(LatestInstance)) { User submit_user = User.GetUser(taskSubmitInformation.submit_to); if (submit_user.IsValid) { if (submit_user.IsGroup == false && submit_user.Equals(CurrentUser)) { return(true); } if (submit_user.IsGroup) { if (CurrentUser.IsInGroup(submit_user)) { return(true); } } } } break; case STATUS_EXECUTE: //If Current Status is not Delegate, it must be equal to Latest instance's user if (STATUS_DELEGATE.Equals(current_status) == false) { Models.DelegateInformation info = DelegateInformation; if (info.DelegationRequired) { if (Instances.Where(i => i.task_status.Equals(STATUS_DELEGATE) && i.entry_author.Equals(CurrentUser.UserID)).Count() > 0) { return(true); } User previousUser = User.GetUser(LatestInstance.entry_author); if (previousUser.IsValid && previousUser.Equals(CurrentUser)) { return(true); } } else { User previousUser = User.GetUser(LatestInstance.entry_author); if (previousUser.IsValid && previousUser.Equals(CurrentUser)) { return(true); } } } //Else it must be submit user in the latest instance else { foreach (Models.TaskSubmitInformation taskSubmitInformation in GyomuDataAccess.SelectTaskSubmitInformation(LatestInstance)) { User submit_user = User.GetUser(taskSubmitInformation.submit_to); if (submit_user.IsValid) { if (submit_user.IsGroup == false && submit_user.Equals(CurrentUser)) { return(true); } if (submit_user.IsGroup && CurrentUser.IsInGroup(submit_user)) { return(true); } } } } break; case STATUS_REQUEST: //Approver or Starter User starter = User.GetUser(CurrentTask.entry_author); if (starter.IsValid && starter.Equals(CurrentUser)) { return(true); } if (LatestInstance.task_status.Equals(STATUS_APPROVAL)) { User approver = User.GetUser(LatestInstance.entry_author); if (approver.IsValid && approver.Equals(CurrentUser)) { return(true); } } break; case STATUS_CANCEL: //Requester requestor = User.GetUser(LatestInstance.entry_author); if (requestor.IsValid && requestor.Equals(CurrentUser)) { return(true); } break; case STATUS_COMPLETE: //For Force Success if (internalCheckTaskAccessibility() == false) { return(false); } if (current_status.Equals(STATUS_FAIL)) { return(true); } break; default: return(true); } return(false); }
protected List <Models.TaskSubmitInformation> LoadSubmitInformation(Models.TaskInstance taskInstance) { return(GyomuDataAccess.SelectTaskSubmitInformation(taskInstance)); }