Example #1
0
        private static Dictionary <string, SCSimpleObject> PrepareParentsList(string navOu)
        {
            Dictionary <string, SCSimpleObject> result = null;

            if (navOu != SCOrganization.RootOrganizationID)
            {
                Dictionary <string, SCSimpleObjectCollection> parents = PC.Adapters.SCSnapshotAdapter.Instance.LoadAllParentsInfo(true, navOu);

                if (parents != null && parents.ContainsKey(navOu))
                {
                    Dictionary <string, SCSimpleObject> queue = parents[navOu].ToDictionary();

                    result = parents[navOu].ToDictionary();
                }
            }
            else
            {
                SCOrganization root = SCOrganization.GetRoot();

                result = new Dictionary <string, SCSimpleObject>()
                {
                    { root.ID, root.ToSimpleObject() }
                };
            }

            return(result);
        }
Example #2
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);
            }
        }
Example #3
0
        protected override void OnPreRender(EventArgs e)
        {
            if (string.IsNullOrEmpty(this.lastVisitOrg.Value) == false)
            {
                this.Response.Redirect("OUExplorer.aspx?ou=" + Server.UrlEncode(this.lastVisitOrg.Value), true);
            }
            else
            {
                base.OnPreRender(e);

                SCOrganization root = SCOrganization.GetRoot();

                if (this.IsPostBack == false)
                {
                    this.navOUID.Value = WebUtility.GetRequestQueryString("ou", root.ID);
                }

                DeluxeTreeNode rootTreeNode = CreateTreeNode(root.ID, root.Name, root.DisplayName, string.Empty);

                rootTreeNode.Expanded = true;
                this.tree.Nodes.Add(rootTreeNode);

                rootTreeNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.Normal;

                Dictionary <string, SCSimpleObject> parentsList = PrepareParentsList(this.navOUID.Value);

                PrepareTreeNodeRecursively(root.ToSimpleObject(), rootTreeNode, parentsList, Util.GetTime(), this.navOUID.Value);
            }
        }
Example #4
0
        protected void InitUserAndDefaultOrganization(string id)
        {
            SCUser user = (SCUser)SchemaObjectAdapter.Instance.Load(id);

            (user != null).FalseThrow <ObjectNotFoundException>("不能找到ID为{0}的用户", id);
            (user.Status == SchemaObjectStatus.Normal).FalseThrow <ObjectNotFoundException>("ID为{0}的用户的状态已经失效了", id);

            this.UserObject = user.ToSimpleObject();

            SCOrganization defOrg = (SCOrganization)user.CurrentParentRelations.GetDefaultParent();

            this.DefaultOrg = defOrg != null?defOrg.ToSimpleObject() : null;

            this.OwnerID   = user.OwnerID;
            this.OwnerName = user.OwnerName;
        }
Example #5
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);
        }