public void DoImport(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context) { var exec = Operations.Facade.InstanceWithPermissions; if (string.IsNullOrEmpty(this.AUSchemaID)) { throw new InvalidOperationException("操作前必须对SchemaID进行赋值"); } var item = (AUSchema)Adapters.AUSnapshotAdapter.Instance.LoadAUSchema(this.AUSchemaID, true, DateTime.MinValue).FirstOrDefault(); if (item == null) { throw new AUObjectValidationException("不存在指定的管理架构,或已删除。"); } var roles = (from p in objectSet.Membership where p.ContainerID == item.ID && p.MemberSchemaType == AUCommon.SchemaAUSchemaRole join q in objectSet.Objects on p.ID equals q.ID where q.SchemaType == AUCommon.SchemaAUSchemaRole select q); int total = roles.Count(); int roleCount = 0; foreach (AUSchemaRole role in roles) { roleCount++; try { context.SetStatusAndLog(roleCount, total, "正在添加角色:" + role.GetQualifiedName()); exec.AddAdminSchemaRole(role, item); } catch (Exception ex) { context.AppendLog("对角色的操作失败,原因是:" + ex.Message); } } }
private void ImportSchemaRoles(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context, Operations.IFacade exec, AUSchema item) { if (this.IncludeSchemaRoles) { var roles = (from p in objectSet.Membership where p.ContainerID == item.ID && p.MemberSchemaType == AUCommon.SchemaAUSchemaRole join q in objectSet.Objects on p.ID equals q.ID select q); int total = roles.Count(); int roleCount = 0; foreach (AUSchemaRole role in roles) { roleCount++; try { context.SetSubStatusAndLog(roleCount, total, "正在添加角色:" + role.GetQualifiedName()); exec.AddAdminSchemaRole(role, item); } catch (Exception ex) { context.ErrorCount++; context.AppendLog("对角色的操作失败,原因是:" + ex.Message); } } } }
public void DoImport(MCS.Library.SOA.DataObjects.Security.SCObjectSet objectSet, IImportContext context) { var exec = this.IgnorePermission ? Operations.Facade.DefaultInstance : Operations.Facade.InstanceWithPermissions; IEnumerable <SchemaObjectBase> schemas; if (string.IsNullOrEmpty(TargetCategory)) { schemas = objectSet.Objects.Where(m => m.SchemaType == AUCommon.SchemaAUSchema && m.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal); } else { schemas = objectSet.Objects.Where(m => m.SchemaType == AUCommon.SchemaAUSchema && m.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal && ((AUSchema)m).CategoryID == TargetCategory); } int allCount = schemas.Count(); int count = 0; foreach (AUSchema item in schemas) { count++; try { context.SetStatusAndLog(count, allCount, "正在导入对象:" + item.GetQualifiedName()); exec.AddAdminSchema(item); ImportSchemaRoles(objectSet, context, exec, item); } catch (Exception ex) { context.ErrorCount++; context.AppendLog("对项的操作失败,原因是:" + ex.Message); } } }