예제 #1
0
        private void ImportApplication(SCObjectSet objectSet, IImportContext context, PC.Executors.ISCObjectOperations executor, int allCount, int currentStep, int extStepCount, Dictionary <object, object> mappings, PC.SCApplication app)
        {
            var app2        = this.CopyMode ? AppImportAction.MakeCopy(app) : app;
            var summaryName = app2.DisplayName ?? app.Name;

            context.SetStatus(currentStep, allCount, "正在导入项目:" + summaryName);
            context.AppendLog("正在导入应用" + summaryName);
            executor.AddApplication((PC.SCApplication)app2);

            var permissionRelation = from p in objectSet.Membership where p.ContainerID == app.ID && p.MemberSchemaType == "Permissions" orderby p.InnerSort ascending select p;
            var permissions        = (from o in objectSet.Objects join p in permissionRelation on o.ID equals p.ID select(PC.SCPermission) o).ToArray();

            var roleRelations = from r in objectSet.Membership where r.ContainerID == app.ID && r.MemberSchemaType == "Roles" orderby r.InnerSort ascending select r;
            var roles         = (from o in objectSet.Objects join r in roleRelations on o.ID equals r.ID select(PC.SCRole) o).ToArray();

            var acls = (from acl in objectSet.Acls where acl.Status == SchemaObjectStatus.Normal && acl.ContainerID == app.ID orderby acl.SortID ascending select acl).ToArray();

            int allStepCount = allCount * (extStepCount + 1);
            int step         = currentStep * (extStepCount + 1);

            if (this.IncludePermissions)
            {
                context.SetStatus(step++, allStepCount, "正在查找功能...");
                this.ImportPermissions(context, executor, mappings, app2, permissions, this.CopyMode);
            }

            if (this.IncludeRoles)
            {
                context.SetStatus(step++, allStepCount, "正在查找角色...");
                this.ImportRoles(context, executor, mappings, app2, roles);
            }

            if (this.IncludeAcls)
            {
                context.SetStatus(step++, allStepCount, "正在查找Acl...");
                this.ImportAcl(context, executor, app2, acls);
            }

            if (this.IncludeRoleMembers)
            {
                context.SetStatus(step++, allStepCount, "正在查找角色成员...");
                this.ImportRoleMembers(objectSet, context, executor, mappings, roles);
            }

            if (this.IncludeRoleConditions)
            {
                context.SetStatus(step++, allStepCount, "正在查找角色条件...");
                this.ImportRoleConditions(objectSet, context, executor, mappings, roles);
            }

            if (this.IncludeRoles && this.IncludePermissions && this.IncludeRoleDefinitions)
            {
                context.SetStatus(step++, allStepCount, "正在查找角色功能定义...");
                this.ImportRolePermissions(objectSet, context, executor, mappings, permissions, roles, this.CopyMode);
            }
        }
예제 #2
0
 private void ImportRoles(IImportContext context, PC.Executors.ISCObjectOperations executor, Dictionary <object, object> mappings, PC.SCApplication app2, PC.SCRole[] roles)
 {
     if (this.IncludeRoles && roles.Length > 0)
     {
         context.AppendLog("正准备导入角色");
         foreach (var p in roles)
         {
             var role2 = this.CopyMode ? AppImportAction.MakeCopy(p) : p;
             mappings.Add(p, role2);
             context.AppendLog("正在导入角色" + role2.ToDescription());
             executor.AddRole(role2, app2);
         }
     }
 }
예제 #3
0
        public override void DoImport(SCObjectSet objectSet, IImportContext context)
        {
            if (string.IsNullOrEmpty(this.ApplicationId))
            {
                throw new HttpException("没有指定ApplicationId的情况下无法导入。");
            }

            var app = (PC.SCApplication)PC.Adapters.SchemaObjectAdapter.Instance.Load(this.ApplicationId);

            if (app == null)
            {
                throw new HttpException("指定的应用并不存在");
            }

            if (objectSet.HasObjects)
            {
                int count    = 0;
                int allCount = 0;
                var exec     = PC.Executors.SCObjectOperations.InstanceWithPermissions;

                IEnumerable <PC.SCSimpleRelationBase> permissionRelations = null;

                if (this.CopyMode)
                {
                    permissionRelations = from r in objectSet.Membership where r.MemberSchemaType == "Permissions" orderby r.InnerSort ascending select r;
                }
                else
                {
                    permissionRelations = from r in objectSet.Membership where r.MemberSchemaType == "Permissions" && r.ContainerID == app.ID orderby r.InnerSort ascending select r;
                }

                var permissions = (from o in objectSet.Objects join p in permissionRelations on o.ID equals p.ID select(PC.SCPermission) o).ToArray();

                allCount = permissions.Length;

                foreach (var p in permissions)
                {
                    count++;
                    PC.SCPermission fun = this.CopyMode ? AppImportAction.MakeCopy(p) : p;

                    // 只导入明确的
                    context.SetStatus(count, allCount, "正在导入权限:" + fun.DisplayName);
                    context.AppendLogFormat("正在导入权限 {0} \r\n", fun.DisplayName ?? fun.Name);
                    exec.AddPermission(fun, app);
                }
            }
        }
예제 #4
0
        public override void DoImport(SCObjectSet objectSet, IImportContext context)
        {
            if (string.IsNullOrEmpty(this.ApplicationId))
            {
                throw new HttpException("没有指定ApplicationId的情况下无法导入。");
            }

            var app = (PC.SCApplication)PC.Adapters.SchemaObjectAdapter.Instance.Load(this.ApplicationId);

            if (app == null)
            {
                throw new HttpException("指定的应用并不存在");
            }

            if (objectSet.HasObjects)
            {
                var exec = PC.Executors.SCObjectOperations.InstanceWithPermissions;

                PC.SCRole[] pendingRoles;
                if (this.CopyMode)
                {
                    pendingRoles = (from r in objectSet.Objects where r is PC.SCRole select(PC.SCRole) r).ToArray();
                }
                else
                {
                    pendingRoles = (from r in objectSet.Objects join m in objectSet.Membership on r.ID equals m.ID where r.SchemaType == "Roles" && m.ContainerID == app.ID select(PC.SCRole) r).ToArray();
                }

                int count    = 0;
                int allCount = pendingRoles.Length;

                foreach (var role in pendingRoles)
                {
                    var role2 = this.CopyMode ? AppImportAction.MakeCopy(role) : role;

                    context.SetStatus(count, allCount, "正在导入角色:" + role2.DisplayName);
                    context.AppendLog("正在导入角色" + role2.ToDescription());
                    exec.AddRole(role2, app);                     // 导入角色

                    if (this.IncludeConstMembers && objectSet.HasMembership)
                    {
                        context.SetStatus(count, allCount, "正在查找并添加角色成员");
                        context.AppendLog("正在查找角色成员");
                        ImportRoleMembers(objectSet, context, exec, role, role2);
                    }

                    if (this.IncludeConditions && objectSet.HasConditions)
                    {
                        context.SetStatus(count, allCount, "正在查找并添加角色条件");
                        context.AppendLog("正在查找角色条件");
                        this.ImportRoleConditions(objectSet, context, exec, role, role2);
                    }

                    if (this.IncludeRoleDefinitions && this.CopyMode == false && objectSet.HasRelations)
                    {
                        this.ImportRoleDefinitions(objectSet, context, exec, count, allCount, role, role2);
                    }

                    count++;
                }
            }
        }