Esempio n. 1
0
        private void DoMoveToOrg(string orgKey, List <string> groupKeys, IList <object> errors)
        {
            try
            {
                PC.SCOrganization org = (PC.SCOrganization)DbUtil.GetEffectiveObject(orgKey, string.Format("指定的组织(ID:{0})无效", orgKey));
                var grps = DbUtil.LoadObjects(groupKeys.ToArray());

                foreach (PC.SCBase item in grps)
                {
                    try
                    {
                        if (item is PC.SCGroup && item.Status == SchemaObjectStatus.Normal)
                        {
                            PC.Executors.SCObjectOperations.InstanceWithPermissions.MoveObjectToOrganization(null, item, org);
                        }
                        else
                        {
                            errors.Add(string.Format("{0}不是有效的群组,已跳过", item.ToDescription()));
                        }
                    }
                    catch (Exception ex)
                    {
                        WebUtility.ShowClientError(ex);
                        errors.Add(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex);
                errors.Add(ex);
            }

            this.InnerRefreshList();             // 必须的
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId = Request.QueryString["id"];

            this.Page.Response.CacheControl = "no-cache";

            Util.InitSecurityContext(this.notice);

            if (Page.IsPostBack == false)
            {
                var user = (SCUser)DbUtil.GetEffectiveObject(userId, null);

                this.UserObject = user.ToSimpleObject();

                this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default");
                this.CurrentAdvancedSearchCondition          = new PageAdvancedSearchCondition();

                this.gridMain.PageSize     = this.grid2.PageSize = ProfileUtil.PageSize;
                this.views.ActiveViewIndex = ProfileUtil.GeneralViewModeIndex;
            }

            if (Request.QueryString["view"] == "boss")
            {
                this.tabBosses.Attributes.Add("class", "pc-active");
                this.grid2.GridTitle = this.gridMain.GridTitle = "上司列表";
            }
            else
            {
                this.tabSecretaries.Attributes.Add("class", "pc-active");
                this.grid2.GridTitle = this.gridMain.GridTitle = "秘书列表";
            }

            this.binding1.Data      = this.UserObject;
            this.searchBinding.Data = this.CurrentAdvancedSearchCondition;
        }
Esempio n. 3
0
        private void DoDelete(IEnumerable <string> keys)
        {
            try
            {
                Util.EnsureOperationSafe();
                DbUtil.GetEffectiveObject(this.AppObject);

                var actor        = SCObjectOperations.InstanceWithPermissions;
                var adapter      = SchemaObjectAdapter.Instance;
                var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                var objects = DbUtil.LoadAndCheckObjects("角色", errorAdapter, keys.ToArray());

                foreach (SCRole role in objects)
                {
                    try
                    {
                        actor.DeleteRole(role);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("删除角色 {0} 时出错:{1}", role.DisplayName, ex.Message));
                        MCS.Web.Library.WebUtility.ShowClientError(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 4
0
        protected void AddExistMembers(object sender, EventArgs e)
        {
            try
            {
                Util.EnsureOperationSafe();

                var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                SCOrganization parent = (SCOrganization)DbUtil.GetEffectiveObject(this.ParentOrganization);
                this.ParentOrganization = parent.ToSimpleObject();

                var users = DbUtil.LoadAndCheckObjects("人员", errorAdapter, this.GetPostedKeys());
                foreach (SCUser user in users)
                {
                    try
                    {
                        SCObjectOperations.InstanceWithPermissions.AddUserToOrganization(user, parent);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("无法添加人员 {0} :{1}", user.DisplayName, ex.Message));
                        WebUtility.ShowClientError(ex);
                    }
                }

                this.InnerRefreshList();
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex);
                this.notice.AddErrorInfo(ex);
            }
        }
Esempio n. 5
0
        private void DoDelete(IEnumerable <string> keys)
        {
            try
            {
                Util.EnsureOperationSafe();
                var grp = (SCGroup)DbUtil.GetEffectiveObject(this.GroupObject);

                var actor        = SCObjectOperations.InstanceWithPermissions;
                var adapter      = SchemaObjectAdapter.Instance;
                var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                var objects = DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys.ToArray());

                foreach (SCUser user in objects)
                {
                    try
                    {
                        actor.RemoveUserFromGroup(user, grp);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("替群组移除人员 {0} 时出错:{1}", user.DisplayName, ex.Message));
                        MCS.Web.Library.WebUtility.ShowClientError(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string roleId = Request.QueryString["role"];

            Util.InitSecurityContext(this.notice1);

            this.Page.Response.CacheControl = "no-cache";

            if (Page.IsPostBack == false)
            {
                var role = (SCRole)DbUtil.GetEffectiveObject(roleId, null);
                var app  = role.CurrentApplication;

                this.RoleAndAppObject = new RoleAndAppData()
                {
                    AppID = app.ID, AppCodeName = app.CodeName, AppDisplayName = app.DisplayName, RoleCodeName = role.CodeName, RoleDisplayName = role.DisplayName, RoleID = role.ID, RoleName = role.Name
                };

                this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default");
                this.CurrentAdvancedSearchCondition          = new PageAdvancedSearchCondition();

                this.gridMain.PageSize     = this.grid2.PageSize = ProfileUtil.PageSize;
                this.views.ActiveViewIndex = ProfileUtil.GeneralViewModeIndex;
            }

            this.binding1.Data      = this.RoleAndAppObject;
            this.searchBinding.Data = this.CurrentAdvancedSearchCondition;
        }
Esempio n. 7
0
        private void DoDelete(string[] funKeys)
        {
            try
            {
                Util.EnsureOperationSafe();
                DbUtil.GetEffectiveObject(this.AppObject);

                var actor   = SCObjectOperations.InstanceWithPermissions;
                var adapter = SchemaObjectAdapter.Instance;

                var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                var objects = DbUtil.LoadAndCheckObjects("功能", errorAdapter, funKeys);

                foreach (SCPermission permission in objects)
                {
                    try
                    {
                        actor.DeletePermission(permission);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("删除功能 {0} 时出错:{1}", permission.DisplayName, ex.Message));
                        MCS.Web.Library.WebUtility.ShowClientError(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 8
0
        private void DoDelete(IEnumerable <string> keys)
        {
            try
            {
                Util.EnsureOperationSafe();
                var mySelf = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);

                var actor   = SCObjectOperations.InstanceWithPermissions;
                var adapter = SchemaObjectAdapter.Instance;
                ISecretaryAction executor = this.GetAction();
                var errorAdapter          = new ListErrorAdapter(this.notice.Errors);

                var objects = DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys.ToArray());

                foreach (SCUser user in objects)
                {
                    try
                    {
                        executor.DoRemove(user, mySelf);
                    }
                    catch (Exception ex)
                    {
                        this.notice.AddErrorInfo(string.Format("指定秘书/上司关系人员 {0} 时出错:{1}", user.DisplayName, ex.Message));
                        MCS.Web.Library.WebUtility.ShowClientError(ex);
                    }

                    this.InnerRefreshList();
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["role"];

            Util.InitSecurityContext(this.notice);

            this.Page.Response.CacheControl = "no-cache";

            if (Page.IsPostBack == false)
            {
                this.RoleObject = DbUtil.GetEffectiveObject <SCRole>(id).ToSimpleObject();

                this.gridMain.PageSize = ProfileUtil.PageSize;
            }

            this.binding1.Data = this.RoleObject;
        }
Esempio n. 10
0
        private void DoDeleteItem(string grpKey)
        {
            try
            {
                var grp = (SCGroup)DbUtil.GetEffectiveObject(grpKey, string.Format("指定的群组(ID:{0})无效", grpKey));

                var user = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);

                SCObjectOperations.InstanceWithPermissions.RemoveUserFromGroup(user, grp);
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex);
                this.notice.AddErrorInfo(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 11
0
        private bool InitState()
        {
            string ouID   = WebUtility.GetRequestQueryString("ou", string.Empty);
            bool   result = true;

            try
            {
                SchemaObjectBase parent = DbUtil.GetEffectiveObject(ouID, null);

                this.ParentOrganization = parent.ToSimpleObject();
                this.hfOuParentId.Value = parent.ID == SCOrganization.RootOrganizationID ? string.Empty : DbUtil.GetParentOURelation(parent.ID).ParentID;
            }
            catch (ObjectNotFoundException)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string groupId = Request.QueryString["id"];

            Util.InitSecurityContext(this.notice);

            this.calcProgress.Tag = groupId;

            if (Page.IsPostBack == false)
            {
                this.GroupObject   = DbUtil.GetEffectiveObject(groupId, null).ToSimpleObject();
                this.GroupParentId = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.GroupObject.ID).Find(m => m.Status == SchemaObjectStatus.Normal && m.ParentSchemaType == "Organizations").ParentID;

                this.binding1.Data = this.GroupObject;

                this.gridMain.InitialData = new Services.ConditionSvc().GetGroupConditions(groupId);
                this.gridMain.DataBind();
            }
        }
Esempio n. 13
0
        protected void HandleAddUser(object sender, EventArgs e)
        {
            string[] keys = this.GetPostedKeys();

            if (keys.Length > 0)
            {
                try
                {
                    Util.EnsureOperationSafe();
                    var adapter      = SchemaObjectAdapter.Instance;
                    var myself       = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);
                    var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                    ISecretaryAction executor = this.GetAction();

                    foreach (SCUser user in DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys))
                    {
                        try
                        {
                            executor.DoAdd(user, myself);
                        }
                        catch (Exception ex)
                        {
                            this.notice.AddErrorInfo(ex);
                            MCS.Web.Library.WebUtility.ShowClientError(ex);
                        }
                    }

                    this.InnerRefreshList();
                }
                catch (Exception ex)
                {
                    this.notice.AddErrorInfo(ex);
                    MCS.Web.Library.WebUtility.ShowClientError(ex);
                }
            }
            else
            {
                this.notice.Text       = "在执行操作前至少应选择一个项目";
                this.notice.RenderType = WebControls.NoticeType.Info;
            }
        }
Esempio n. 14
0
        private void DoChangeOwner(string orgKey)
        {
            try
            {
                var org = (SCOrganization)DbUtil.GetEffectiveObject(orgKey, string.Format("指定的组织(ID:{0})无效", orgKey));

                var user = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);

                SCObjectOperations.InstanceWithPermissions.ChangeOwner(user, org);

                this.InitUserAndDefaultOrganization(this.UserObject.ID);
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                WebUtility.RegisterClientErrorMessage(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId = Request.QueryString["id"];

            Util.InitSecurityContext(this.notice);

            this.Page.Response.CacheControl = "no-cache";

            if (Page.IsPostBack == false)
            {
                this.UserObject = DbUtil.GetEffectiveObject <SCUser>(userId).ToSimpleObject();

                this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default");
                this.CurrentAdvancedSearchCondition          = new PageAdvancedSearchCondition();

                this.gridMain.PageSize = ProfileUtil.PageSize;
            }

            this.binding1.Data      = this.UserObject;
            this.searchBinding.Data = this.CurrentAdvancedSearchCondition;
        }
Esempio n. 16
0
        private bool InitState()
        {
            string ouID   = WebUtility.GetRequestQueryString("ou", string.Empty);
            bool   result = true;

            try
            {
                SCOrganization   parent         = DbUtil.GetEffectiveObject <SCOrganization>(ouID);
                SCRelationObject parentRelation = DbUtil.GetParentOURelation(parent.ID);

                this.ParentOrganization = parent.ToSimpleObject();
                this.StartFullPath      = parentRelation != null ? parentRelation.FullPath : string.Empty;
                this.hfOuParentId.Value = parent.ID == SCOrganization.RootOrganizationID ? string.Empty : parentRelation.ParentID;
            }
            catch (ObjectNotFoundException)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 17
0
        private void DoSave()
        {
            SCConditionCollection conditions = this.gridMain.InitialData as SCConditionCollection;

            if (conditions != null)
            {
                var owner = PC.Adapters.SCConditionAdapter.Instance.Load(this.GroupObject.ID, "Default") ?? new SCConditionOwner()
                {
                    OwnerID = this.GroupObject.ID, Type = "Default"
                };

                var ownerConditions = owner.Conditions;

                owner.OwnerID = this.GroupObject.ID;

                owner.Conditions.ReplaceItemsWith(conditions, this.GroupObject.ID, "Default");

                try
                {
                    Util.EnsureOperationSafe();
                    DbUtil.GetEffectiveObject(this.GroupObject);

                    PC.Executors.SCObjectOperations.InstanceWithPermissions.UpdateGroupConditions(owner);
                    this.msg.Text             = "条件已保存完成";
                    this.gridMain.InitialData = new Services.ConditionSvc().GetGroupConditions(this.GroupObject.ID);
                    this.gridMain.DataBind();

                    if (this.chkAutoCalc.Checked)
                    {
                        this.postScript.Text = Util.SurroundScriptBlock("Sys.Application.add_init(function(){ document.getElementById('btnRecalc').click();});");
                    }
                }
                catch (Exception ex)
                {
                    WebUtility.ShowClientError(ex.GetRealException());
                    this.notice.AddErrorInfo(ex);
                    this.msg.Text = "操作遇到错误,可能没有成功保存条件";
                }
            }
        }
Esempio n. 18
0
        protected void HandleAddUser(object sender, EventArgs e)
        {
            try
            {
                string[] keys = this.GetPostedKeys();
                if (keys.Length > 0)
                {
                    var adapter  = SchemaObjectAdapter.Instance;
                    var executor = SCObjectOperations.InstanceWithPermissions;

                    var errorAdapter = new ListErrorAdapter(this.notice.Errors);

                    Util.EnsureOperationSafe();
                    var group = (SCGroup)DbUtil.GetEffectiveObject(this.GroupObject);

                    var objects = DbUtil.LoadAndCheckObjects("人员", errorAdapter, keys);

                    foreach (SCUser user in objects)
                    {
                        try
                        {
                            executor.AddUserToGroup(user, group);
                        }
                        catch (Exception ex)
                        {
                            this.notice.AddErrorInfo(string.Format("向群组添加人员 {0} 时发生错误:{1}", user.DisplayName, ex.Message));
                            MCS.Web.Library.WebUtility.ShowClientError(ex);
                        }
                    }

                    this.InnerRefreshList();
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex.Message);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }
        }
Esempio n. 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];

            Util.InitSecurityContext(this.notice);

            this.Page.Response.CacheControl = "no-cache";

            if (Page.IsPostBack == false)
            {
                this.UserObject = DbUtil.GetEffectiveObject(id, string.Format("指定的群组(ID:{0})无效", id)).ToSimpleObject();

                this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default");
                this.CurrentAdvancedSearchCondition          = new PageAdvancedSearchCondition();

                this.gridMain.PageSize     = this.grid2.PageSize = ProfileUtil.PageSize;
                this.views.ActiveViewIndex = ProfileUtil.GeneralViewModeIndex;
            }

            this.binding1.Data      = this.UserObject;
            this.searchBinding.Data = this.CurrentAdvancedSearchCondition;
        }
Esempio n. 20
0
        private void DoRemoveFromOrg(string orgKey)
        {
            try
            {
                var org = (SCOrganization)DbUtil.GetEffectiveObject(orgKey, string.Format("指定的组织(ID:{0})无效", orgKey));

                var user = (SCUser)DbUtil.GetEffectiveObject(this.UserObject);

                SCObjectOperations.InstanceWithPermissions.DeleteObjectsRecursively(new SchemaObjectCollection()
                {
                    user
                }, org);

                this.InitUserAndDefaultOrganization(this.UserObject.ID);
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
                WebUtility.RegisterClientErrorMessage(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string groupId = Request.QueryString["id"];

            Util.InitSecurityContext(this.notice);

            this.Page.Response.CacheControl = "no-cache";

            if (Page.IsPostBack == false)
            {
                this.GroupObject   = DbUtil.GetEffectiveObject(groupId, null).ToSimpleObject();
                this.GroupParentId = SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.GroupObject.ID).Find(m => m.Status == SchemaObjectStatus.Normal).ParentID;

                this.DeluxeSearch.UserCustomSearchConditions = DbUtil.LoadSearchCondition(ThisPageSearchResourceKey, "Default");
                this.CurrentAdvancedSearchCondition          = new PageAdvancedSearchCondition();

                this.gridMain.PageSize     = this.grid2.PageSize = ProfileUtil.PageSize;
                this.views.ActiveViewIndex = ProfileUtil.GeneralViewModeIndex;
            }

            this.binding1.Data      = this.GroupObject;
            this.searchBinding.Data = this.CurrentAdvancedSearchCondition;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string roleId = Request.QueryString["role"];

            Util.InitSecurityContext(this.notice);

            if (Page.IsPostBack == false)
            {
                var role = DbUtil.GetEffectiveObject <PC.SCRole>(roleId);
                var app  = role.CurrentApplication;

                this.RoleAndAppObject = new RoleAndAppData()
                {
                    AppID = app.ID, AppCodeName = app.CodeName, AppName = app.Name, RoleID = role.ID, RoleCodeName = role.CodeName, RoleDisplayName = role.DisplayName, RoleName = role.Name
                };

                this.binding1.Data = this.RoleAndAppObject;                 // 绑定数据

                this.gridMain.InitialData = new Services.ConditionSvc().GetRoleConditions(roleId);
                this.gridMain.DataBind();
            }

            this.calcProgress.Tag = roleId;
        }
Esempio n. 23
0
        private void DoDelete(IEnumerable <string> keys)
        {
            try
            {
                Util.EnsureOperationSafe();
                var role         = (SCRole)DbUtil.GetEffectiveObject(this.RoleAndAppObject.RoleID, null);
                var actor        = SCObjectOperations.InstanceWithPermissions;
                var errorAdapter = new ListErrorAdapter(this.notice1.Errors);

                var objects = DbUtil.LoadAndCheckObjects("应用", errorAdapter, keys.ToArray());

                foreach (SCBase obj in objects)
                {
                    actor.RemoveMemberFromRole(obj, role);
                }
            }
            catch (Exception ex)
            {
                this.notice1.Errors.Add(ex);
                MCS.Web.Library.WebUtility.ShowClientError(ex);
            }

            this.InnerRefreshList();
        }
Esempio n. 24
0
        protected void DoDeepFileUpload(HttpPostedFile file, MCS.Web.WebControls.UploadProgressResult result)
        {
            if (Path.GetExtension(file.FileName).ToLower() != ".xml")
            {
                throw new InvalidDataException("上传的文件类型错误");
            }

            string oguId = Request.Form["parentId"];

            if (string.IsNullOrEmpty(oguId))
            {
                throw new HttpException("没有使用parentId");
            }

            Util.EnsureOperationSafe();

            PC.SCOrganization parent = oguId == PC.SCOrganization.RootOrganizationID ? PC.SCOrganization.GetRoot() : (PC.SCOrganization)DbUtil.GetEffectiveObject(oguId, "当前组织不存在或已删除");

            ImportExecutor executor = new ImportExecutor(file, result);

            if (Request.Form["includeAcl"] == "includeAcl")
            {
                executor.AddAction(new OguAclImportAction(parent)
                {
                });
            }

            if (Request.Form["includeUser"] == "includeUser")
            {
                executor.AddAction(new OguUserImportAction(parent)
                {
                    IncludeSecretaries = Request.Form["includeSecretary"] == "includeSecretary"
                });
            }

            if (Request.Form["includeGroup"] == "includeGroup")
            {
                executor.AddAction(new OguGroupImportAction(parent)
                {
                    IncludeConditions = Request.Form["includeGroupConditions"] == "includeGroupConditions",
                    IncludeMembers    = Request.Form["includeGroupMembers"] == "includeGroupMembers"
                });
            }

            executor.AddAction(new OguFullImportAction(parent)
            {
                IncludeOrganizations   = this.Request.Form["includeOrg"] == "includeOrg",
                IncludeAcl             = this.Request.Form["includeAcl"] == "includeAcl",
                IncludeUser            = this.Request.Form["includeUser"] == "includeUser",
                IncludeSecretaries     = this.Request.Form["includeSecretary"] == "includeSecretary",
                IncludeGroup           = this.Request.Form["includeGroup"] == "includeGroup",
                IncludeGroupConditions = this.Request.Form["includeGroupConditions"] == "includeGroupConditions",
                IncludeGroupMembers    = this.Request.Form["includeGroupMembers"] == "includeGroupMembers"
            });

            executor.Execute();
        }
Esempio n. 25
0
        protected void SaveClick(object sender, EventArgs e)
        {
            try
            {
                Util.EnsureOperationSafe();
                var role = (SCRole)DbUtil.GetEffectiveObject(this.RoleObject, "角色不存在或已被删除");

                string strToAdd    = this.hfAdded.Value;
                string strToRemove = this.hfRemoved.Value;

                var actor   = SCObjectOperations.InstanceWithPermissions;
                var adapter = SchemaObjectAdapter.Instance;
                if (strToAdd.Length > 0)
                {
                    foreach (string key in strToAdd.Split(Util.CommaSpliter, StringSplitOptions.RemoveEmptyEntries))
                    {
                        try
                        {
                            var permission = (SCPermission)adapter.Load(key);
                            if (permission == null || permission.Status != SchemaObjectStatus.Normal)
                            {
                                throw new InvalidOperationException("指定的权限无效");
                            }
                            actor.JoinRoleAndPermission(role, permission);
                        }
                        catch (Exception ex)
                        {
                            this.notice.AddErrorInfo(ex);
                        }
                    }
                }

                if (strToRemove.Length > 0)
                {
                    foreach (string key in strToRemove.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        try
                        {
                            var permission = (SCPermission)adapter.Load(key);
                            if (permission == null || permission.Status != SchemaObjectStatus.Normal)
                            {
                                throw new InvalidOperationException("指定的权限无效");
                            }
                            actor.DisjoinRoleAndPermission(role, permission);
                        }
                        catch (Exception ex)
                        {
                            this.notice.AddErrorInfo(ex);
                        }
                    }
                }

                this.hfAdded.Value   = string.Empty;
                this.hfRemoved.Value = string.Empty;
                if (this.notice.HasErrors == false)
                {
                    this.notice.Text       = "权限设置成功。";
                    this.notice.RenderType = WebControls.NoticeType.Info;
                    this.preScript.Text    = Util.SurroundScriptBlock("window.close();");
                }
            }
            catch (Exception ex)
            {
                this.notice.AddErrorInfo(ex);
            }
        }
Esempio n. 26
0
        protected void DoDeleteProgressFull(object sender, PostProgressDoPostedDataEventArgs e)
        {
            var parent = (SCOrganization)DbUtil.GetEffectiveObject(this.deleteFullProgress.Tag, null);

            DeleteProgressNextStepDestroyUsers(e, parent);
        }
Esempio n. 27
0
 public OUTransferExecutor(string orgKey, string[] src, string[] target)
     : base(src, target)
 {
     orgKey.NullCheck("orgKey");
     this.parent = (SCOrganization)DbUtil.GetEffectiveObject(orgKey, null);
 }
Esempio n. 28
0
 internal static SCBase GetEffectiveObject(SCSimpleObject obj)
 {
     return(DbUtil.GetEffectiveObject(obj, null));
 }