本文整理汇总了C#中WorkflowTypeService类的典型用法代码示例。如果您正苦于以下问题:C# WorkflowTypeService类的具体用法?C# WorkflowTypeService怎么用?C# WorkflowTypeService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkflowTypeService类属于命名空间,在下文中一共展示了WorkflowTypeService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
var names = new List<string>();
var guids = new List<Guid>();
foreach ( string guidValue in value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
{
Guid? guid = guidValue.AsGuidOrNull();
if ( guid.HasValue )
{
guids.Add( guid.Value );
}
}
if ( guids.Any() )
{
var workflowTypes = new WorkflowTypeService( new RockContext() ).Queryable().Where( a => guids.Contains( a.Guid ) );
if ( workflowTypes.Any() )
{
formattedValue = string.Join( ", ", ( from workflowType in workflowTypes select workflowType.Name ).ToArray() );
}
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例2: LaunchTheWorkflow
/// <summary>
/// Launch the workflow
/// </summary>
protected void LaunchTheWorkflow(string workflowName)
{
Guid workflowTypeGuid = Guid.NewGuid();
if ( Guid.TryParse( workflowName, out workflowTypeGuid ) )
{
var rockContext = new RockContext();
var workflowTypeService = new WorkflowTypeService(rockContext);
var workflowType = workflowTypeService.Get( workflowTypeGuid );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, workflowName );
List<string> workflowErrors;
if ( workflow.Process( rockContext, out workflowErrors ) )
{
if ( workflow.IsPersisted || workflowType.IsPersisted )
{
var workflowService = new Rock.Model.WorkflowService(rockContext);
workflowService.Add( workflow );
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
}
}
}
}
}
示例3: Execute
/// <summary>
/// Execute method to write transaction to the database.
/// </summary>
public void Execute()
{
if ( Trigger != null )
{
var rockContext = new RockContext();
var workflowTypeService = new WorkflowTypeService( rockContext );
var workflowType = workflowTypeService.Get( Trigger.WorkflowTypeId );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, Trigger.WorkflowName );
List<string> workflowErrors;
if ( workflow.Process( rockContext, Entity, out workflowErrors ) )
{
if ( workflow.IsPersisted || workflowType.IsPersisted )
{
var workflowService = new Rock.Model.WorkflowService( rockContext );
workflowService.Add( workflow );
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
}
}
}
}
}
示例4: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
var guid = GetAttributeValue( action, "Workflow" ).AsGuid();
if (guid.IsEmpty())
{
action.AddLogEntry( "Invalid Workflow Property", true );
return false;
}
var currentActivity = action.Activity;
var newWorkflowType = new WorkflowTypeService( rockContext ).Get( guid );
var newWorkflowName = GetAttributeValue(action, "WorkflowName" );
if (newWorkflowType == null)
{
action.AddLogEntry( "Invalid Workflow Property", true );
return false;
}
var newWorkflow = Rock.Model.Workflow.Activate( newWorkflowType, newWorkflowName );
if (newWorkflow == null)
{
action.AddLogEntry( "The Workflow could not be activated", true );
return false;
}
CopyAttributes( newWorkflow, currentActivity, rockContext );
SaveForProcessingLater( newWorkflow, rockContext );
return true;
// Kick off processing of new Workflow
/*if(newWorkflow.Process( rockContext, entity, out errorMessages ))
{
if (newWorkflow.IsPersisted || newWorkflowType.IsPersisted)
{
var workflowService = new Rock.Model.WorkflowService( rockContext );
workflowService.Add( newWorkflow );
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
newWorkflow.SaveAttributeValues( rockContext );
foreach (var activity in newWorkflow.Activities)
{
activity.SaveAttributeValues( rockContext );
}
} );
}
return true;
}
else
{
return false;
}*/
}
示例5: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute(RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages)
{
errorMessages = new List<string>();
var workflowTypeGuid = GetAttributeValue(action, "WorkflowType").AsGuidOrNull();
var workflowName = GetAttributeValue(action, "WorkflowName");
if (workflowTypeGuid.HasValue && !string.IsNullOrEmpty(workflowName))
{
var sourceKeyMap = new Dictionary<string, string>();
var workflowAttributeKeys = GetAttributeValue(action, "WorkflowAttributeKey");
if (!string.IsNullOrWhiteSpace(workflowAttributeKeys))
{
//TODO Find a way upstream to stop an additional being appended to the value
sourceKeyMap = workflowAttributeKeys.AsDictionaryOrNull();
var workflowTypeService = new WorkflowTypeService(rockContext);
var workflow = Rock.Model.Workflow.Activate(workflowTypeService.Get(workflowTypeGuid.Value), workflowName);
workflow.LoadAttributes(rockContext);
foreach (var keyPair in sourceKeyMap)
{
//Does the source key exist as an attribute in the source workflow?
if (action.Activity.Workflow.Attributes.ContainsKey(keyPair.Key))
{
if (workflow.Attributes.ContainsKey(keyPair.Value))
{
var value = action.Activity.Workflow.AttributeValues[keyPair.Key].Value;
workflow.SetAttributeValue(keyPair.Value, value);
}
else
{
errorMessages.Add(string.Format("{0} not a key in {1}", keyPair.Value, action.Activity.Workflow.Name));
}
}
else
{
errorMessages.Add(string.Format("{0} not a key in {1}", keyPair.Key, workflowName));
}
}
new Rock.Model.WorkflowService(rockContext).Process(workflow, out errorMessages);
}
}
else
{
errorMessages.Add("Workflow type or name not provided");
}
return true;
}
示例6: LaunchTheWorkflow
/// <summary>
/// Launch the workflow
/// </summary>
protected void LaunchTheWorkflow(string workflowName)
{
Guid workflowTypeGuid = Guid.NewGuid();
if ( Guid.TryParse( workflowName, out workflowTypeGuid ) )
{
var rockContext = new RockContext();
var workflowTypeService = new WorkflowTypeService(rockContext);
var workflowType = workflowTypeService.Get( workflowTypeGuid );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, workflowName );
List<string> workflowErrors;
new Rock.Model.WorkflowService( rockContext ).Process( workflow, out workflowErrors );
}
}
}
示例7: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
Guid workflowTypeGuid = Guid.Empty;
if (Guid.TryParse( value, out workflowTypeGuid ))
{
var workflowtype = new WorkflowTypeService().Get( workflowTypeGuid );
if ( workflowtype != null )
{
formattedValue = workflowtype.Name;
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例8: LaunchTheWorkflow
/// <summary>
/// Launch the workflow
/// </summary>
protected void LaunchTheWorkflow( string workflowName, IJobExecutionContext context )
{
Guid workflowTypeGuid = Guid.NewGuid();
if ( Guid.TryParse( workflowName, out workflowTypeGuid ) )
{
var rockContext = new RockContext();
var workflowTypeService = new WorkflowTypeService( rockContext );
var workflowType = workflowTypeService.Get( workflowTypeGuid );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, workflowName );
List<string> workflowErrors;
var processed = new Rock.Model.WorkflowService( rockContext ).Process( workflow, out workflowErrors );
context.Result = ( processed ? "Processed " : "Did not process " ) + workflow.ToString();
}
}
}
示例9: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
Guid? guid = value.AsGuidOrNull();
if ( guid.HasValue )
{
var workflowType = new WorkflowTypeService( new RockContext() )
.Queryable().FirstOrDefault( a => a.Guid.Equals( guid.Value ) );
if ( workflowType != null )
{
formattedValue = workflowType.Name;
}
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例10: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
// build a drop down list of defined types (the one that gets selected is
// used to build a list of defined values)
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.Label = "Workflow Type";
ddl.Help = "Workflow Type to select workflows from, if left blank any workflow type's workflows can be selected.";
ddl.Items.Add( new ListItem() );
var workflowTypeService = new WorkflowTypeService( new RockContext() );
var workflowTypes = workflowTypeService.Queryable().OrderBy( a => a.Name ).ToList();
workflowTypes.ForEach( g =>
ddl.Items.Add( new ListItem( g.Name, g.Id.ToString().ToUpper() ) )
);
return controls;
}
示例11: LaunchTheWorkflow
/// <summary>
/// Launch the workflow
/// </summary>
protected void LaunchTheWorkflow(string workflowName)
{
Guid workflowTypeGuid = Guid.NewGuid();
if ( Guid.TryParse( workflowName, out workflowTypeGuid ) )
{
var workflowTypeService = new WorkflowTypeService();
var workflowType = workflowTypeService.Get( workflowTypeGuid );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, workflowName );
List<string> workflowErrors;
if ( workflow.Process( out workflowErrors ) )
{
if ( workflowType.IsPersisted )
{
var workflowService = new Rock.Model.WorkflowService();
workflowService.Add( workflow, CurrentPersonId );
workflowService.Save( workflow, CurrentPersonId );
}
}
}
}
}
示例12: Execute
/// <summary>
/// Execute method to write transaction to the database.
/// </summary>
public void Execute()
{
if ( Trigger != null )
{
var workflowTypeService = new WorkflowTypeService();
var workflowType = workflowTypeService.Get( Trigger.WorkflowTypeId );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, Trigger.WorkflowName );
List<string> workflowErrors;
if ( workflow.Process( Entity, out workflowErrors ) )
{
if ( workflowType.IsPersisted )
{
var workflowService = new Rock.Model.WorkflowService();
workflowService.Add( workflow, PersonId );
workflowService.Save( workflow, PersonId );
}
}
}
}
}
示例13: GetEntityFields
//.........这里部分代码省略.........
entityField.FieldType = FieldTypeCache.Read( SystemGuid.FieldType.TEXT.AsGuid() );
}
// Integer Properties (which may be a DefinedValue)
else if ( property.PropertyType == typeof( int ) || property.PropertyType == typeof( int? ) )
{
entityField.FieldType = FieldTypeCache.Read( SystemGuid.FieldType.INTEGER.AsGuid() );
var definedValueAttribute = property.GetCustomAttribute<Rock.Data.DefinedValueAttribute>();
if ( definedValueAttribute != null )
{
// Defined Value Properties
Guid? definedTypeGuid = ( (Rock.Data.DefinedValueAttribute)definedValueAttribute ).DefinedTypeGuid;
if ( definedTypeGuid.HasValue )
{
var definedType = DefinedTypeCache.Read( definedTypeGuid.Value );
entityField.Title = definedType != null ? definedType.Name : property.Name.Replace( "ValueId", string.Empty ).SplitCase();
if ( definedType != null )
{
entityField.FieldType = FieldTypeCache.Read( SystemGuid.FieldType.DEFINED_VALUE.AsGuid() );
entityField.FieldConfig.Add( "definedtype", new Field.ConfigurationValue( definedType.Id.ToString() ) );
}
}
}
}
if ( entityField != null && entityField.FieldType != null )
{
entityFields.Add( entityField );
}
}
}
// Get Attributes
var entityTypeCache = EntityTypeCache.Read( entityType, true );
if ( entityTypeCache != null )
{
int entityTypeId = entityTypeCache.Id;
using ( var rockContext = new RockContext() )
{
var qryAttributes = new AttributeService( rockContext ).Queryable().Where( a => a.EntityTypeId == entityTypeId );
if ( entityType == typeof( Group ) )
{
// in the case of Group, show attributes that are entity global, but also ones that are qualified by GroupTypeId
qryAttributes = qryAttributes
.Where( a =>
a.EntityTypeQualifierColumn == null ||
a.EntityTypeQualifierColumn == string.Empty ||
a.EntityTypeQualifierColumn == "GroupTypeId" );
}
else if ( entityType == typeof( ContentChannelItem ) )
{
// in the case of ContentChannelItem, show attributes that are entity global, but also ones that are qualified by ContentChannelTypeId
qryAttributes = qryAttributes
.Where( a =>
a.EntityTypeQualifierColumn == null ||
a.EntityTypeQualifierColumn == string.Empty ||
a.EntityTypeQualifierColumn == "ContentChannelTypeId" );
}
else if ( entityType == typeof( Rock.Model.Workflow ) )
{
// in the case of Workflow, show attributes that are entity global, but also ones that are qualified by WorkflowTypeId (and have a valid WorkflowTypeId)
var validWorkflowTypeIds = new WorkflowTypeService(rockContext).Queryable().Select(a=> a.Id).ToList().Select(a => a.ToString()).ToList();
qryAttributes = qryAttributes
.Where( a =>
a.EntityTypeQualifierColumn == null ||
a.EntityTypeQualifierColumn == string.Empty ||
(a.EntityTypeQualifierColumn == "WorkflowTypeId" && validWorkflowTypeIds.Contains(a.EntityTypeQualifierValue) ));
}
else
{
qryAttributes = qryAttributes.Where( a => a.EntityTypeQualifierColumn == string.Empty && a.EntityTypeQualifierValue == string.Empty );
}
var attributeIdList = qryAttributes.Select( a => a.Id ).ToList();
foreach ( var attributeId in attributeIdList )
{
AddEntityFieldForAttribute( entityFields, AttributeCache.Read( attributeId ), limitToFilterableFields );
}
}
}
// Order the fields by title, name
int index = 0;
var sortedFields = new List<EntityField>();
foreach ( var entityField in entityFields.OrderBy( p => !string.IsNullOrEmpty(p.AttributeEntityTypeQualifierName)).ThenBy( p => p.Title ).ThenBy( p => p.Name ) )
{
entityField.Index = index;
index++;
sortedFields.Add( entityField );
}
if ( HttpContext.Current != null )
{
HttpContext.Current.Items[EntityHelper.GetCacheKey( entityType, includeOnlyReportingFields, limitToFilterableFields )] = sortedFields;
}
return sortedFields;
}
示例14: GetData
private List<WorkflowNavigationCategory> GetData()
{
int entityTypeId = EntityTypeCache.Read( typeof( Rock.Model.WorkflowType ) ).Id;
var selectedCategories = new List<Guid>();
GetAttributeValue( "Categories" ).SplitDelimitedValues().ToList().ForEach( c => selectedCategories.Add( c.AsGuid() ) );
bool includeChildCategories = GetAttributeValue( "IncludeChildCategories" ).AsBoolean();
var rockContext = new RockContext();
var categories = new CategoryService( rockContext ).GetNavigationItems( entityTypeId, selectedCategories, includeChildCategories, CurrentPerson );
var workflowTypes = new WorkflowTypeService( rockContext ).Queryable( "ActivityTypes.ActionTypes" ).ToList();
return GetWorkflowNavigationCategories( categories, workflowTypes );
}
示例15: lbSave_Click
//.........这里部分代码省略.........
{
// If the occurrence is based on a schedule, set the did not meet flags
foreach ( var attendance in existingAttendees )
{
attendance.DidAttend = null;
attendance.DidNotOccur = true;
}
}
foreach ( var attendee in _attendees )
{
var attendance = existingAttendees
.Where( a => a.PersonAlias.PersonId == attendee.PersonId )
.FirstOrDefault();
if ( attendance == null )
{
int? personAliasId = personAliasService.GetPrimaryAliasId( attendee.PersonId );
if ( personAliasId.HasValue )
{
attendance = new Attendance();
attendance.GroupId = _group.Id;
attendance.ScheduleId = _group.ScheduleId;
attendance.PersonAliasId = personAliasId;
attendance.StartDateTime = _occurrence.Date.Date.Add( _occurrence.StartTime );
attendance.LocationId = _occurrence.LocationId;
attendance.CampusId = campusId;
attendance.ScheduleId = _occurrence.ScheduleId;
// check that the attendance record is valid
cvAttendance.IsValid = attendance.IsValid;
if ( !cvAttendance.IsValid )
{
cvAttendance.ErrorMessage = attendance.ValidationResults.Select( a => a.ErrorMessage ).ToList().AsDelimited( "<br />" );
return;
}
attendanceService.Add( attendance );
}
}
if ( attendance != null )
{
if ( cbDidNotMeet.Checked )
{
attendance.DidAttend = null;
attendance.DidNotOccur = true;
}
else
{
attendance.DidAttend = attendee.Attended;
attendance.DidNotOccur = null;
}
}
}
}
if ( _occurrence.LocationId.HasValue )
{
Rock.CheckIn.KioskLocationAttendance.Flush( _occurrence.LocationId.Value );
}
rockContext.SaveChanges();
WorkflowType workflowType = null;
Guid? workflowTypeGuid = GetAttributeValue( "Workflow" ).AsGuidOrNull();
if ( workflowTypeGuid.HasValue )
{
var workflowTypeService = new WorkflowTypeService( rockContext );
workflowType = workflowTypeService.Get( workflowTypeGuid.Value );
if ( workflowType != null )
{
try
{
var workflow = Workflow.Activate( workflowType, _group.Name );
workflow.SetAttributeValue( "StartDateTime", _occurrence.Date.ToString( "o" ) );
workflow.SetAttributeValue( "Schedule", _group.Schedule.Guid.ToString() );
List<string> workflowErrors;
new WorkflowService( rockContext ).Process( workflow, _group, out workflowErrors );
}
catch ( Exception ex )
{
ExceptionLogService.LogException( ex, this.Context );
}
}
}
var qryParams = new Dictionary<string, string> { { "GroupId", _group.Id.ToString() } };
var groupTypeIds = PageParameter( "GroupTypeIds" );
if ( !string.IsNullOrWhiteSpace( groupTypeIds ) )
{
qryParams.Add( "GroupTypeIds", groupTypeIds );
}
NavigateToParentPage( qryParams );
}
}