Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
afaniuolo committed Jul 10, 2019
2 parents f15a343 + 9e0d322 commit 946fc30
Show file tree
Hide file tree
Showing 26 changed files with 570 additions and 19 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The tool needs to be configured before using it. The following steps describe th
- `invalidItemNameChars` - This settings is used to configure the list of invalid characters to be excluded when creating a new item's name.
- `enableReferencedItemCheck` - This setting is used to enable or disable the check existence of a referenced item in any form fields value. When enabled, the tool will not populate fields that refers an item that doesn't exist in the destination Sitecore master database.
- `analysis_ExcludeBaseStandardFields` - This setting is used to exclude base standard fields of Sitecore items from the list of fields that are reported about in the *conversion analysis report* output. The exclusion of the base standard fields from the analysis reporting process doesn't exclude them from the conversion process.
- `includeOnlyFormIds` - This setting is used to select a subset of source forms to convert, specifying an array of source form IDs. This selection applies to both forms items conversion process and forms data migration process.

## How to Use the Tool
The tool should be executed in a Command Prompt window application in order to control its input parameters and visualize the execution progress.
Expand Down Expand Up @@ -115,7 +116,9 @@ The *analysis convertion report* contains the following columns for each record:
- `FieldId` - Id of the field of the souce item.
- `FieldName` - Name of the field of the source item.
- `FieldType` - Type of the field of the source item.
- `FieldValue` - Value of the field of the source item.
- `FieldValueElementName` - Name of the XML element stored in the field of the source item.
- `FieldValueElementValue` - Value of the XML element stored in the field of the source item.
- `FieldValueReferencedItemId` - Id of the item referenced as value of the XML value element.
- `FieldValueReferencedItemName` - Name of the item referenced as value of the XML value element.
- `Message` - Analysis result message. Possible values are:
Expand All @@ -124,6 +127,21 @@ The *analysis convertion report* contains the following columns for each record:
- *Source Field Element Value Not Mapped* - The source field XML element value is not mapped.
- *Form Field Item Not Mapped - Form Field Type Name = field-type-name* - The form field type is not mapped, because the field is a custom field type. Form fields that are not mapped are still migrated and converted using the default destination *Input* form field type.

## WFFM Conversion Tool Extensions - NEW !!!
The v1.1.0 release of the WFFM Conversion Tool introduces the availability of the *WFFM Conversion Tool Extensions*, a group of plugins that add support for the conversion of WFFM forms items that don't exist in the Sitecore Forms out-of-the-box solution, but that are extended using popular Sitecore modules available on the Sitecore Marketplace.

The WFFM Conversion Tool Extensions plugins are available in the `Extensions` folder in the tool root folder. Each *extension* plugin has its own subfolder that contains the plugin files and a `readme_<module_name>.txt` file that describes step-by-step instructions to install each plugin.

### Sitecore Forms Extensions
The *extension* plugin for the [Sitecore Forms Extensions](https://github.com/bartverdonck/Sitecore-Forms-Extensions) module developed by Bart Verdonck adds the support for the conversion of the following two form field types:
- Captcha field
- File Upload field

NOTE: The data of the File Upload field is converted and migrated using the storage format of the File System storage provider (`FileSystemFileUploadStorageProvider` class).

### Sitecore Forms Send Email Submit Action
The *extension* plugin for the [Sitecore Forms Send Email Submit Action](https://marketplace.sitecore.net/Modules/S/Sitecore_Forms_Send_Email_Submit_Action.aspx) module developed by Byron Calisto adds the support for the conversion of the *Send Email* submit action.

## How to Expand the WFFM Conversion Tool to Convert Custom Entities
Some of the items or fields that cannot be mapped could be custom items created to expand the out-of-the-box functionality of the Sitecore WFFM module. For example, custom entities could be custom form field types or custom save actions. To help developers to automate the conversion and migration of custom entities, the tool allows to expand its default mapping capabilities, as described in the next three sections.

Expand Down
18 changes: 18 additions & 0 deletions WFFM.ConversionTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFFM.ConversionTool.Library
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFFM.ConversionTool", "src\WFFM.ConversionTool\WFFM.ConversionTool.csproj", "{49CD87DD-7950-4296-87B0-D5495D7A3A5A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{A8AB7F81-859B-4B4C-84B3-08FD913AEC9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFFM.ConversionTool.Extensions.SitecoreFormsSendEmailSubmitAction", "src\WFFM.ConversionTool.Extensions.SitecoreFormsSendEmailSubmitAction\WFFM.ConversionTool.Extensions.SitecoreFormsSendEmailSubmitAction.csproj", "{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFFM.ConversionTool.Extensions.SitecoreFormsExtensions", "src\WFFM.ConversionTool.Extensions.SitecoreFormsExtensions\WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.csproj", "{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,10 +27,22 @@ Global
{49CD87DD-7950-4296-87B0-D5495D7A3A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49CD87DD-7950-4296-87B0-D5495D7A3A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49CD87DD-7950-4296-87B0-D5495D7A3A5A}.Release|Any CPU.Build.0 = Release|Any CPU
{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1}.Release|Any CPU.Build.0 = Release|Any CPU
{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0EA8EAA3-981A-4525-AFD5-6A539FDED0C1} = {A8AB7F81-859B-4B4C-84B3-08FD913AEC9C}
{B0F28BBF-BCDF-491B-A6D3-406F7B042C24} = {A8AB7F81-859B-4B4C-84B3-08FD913AEC9C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {30DFC773-BB3F-4D98-94A1-7E07A4F3078A}
EndGlobalSection
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Constants
{
public class MediaItemConstants
{
public const string ExtensionFieldId = "{C06867FE-9A43-4C7D-B739-48780492D06F}";
public const string MimeTypeFieldId = "{6F47A0A5-9C94-4B48-ABEB-42D38DEF6054}";
public const string SizeFieldId = "{6954B7C7-2487-423F-8600-436CB3B6DC0E}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Constants;
using WFFM.ConversionTool.Library.Converters;
using WFFM.ConversionTool.Library.Logging;
using WFFM.ConversionTool.Library.Models.Metadata;
using WFFM.ConversionTool.Library.Repositories;

namespace WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Converters.FieldValueConverter
{
public class FileUploadConverter : BaseFieldConverter
{
private ISourceMasterRepository _sourceMasterRepository;
private AppSettings _appSettings;
private ILogger _logger;

public FileUploadConverter(ISourceMasterRepository sourceMasterRepository, AppSettings appSettings, ILogger logger)
{
_sourceMasterRepository = sourceMasterRepository;
_appSettings = appSettings;
_logger = logger;
}

public override string ConvertValue(string sourceValue)
{
// Parse the value to get the media item ID
// Example: sitecore://master/{A1207618-AFC1-465A-A45A-5F1C47A59B34}?lang=en&ver=1
var mediaItemRegexMatch = Regex.Match(sourceValue, @"sitecore:\/\/master\/(.*)\?lang=(.*)&ver=1");
var mediaItemId = mediaItemRegexMatch.Groups[1].Value;
var mediaItemLanguage = mediaItemRegexMatch.Groups[2].Value;

if (string.IsNullOrEmpty(mediaItemId) || !Guid.TryParse(mediaItemId, out var mediaItemGuid))
{
return sourceValue;
}

// Get the media item from source master db and map fields
var mediaItem = _sourceMasterRepository.GetSitecoreItem(mediaItemGuid);

if (string.IsNullOrEmpty(mediaItem.Name)) return sourceValue;

var mediaItemName = mediaItem.Name;
var mediaItemExtension =
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.ExtensionFieldId))?.Value;
var mediaItemContentType =
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.MimeTypeFieldId))?.Value;
var mediaItemContentLength =
mediaItem.Fields.FirstOrDefault(f => f.FieldId == new Guid(MediaItemConstants.SizeFieldId))?.Value;

var useItemIdForFileName =
_appSettings.extensions["sitecoreFormsExtensions_UseItemIdForFilename"].ToLower() == "true";
var mediaItemFileName = useItemIdForFileName ? $"{mediaItemGuid.ToString("D").ToLower()}.{mediaItemExtension}" : $"{mediaItemName}.{mediaItemExtension}";

var mediaItemUrl = _appSettings.extensions["sitecoreFormsExtensions_FileDownloadUrlBase"]
.Replace("{0}", mediaItemFileName);

return $"{{\"Url\":\"{mediaItemUrl}\",\"OriginalFileName\":\"{mediaItemName}.{mediaItemExtension}\",\"ContentType\":\"{mediaItemContentType}\",\"ContentLength\":{mediaItemContentLength},\"StoredFileName\":\"{mediaItemFileName}\",\"StoredFilePath\":\"\"}}";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"sourceMappingFieldValue": "{827BDF4A-D886-4B36-9D32-C443EBCA1806}", // File Upload
"destTemplateId": "{27686F73-AA5C-4E0E-AC6B-E3000D129E4F}",
"destTemplateName": "FileUploadField",
"baseTemplateMetadataFileName": "Input.json",
"dataValueType": "Feature.FormsExtensions.Business.FileUpload.StoredFile",
"dataValueConverter": "FileUploadConverter",
"fields": {
"newFields": [
{
"fieldType": "shared",
"destFieldId": "{589A7ADE-81D4-4A60-B9E2-7EAF6AE8A563}", // Field Type
"value": "{687A7B09-47E3-4FAA-AB2D-A4BF83DB0F1B}"
}
],
"convertedFields": [
{
"fieldConverter": "",
"sourceFieldId": "{358E7AA0-E3E6-4EF6-92DF-EC1301737B50}", // Parameters
"destFields": [

]
},
{
"fieldConverter": "",
"sourceFieldId": "{26CDC7C2-5307-4591-A7F9-5C034A05630A}", // Localized Parameters
"destFields": [

]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"sourceMappingFieldValue": "{7FB270BE-FEFC-49C3-8CB4-947878C099E5}", // Captcha
"destTemplateId": "{5A59C481-E3C3-4A03-A471-B5D1FB45181A}", // ReCaptcha
"destTemplateName": "CaptchaField",
"baseTemplateMetadataFileName": "Field.json",
"fields": {
"newFields": [
{
"fieldType": "shared",
"destFieldId": "{589A7ADE-81D4-4A60-B9E2-7EAF6AE8A563}", // Field Type
"value": "{E383BDE2-BC88-4278-83EF-832A15C9E94A}"
}
],
"convertedFields": [
{
"fieldConverter": "",
"sourceFieldId": "{358E7AA0-E3E6-4EF6-92DF-EC1301737B50}", // Parameters
"destFields": [

]
},
{
"fieldConverter": "",
"sourceFieldId": "{26CDC7C2-5307-4591-A7F9-5C034A05630A}", // Localized Parameters
"destFields": [

]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WFFM.ConversionTool.Extensions.SitecoreFormsExtensions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WFFM.ConversionTool.Extensions.SitecoreFormsExtensions")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b0f28bbf-bcdf-491b-a6d3-406f7b042c24")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B0F28BBF-BCDF-491B-A6D3-406F7B042C24}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WFFM.ConversionTool.Extensions.SitecoreFormsExtensions</RootNamespace>
<AssemblyName>WFFM.ConversionTool.Extensions.SitecoreFormsExtensions</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants\MediaItemConstants.cs" />
<Compile Include="Converters\FieldValueConverter\FileUploadConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WFFM.ConversionTool.Library\WFFM.ConversionTool.Library.csproj">
<Project>{670ad498-f9f3-45bc-81a5-4c5841249298}</Project>
<Name>WFFM.ConversionTool.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="readme_SitecoreFormsExtensions.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Metadata\Custom\FileUpload.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Metadata\Custom\Recaptcha.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
+------------------------------------------------------+
| Installation Instructions |
+------------------------------------------------------+

1) Copy the entire module extension folder in the WFFM Conversion Tool root folder. When prompted, choose to merge the existing folders.

2) Open the AppSettings.json file located in the WFFM Conversion Tool root folder and uncomment the following JSON object in the "converters" property:

//,
//{
// "name": "FileUploadConverter",
// "converterType": "WFFM.ConversionTool.Extensions.SitecoreFormsExtensions.Converters.FieldValueConverter.FileUploadConverter, WFFM.ConversionTool.Extensions.SitecoreFormsExtensions"
//}

3) In the AppSettings.json file, modify the following settings to configure the File Upload field data conversion process:

"extensions": {
"sitecoreFormsExtensions_FileDownloadUrlBase": "https://myfile.com/{0}", // File Download Url Base for Sitecore Forms Extensions File Upload data.
"sitecoreFormsExtensions_UseItemIdForFilename": "false" // Default value: "false". If "true", the media item filename for the Sitecore Forms Extension File Upload data is built using the media item ID instead of the media item name.
}
Loading

0 comments on commit 946fc30

Please sign in to comment.