public static bool CanUserChangeStep(Workflow workflow, WorkflowStep step, string EntityID, string UserName) { bool retVal = false; foreach (WorkflowNextStep possibleStep in step.PossibleNextSteps) { foreach (BaseSecurityGroup group in possibleStep.SecurityGroups) { retVal = IsUserInSecurityGroup(group, workflow, step, EntityID, UserName); if (retVal) { break; } } if (retVal) { break; } } return(retVal); }
private static bool IsUserInSecurityGroup(BaseSecurityGroup group, Workflow workflow, WorkflowStep step, string EntityID, string UserName) { bool retVal = false; switch (group.Type.ToLower()) { case "everyone": retVal = true; break; case "user": UserSecurityGroup userGroup = (UserSecurityGroup)group; if (!String.IsNullOrEmpty(userGroup.User)) { if (userGroup.User.ToLower() == UserName) { retVal = true; } } break; case "role": RoleSecurityGroup roleGroup = (RoleSecurityGroup)group; retVal = AuthorizationService.GetInstance().AuthorizationProvider.IsInRole(roleGroup.Role); break; case "dynamic": WorkflowDynamicSecurityGroup dynamicGroup = (WorkflowDynamicSecurityGroup)group; DataTable users = WorkflowDynamicSecurityGroup.GetUsers(dynamicGroup, workflow, step, EntityID, UserName); if (users.Rows.Count > 0) { retVal = true; } break; } return(retVal); }
public static List <WorkflowNextStep> GetPossibleNextSteps(Workflow workflow, WorkflowStep step, string EntityID, string UserName) { List <WorkflowNextStep> possibleSteps = new List <WorkflowNextStep>(); foreach (WorkflowNextStep possibleStep in step.PossibleNextSteps) { bool CanChangeToStep = false; foreach (BaseSecurityGroup group in possibleStep.SecurityGroups) { CanChangeToStep = IsUserInSecurityGroup(group, workflow, step, EntityID, UserName); if (CanChangeToStep) { break; } } if (CanChangeToStep) { WorkflowNextStep copy = ObjectCopier.Clone <WorkflowNextStep>(possibleStep); possibleSteps.Add(copy); } } return(possibleSteps); }
public static DataTable GetUsers(WorkflowDynamicSecurityGroup group, Workflow workflow, WorkflowStep step, string EntityID, string UserName) { DataTable retVal = null; DataCommandService dataCommandDB = DataCommandService.GetInstance(); DataCommand command = Core.DataCommand.GetDataCommand(group.DataCommand); if (command == null) { throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration", group.DataCommand)); } List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter parameter = null; if (!String.IsNullOrEmpty(group.WorkflowCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = group.WorkflowCodeParameter; parameter.Value = workflow.Code; parameters.Add(parameter); } if (!String.IsNullOrEmpty(group.CurrentWorkflowStepCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = group.CurrentWorkflowStepCodeParameter; parameter.Value = step.Code; parameters.Add(parameter); } if (!String.IsNullOrEmpty(group.EntityIDParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = group.EntityIDParameter; parameter.Value = EntityID; parameters.Add(parameter); } if (!String.IsNullOrEmpty(group.UsernameParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = group.UsernameParameter; parameter.Value = UserName; parameters.Add(parameter); } //execute command with transaction //CommandType type = (command.Type == DataCommandCommandType.StoredProcedure) ? CommandType.StoredProcedure : CommandType.Text; retVal = dataCommandDB.GetDataForDataCommand(command.Name, parameters); return(retVal); }