Beispiel #1
0
            private void DoImportConditions(SCObjectSet objectSet, IImportContext context, PC.SCGroup group)
            {
                if (this.ImportConditions && objectSet.HasConditions)
                {
                    context.SetStatusAndLog(Owner.currentSteps, Owner.allSteps, string.Format("正在替换群组 {0} 的条件", group.Name));

                    try
                    {
                        var owner = PC.Adapters.SCConditionAdapter.Instance.Load(group.ID, "Default") ?? new PC.Conditions.SCConditionOwner()
                        {
                            OwnerID = group.ID, Type = "Default"
                        };

                        PC.Conditions.SCConditionCollection src = new PC.Conditions.SCConditionCollection();
                        src.CopyFrom(ImportService.Instance.FilterConditions(objectSet.Conditions, c => c.OwnerID == group.ID));

                        owner.Conditions.ReplaceItemsWith(src, group.ID, "Default");

                        PC.Adapters.SCConditionAdapter.Instance.UpdateConditions(owner);
                    }
                    catch (Exception ex)
                    {
                        context.AppendLog(string.Format("替换群组 {0} 条件成员时出错:{1}", group.ToDescription(), ex.ToString()));
                    }
                }
            }
Beispiel #2
0
            private void DoImportMembers(SCObjectSet objectSet, IImportContext context, IDictionary <string, PC.SchemaObjectBase> knownObjects, PC.SCGroup group)
            {
                if (this.ImportMembers && objectSet.HasMembership)
                {
                    var members = ImportService.Instance.FilterMembership(objectSet.Membership, m => m.ContainerID == group.ID && m.Status == SchemaObjectStatus.Normal).ToArray();
                    if (members.Length > 0)
                    {
                        context.SetStatus(Owner.currentSteps, Owner.allSteps, string.Format("正在查找群组 {0} 的固定成员", group.ToDescription()));

                        for (int j = 0; j < members.Length; j++)
                        {
                            try
                            {
                                var gm = members[j];

                                ImportService.Instance.WithEffectObject <PC.SCUser>(gm.ID, knownObjects, user =>
                                {
                                    context.SetSubStatusAndLog(j, members.Length, string.Format("正在向群组 {0} 添加成员 {1} ", group.Name, user.Name));
                                    PC.Executors.SCObjectOperations.Instance.AddUserToGroup(user, group);
                                }, null);
                            }
                            catch (Exception ex2)
                            {
                                context.SetSubStatusAndLog(j, members.Length, string.Format("向群组 {0} 添加成员时出错:", group.ToDescription(), ex2.ToString()));
                            }
                        }
                    }
                }
            }