private void LoadMethodDropDownList(int entWorkflowId)
    {
        var workflow = new ENTWorkflowEO();

        if (workflow.Load(entWorkflowId))
        {
            //Create an instance of the type.
            var methods = Type.GetType(workflow.ENTWorkflowObjectName).GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);

            //Load the methods for this workflow that return a boolean value into the conditions drop down list.
            foreach (var mi in methods)
            {
                //Only methods that take a parameter of a data context can be used.
                var parameters = mi.GetParameters();
                if (parameters.Length == 1)
                {
                    if (parameters[0].ParameterType == typeof(Agency.PaidTimeOffDAL.HRPaidTimeOffDataContext))
                    {
                        ddlPostTransitionMethodName.Items.Add(mi.Name);
                    }
                }
            }

            ddlPostTransitionMethodName.Items.Insert(0, "");
        }
        else
        {
            throw new Exception("The workflow can not be found in the database.");
        }
    }
Esempio n. 2
0
    void lbtnDelete_Command(object sender, CommandEventArgs e)
    {
        var validationErrors = new ENTValidationErrors();
        var workflow         = new ENTWorkflowEO();

        workflow.DBAction = ENTBaseEO.DBActionEnum.Delete;
        workflow.ID       = Convert.ToInt32(e.CommandArgument);
        workflow.Delete(ref validationErrors, CurrentUser.ID);

        Master.ValidationErrors = validationErrors;

        cgvWorkflows.DataBind();
    }
        private void CreateWFGroupOwnersTable()
        {
            var tr1 = new HtmlTableRow();
            var tc1 = new HtmlTableCell();

            tc1.Attributes.Add("class", "gridViewHeader");
            tc1.ColSpan   = 2;
            tc1.InnerText = "Users";
            tr1.Cells.Add(tc1);
            tblWFUserGroups.Rows.Add(tr1);

            //Get the workflow associated with this object.
            Workflow = new ENTWorkflowEO();
            Workflow.LoadByObjectName(WorkflowObjectName);

            //Get the groups associated with this workflow
            var entWFOwnerGroups = new ENTWFOwnerGroupEOList();

            entWFOwnerGroups.Load(Workflow.ID);

            //Create the table for all the owner groups
            foreach (var wfOwnerGroup in entWFOwnerGroups)
            {
                var tr     = new HtmlTableRow();
                var tcName = new HtmlTableCell();
                tcName.InnerText = wfOwnerGroup.OwnerGroupName + ":";
                tcName.Attributes.Add("ENTWFOwnerGroupId", wfOwnerGroup.ID.ToString());
                tr.Cells.Add(tcName);

                var tcUsers  = new HtmlTableCell();
                var ddlUsers = new DropDownList();
                ddlUsers.DataSource     = wfOwnerGroup.UserAccounts;
                ddlUsers.DataTextField  = "UserName";
                ddlUsers.DataValueField = "ENTUserAccountId";
                ddlUsers.DataBind();
                ddlUsers.Items.Insert(0, new ListItem("", "0"));
                tcUsers.Controls.Add(ddlUsers);
                tr.Cells.Add(tcUsers);
                tblWFUserGroups.Rows.Add(tr);
            }
            Controls.Add(tblWFUserGroups);
        }
    private void LoadPropertiesTable(int entWorkflowId, ENTWFStateEO entWFStateEO)
    {
        if (entWorkflowId != 0)
        {
            var workflow = new ENTWorkflowEO();
            if (workflow.Load(entWorkflowId))
            {
                tblProperties.Rows.Clear();

                //Add header
                var trHeader = new TableRow();
                var tc1      = new TableCell();
                tc1.Text = "Property";
                trHeader.Cells.Add(tc1);

                var tc2 = new TableCell();
                tc2.Text = "Read Only";
                trHeader.Cells.Add(tc2);

                var tc3 = new TableCell();
                tc3.Text = "Required";
                trHeader.Cells.Add(tc3);

                tblProperties.Rows.Add(trHeader);

                //Create an instance of the type.
                var type = Type.GetType(workflow.ENTWorkflowObjectName);
                if (type != null)
                {
                    var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);

                    //Populate the table with all the fields.
                    foreach (var prop in properties)
                    {
                        //Only show properties the have a public set property.
                        var methodInfo = prop.GetAccessors();

                        //Get the set method
                        var set =
                            from m in methodInfo
                            where m.Name.StartsWith("set")
                            select m;

                        if (set.Any())
                        {
                            if (set.Single().IsPublic)
                            {
                                var entWFStateProperty = new ENTWFStatePropertyEO();

                                if (entWFStateEO.ENTWorkflowId == Convert.ToInt32(ddlWorkflow.SelectedValue))
                                {
                                    //Try to find this property in the ENTWFStateObject
                                    entWFStateProperty = entWFStateEO.ENTWFStateProperties.GetByPropertyName(prop.Name);

                                    if (entWFStateProperty == null)
                                    {
                                        entWFStateProperty = new ENTWFStatePropertyEO();
                                    }
                                }

                                var tr = new TableRow();

                                //Name of property
                                var tcName = new TableCell();
                                tcName.Text = prop.Name;
                                tr.Cells.Add(tcName);

                                //Read Only checkbox
                                var tcReadOnly  = new TableCell();
                                var chkReadOnly = new CheckBox();
                                chkReadOnly.Enabled = !ReadOnly;
                                chkReadOnly.Checked = entWFStateProperty.ReadOnly;
                                tcReadOnly.Controls.Add(chkReadOnly);
                                tr.Cells.Add(tcReadOnly);

                                //Required checkbox
                                var tcRequired  = new TableCell();
                                var chkRequired = new CheckBox();
                                chkRequired.Enabled = !ReadOnly;
                                chkRequired.Checked = entWFStateProperty.Required;
                                tcRequired.Controls.Add(chkRequired);
                                tr.Cells.Add(tcRequired);
                                tblProperties.Rows.Add(tr);
                            }
                        }
                    }
                }
            }
            else
            {
                throw new Exception("The workflow can not be found in the database.");
            }
        }
    }