Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }