本文整理汇总了C#中DataView.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# DataView.IsAuthorized方法的具体用法?C# DataView.IsAuthorized怎么用?C# DataView.IsAuthorized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataView
的用法示例。
在下文中一共展示了DataView.IsAuthorized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAuthorizedForAllDataViewComponents
/// <summary>
/// Determines whether [is authorized for all data view components] [the specified data view].
/// </summary>
/// <param name="dataViewAction">The data view action.</param>
/// <param name="dataView">The data view.</param>
/// <param name="authorizationMessage">The authorization message.</param>
/// <returns></returns>
private bool IsAuthorizedForAllDataViewComponents( string dataViewAction, DataView dataView, out string authorizationMessage )
{
bool isAuthorized = true;
authorizationMessage = string.Empty;
if ( !dataView.IsAuthorized( dataViewAction, CurrentPerson ) )
{
isAuthorized = false;
authorizationMessage = EditModeMessage.ReadOnlyEditActionNotAllowed( DataView.FriendlyTypeName );
}
if ( dataView.DataViewFilter != null && !dataView.DataViewFilter.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
isAuthorized = false;
authorizationMessage = "INFO: This Data View contains a filter that you do not have access to view.";
}
if ( dataView.TransformEntityTypeId != null )
{
string dataTransformationComponentTypeName = EntityTypeCache.Read( dataView.TransformEntityTypeId ?? 0 ).GetEntityType().FullName;
var dataTransformationComponent = Rock.Reporting.DataTransformContainer.GetComponent( dataTransformationComponentTypeName );
if ( dataTransformationComponent != null )
{
if ( !dataTransformationComponent.IsAuthorized( Authorization.VIEW, this.CurrentPerson ) )
{
isAuthorized = false;
authorizationMessage = "INFO: The Data View for this report contains a data transformation that you do not have access to view.";
}
}
}
return isAuthorized;
}
示例2: ShowReport
/// <summary>
/// Shows the report.
/// </summary>
/// <param name="dataView">The data view.</param>
private void ShowReport( DataView dataView )
{
var rockContext = new RockContext();
if ( dataView.EntityTypeId.HasValue && dataView.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
string authorizationMessage = string.Empty;
bool isPersonDataSet = dataView.EntityTypeId == EntityTypeCache.Read( typeof( Rock.Model.Person ) ).Id;
if ( isPersonDataSet )
{
gReport.PersonIdField = "Id";
gReport.DataKeyNames = new string[] { "Id" };
}
else
{
gReport.PersonIdField = null;
}
if ( dataView.EntityTypeId.HasValue )
{
var entityTypeCache = EntityTypeCache.Read( dataView.EntityTypeId.Value, rockContext );
if (entityTypeCache != null)
{
gReport.RowItemText = entityTypeCache.FriendlyName;
}
}
pnlResultsGrid.Visible = true;
BindGrid( gReport, dataView );
}
else
{
pnlResultsGrid.Visible = false;
}
}