本文整理汇总了C#中WorkflowTypeService.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowTypeService.Clone方法的具体用法?C# WorkflowTypeService.Clone怎么用?C# WorkflowTypeService.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowTypeService
的用法示例。
在下文中一共展示了WorkflowTypeService.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCopy_Click
/// <summary>
/// Handles the Click event of the btnCopy control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void btnCopy_Click( object sender, EventArgs e )
{
var rockContext = new RockContext();
var workflowType = new WorkflowTypeService( rockContext ).Get( hfWorkflowTypeId.Value.AsInteger() );
if ( workflowType != null )
{
// Load the state objects for the source workflow type
LoadStateDetails( workflowType, rockContext );
// clone the workflow type
var newWorkflowType = workflowType.Clone( false );
newWorkflowType.CreatedByPersonAlias = null;
newWorkflowType.CreatedByPersonAliasId = null;
newWorkflowType.CreatedDateTime = RockDateTime.Now;
newWorkflowType.ModifiedByPersonAlias = null;
newWorkflowType.ModifiedByPersonAliasId = null;
newWorkflowType.ModifiedDateTime = RockDateTime.Now;
newWorkflowType.Id = 0;
newWorkflowType.Guid = Guid.NewGuid();
newWorkflowType.IsSystem = false;
newWorkflowType.Name = workflowType.Name + " - Copy";
// Create temporary state objects for the new workflow type
var newAttributesState = new List<Attribute>();
var newActivityTypesState = new List<WorkflowActivityType>();
var newActivityAttributesState = new Dictionary<Guid, List<Attribute>>();
// Dictionary to keep the attributes and activity types linked between the source and the target based on their guids
var guidXref = new Dictionary<Guid, Guid>();
// Clone the workflow attributes
foreach ( var attribute in AttributesState )
{
var newAttribute = attribute.Clone( false );
newAttribute.Id = 0;
newAttribute.Guid = Guid.NewGuid();
newAttribute.IsSystem = false;
newAttributesState.Add( newAttribute );
guidXref.Add( attribute.Guid, newAttribute.Guid );
foreach ( var qualifier in attribute.AttributeQualifiers )
{
var newQualifier = qualifier.Clone( false );
newQualifier.Id = 0;
newQualifier.Guid = Guid.NewGuid();
newQualifier.IsSystem = false;
newAttribute.AttributeQualifiers.Add( qualifier );
guidXref.Add( qualifier.Guid, newQualifier.Guid );
}
}
// Create new guids for all the existing activity types
foreach (var activityType in ActivityTypesState)
{
guidXref.Add( activityType.Guid, Guid.NewGuid() );
}
foreach ( var activityType in ActivityTypesState )
{
var newActivityType = activityType.Clone( false );
newActivityType.WorkflowTypeId = 0;
newActivityType.Id = 0;
newActivityType.Guid = guidXref[activityType.Guid];
newActivityTypesState.Add( newActivityType );
var newActivityAttributes = new List<Attribute>();
foreach ( var attribute in ActivityAttributesState[activityType.Guid] )
{
var newAttribute = attribute.Clone( false );
newAttribute.Id = 0;
newAttribute.Guid = Guid.NewGuid();
newAttribute.IsSystem = false;
newActivityAttributes.Add( newAttribute );
guidXref.Add( attribute.Guid, newAttribute.Guid );
foreach ( var qualifier in attribute.AttributeQualifiers )
{
var newQualifier = qualifier.Clone( false );
newQualifier.Id = 0;
newQualifier.Guid = Guid.NewGuid();
newQualifier.IsSystem = false;
newAttribute.AttributeQualifiers.Add( qualifier );
guidXref.Add( qualifier.Guid, newQualifier.Guid );
}
}
newActivityAttributesState.Add( newActivityType.Guid, newActivityAttributes );
foreach ( var actionType in activityType.ActionTypes )
{
var newActionType = actionType.Clone( false );
//.........这里部分代码省略.........