private void BindState()
        {
            string savedValue = ddlState.SelectedValue;

            ddlState.Items.Clear();

            int stateMachineId = int.Parse(ddlStateMachine.SelectedValue);

            sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, stateMachineId);

            grdMain.Visible = true;
            if (sm.States.Count == 0)
            {
                grdMain.Visible = false;
                return;
            }

            foreach (State state in sm.States)
            {
                MetaObject mo = StateMachineManager.GetState(mc, state.Name);

                ListItem li = new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.PrimaryKeyId.Value.ToString());
                ddlState.Items.Add(li);
            }

            if (savedValue != null)
            {
                CHelper.SafeSelect(ddlState, savedValue);
            }

            GenerateStructure();
        }
Example #2
0
        private void BindData()
        {
            if (SMId > 0)
            {
                Mediachase.Ibn.Data.Services.StateMachine sm = StateMachineManager.GetStateMachine(ClassName, SMId);
                txtName.Text = sm.Name;

                foreach (State state in sm.States)
                {
                    MetaObject mo = StateMachineManager.GetState(ClassName, state.Name);
                    lstSelectedStates.Items.Add(new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), state.Name));
                }

                foreach (MetaObject mo in StateMachineManager.GetAvailableStates(ClassName))
                {
                    string   sName = mo.Properties["Name"].Value.ToString();
                    ListItem item  = lstSelectedStates.Items.FindByValue(sName);
                    if (item == null)
                    {
                        lstAvailableStates.Items.Add(new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.Properties["Name"].Value.ToString()));
                    }
                }
            }
            else
            {
                foreach (MetaObject mo in StateMachineManager.GetAvailableStates(ClassName))
                {
                    lstAvailableStates.Items.Add(new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.Properties["Name"].Value.ToString()));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            mc = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRoleMetaClass(ClassName);
            sm = new Mediachase.Ibn.Data.Services.StateMachine(MetaDataWrapper.GetMetaClassByName(ClassName), StateMachineId);

            GenerateStructure();
            if (!IsPostBack)
            {
                BindData();
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            sm = StateMachineManager.GetStateMachine(ClassName, SMId);

            GenerateStructure();

            if (!IsPostBack)
            {
                MetaObject mo = StateMachineManager.GetState(ClassName, FromState);
                lblFrom.Text = CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString());
            }
        }
Example #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!this.Page.IsValid)
            {
                return;
            }

            Mediachase.Ibn.Data.Services.StateMachine sm = null;
            if (SMId > 0)
            {
                sm = StateMachineManager.GetStateMachine(ClassName, SMId);
                sm.States.Clear();
            }
            else
            {
                sm = new Mediachase.Ibn.Data.Services.StateMachine(MetaDataWrapper.GetMetaClassByName(ClassName));
            }

            sm.Name = txtName.Text;

            foreach (string s in hdnStates.Value.Split(','))
            {
                sm.States.Add(new State(s));
            }

            sm.Save();

            // Closing window
            if (RefreshButton == String.Empty)
            {
                CHelper.CloseItAndRefresh(Response);
            }
            else              // Dialog Mode
            {
                CHelper.CloseItAndRefresh(Response, RefreshButton);
            }
        }
Example #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!this.Page.IsValid)
                return;

            Mediachase.Ibn.Data.Services.StateMachine sm = null;
            if (SMId > 0)
            {
                sm = StateMachineManager.GetStateMachine(ClassName, SMId);
                sm.States.Clear();
            }
            else
            {
                sm = new Mediachase.Ibn.Data.Services.StateMachine(MetaDataWrapper.GetMetaClassByName(ClassName));
            }

            sm.Name = txtName.Text;

            foreach (string s in hdnStates.Value.Split(','))
            {
                sm.States.Add(new State(s));
            }

            sm.Save();

            // Closing window
            if (RefreshButton == String.Empty)
            {
                CHelper.CloseItAndRefresh(Response);
            }
            else  // Dialog Mode
            {
                CHelper.CloseItAndRefresh(Response, RefreshButton);
            }
        }
Example #7
0
        private void BindState()
        {
            string savedValue = StateList.SelectedValue;

            StateList.Items.Clear();

            int stateMachineId = int.Parse(StateMachineList.SelectedValue, CultureInfo.InvariantCulture);

            Mediachase.Ibn.Data.Services.StateMachine sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, stateMachineId);
            foreach (State state in sm.States)
            {
                MetaObject mo = StateMachineManager.GetState(mc, state.Name);

                ListItem li = new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.PrimaryKeyId.ToString());
                StateList.Items.Add(li);
            }

            if (savedValue != null)
            {
                CHelper.SafeSelect(StateList, savedValue);
            }

            BindGrid();
        }
        private void BindGrid()
        {
            if (sm == null)
            {
                sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue));
            }

            // DataTable structure
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(principalColumn, typeof(string));

            MetaObject moState   = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue));
            string     fromState = moState.Properties["Name"].Value.ToString();

            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                {
                    dt.Columns.Add(state.Name, typeof(string));
                }
            }
            dt.Columns.Add(editColumn, typeof(string));

            // Fill data
            DataRow dr;

            foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name))
            {
                int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value;

                dr = dt.NewRow();
                dr[principalColumn] = CHelper.GetUserName(principalId);

                MetaObject obj = StateMachineUtil.GetGlobalAclStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(ddlStateMachine.SelectedValue), int.Parse(ddlState.SelectedValue));

                for (int i = 1; i < grdMain.Columns.Count - 1; i++)
                {
                    BoundField rightsField = grdMain.Columns[i] as BoundField;
                    if (rightsField != null)
                    {
                        string fieldName = rightsField.DataField;
                        if (obj != null)
                        {
                            dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value);
                        }
                        else
                        {
                            dr[fieldName] = CHelper.GetPermissionImage((int)Mediachase.Ibn.Data.Services.Security.Rights.None);
                        }
                    }
                }

                string url = String.Format("javascript:ShowWizard(&quot;{7}?ClassName={0}&btn={1}&PrincipalId={2}&SmId={3}&StateId={4}&quot;, {5}, {6});",
                                           mc.Name, Page.ClientScript.GetPostBackEventReference(btnRefresh, ""),
                                           principalId, ddlStateMachine.SelectedValue, ddlState.SelectedValue,
                                           dialogWidth, dialogHeight,
                                           ResolveClientUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclStateTransitionEdit.aspx"));
                dr[editColumn] = String.Format("<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString());

                dt.Rows.Add(dr);
            }

            grdMain.DataSource = dt;
            grdMain.DataBind();
        }
        private void GenerateStructure()
        {
            if (sm == null)
            {
                sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue));
            }

            if (grdMain.Columns.Count > 0)
            {
                grdMain.Columns.Clear();
            }

            BoundField field = new BoundField();

            field.DataField  = principalColumn;
            field.HeaderText = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Principal").ToString();
            field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            field.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            field.HeaderStyle.CssClass        = "ibn-vh";
            field.HtmlEncode = false;
            grdMain.Columns.Add(field);

            int        transitionCounter = 0;
            MetaObject mo        = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue));
            string     fromState = mo.Properties["Name"].Value.ToString();

            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                {
                    transitionCounter++;
                    field                      = new BoundField();
                    field.DataField            = state.Name;
                    field.HeaderText           = CHelper.GetResFileString(st.Name);
                    field.HeaderStyle.CssClass = "thCenter";
                    field.HtmlEncode           = false;
                    grdMain.Columns.Add(field);
                }
            }

            grdMain.Visible = true;
            if (transitionCounter == 0)
            {
                grdMain.Visible = false;
                return;
            }

            for (int i = 1; i <= transitionCounter; i++)
            {
                grdMain.Columns[i].HeaderStyle.Width = Unit.Percentage(percentsForTransition / transitionCounter);
            }

            // Edit
            field                   = new BoundField();
            field.DataField         = editColumn;
            field.HeaderText        = String.Empty;
            field.HtmlEncode        = false;
            field.HeaderStyle.Width = Unit.Pixel(25);
            field.ItemStyle.Width   = Unit.Pixel(25);
            grdMain.Columns.Add(field);

            BindGrid();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            mc = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRoleMetaClass(ClassName);
            sm = new Mediachase.Ibn.Data.Services.StateMachine(MetaDataWrapper.GetMetaClassByName(ClassName), StateMachineId);

            GenerateStructure();
            if (!IsPostBack)
            {
                BindData();
            }
        }
Example #11
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Title", typeof(string));
            dt.Columns.Add("SuperType", typeof(string));
            dt.Columns.Add("StateMachine", typeof(string));
            dt.Columns.Add("BlockCard", typeof(string));
            dt.Columns.Add("EntryCard", typeof(string));
            dt.Columns.Add("EditLink", typeof(string));

            foreach (MetaObject mo in TimeTrackingManager.GetBlockTypeList())
            {
                DataRow row = dt.NewRow();
                row["Id"]    = mo.PrimaryKeyId;
                row["Title"] = mo.Properties["Title"].Value.ToString();
                if ((bool)mo.Properties["IsProject"].Value)
                {
                    row["SuperType"] = GetGlobalResourceObject("IbnFramework.TimeTracking", "ProjectType").ToString();
                }
                else
                {
                    row["SuperType"] = GetGlobalResourceObject("IbnFramework.TimeTracking", "GlobalType").ToString();
                }

                int stateMachineId = (Mediachase.Ibn.Data.PrimaryKeyId)mo.Properties["StateMachineId"].Value;
                Mediachase.Ibn.Data.Services.StateMachine sm = StateMachineManager.GetStateMachine(TimeTrackingManager.BlockMetaClassName, stateMachineId);
                row["StateMachine"] = CHelper.GetResFileString(sm.Name);

                if (mo.Properties["BlockCard"].Value != null)
                {
                    string    cardName = mo.Properties["BlockCard"].Value.ToString();
                    MetaClass mcCard   = MetaDataWrapper.GetMetaClassByName(cardName);
                    if (mcCard != null)
                    {
                        row["BlockCard"] = CHelper.GetResFileString(mcCard.FriendlyName);
                    }
                }
                if (mo.Properties["EntryCard"].Value != null)
                {
                    string    cardName = mo.Properties["EntryCard"].Value.ToString();
                    MetaClass mcCard   = MetaDataWrapper.GetMetaClassByName(cardName);
                    if (mcCard != null)
                    {
                        row["EntryCard"] = CHelper.GetResFileString(mcCard.FriendlyName);
                    }
                }

                dt.Rows.Add(row);
            }

            grdMain.DataSource = dt;
            grdMain.DataBind();

            foreach (GridViewRow row in grdMain.Rows)
            {
                ImageButton ib = (ImageButton)row.FindControl("ibDelete");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')");
                }
            }
        }
Example #12
0
        private void BindState()
        {
            string savedValue = StateList.SelectedValue;

            StateList.Items.Clear();

            int stateMachineId = int.Parse(StateMachineList.SelectedValue);
            Mediachase.Ibn.Data.Services.StateMachine sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, stateMachineId);
            foreach (State state in sm.States)
            {
                MetaObject mo = StateMachineManager.GetState(mc, state.Name);

                ListItem li = new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.PrimaryKeyId.ToString());
                StateList.Items.Add(li);
            }

            if (savedValue != null)
                CHelper.SafeSelect(StateList, savedValue);

            BindGrid();
        }
        private void GenerateStructure()
        {
            if (sm == null)
                sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue));

            if (grdMain.Columns.Count > 0)
                grdMain.Columns.Clear();

            BoundField field = new BoundField();
            field.DataField = roleColumn;
            field.HeaderText = GetGlobalResourceObject("IbnFramework.Security", "Role").ToString();
            field.HeaderStyle.CssClass = "ibn-vh";
            field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            field.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            grdMain.Columns.Add(field);

            int transitionCounter = 0;
            MetaObject mo = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue));
            string fromState = mo.Properties["Name"].Value.ToString();
            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                {
                    transitionCounter++;
                    field = new BoundField();
                    field.DataField = state.Name;
                    field.HeaderText = CHelper.GetResFileString(st.Name);
                    field.HeaderStyle.CssClass = "thCenter";
                    field.HtmlEncode = false;
                    grdMain.Columns.Add(field);
                }
            }

            grdMain.Visible = true;
            if (transitionCounter == 0)
            {
                grdMain.Visible = false;
                return;
            }

            for (int i = 1; i <= transitionCounter; i++)
            {
                grdMain.Columns[i].HeaderStyle.Width = Unit.Percentage(percentsForTransition / transitionCounter);
            }

            // Edit
            field = new BoundField();
            field.DataField = editColumn;
            field.HeaderText = String.Empty;
            field.HtmlEncode = false;
            field.HeaderStyle.Width = Unit.Pixel(25);
            field.ItemStyle.Width = Unit.Pixel(25);
            grdMain.Columns.Add(field);

            BindGrid();
        }
        private void BindState()
        {
            string savedValue = ddlState.SelectedValue;

            ddlState.Items.Clear();

            int stateMachineId = int.Parse(ddlStateMachine.SelectedValue);

            sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, stateMachineId);

            grdMain.Visible = true;
            if (sm.States.Count == 0)
            {
                grdMain.Visible = false;
                return;
            }

            foreach (State state in sm.States)
            {
                MetaObject mo = StateMachineManager.GetState(mc, state.Name);

                ListItem li = new ListItem(CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString()), mo.PrimaryKeyId.Value.ToString());
                ddlState.Items.Add(li);
            }

            if (savedValue != null)
                CHelper.SafeSelect(ddlState, savedValue);

            GenerateStructure();
        }
        private void BindGrid()
        {
            if (sm == null)
                sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue));

            // DataTable structure
            DataTable dt = new DataTable();
            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(roleColumn, typeof(string));

            MetaObject moState = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue));
            string fromState = moState.Properties["Name"].Value.ToString();

            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                    dt.Columns.Add(state.Name, typeof(string));
            }
            dt.Columns.Add(editColumn, typeof(string));

            // Fill data
            DataRow dr;

            foreach (MetaObject mo in Mediachase.Ibn.Data.Services.RoleManager.GetObjectRoleItems(mc.Name))
            {
                string roleName = mo.Properties["RoleName"].Value.ToString();

                dr = dt.NewRow();
                dr[roleColumn] = CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString());
                if (mo.Properties["ClassName"].Value != null)
                {
                    string className = (string)mo.Properties["ClassName"].Value;
                    if (className.Contains("::"))
                    {
                        string[] s = new string[] { "::" };
                        className = className.Split(s, StringSplitOptions.None)[0];
                    }
                    dr[roleColumn] += String.Format(" ({0})", CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(className).PluralName));
                }

                MetaObject obj = StateMachineUtil.GetObjectRoleStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(ddlStateMachine.SelectedValue), int.Parse(ddlState.SelectedValue));

                for (int i = 1; i < grdMain.Columns.Count - 1; i++)
                {
                    BoundField rightsField = grdMain.Columns[i] as BoundField;
                    if (rightsField != null)
                    {
                        string fieldName = rightsField.DataField;
                        if (obj != null)
                            dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value);
                        else
                            dr[fieldName] = CHelper.GetPermissionImage((int)Mediachase.Ibn.Data.Services.Security.Rights.None);
                    }
                }

                string url = String.Format("javascript:ShowWizard(&quot;{7}?ClassName={0}&btn={1}&Role={2}&SmId={3}&StateId={4}&quot;, {5}, {6});",
                    mc.Name, Page.ClientScript.GetPostBackEventReference(lnkRefresh, ""),
                    roleName, ddlStateMachine.SelectedValue, ddlState.SelectedValue,
                    dialogWidth, dialogHeight,
                    ResolveClientUrl("~/Apps/Security/Pages/Admin/ObjectRoleStateTransitionEdit.aspx"));
                dr[editColumn] = String.Format("<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString());

                dt.Rows.Add(dr);
            }

            grdMain.DataSource = dt;
            grdMain.DataBind();
        }
Example #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            sm = StateMachineManager.GetStateMachine(ClassName, SMId);

            GenerateStructure();

            if (!IsPostBack)
            {
                MetaObject mo = StateMachineManager.GetState(ClassName, FromState);
                lblFrom.Text = CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString());
            }
        }