Exemplo n.º 1
0
        public Boolean HasPermissionForSession()
        {
            Boolean hasPermission = false;


            foreach (WorkTeam currentWorkTeam in application.WorkTeamsForSession())
            {
                WorkflowPermission permission = Permission(currentWorkTeam.Id);

                if (permission != null)
                {
                    if (permission.IsDenied)
                    {
                        hasPermission = false;

                        break;
                    }

                    else if (permission.IsGranted)
                    {
                        hasPermission = true;
                    }
                }
            }


            return(hasPermission);
        }
Exemplo n.º 2
0
        public WorkflowPermission Permission(Int64 workTeamId)
        {
            WorkflowPermission permission = null;

            foreach (WorkflowPermission currentPermission in permissions)
            {
                if (currentPermission.WorkTeamId == workTeamId)
                {
                    permission = currentPermission;

                    break;
                }
            }

            return(permission);
        }
Exemplo n.º 3
0
        public override void MapDataFields(System.Data.DataRow currentRow)
        {
            base.MapDataFields(currentRow);

            System.Xml.XmlDocument parametersXml = new System.Xml.XmlDocument();


            framework = (Enumerations.WorkflowFramework)Convert.ToInt32(currentRow["Framework"]);

            entityType = (Core.Enumerations.EntityType)Convert.ToInt32(currentRow ["EntityType"]);

            actionVerb = (String)currentRow["ActionVerb"];

            assemblyPath = (String)currentRow["AssemblyPath"];

            assemblyName = (String)currentRow["AssemblyName"];

            assemblyClassName = (String)currentRow["AssemblyClassName"];


            #region Workflow Parameters

            if (!String.IsNullOrEmpty((String)currentRow["WorkflowParameters"]))
            {
                parametersXml.LoadXml((String)currentRow["WorkflowParameters"]);

                workflowParameters = new Dictionary <string, Mercury.Server.Core.Action.ActionParameter> ();


                foreach (System.Xml.XmlNode currentParameterNode in parametersXml.SelectNodes("//Parameter"))
                {
                    try {
                        String parameterName = currentParameterNode.Attributes["Name"].Value;

                        if (!workflowParameters.ContainsKey(parameterName))
                        {
                            workflowParameters.Add(parameterName, new Mercury.Server.Core.Action.ActionParameter());

                            workflowParameters[parameterName].Name = parameterName;

                            if (currentParameterNode.Attributes["DataType"] != null)
                            {
                                workflowParameters[parameterName].DataType = (Mercury.Server.Core.Action.Enumerations.ActionParameterDataType)Convert.ToInt32(currentParameterNode.Attributes["DataType"].Value);
                            }

                            if (currentParameterNode.Attributes["AllowFixedValue"] != null)
                            {
                                workflowParameters[parameterName].AllowFixedValue = Convert.ToBoolean(currentParameterNode.Attributes["AllowFixedValue"].Value);
                            }

                            if (currentParameterNode.Attributes["Required"] != null)
                            {
                                workflowParameters[parameterName].Required = Convert.ToBoolean(currentParameterNode.Attributes["Required"].Value);
                            }

                            if (currentParameterNode.Attributes["ValueType"] != null)
                            {
                                Int32 xmlValueType = 0;

                                Int32.TryParse(currentParameterNode.Attributes["ValueType"].Value, out xmlValueType);

                                workflowParameters[parameterName].ValueType = (Mercury.Server.Core.Action.Enumerations.ActionParameterValueType)xmlValueType;
                            }

                            if (currentParameterNode.Attributes["Description"] != null)
                            {
                                workflowParameters[parameterName].ValueDescription = (String)currentParameterNode.Attributes["Description"].Value;
                            }
                        }
                    }

                    catch (Exception parameterException) {
                        System.Diagnostics.Trace.WriteLineIf(application.TraceSwitchWorkflow.TraceError, parameterException.Message);
                    }
                } // foreach
            }     // if

            #endregion



            System.Data.DataTable permissionTable = application.EnvironmentDatabase.SelectDataTable("SELECT * FROM WorkflowPermission WHERE WorkflowId = " + Id.ToString(), 0);

            foreach (System.Data.DataRow currentPermissionRow in permissionTable.Rows)
            {
                WorkflowPermission permission = new WorkflowPermission(application);

                permission.MapDataFields(currentPermissionRow);

                permissions.Add(permission);
            }

            return;
        }
Exemplo n.º 4
0
        public override List <ImportExport.Result> XmlImport(System.Xml.XmlNode objectNode)
        {
            List <ImportExport.Result> response = base.XmlImport(objectNode);

            System.Xml.XmlNode propertiesNode;

            String exceptionMessage = String.Empty;


            try {
                propertiesNode = objectNode.SelectSingleNode("Properties");

                foreach (System.Xml.XmlNode currentPropertyNode in propertiesNode)
                {
                    switch (currentPropertyNode.Attributes["Name"].InnerText)
                    {
                    case "Framework": Framework = (Enumerations.WorkflowFramework)Convert.ToInt32(currentPropertyNode.InnerText); break;

                    case "EntityType": EntityType = (Core.Enumerations.EntityType)Convert.ToInt32(currentPropertyNode.InnerText); break;


                    case "ActionVerb": ActionVerb = currentPropertyNode.InnerText; break;

                    case "AssemblyPath": AssemblyPath = currentPropertyNode.InnerText; break;

                    case "AssemblyName": AssemblyName = currentPropertyNode.InnerText; break;

                    case "AssemblyClassName": AssemblyClassName = currentPropertyNode.InnerText; break;


                    case "WorkflowParameters":

                        #region Workflow Parameters

                        foreach (System.Xml.XmlNode currentParameter in currentPropertyNode.ChildNodes)
                        {
                            Core.Action.ActionParameter workflowParameter = new Action.ActionParameter();

                            workflowParameter.Name = currentParameter.Attributes["Name"].Value;

                            workflowParameter.DataType = (Action.Enumerations.ActionParameterDataType)Convert.ToInt32(currentParameter.Attributes["DataType"].Value);

                            workflowParameter.AllowFixedValue = Convert.ToBoolean(currentParameter.Attributes["AllowFixedValue"].Value);

                            workflowParameter.Required = Convert.ToBoolean(currentParameter.Attributes["Required"].Value);

                            workflowParameter.ValueType = (Core.Action.Enumerations.ActionParameterValueType)Convert.ToInt32(currentParameter.Attributes["ValueType"].Value);

                            workflowParameter.ValueDescription = currentParameter.Attributes["Description"].Value;

                            if (!workflowParameters.ContainsKey(workflowParameter.Name))
                            {
                                workflowParameters.Add(workflowParameter.Name, workflowParameter);
                            }
                        }

                        #endregion

                        break;
                    }
                }



                #region Workflow Permissions

                System.Xml.XmlNode workflowPermissionsNode = objectNode.SelectSingleNode("WorkflowPermissions");

                foreach (System.Xml.XmlNode currentPermissionNode in workflowPermissionsNode.ChildNodes)
                {
                    WorkflowPermission workflowPermission = new WorkflowPermission(application);

                    response.AddRange(workflowPermission.XmlImport(currentPermissionNode));


                    if (workflowPermission.WorkTeamId != 0)
                    {
                        workflowPermission.WorkflowId = 0;

                        permissions.Add(workflowPermission);

                        response.Add(new ImportExport.Result(workflowPermission.ObjectType, workflowPermission.Name, 0));
                    }

                    else
                    {
                        response.Add(new ImportExport.Result(workflowPermission.ObjectType, currentPermissionNode.Attributes["Name"].InnerText, new ApplicationException("Unable to map Workflow Permission to local Work Team.")));
                    }
                }

                #endregion
            }

            catch (Exception importException) {
                response.Add(new ImportExport.Result(ObjectType, Name, importException));
            }

            return(response);
        }