protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e) { if (e.ReturnValue is DataView && Util.SuperVisiorMode == false) { var view = e.ReturnValue as DataView; string[] ids = new string[view.Count]; for (int i = 0; i < view.Count; i++) { ids[i] = view[i]["ID"].ToString(); } this.relations = ids.Length > 0 ? DbUtil.LoadCurrentParentRelations(ids, SchemaInfo.FilterByCategory("Organizations").ToSchemaNames()) : new SCRelationObjectCollection(); this.acls = this.relations.Count > 0 ? SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, this.relations.ToParentIDArray()) : new SCContainerAndPermissionCollection(); } }
protected override void OnPreRender(EventArgs e) { var parentIds = DbUtil.LoadCurrentParentRelations(new string[] { this.UserObject.ID }, SchemaInfo.FilterByCategory("Organizations").ToSchemaNames()).ToParentIDArray(); var containerPermissions = parentIds.Length > 0 ? SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, parentIds) : new SCContainerAndPermissionCollection(); bool enabled = false; for (int i = parentIds.Length - 1; i >= 0; i--) { enabled |= Util.ContainsPermission(containerPermissions, parentIds[i], "UpdateChildren"); } this.hasSelfRight = enabled; this.hfSelfID.Value = this.UserObject.ID; Util.ConfigToggleViewButton(this.views.ActiveViewIndex, this.lnkViewMode, this.lblViewMode); base.OnPreRender(e); }
/// <summary> /// 获取可用的操作类型 /// </summary> /// <param name="keys"></param> /// <returns><see cref="TransferObjectType"/>的组合值</returns> internal static TransferObjectType GetAvailableOperation(string[] keys) { TransferObjectType result = TransferObjectType.None; if (keys != null) { var relations = DbUtil.LoadCurrentParentRelations(keys, SchemaInfo.FilterByCategory("Organizations").ToSchemaNames()); bool existRootOrg = false; foreach (var r in relations) { if (Util.IsOrganization(r.ChildSchemaType) && r.ParentID == PC.SCOrganization.RootOrganizationID) { existRootOrg = true; // 一级组织原则上不允许转移,如果含有一级组织,则什么都做不成 break; } } if (existRootOrg == false) { foreach (var item in DbUtil.LoadObjects(keys)) { if (item is SCUser) { result |= TransferObjectType.Members; } else if (item is SCGroup) { result |= TransferObjectType.Groups; } else if (item is SCOrganization) { result |= TransferObjectType.Orgnizations; } } } } return(result); }