Esempio n. 1
0
 public OUTransferExecutor(string orgKey, string[] src, string[] target)
     : base(src, target)
 {
     orgKey.NullCheck("orgKey");
     this.parent = (SCOrganization)DbUtil.GetEffectiveObject(orgKey, null);
 }
Esempio n. 2
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. 3
0
        protected void DoDeleteProgressFull(object sender, PostProgressDoPostedDataEventArgs e)
        {
            var parent = (SCOrganization)DbUtil.GetEffectiveObject(this.deleteFullProgress.Tag, null);

            DeleteProgressNextStepDestroyUsers(e, parent);
        }
Esempio n. 4
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. 5
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();
        }