Exemplo n.º 1
0
        public void GenerateUserAndContainerSnapshotTest()
        {
            TestRoleData roleData = SCObjectGenerator.PrepareTestRoleWithOrgAndGroup();

            SCConditionCalculator calculator = new SCConditionCalculator();

            ProcessProgress.Clear();
            ProcessProgress.Current.RegisterResponser(TestProgressResponser.Instance);

            calculator.GenerateUserAndContainerSnapshot(new List <ISCUserContainerObject>()
            {
                roleData.Group
            });
            calculator.GenerateUserAndContainerSnapshot(new List <ISCUserContainerObject>()
            {
                roleData.Role
            });

            SameContainerUserAndContainerSnapshotCollection snapshot = UserAndContainerSnapshotAdapter.Instance.LoadByContainerID(roleData.Role.ID);

            Console.WriteLine(roleData.ToString());
            Console.Error.WriteLine("Error: {0}", ProcessProgress.Current.GetDefaultError());
            Console.WriteLine("Output: {0}", ProcessProgress.Current.GetDefaultOutput());

            Assert.IsTrue(snapshot.ContainsKey(roleData.UserInGroup.ID));
            Assert.IsTrue(snapshot.ContainsKey(roleData.UserInOrg.ID));
            Assert.IsTrue(snapshot.ContainsKey(roleData.UserInRole.ID));
            Assert.IsTrue(snapshot.ContainsKey(roleData.UserInConditionRole.ID));
            Assert.IsTrue(snapshot.ContainsKey(roleData.UserInConditionGroup.ID));
        }
Exemplo n.º 2
0
        public void RecalculateAllConditions()
        {
            SCConditionCalculator calculator = new SCConditionCalculator();

            SCCacheHelper.InvalidateAllCache();
            calculator.GenerateAllUserAndContainerSnapshot();
        }
Exemplo n.º 3
0
        public void SimpleConditionTest()
        {
            SCConditionOwner owner = new SCConditionOwner();

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCUser user2 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user2, SCOrganization.GetRoot());

            owner.OwnerID = UuidHelper.NewUuidString();

            string expression = string.Format("Users.CodeName == \"{0}\"", user2.CodeName);

            owner.Conditions.Add(new SCCondition()
            {
                Description = "基本测试", Condition = expression
            });

            SCConditionCalculator calculator = new SCConditionCalculator();

            IEnumerable <SchemaObjectBase> result = calculator.Calculate(owner);

            Assert.AreEqual(1, result.Count());

            foreach (SchemaObjectBase obj in result)
            {
                Console.WriteLine("ID:{0}, Name: {1}", obj.ID, obj.Properties.GetValue("Name", string.Empty));
            }
        }
Exemplo n.º 4
0
        protected void ProcessCaculating(object sender, MCS.Web.WebControls.PostProgressDoPostedDataEventArgs e)
        {
            SCConditionCalculator calc = new SCConditionCalculator();

            calc.GenerateUserAndContainerSnapshot(new[] { (PC.SCGroup)SchemaObjectAdapter.Instance.Load(this.calcProgress.Tag) });

            e.Result.DataChanged = true;
            e.Result.CloseWindow = false;
            e.Result.ProcessLog  = ProcessProgress.Current.GetDefaultOutput();
        }
Exemplo n.º 5
0
        protected void ProcessGlobalCaculating(object sender, MCS.Web.WebControls.PostProgressDoPostedDataEventArgs e)
        {
            SCConditionCalculator calc = new SCConditionCalculator();

            calc.GenerateAllUserAndContainerSnapshot();

            SCCacheHelper.InvalidateAllCache();

            e.Result.DataChanged = true;
            e.Result.CloseWindow = false;
            e.Result.ProcessLog  = ProcessProgress.Current.GetDefaultOutput();
        }
Exemplo n.º 6
0
        public void GenerateAllUserAndContainerSnapshotTest()
        {
            ProcessProgress.Clear();
            ProcessProgress.Current.RegisterResponser(TestProgressResponser.Instance);

            TestRoleData roleData = SCObjectGenerator.PrepareTestRoleWithOrgAndGroup();

            SCConditionCalculator calculator = new SCConditionCalculator();

            calculator.GenerateAllUserAndContainerSnapshot();

            Console.Error.WriteLine("Error: {0}", ProcessProgress.Current.GetDefaultError());
            Console.WriteLine("Output: {0}", ProcessProgress.Current.GetDefaultOutput());
        }
Exemplo n.º 7
0
        public void SimpleGroupConditionsTest()
        {
            SCUser userInGroup;
            SCUser userNotInGroup;

            SCGroup group = SCObjectGenerator.PrepareGroupWithConditions(out userInGroup, out userNotInGroup);

            SCConditionCalculator calculator = new SCConditionCalculator();

            SCConditionOwner owner = SCConditionAdapter.Instance.Load(group.ID, string.Empty);

            SchemaObjectCollection calculateResult = calculator.Calculate(owner);

            ConditionCalculateResultAdapter.Instance.Update(group.ID, calculateResult);

            SchemaObjectCollection loadedResult = ConditionCalculateResultAdapter.Instance.LoadCurrentUsers(group.ID);

            Assert.IsTrue(loadedResult.ContainsKey(userInGroup.ID));
            Assert.IsFalse(loadedResult.ContainsKey(userNotInGroup.ID));
        }
Exemplo n.º 8
0
        public void IsChildAllByIDBuiltInFunctionTest()
        {
            SchemaObjectAdapter.Instance.ClearAllData();

            TestRoleData roleData = SCObjectGenerator.PrepareTestRoleWithOrgAndGroup(data => string.Format("IsChildAll(\"{0}\", \"{1}\")", "Guid", data.SidelineOrganization.ID));

            SCConditionCalculator calculator = new SCConditionCalculator();

            ProcessProgress.Clear();
            ProcessProgress.Current.RegisterResponser(TestProgressResponser.Instance);

            calculator.GenerateUserAndContainerSnapshot(new List <ISCUserContainerObject>()
            {
                roleData.BuiltInFunctionRole
            });

            SameContainerUserAndContainerSnapshotCollection snapshot = UserAndContainerSnapshotAdapter.Instance.LoadByContainerID(roleData.BuiltInFunctionRole.ID);

            Console.WriteLine(roleData.ToString());
            Console.Error.WriteLine("Error: {0}", ProcessProgress.Current.GetDefaultError());
            Console.WriteLine("Output: {0}", ProcessProgress.Current.GetDefaultOutput());

            Assert.IsFalse(snapshot.ContainsKey(roleData.SidelineUserInOrg.ID));
        }