Exemple #1
0
        private void PrepareToBeAddedScopes(string[] items, PendingActionCollection pendingActions)
        {
            foreach (string scope in items)
            {
                foreach (AdminUnit au in allCurrentAUs)
                {
                    var existed = Adapters.AUSnapshotAdapter.Instance.LoadAUScope(au.ID, scope, false, false, DateTime.MinValue);
                    if (existed.Count == 0)
                    {
                        pendingActions.Add(new AddMemberAction(au, new AUAdminScope()
                        {
                            ID = UuidHelper.NewUuidString(), ScopeSchemaType = scope
                        }));
                    }
                    else
                    {
                        // 尽量恢复已经删除的Scope,而不是重新创建一个
                        if (existed.GetUniqueNormalObject <AUAdminScope>() == null)
                        {
                            AUAdminScope onlyScope = (AUAdminScope)existed.First();
                            onlyScope.Status = SchemaObjectStatus.Normal;
                            pendingActions.Add(new EnableMemberAction(au, onlyScope));
                        }

                        // 否则,这个Scope已经是正常状态了?
                    }
                }
            }
        }
Exemple #2
0
 private void PrepareToBeDeletedScopes(string[] items, PendingActionCollection pendingActions)
 {
     foreach (string scope in items)
     {
         foreach (AdminUnit au in allCurrentAUs)
         {
             var auScope = Adapters.AUSnapshotAdapter.Instance.LoadAUScope(au.ID, scope, true, DateTime.MinValue).GetUniqueNormalObject <AUAdminScope>();
             if (auScope != null)
             {
                 pendingActions.Add(new ClearConditionAction(auScope));
                 pendingActions.Add(new ClearContainerAction(auScope));
                 pendingActions.Add(new RemoveMemberAction(au, auScope));
             }
         }
     }
 }