Ejemplo n.º 1
0
        protected override void OnPreRender(EventArgs e)
        {
            this.spObjName.InnerText = string.Format("{0}({1})", this.Object.Name, this.Object.VisibleName);

            this.RenderInitJson();

            if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
            {
                AU.AUCommon.DoDbAction(() =>
                                       this.allParents = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.Object.ID));

                var parentSet = new HashSet <string>();
                foreach (var item in this.allParents)
                {
                    if (item.Status == SchemaObjectStatus.Normal)
                    {
                        parentSet.Add(item.ParentID);
                    }
                }

                this.containerPermissions = AU.Adapters.AUAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, parentSet);
            }

            base.OnPreRender(e);
        }
Ejemplo n.º 2
0
 protected override void OnPreRender(EventArgs e)
 {
     if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
     {
         this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.AppObject.ID });
     }
     base.OnPreRender(e);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据userID和一组ContainerID,加载该Member所拥有的权限
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="containerIDs"></param>
        /// <returns></returns>
        public SCContainerAndPermissionCollection LoadCurrentContainerAndPermissions(string userID, IEnumerable <string> containerIDs)
        {
            var ids = containerIDs.ToArray();
            SCContainerAndPermissionCollection result = null;

            var roleIDs = (from r in new OguUser(userID).Roles.GetAllRoles() select r.ID).ToArray();

            if (ids.Length > 0 && roleIDs.Length > 0)
            {
                var timeConditon1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("A.");
                var condition     = new WhereSqlClauseBuilder();
                condition.AppendItem("A.Status", (int)SchemaObjectStatus.Normal);

                InSqlClauseBuilder inSql = new InSqlClauseBuilder("A.ContainerID");
                inSql.AppendItem(ids);

                InSqlClauseBuilder inSqlRole = new InSqlClauseBuilder("A.MemberID");
                inSqlRole.AppendItem(roleIDs);

                var sql = string.Format(
                    "SELECT A.* FROM SC.Acl_Current A WHERE {0} ORDER BY SortID ",
                    new ConnectiveSqlClauseCollection(timeConditon1, condition, inSql, inSqlRole).ToSqlString(TSqlBuilder.Instance));

                result = new SCContainerAndPermissionCollection();

                AUCommon.DoDbAction(() =>
                {
                    using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
                    {
                        using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
                        {
                            while (reader.Read())
                            {
                                string containerID = (string)reader["ContainerID"];
                                string permission  = (string)reader["ContainerPermission"];

                                if (result.ContainsKey(containerID, permission) == false)
                                {
                                    result.Add(new SCContainerAndPermission()
                                    {
                                        ContainerID         = containerID,
                                        ContainerPermission = permission
                                    });
                                }
                            }
                        }
                    }
                });

                return(result);
            }
            else
            {
                result = new SCContainerAndPermissionCollection();
            }

            return(result);
        }
Ejemplo n.º 4
0
		/// <summary>
		/// 根据userID和一组ContainerID,加载该Member所拥有的权限
		/// </summary>
		/// <param name="userID"></param>
		/// <param name="containerIDs"></param>
		/// <returns></returns>
		public SCContainerAndPermissionCollection LoadCurrentContainerAndPermissions(string userID, IEnumerable<string> containerIDs)
		{
			var ids = containerIDs.ToArray();
			SCContainerAndPermissionCollection result = null;

			var roleIDs = (from r in new OguUser(userID).Roles.GetAllRoles() select r.ID).ToArray();

			if (ids.Length > 0 && roleIDs.Length > 0)
			{
				var timeConditon1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("A.");
				var condition = new WhereSqlClauseBuilder();
				condition.AppendItem("A.Status", (int)SchemaObjectStatus.Normal);

				InSqlClauseBuilder inSql = new InSqlClauseBuilder("A.ContainerID");
				inSql.AppendItem(ids);

				InSqlClauseBuilder inSqlRole = new InSqlClauseBuilder("A.MemberID");
				inSqlRole.AppendItem(roleIDs);

				var sql = string.Format(
					"SELECT A.* FROM SC.Acl_Current A WHERE {0} ORDER BY SortID ",
					new ConnectiveSqlClauseCollection(timeConditon1, condition, inSql, inSqlRole).ToSqlString(TSqlBuilder.Instance));

				result = new SCContainerAndPermissionCollection();

				AUCommon.DoDbAction(() =>
				{
					using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
					{
						using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
						{
							while (reader.Read())
							{
								string containerID = (string)reader["ContainerID"];
								string permission = (string)reader["ContainerPermission"];

								if (result.ContainsKey(containerID, permission) == false)
								{
									result.Add(new SCContainerAndPermission()
									{
										ContainerID = containerID,
										ContainerPermission = permission
									});
								}
							}
						}
					}
				});

				return result;
			}
			else
			{
				result = new SCContainerAndPermissionCollection();
			}

			return result;
		}
Ejemplo n.º 5
0
        protected bool GetEditRoleMembersEnabled(string appID)
        {
            SCContainerAndPermissionCollection containerPermissions = null;

            if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
            {
                containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { appID });
            }
            return(TimePointContext.Current.UseCurrentTime && (Util.SuperVisiorMode || Util.ContainsPermission(containerPermissions, appID, "ModifyMembersInRoles")));
        }
Ejemplo n.º 6
0
 internal static bool ContainsPermission(SCContainerAndPermissionCollection permissions, string containerID, string permission)
 {
     if (permissions == null || string.IsNullOrEmpty(containerID))
     {
         return(false);
     }
     else
     {
         return(permissions.ContainsKey(containerID, permission));
     }
 }
Ejemplo n.º 7
0
        protected override void OnPreRender(EventArgs e)
        {
            if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
            {
                this.appId = SCMemberRelationAdapter.Instance.LoadByMemberID(this.RoleObject.ID).Find(m => m.ContainerSchemaType == "Applications" && m.Status == SchemaObjectStatus.Normal).ContainerID;

                this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.appId });
            }

            base.OnPreRender(e);
        }
Ejemplo n.º 8
0
		protected override void OnPreRender(EventArgs e)
		{
			if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
			{
				this.appId = SCMemberRelationAdapter.Instance.LoadByMemberID(this.RoleObject.ID).Find(m => m.ContainerSchemaType == "Applications" && m.Status == SchemaObjectStatus.Normal).ContainerID;

				this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.appId });
			}

			base.OnPreRender(e);
		}
Ejemplo n.º 9
0
        private static SCContainerAndPermissionCollection GetPrincipalPermissions(IPrincipal principal, params string[] containerIDs)
        {
            string calculatedKey = CalculatePrincipalAndPermissionKey(principal, containerIDs);

            return((SCContainerAndPermissionCollection)ObjectContextCache.Instance.GetOrAddNewValue(calculatedKey, (cache, key) =>
            {
                SCContainerAndPermissionCollection permissions = Adapters.AUAclAdapter.Instance.LoadCurrentContainerAndPermissions(GetUserID(principal), containerIDs);

                cache.Add(key, permissions);

                return permissions;
            }));
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.ReturnValue is DataView)
            {
                if (TimePointContext.Current.UseCurrentTime)
                {
                    DataView      view  = (DataView)e.ReturnValue;
                    List <string> ouIds = new List <string>(view.Count);
                    foreach (DataRow row in view.Table.Rows)
                    {
                        ouIds.Add(row["OUID"].ToString());
                    }

                    this.containerPermissions = SCAclAdapter.Instance.GetCurrentContainerAndPermissions(Util.CurrentUser.ID, ouIds);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 是否拥有指定的权限
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="permissions"></param>
        /// <param name="permissionName"></param>
        /// <param name="containerIDs"></param>
        /// <returns></returns>
        public static bool HasPermissions(IPrincipal principal, SCContainerAndPermissionCollection permissions, string permissionName, params string[] containerIDs)
        {
            bool result = IsSupervisor(principal);

            if (result == false)
            {
                if (principal != null)
                {
                    permissions.NullCheck("permissions");

                    foreach (string containerID in containerIDs)
                    {
                        if (permissions.ContainsKey(containerID, permissionName))
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 13
0
        protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.ReturnValue is System.Data.DataView)
            {
                if (TimePointContext.Current.UseCurrentTime)
                {
                    var view = (DataView)e.ReturnValue;

                    List <string> orgIds = new List <string>(view.Count + 1);
                    foreach (DataRow row in view.Table.Rows)
                    {
                        orgIds.Add(row["ID"].ToString());
                    }

                    if (this.DefaultOrg != null)
                    {
                        orgIds.Add(this.DefaultOrg.ID);
                    }

                    this.containerPermissions = SCAclAdapter.Instance.GetCurrentContainerAndPermissions(Util.CurrentUser.ID, orgIds);
                }
            }
        }
Ejemplo n.º 14
0
		/// <summary>
		/// 是否拥有指定的权限
		/// </summary>
		/// <param name="principal"></param>
		/// <param name="permissions"></param>
		/// <param name="permissionName"></param>
		/// <param name="containerIDs"></param>
		/// <returns></returns>
		public static bool HasPermissions(IPrincipal principal, SCContainerAndPermissionCollection permissions, string permissionName, params string[] containerIDs)
		{
			bool result = IsSupervisor(principal);

			if (result == false)
			{
				if (principal != null)
				{
					permissions.NullCheck("permissions");

					foreach (string containerID in containerIDs)
					{
						if (permissions.ContainsKey(containerID, permissionName))
						{
							result = true;
							break;
						}
					}
				}
			}

			return result;
		}
Ejemplo n.º 15
0
		protected override void OnPreRender(EventArgs e)
		{
			if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
				this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.AppObject.ID });
			base.OnPreRender(e);
		}
Ejemplo n.º 16
0
		protected override void OnPreRender(EventArgs e)
		{
			this.spObjName.InnerText = string.Format("{0}({1})", this.Object.Name, this.Object.VisibleName);

			this.RenderInitJson();

			if (TimePointContext.Current.UseCurrentTime && Util.SuperVisiorMode == false)
			{
				AU.AUCommon.DoDbAction(() =>
					this.allParents = PC.Adapters.SchemaRelationObjectAdapter.Instance.LoadByObjectID(this.Object.ID));

				var parentSet = new HashSet<string>();
				foreach (var item in this.allParents)
				{
					if (item.Status == SchemaObjectStatus.Normal)
					{
						parentSet.Add(item.ParentID);
					}
				}

				this.containerPermissions = AU.Adapters.AUAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, parentSet);
			}

			base.OnPreRender(e);
		}
		protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)
		{
			if (e.ReturnValue is DataView)
			{
				if (TimePointContext.Current.UseCurrentTime)
				{
					var view = (DataView)e.ReturnValue;
					List<string> ouIds = new List<string>(view.Count);

					foreach (DataRow row in view.Table.Rows)
					{
						ouIds.Add(row["ParentID"].ToString());
					}

					this.containerPermissions = SCAclAdapter.Instance.GetCurrentContainerAndPermissions(Util.CurrentUser.ID, ouIds);
				}
			}
		}
		protected override void OnPreRender(EventArgs e)
		{
			this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.GroupParentId });
			Util.ConfigToggleViewButton(this.views.ActiveViewIndex, this.lnkViewMode, this.lblViewMode);
			base.OnPreRender(e);
		}
Ejemplo n.º 19
0
 protected override void OnPreRender(EventArgs e)
 {
     this.containerPermissions = SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, new string[] { this.GroupParentId });
     Util.ConfigToggleViewButton(this.views.ActiveViewIndex, this.lnkViewMode, this.lblViewMode);
     base.OnPreRender(e);
 }
Ejemplo n.º 20
0
		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();
			}
		}