当前位置: 首页>>代码示例>>C#>>正文


C# IIdentity.GetCanOnlySeeOwnReportedBugs方法代码示例

本文整理汇总了C#中IIdentity.GetCanOnlySeeOwnReportedBugs方法的典型用法代码示例。如果您正苦于以下问题:C# IIdentity.GetCanOnlySeeOwnReportedBugs方法的具体用法?C# IIdentity.GetCanOnlySeeOwnReportedBugs怎么用?C# IIdentity.GetCanOnlySeeOwnReportedBugs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IIdentity的用法示例。


在下文中一共展示了IIdentity.GetCanOnlySeeOwnReportedBugs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: alter_sql_per_project_permissions

		///////////////////////////////////////////////////////////////////////
		public static SQLString alter_sql_per_project_permissions(SQLString sql, IIdentity identity)
		{
		    int userId = identity.GetUserId();
		    int organizationId = identity.GetOrganizationId();
		    
			string project_permissions_sql;

			string dpl = Util.get_setting("DefaultPermissionLevel","2");

			if (dpl == "0")
			{
				project_permissions_sql = @" (bugs.bg_project in (
					select pu_project
					from project_user_xref
					where pu_user = $user
					and pu_permission_level > 0)) ";
			}
			else
			{
				project_permissions_sql = @" (bugs.bg_project not in (
					select pu_project
					from project_user_xref
					where pu_user = $user
					and pu_permission_level = 0)) ";
			}

            if (identity.GetCanOnlySeeOwnReportedBugs())
            {
                project_permissions_sql += @"
					    and bugs.bg_reported_user = $user ";

            }
            else
            {
                if (identity.GetOtherOrgsPermissionLevels() == 0)
                {
                    project_permissions_sql += @"
					    and bugs.bg_org = $user.org ";
                }
            }

			project_permissions_sql
				= project_permissions_sql.Replace("$user.org",Convert.ToString(organizationId));

			project_permissions_sql
				= project_permissions_sql.Replace("$user",Convert.ToString(userId));


			// Figure out where to alter sql for project permissions
            // I've tried lots of different schemes over the years....

            int alter_here_pos = sql.ToString().IndexOf("$ALTER_HERE"); // places - can be multiple - are explicitly marked
            if (alter_here_pos != -1)
            {
                return new SQLString(sql.ToString().Replace("$ALTER_HERE", "/* ALTER_HERE */ " + project_permissions_sql), sql.GetParameters());
            }
            else
            {
                string bug_sql;
                var rawSQL = sql.ToString();
                int where_pos = rawSQL.IndexOf("WhErE"); // first look for a "special" where, case sensitive, in case there are multiple where's to choose from
                if (where_pos == -1)
                    where_pos = rawSQL.ToUpper().IndexOf("WHERE");

                int order_pos = rawSQL.IndexOf("/*ENDWHR*/"); // marker for end of the where statement

                if (order_pos == -1)
                    order_pos = rawSQL.ToUpper().LastIndexOf("ORDER BY");

                if (order_pos < where_pos)
                    order_pos = -1; // ignore an order by that occurs in a subquery, for example

                if (where_pos != -1 && order_pos != -1)
                {
                    // both WHERE and ORDER BY clauses
                    bug_sql = rawSQL.Substring(0, where_pos + 5)
                        + " /* altered - both  */ ( "
                        + rawSQL.Substring(where_pos + 5, order_pos - (where_pos + 5))
                        + " ) AND ( "
                        + project_permissions_sql
                        + " ) "
                        + rawSQL.Substring(order_pos);
                }
                else if (order_pos == -1 && where_pos == -1)
                {
                    // Neither
                    bug_sql = rawSQL + " /* altered - neither */ WHERE " + project_permissions_sql;
                }
                else if (order_pos == -1)
                {
                    // WHERE, without order
                    bug_sql = rawSQL.Substring(0, where_pos + 5)
                        + " /* altered - just where */ ( "
                        + rawSQL.Substring(where_pos + 5)
                        + " ) AND ( "
                        + project_permissions_sql + " )";
                }
                else
                {
//.........这里部分代码省略.........
开发者ID:jhadwen,项目名称:BugTracker.NET,代码行数:101,代码来源:util.cs


注:本文中的IIdentity.GetCanOnlySeeOwnReportedBugs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。