本文整理汇总了C#中IIdentity.GetOrganizationId方法的典型用法代码示例。如果您正苦于以下问题:C# IIdentity.GetOrganizationId方法的具体用法?C# IIdentity.GetOrganizationId怎么用?C# IIdentity.GetOrganizationId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIdentity
的用法示例。
在下文中一共展示了IIdentity.GetOrganizationId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetQueriesForUser
public IList<Query> GetQueriesForUser(IIdentity identity)
{
var userId = identity.GetUserId();
var orgId = identity.GetOrganizationId();
return Queries.Where(q =>
(q.User == null || q.User == userId) &&
(q.Org == null || q.Org == orgId)
).OrderBy(q => q.Description).ToList();
}
示例2: get_bug_permission_level
///////////////////////////////////////////////////////////////////////
public static int get_bug_permission_level(int bugid, IIdentity identity)
{
/*
public const int PERMISSION_NONE = 0;
public const int PERMISSION_READONLY = 1;
public const int PERMISSION_REPORTER = 3;
public const int PERMISSION_ALL = 2;
*/
// fetch the revised permission level
var sql = new SQLString(@"
declare @bg_org int
select isnull(pu_permission_level,@dpl),
bg_org
from bugs
left outer join project_user_xref
on pu_project = bg_project
and pu_user = @us
where bg_id = @bg");
;
sql = sql.AddParameterWithValue("@dpl", Util.get_setting("DefaultPermissionLevel", "2"));
sql = sql.AddParameterWithValue("@bg", Convert.ToString(bugid));
sql = sql.AddParameterWithValue("@us", Convert.ToString(identity.GetUserId()));
DataRow dr = btnet.DbUtil.get_datarow(sql);
if (dr == null)
{
return PermissionLevel.None;
}
int pl = (int)dr[0];
int bg_org = (int)dr[1];
// maybe reduce permissions
var organizationId = identity.GetOrganizationId();
if (bg_org != organizationId)
{
var otherOrgsPermissionLevel = identity.GetOtherOrgsPermissionLevels();
if (otherOrgsPermissionLevel == PermissionLevel.None
|| otherOrgsPermissionLevel == PermissionLevel.ReadOnly)
{
if (otherOrgsPermissionLevel < pl)
{
pl = otherOrgsPermissionLevel;
}
}
}
return pl;
}
示例3: get_related_users
//.........这里部分代码省略.........
where pu2.pu_user = @userid
and pu2.pu_permission_level <> 0
)
and pu1.pu_permission_level <> 0
)
if @og_external_user = 1 -- external
and @og_other_orgs_permission_level = 0 -- other orgs
begin
delete from #temp where og_external_user = 1 and us_org <> @userorg
end
");
if (Util.get_setting("LimitUsernameDropdownsInSearch", "0") == "1")
{
sql.Append(limitUsernameDropdownSql);
}
sql.Append(@"
select us_id, us_username, us_email from #temp order by us_username
drop table #temp");
}
else
{
// show users UNLESS they have been explicitly excluded
// from all the projects the viewer is able to view
// the cartesian join in the first select is intentional
sql= new SQLString(@"
/* get related users 2 */
select pj_id, us_id,
case when @fullnames = 1 then
case when len(isnull(us_firstname,'') + ' ' + isnull(us_lastname,'')) > 1
then isnull(us_firstname,'') + ' ' + isnull(us_lastname,'')
else us_username end
else us_username end us_username,
isnull(us_email,'') us_email
into #temp
from projects, users
where pj_id not in
(
select pu_project from project_user_xref
where pu_permission_level = 0 and pu_user = @userid
)
");
if (Util.get_setting("LimitUsernameDropdownsInSearch", "0") == "1")
{
sql.Append(limitUsernameDropdownSql);
}
sql.Append(@"
if @og_external_user = 1 -- external
and @og_other_orgs_permission_level = 0 -- other orgs
begin
select distinct a.us_id, a.us_username, a.us_email
from #temp a
inner join users b on a.us_id = b.us_id
inner join orgs on b.us_org = og_id
where og_external_user = 0 or b.us_org = @userorg
order by a.us_username
end
else
begin
select distinct us_id, us_username, us_email
from #temp
left outer join project_user_xref on pj_id = pu_project
and us_id = pu_user
where isnull(pu_permission_level,2) <> 0
order by us_username
end
drop table #temp");
}
if (force_full_names || Util.get_setting("UseFullNames", "0") == "1")
{
// true condition
sql = sql.AddParameterWithValue("fullnames", 1);
}
else
{
// false condition
sql = sql.AddParameterWithValue("fullnames", 0);
}
sql = sql.AddParameterWithValue("userid",identity.GetUserId());
sql = sql.AddParameterWithValue("userorg",identity.GetOrganizationId());
sql = sql.AddParameterWithValue("og_external_user", identity.GetIsExternalUser() ? 1 : 0);
sql = sql.AddParameterWithValue("og_other_orgs_permission_level",identity.GetOtherOrgsPermissionLevels());
return btnet.DbUtil.get_dataset(sql).Tables[0];
}
示例4: get_bug_datarow
//.........这里部分代码省略.........
}
sql.Append(@"
select bg_id [id],
bg_short_desc [short_desc],
isnull(bg_tags,'') [bg_tags],
isnull(ru.us_username,'[deleted user]') [reporter],
isnull(ru.us_email,'') [reporter_email],
case rtrim(ru.us_firstname)
when null then isnull(ru.us_lastname, '')
when '' then isnull(ru.us_lastname, '')
else isnull(ru.us_lastname + ', ' + ru.us_firstname,'')
end [reporter_fullname],
bg_reported_date [reported_date],
datediff(s,bg_reported_date,getdate()) [seconds_ago],
isnull(lu.us_username,'') [last_updated_user],
case rtrim(lu.us_firstname)
when null then isnull(lu.us_lastname, '')
when '' then isnull(lu.us_lastname, '')
else isnull(lu.us_lastname + ', ' + lu.us_firstname,'')
end [last_updated_fullname],
bg_last_updated_date [last_updated_date],
isnull(bg_project,0) [project],
isnull(pj_name,'[no project]') [current_project],
isnull(bg_org,0) [organization],
isnull(bugorg.og_name,'') [og_name],
isnull(bg_category,0) [category],
isnull(ct_name,'') [category_name],
isnull(bg_priority,0) [priority],
isnull(pr_name,'') [priority_name],
isnull(bg_status,0) [status],
isnull(st_name,'') [status_name],
isnull(bg_user_defined_attribute,0) [udf],
isnull(udf_name,'') [udf_name],
isnull(bg_assigned_to_user,0) [assigned_to_user],
isnull(asg.us_username,'[not assigned]') [assigned_to_username],
case rtrim(asg.us_firstname)
when null then isnull(asg.us_lastname, '[not assigned]')
when '' then isnull(asg.us_lastname, '[not assigned]')
else isnull(asg.us_lastname + ', ' + asg.us_firstname,'[not assigned]')
end [assigned_to_fullname],
isnull(bs_user,0) [subscribed],
case
when
@this_org <> bg_org
and userorg.og_other_orgs_permission_level < 2
and userorg.og_other_orgs_permission_level < isnull(pu_permission_level,@dpl)
then userorg.og_other_orgs_permission_level
else
isnull(pu_permission_level,@dpl)
end [pu_permission_level],
isnull(bg_project_custom_dropdown_value1,'') [bg_project_custom_dropdown_value1],
isnull(bg_project_custom_dropdown_value2,'') [bg_project_custom_dropdown_value2],
isnull(bg_project_custom_dropdown_value3,'') [bg_project_custom_dropdown_value3],
@related [relationship_cnt],
@svn_revisions [svn_revision_cnt],
@git_commits [git_commit_cnt],
@hg_revisions [hg_commit_cnt],
@tasks [task_cnt],
getdate() [snapshot_timestamp]
from bugs
inner join users this_user on us_id = @this_usid
inner join orgs userorg on this_user.us_org = userorg.og_id
left outer join user_defined_attribute on bg_user_defined_attribute = udf_id
left outer join projects on bg_project = pj_id
left outer join orgs bugorg on bg_org = bugorg.og_id
left outer join categories on bg_category = ct_id
left outer join priorities on bg_priority = pr_id
left outer join statuses on bg_status = st_id
left outer join users asg on bg_assigned_to_user = asg.us_id
left outer join users ru on bg_reported_user = ru.us_id
left outer join users lu on bg_last_updated_user = lu.us_id
left outer join bug_subscriptions on bs_bug = bg_id and bs_user = @this_usid
left outer join project_user_xref on pj_id = pu_project
and pu_user = @this_usid
where bg_id = @id");
sql = sql.AddParameterWithValue("id", Convert.ToString(bugid));
sql = sql.AddParameterWithValue("this_usid", Convert.ToString(identity.GetUserId()));
sql = sql.AddParameterWithValue("this_org", Convert.ToString(identity.GetOrganizationId()));
sql = sql.AddParameterWithValue("dpl", Util.get_setting("DefaultPermissionLevel", "2"));
return btnet.DbUtil.get_datarow(sql);
}
示例5: 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
{
//.........这里部分代码省略.........