示例#1
0
        /// <summary>
        /// 生成所有的用户容器下的用户信息快照
        /// </summary>
        public void GenerateAllItemAndContainerSnapshot()
        {
            ProcessProgress.Current.MinStep     = 0;
            ProcessProgress.Current.MaxStep     = 100;
            ProcessProgress.Current.CurrentStep = 0;
            ProcessProgress.Current.StatusText  = string.Format("正在加载所有管理范围");
            ProcessProgress.Current.Response();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            try
            {
                AUCommon.DoDbAction(() =>
                {
                    SchemaObjectCollection containers = AUCommon.DoDbProcess <SchemaObjectCollection>(() => PC.Adapters.SchemaObjectAdapter.Instance.LoadBySchemaType(new string[] { AUCommon.SchemaAUAdminScope }, DateTime.MinValue));

                    containers.Sort((c1, c2) => string.Compare(c1.SchemaType, c2.SchemaType, true));

                    ProcessProgress.Current.StatusText = string.Format("加载所有管理范围完成,总共{0}个对象", containers.Count);
                    ProcessProgress.Current.MaxStep    = containers.Count;

                    ProcessProgress.Current.Response();

                    containers.ForEach(c => this.GenerateOneItemAndContainerSnapshot((IAdminScopeItemContainer)c));
                });
            }
            finally
            {
                sw.Stop();
            }

            ProcessProgress.Current.StatusText = string.Format("计算人员完成,耗时{0:#,##0.00}秒", sw.Elapsed.TotalSeconds);
            ProcessProgress.Current.Response();
        }
示例#2
0
        public ClientAURole GetAURoleBySchemaRoleID(string unitID, string schemaRoleID, bool normalOnly)
        {
            unitID.NullCheck("unitID"); schemaRoleID.NullCheck("schemaRoleID");
            AURole result = null;
            var    unit   = AUCommon.DoDbProcess(() =>
                                                 (AdminUnit)SchemaObjectAdapter.Instance.Load(unitID));

            if (unit != null && normalOnly)
            {
                unit = unit.Status == SchemaObjectStatus.Normal ? unit : null;
            }

            if (unit != null)
            {
                var schemaRole = (AUSchemaRole)AUCommon.DoDbProcess(() => SchemaObjectAdapter.Instance.Load(schemaRoleID));
                if (schemaRole != null && normalOnly)
                {
                    schemaRole = schemaRole.Status == SchemaObjectStatus.Normal ? schemaRole : null;
                }

                if (schemaRole != null)
                {
                    result = AUSnapshotAdapter.Instance.LoadAURole(schemaRole.ID, unitID, normalOnly, SimpleRequestSoapMessage.Current.TimePoint);
                }
            }

            return(result != null ? (ClientAURole)result.ToClientSchemaObject() : null);
        }
示例#3
0
 private string GetUnitFullPath(string unitID)
 {
     return(AUCommon.DoDbProcess(() =>
     {
         var relation = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByObjectID(new string[] { unitID }).Where(m => m.ChildSchemaType == AUCommon.SchemaAdminUnit && m.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal && (m.ParentSchemaType == AUCommon.SchemaAdminUnit || m.ParentSchemaType == AUCommon.SchemaAUSchema)).FirstOrDefault();
         return relation != null ? relation.FullPath : string.Empty;
     }));
 }
示例#4
0
        public ClientSchemaObjectBase[] GetContainers(string id, string[] containerSchemaTypes, bool normalOnly)
        {
            id.NullCheck("id");

            string[] containers = AUCommon.DoDbProcess(() =>
                                                       SCMemberRelationAdapter.Instance.LoadByMemberID(id, containerSchemaTypes, normalOnly, SimpleRequestSoapMessage.Current.TimePoint).ToContainerIDArray());

            return(GetObjectByIDInner(containers, containerSchemaTypes, normalOnly));
        }
示例#5
0
        public ClientSchemaObjectBase[] GetChildren(string id, string[] childSchemaTypes, bool normalOnly)
        {
            childSchemaTypes.NullCheck("childSchemaTypes");

            string[] childrenIds = AUCommon.DoDbProcess(() =>
                                                        SchemaRelationObjectAdapter.Instance.LoadByParentID(id, normalOnly, SimpleRequestSoapMessage.Current.TimePoint).ToIDArray());

            return(GetObjectByIDInner(childrenIds, childSchemaTypes, normalOnly));
        }
示例#6
0
        public ClientSchemaMember[] GetMemberships(string containerID, string[] memberSchemaTypes, bool normalOnly)
        {
            containerID.NullCheck("id");
            memberSchemaTypes.NullCheck("memberSchemaTypes");

            var memberships = AUCommon.DoDbProcess(() =>
                                                   SCMemberRelationAdapter.Instance.LoadByContainerID(containerID, memberSchemaTypes, normalOnly, SimpleRequestSoapMessage.Current.TimePoint));

            return(memberships.ToClientSchemaObjectBaseObjectArray <SCSimpleRelationBase, ClientSchemaMember>());
        }
        protected override void InitializeParent()
        {
            var relation = AUCommon.DoDbProcess(() => SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.ObjectID, AUCommon.SchemaAdminUnit).Find(m => m.Status == SchemaObjectStatus.Normal));

            if (relation != null)
            {
                this.ParentID = relation.ParentID;
            }
            else
            {
                this.ParentID = string.Empty;
            }
        }
示例#8
0
        private static void ValidateCodeName(string codeName, string parentID, ValidationResult result)
        {
            if (string.IsNullOrEmpty(codeName))
            {
                result.CodeNameValidationResult = "代码名称不得为空";
                result.Passed = false;
            }
            else
            {
                var codeNameValid = AUCommon.DoDbProcess <bool>(() => CodeNameUniqueValidatorFacade.Validate(codeName, "SomeNewID", AUCommon.SchemaAdminUnit, parentID, false, false, DateTime.MinValue));

                result.Passed &= codeNameValid;
                result.CodeNameValidationResult = codeNameValid ? "通过" : string.Format("指定的代码名称 {0} 已经被其他对象使用,请使用其他名称。", codeName);
            }
        }
示例#9
0
        public ClientSchemaObjectBase[] GetParents(string id, string[] parentSchemaTypes, bool normalOnly)
        {
            parentSchemaTypes.NullCheck("parentSchemaTypes");

            var parentRelations = AUCommon.DoDbProcess(() => SchemaRelationObjectAdapter.Instance.LoadByObjectID(id, normalOnly == false, SimpleRequestSoapMessage.Current.TimePoint));

            string[] ids = new string[parentRelations.Count];

            for (int i = 0; i < ids.Length; i++)
            {
                ids[i] = parentRelations[i].ParentID;
            }

            return(GetObjectByIDInner(ids, parentSchemaTypes, normalOnly));
        }
示例#10
0
        private static ClientSchemaObjectBase[] GetObjectByIDInner(string[] ids, string[] objectSchemaTypes, bool normalOnly)
        {
            ClientSchemaObjectBase[] result;
            objectSchemaTypes.NullCheck("objectSchemaTypes");

            bool noIDMatch = ids != null && ids.Length == 0;

            if (noIDMatch)
            {
                result = new ClientSchemaObjectBase[0];
            }
            else
            {
                ConnectiveSqlClauseCollection builder = new ConnectiveSqlClauseCollection();
                if (ids != null)
                {
                    InSqlClauseBuilder idInBuilder = new InSqlClauseBuilder("ID");
                    idInBuilder.AppendItem(ids);

                    builder.Add(idInBuilder);
                }

                if (objectSchemaTypes != null)
                {
                    InSqlClauseBuilder typeInBuilder = new InSqlClauseBuilder("SchemaType");
                    typeInBuilder.AppendItem(objectSchemaTypes);
                    builder.Add(typeInBuilder);
                }

                if (normalOnly)
                {
                    builder.Add((IConnectiveSqlClause) new WhereSqlClauseBuilder().AppendItem("Status", (int)SchemaObjectStatus.Normal));
                }

                if (builder.IsEmpty == false)
                {
                    result = AUCommon.DoDbProcess(() => SchemaObjectAdapter.Instance.Load(builder, SimpleRequestSoapMessage.Current.TimePoint).ToClientSchemaObjectBaseObjectArray());
                }
                else
                {
                    result = new ClientSchemaObjectBase[0];
                }
            }

            return(result);
        }
示例#11
0
        public ClientSchemaObjectBase[] GetObjectsByCodeNames(string[] codeNames, string[] objectSchemaTypes, bool normalOnly)
        {
            codeNames.NullCheck("codeNames");
            objectSchemaTypes.NullCheck("objectsSchemaTypes");

            if (codeNames.Length > 0)
            {
                SchemaObjectCollection pcObjects = AUCommon.DoDbProcess(() =>
                                                                        SchemaObjectAdapter.Instance.LoadByCodeNameAndSchema(objectSchemaTypes, codeNames, normalOnly, false, SimpleRequestSoapMessage.Current.TimePoint));

                return(pcObjects.ToClientSchemaObjectBaseObjectArray());
            }
            else
            {
                return(new ClientSchemaObjectBase[0]);
            }
        }
示例#12
0
        public void ReplaceAclRecursively(string ownerID, bool force)
        {
            var owner = AUCommon.DoDbProcess(() => SchemaObjectAdapter.Instance.Load(ownerID));

            if (owner == null || owner.Status != SchemaObjectStatus.Normal)
            {
                throw new InvalidOperationException("未能根据ownerID检索到有效对象");
            }

            if (owner is ISCAclContainer)
            {
                Facade.ReplaceAclRecursively((ISCAclContainer)owner, force);
            }
            else
            {
                throw new InvalidOperationException("ownerID指定的对象不实现ISAclContainer");
            }
        }
示例#13
0
        public static ValidationResult DoClientValidation(string schemaID, string parentID, string name, string codeName)
        {
            ValidationResult result = new ValidationResult();

            ValidateCodeName(codeName, parentID, result);

            if (result.Passed)
            {
                var schema = (AU.AUSchema)AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchema(schemaID, true, DateTime.MinValue).FirstOrDefault();
                SchemaObjectBase targetUnit = null;
                if (schema == null)
                {
                    result.Passed = false;
                    result.TargetValidationResult = "管理架构不存在或已删除";
                }
                else
                {
                    bool hasPermission;
                    hasPermission = AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) || (string.IsNullOrEmpty(schema.MasterRole) == false && DeluxePrincipal.Current.IsInRole(schema.MasterRole));
                    if (parentID == schemaID || parentID == null)
                    {
                        targetUnit = schema;
                    }
                    else
                    {
                        targetUnit = AUCommon.DoDbProcess(() => (AdminUnit)PC.Adapters.SchemaObjectAdapter.Instance.Load(parentID));
                        if (hasPermission == false)
                        {
                            hasPermission = CheckAddSubPermission(schema, (AdminUnit)targetUnit);
                        }
                    }

                    result.Passed &= hasPermission;
                    result.TargetValidationResult = hasPermission ? "通过" : "没有在目标添加子单元的权限";

                    if (result.Passed)
                    {
                        ValidateName(name, codeName, result, schema, targetUnit);
                    }
                }
            }

            return(result);
        }
示例#14
0
        public void UpdateObjectAcl(string ownerID, ClientAclItem[] clientAcls)
        {
            var owner = AUCommon.DoDbProcess(() => SchemaObjectAdapter.Instance.Load(ownerID));

            if (owner == null || owner.Status != SchemaObjectStatus.Normal)
            {
                throw new InvalidOperationException("指定对象不存在或已删除");
            }

            SCAclContainer container = new SCAclContainer(owner);

            foreach (ClientAclItem item in clientAcls)
            {
                if (item.Status == ClientSchemaObjectStatus.Normal)
                {
                    container.Members.Add(item.ToSCAcl());
                }
            }

            container.Members.MergeChangedItems(AUAclAdapter.Instance.LoadByContainerID(ownerID, DateTime.MinValue));

            this.Facade.UpdateObjectAcl(container);
        }
示例#15
0
 public bool ValidateCodeNameUnique(string schemaType, string id, string parentID, string currentValue, bool includingDeleted)
 {
     return(AUCommon.DoDbProcess <bool>(() => CodeNameUniqueValidatorFacade.Validate(currentValue, id, schemaType, parentID, includingDeleted == false, false, DateTime.MinValue)));
 }