示例#1
0
        protected void HandleDelete(object sender, EventArgs e)
        {
            if (this.SupervisiorMode)
            {
                LinkButton lb = sender as LinkButton;
                if (lb != null)
                {
                    string appName             = lb.Attributes["data-appname"];
                    string pgname              = lb.Attributes["data-pgname"];
                    WfApplicationAuthType type = (WfApplicationAuthType)Enum.Parse(typeof(WfApplicationAuthType), lb.Attributes["data-type"]);

                    using (System.Transactions.TransactionScope scope = TransactionScopeFactory.Create())
                    {
                        WfApplicationAuth auth = WfApplicationAuthAdapter.Instance.Load(appName, pgname, type);
                        if (auth != null)
                        {
                            WfApplicationAuthAdapter.Instance.Delete(auth);
                        }

                        scope.Complete();
                    }
                }
            }
            else
            {
                WebUtility.ShowClientError("只有管理员可以进行删除", "", "失败");
            }

            this.InnerRefreshList();
        }
        private static WfApplicationAuth PrepareData(string appName, string progName)
        {
            WfApplicationAuth auth = new WfApplicationAuth();

            auth.ApplicationName = appName;
            auth.ProgramName = progName;
            auth.AuthType = WfApplicationAuthType.FormAdmin;

            OguRole role = new OguRole(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles);

            auth.RoleID = role.ID;
            auth.RoleDescription = role.FullCodeName;

            return auth;
        }
示例#3
0
        private static WfApplicationAuth PrepareData(string appName, string progName)
        {
            WfApplicationAuth auth = new WfApplicationAuth();

            auth.ApplicationName = appName;
            auth.ProgramName     = progName;
            auth.AuthType        = WfApplicationAuthType.FormAdmin;

            OguRole role = new OguRole(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles);

            auth.RoleID          = role.ID;
            auth.RoleDescription = role.FullCodeName;

            return(auth);
        }
示例#4
0
        public void SaveWfApplicationAuth()
        {
            WfApplicationAuth auth = PrepareData("秘书服务", "部门通知");

            WfApplicationAuthAdapter.Instance.Update(auth);

            WfApplicationAuth dataRead = WfApplicationAuthAdapter.Instance.Load(
                auth.ApplicationName,
                auth.ProgramName,
                auth.AuthType);

            Assert.IsNotNull(dataRead);
            Assert.AreEqual(auth.RoleID, dataRead.RoleID);
            Assert.AreEqual(auth.RoleDescription, dataRead.RoleDescription);
        }
示例#5
0
        protected void OkClick(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                try
                {
                    if (RolesDefineConfig.GetConfig().IsCurrentUserInRoles("ProcessAdmin") == false)
                        throw new OperationDeniedException("只有管理员可以进行此操作");

                    RolesDefineConfig.GetConfig().IsCurrentUserInRoles("ProcessAdmin").FalseThrow("只有管理员可以进行此操作");

                    if (string.IsNullOrEmpty(this.ddPg.SelectedValue) == false)
                    {
                        var old = WfApplicationAuthAdapter.Instance.Load(this.ddApp.SelectedValue, this.ddPg.SelectedValue, this.chkAdjuster.Checked ? WfApplicationAuthType.FormAdmin : WfApplicationAuthType.FormViewer);
                        if (old == null)
                            old = new WfApplicationAuth() { ApplicationName = this.ddApp.SelectedValue, AuthType = this.chkAdjuster.Checked ? WfApplicationAuthType.FormAdmin : WfApplicationAuthType.FormViewer, ProgramName = this.ddPg.SelectedItem.Value };

                        old.RoleID = this.inputRole.Text;
                        old.RoleDescription = this.inputRoleName.Value;

                        WfApplicationAuthAdapter.Instance.Update(old);
                        WebUtility.CloseWindow();
                    }
                    else
                    {
                        var appName = this.ddApp.SelectedValue;
                        var authType = this.chkAdjuster.Checked ? WfApplicationAuthType.FormAdmin : WfApplicationAuthType.FormViewer;
                        var old = WfApplicationAuthAdapter.Instance.Load(appName, authType);
                        var appPrograms = WfApplicationAdapter.Instance.LoadProgramsByApplication(appName);

                        var roleID = this.inputRole.Text;
                        var roleDescription = this.inputRoleName.Value;

                        List<WfApplicationAuth> auths = new List<WfApplicationAuth>(appPrograms.Count);
                        foreach (var item in appPrograms)
                        {
                            WfApplicationAuth auth = old.Find(m => m.ApplicationName == appName && m.AuthType == authType && m.ProgramName == item.CodeName);
                            if (auth == null)
                            {
                                auths.Add(new WfApplicationAuth() { ApplicationName = appName, AuthType = authType, ProgramName = item.CodeName, RoleID = roleID, RoleDescription = roleDescription });
                            }
                            else if (auth.RoleID != roleID)
                            {
                                auth.RoleID = roleID;
                                auth.RoleDescription = roleDescription;
                                auths.Add(auth);
                            }
                        }

                        using (System.Transactions.TransactionScope scope = MCS.Library.Data.TransactionScopeFactory.Create())
                        {
                            foreach (var item in auths)
                            {
                                WfApplicationAuthAdapter.Instance.Update(item);
                            }

                            scope.Complete();
                        }

                        WebUtility.CloseWindow();
                    }
                }
                catch (Exception ex)
                {
                    WebUtility.ShowClientError(ex);
                }
            }
        }