本文整理汇总了C#中WorkflowTypeService.Where方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowTypeService.Where方法的具体用法?C# WorkflowTypeService.Where怎么用?C# WorkflowTypeService.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowTypeService
的用法示例。
在下文中一共展示了WorkflowTypeService.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
private void GetData()
{
var rockContext = new RockContext();
int personId = CurrentPerson != null ? CurrentPerson.Id : 0;
// Get all of the workflow types
var allWorkflowTypes = new WorkflowTypeService( rockContext ).Queryable( "ActivityTypes" )
.OrderBy( w => w.Name )
.ToList();
// Get the authorized activities in all workflow types
var authorizedActivityTypes = AuthorizedActivityTypes( allWorkflowTypes );
// Get the workflow types that contain authorized activity types
var workflowTypeIds = allWorkflowTypes
.Where( w => w.ActivityTypes.Any( a => authorizedActivityTypes.Contains( a.Id ) ) )
.Select( w => w.Id )
.Distinct()
.ToList();
// Create variable for storing authorized types and the count of active form actions
var workflowTypeCounts = new Dictionary<int, int>();
List<Workflow> workflows = null;
if ( RoleFilter.HasValue && RoleFilter.Value )
{
workflows = new WorkflowService( rockContext ).Queryable()
.Where( w =>
w.ActivatedDateTime.HasValue &&
!w.CompletedDateTime.HasValue &&
w.InitiatorPersonAlias.PersonId == personId )
.ToList();
workflowTypeIds.ForEach( id =>
workflowTypeCounts.Add( id, workflows.Where( w => w.WorkflowTypeId == id ).Count() ) );
}
else
{
// Get all the active forms for any of the authorized activities
var activeForms = new WorkflowActionService( rockContext ).Queryable( "ActionType.ActivityType.WorkflowType, Activity.Workflow" )
.Where( a =>
a.ActionType.WorkflowFormId.HasValue &&
!a.CompletedDateTime.HasValue &&
a.Activity.ActivatedDateTime.HasValue &&
!a.Activity.CompletedDateTime.HasValue &&
a.Activity.Workflow.ActivatedDateTime.HasValue &&
!a.Activity.Workflow.CompletedDateTime.HasValue &&
authorizedActivityTypes.Contains( a.ActionType.ActivityTypeId ) &&
(
( a.Activity.AssignedPersonAlias != null && a.Activity.AssignedPersonAlias.PersonId == personId ) ||
( a.Activity.AssignedGroup != null && a.Activity.AssignedGroup.Members.Any( m => m.PersonId == personId ) )
)
)
.ToList();
// Get any workflow types that have authorized activites and get the form count
workflowTypeIds.ForEach( w =>
workflowTypeCounts.Add( w, activeForms.Where( a => a.Activity.Workflow.WorkflowTypeId == w ).Count() ) );
workflows = activeForms
.Select( a => a.Activity.Workflow )
.Distinct()
.ToList();
}
var displayedTypes = new List<WorkflowType>();
foreach ( var workflowType in allWorkflowTypes.Where( w => workflowTypeCounts.Keys.Contains( w.Id ) ) )
{
if ( workflowTypeCounts[workflowType.Id] > 0 )
{
// Always show any types that have active assignments assigned to user
displayedTypes.Add( workflowType );
}
else
{
// If there are not any active assigned activities, and not filtering by active, then also
// show any types that user is authorized to edit
if ( ( !StatusFilter.HasValue || !StatusFilter.Value ) &&
workflowType.IsAuthorized( Authorization.EDIT, CurrentPerson ) )
{
displayedTypes.Add( workflowType );
}
}
}
// Create a query to return workflow type, the count of active action forms, and the selected class
var qry = displayedTypes
.Select( w => new
{
WorkflowType = w,
Count = workflowTypeCounts[w.Id],
Class = ( SelectedWorkflowTypeId.HasValue && SelectedWorkflowTypeId.Value == w.Id ) ? "active" : ""
} );
rptWorkflowTypes.DataSource = qry.ToList();
rptWorkflowTypes.DataBind();
WorkflowType selectedWorkflowType = null;
//.........这里部分代码省略.........
示例2: GetData
private void GetData()
{
var rockContext = new RockContext();
int personId = CurrentPerson != null ? CurrentPerson.Id : 0;
// Get all of the workflow types
var allWorkflowTypes = new WorkflowTypeService( rockContext ).Queryable( "ActivityTypes" )
.OrderBy( w => w.Name )
.ToList();
// Get the authorized activities in all workflow types
var authorizedActivityTypes = AuthorizedActivityTypes( allWorkflowTypes );
// Get the workflow types that contain authorized activity types
var workflowTypeIds = allWorkflowTypes
.Where( w => w.ActivityTypes.Any( a => authorizedActivityTypes.Contains( a.Id ) ) )
.Select( w => w.Id )
.Distinct()
.ToList();
// Create variable for storing authorized types and the count of active form actions
var workflowTypeCounts = new Dictionary<int, int>();
List<Workflow> workflows = null;
if ( RoleFilter.HasValue && RoleFilter.Value )
{
workflows = new WorkflowService( rockContext ).Queryable()
.Where( w =>
w.ActivatedDateTime.HasValue &&
!w.CompletedDateTime.HasValue &&
w.InitiatorPersonAlias.PersonId == personId )
.ToList();
workflowTypeIds.ForEach( id =>
workflowTypeCounts.Add( id, workflows.Where( w => w.WorkflowTypeId == id ).Count() ) );
}
else
{
// Get all the active forms for any of the authorized activities
var activeForms = new WorkflowActionService( rockContext ).Queryable( "ActionType.ActivityType.WorkflowType, Activity.Workflow" )
.Where( a =>
a.ActionType.WorkflowFormId.HasValue &&
!a.CompletedDateTime.HasValue &&
a.Activity.ActivatedDateTime.HasValue &&
!a.Activity.CompletedDateTime.HasValue &&
a.Activity.Workflow.ActivatedDateTime.HasValue &&
!a.Activity.Workflow.CompletedDateTime.HasValue &&
authorizedActivityTypes.Contains( a.ActionType.ActivityTypeId ) &&
(
( a.Activity.AssignedPersonAlias != null && a.Activity.AssignedPersonAlias.PersonId == personId ) ||
( a.Activity.AssignedGroup != null && a.Activity.AssignedGroup.Members.Any( m => m.PersonId == personId ) )
)
)
.ToList();
// Get any workflow types that have authorized activites and get the form count
workflowTypeIds.ForEach( w =>
workflowTypeCounts.Add( w, activeForms.Where( a => a.Activity.Workflow.WorkflowTypeId == w ).Count() ) );
workflows = activeForms
.Select( a => a.Activity.Workflow )
.Distinct()
.ToList();
}
// Create a query to return workflow type, the count of active action forms, and the selected class
var qry = allWorkflowTypes
.Where( w => workflowTypeCounts.Keys.Contains( w.Id ) )
.Select( w => new
{
WorkflowType = w,
Count = workflowTypeCounts[w.Id],
Class = ( SelectedWorkflowTypeId.HasValue && SelectedWorkflowTypeId.Value == w.Id ) ? "active" : ""
} );
// If displaying active only, update query to exclude those workflow types without any active form actions
if ( StatusFilter.HasValue && StatusFilter.Value )
{
qry = qry.Where( q => q.Count > 0 );
}
rptWorkflowTypes.DataSource = qry.ToList();
rptWorkflowTypes.DataBind();
WorkflowType selectedWorkflowType = null;
if ( SelectedWorkflowTypeId.HasValue )
{
selectedWorkflowType = allWorkflowTypes
.Where( w =>
w.Id == SelectedWorkflowTypeId.Value &&
workflowTypeCounts.Keys.Contains( SelectedWorkflowTypeId.Value ) )
.FirstOrDefault();
}
if ( selectedWorkflowType != null )
{
AddAttributeColumns( selectedWorkflowType );
//.........这里部分代码省略.........