コード例 #1
0
        public void LoadObjectFromControl(ENTBaseWorkflowEO baseWorkflowEO)
        {
            this.EnsureChildControls();

            baseWorkflowEO.WFItem.ItemId        = baseWorkflowEO.ID;
            baseWorkflowEO.WFItem.ENTWorkflowId = baseWorkflowEO.Workflow.ID;

            //Get the users that have been selected to be owners for this workflow.
            for (int row = 1; row < tblWFUserGroups.Rows.Count; row++)
            {
                var tr = tblWFUserGroups.Rows[row];

                //Get selected user id
                var ddlOwner         = (DropDownList)tr.Cells[1].Controls[0];
                int entUserAccountId = Convert.ToInt32(ddlOwner.SelectedValue);

                //Try to find the owner group
                int entWFOwnerGroupId = Convert.ToInt32(tr.Cells[0].Attributes["ENTWFOwnerGroupId"]);
                var itemOwner         = baseWorkflowEO.WFOwners.GetByENTWFOwnerGroupId(entWFOwnerGroupId);
                if (itemOwner == null)
                {
                    //This must be added to the object
                    baseWorkflowEO.WFOwners.Add(new ENTWFItemOwnerEO
                    {
                        ENTUserAccountId  = entUserAccountId,
                        ENTWFItemId       = baseWorkflowEO.ID,
                        ENTWFOwnerGroupId = entWFOwnerGroupId,
                    });
                }
                else
                {
                    //Set the id of the selected user
                    itemOwner.ENTUserAccountId = entUserAccountId;
                }
            }

            //Check if the user is transitioning this item
            baseWorkflowEO.ENTWFTransitionId = Convert.ToInt32(ddlTransitions.SelectedValue);
            if (baseWorkflowEO.ENTWFTransitionId != 0)
            {
                //Change the current state.
                var transition = new ENTWFTransitionEO();
                transition.Load(baseWorkflowEO.ENTWFTransitionId);

                baseWorkflowEO.WFItem.CurrentWFStateId = transition.ToENTWFStateId;

                //Add to state history
                baseWorkflowEO.WFStateHistory.Add(new ENTWFItemStateHistoryEO
                {
                    ENTWFStateId     = baseWorkflowEO.WFItem.CurrentWFStateId,
                    ENTUserAccountId = baseWorkflowEO.CurrentOwnerENTUserAccountId
                });
            }
            else
            {
                //Check if the user change the owner by chaning, this should be shown in the state history also.
                if (baseWorkflowEO.CurrentOwnerENTUserAccountId != ((ENTBaseWorkflowEO)baseWorkflowEO.OriginalItem).CurrentOwnerENTUserAccountId)
                {
                    //Add to state history
                    baseWorkflowEO.WFStateHistory.Add(new ENTWFItemStateHistoryEO
                    {
                        ENTWFStateId     = baseWorkflowEO.WFItem.CurrentWFStateId,
                        ENTUserAccountId = baseWorkflowEO.CurrentOwnerENTUserAccountId
                    });
                }
            }
            //Set the notification page
            baseWorkflowEO.NotificationPage = this.Context.Request.Url.AbsoluteUri;
        }
コード例 #2
0
        public void LoadControlFromObject(ENTBaseWorkflowEO baseWorkflowEO, int currentUserId)
        {
            this.EnsureChildControls();

            //Select the user for the group
            for (int row = 1; row < tblWFUserGroups.Rows.Count; row++)
            {
                HtmlTableRow tr = tblWFUserGroups.Rows[row];

                //The owner group id is an attribute in the first cell
                int entWFOwnerGroupId = Convert.ToInt32(tr.Cells[0].Attributes["ENTWFOwnerGroupId"]);

                var ddlUsers = (DropDownList)tr.Cells[1].Controls[0];

                //Select the correct record.
                var itemOwner = baseWorkflowEO.WFOwners.GetByENTWFOwnerGroupId(entWFOwnerGroupId);
                if (itemOwner.ENTUserAccountId == null)
                {
                    ddlUsers.SelectedIndex = 0;
                }
                else
                {
                    ddlUsers.Items.FindByValue(itemOwner.ENTUserAccountId.ToString()).Selected = true;
                }
            }

            //Set the current state label.
            lblCurrentState.Text = baseWorkflowEO.CurrentState.StateName + " (" + baseWorkflowEO.CurrentOwnerUserName + ")";

            if (baseWorkflowEO.WFTransitions.Count == 0)
            {
                //Hide Transitions
                lblActions.Visible     = false;
                ddlTransitions.Visible = false;
            }
            else
            {
                //Load the transition drop down
                ddlTransitions.DataSource     = baseWorkflowEO.WFTransitions;
                ddlTransitions.DataTextField  = "DisplayText";
                ddlTransitions.DataValueField = "ID";
                ddlTransitions.DataBind();
            }

            //If this is a new item then there must be a transition picked.
            if (baseWorkflowEO.ID != 0)
            {
                ddlTransitions.Items.Insert(0, new ListItem("", "0"));

                //If this is an existing item and the current user is not the current owner then do not let them
                //transition the item.
                if (currentUserId != baseWorkflowEO.CurrentOwnerENTUserAccountId)
                {
                    lblActions.Visible     = false;
                    ddlTransitions.Visible = false;
                }
            }

            //Load the state history grid
            cgvWFStateHistory.ListClassName  = typeof(ENTWFItemStateHistoryEOList).AssemblyQualifiedName;
            cgvWFStateHistory.LoadMethodName = "Load";
            cgvWFStateHistory.LoadMethodParameters.Add(baseWorkflowEO.WFItem.ID);
            cgvWFStateHistory.SortExpressionLast = "InsertDate";

            //Name
            cgvWFStateHistory.AddBoundField("StateName", "State", "");
            cgvWFStateHistory.AddBoundField("OwnerName", "Owner", "");
            cgvWFStateHistory.AddBoundField("InsertDate", "Date", "");
            cgvWFStateHistory.AddBoundField("InsertedBy", "Moved By", "");

            cgvWFStateHistory.DataBind();
        }