Ejemplo n.º 1
0
 /// <summary>
 /// An entity has been exported and can now have any post-processing done to it
 /// that is needed. For example a processor might remove some properties that shouldn't
 /// actually have been exported.
 /// </summary>
 /// <param name="entity">The source entity that was exported.</param>
 /// <param name="encodedEntity">The exported data from the entity.</param>
 /// <param name="helper">The helper that is doing the exporting.</param>
 /// <returns>
 /// An object that will be encoded with the entity and passed to the ProcessImportEntity method later, or null.
 /// </returns>
 protected override object ProcessExportedEntity(WorkflowActionForm entity, EncodedEntity encodedEntity, EntityCoder helper)
 {
     //
     // Return the Actions data that we will pre-process on import to fixup any references.
     //
     return(entity.Actions);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is called before the entity is saved and allows any final changes to the
        /// entity before it is stored in the database. Any Guid references that are not standard
        /// properties must also be updated, such as the Actions string of a WorkflowActionForm.
        /// </summary>
        /// <param name="entity">The in-memory entity that is about to be saved.</param>
        /// <param name="encodedEntity">The encoded information that was used to reconstruct the entity.</param>
        /// <param name="data">Custom data that was previously returned by ProcessExportedEntity.</param>
        /// <param name="helper">The helper in charge of the import process.</param>
        protected override void ProcessImportedEntity(WorkflowActionForm entity, EncodedEntity encodedEntity, object data, EntityDecoder helper)
        {
            if (data != null && data is string)
            {
                //
                // Update the Guids in all the action buttons.
                //
                List <string> actions = (( string )data).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                for (int i = 0; i < actions.Count; i++)
                {
                    var details = actions[i].Split(new char[] { '^' });
                    if (details.Length > 2)
                    {
                        Guid definedValueGuid = details[1].AsGuid();
                        Guid?activityTypeGuid = details[2].AsGuidOrNull();

                        details[1] = helper.FindMappedGuid(definedValueGuid).ToString();
                        if (activityTypeGuid.HasValue)
                        {
                            details[2] = helper.FindMappedGuid(activityTypeGuid.Value).ToString();
                        }

                        actions[i] = string.Join("^", details);
                    }
                }

                entity.Actions = string.Join("|", actions);
            }
        }