From 67e476ba95b9ea96889f1e63a39a52f1a182ca91 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Thu, 10 Oct 2019 21:05:57 -0400 Subject: [PATCH 01/11] Updated assembly/program version for 1.2.0 release. --- src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs | 4 ++-- src/WFFM.ConversionTool/Program.cs | 2 +- src/WFFM.ConversionTool/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs b/src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs index 91a2d10..72976b7 100644 --- a/src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs +++ b/src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/src/WFFM.ConversionTool/Program.cs b/src/WFFM.ConversionTool/Program.cs index f3fa2f8..050dc79 100644 --- a/src/WFFM.ConversionTool/Program.cs +++ b/src/WFFM.ConversionTool/Program.cs @@ -60,7 +60,7 @@ static void Main(string[] args) System.Console.WriteLine(); System.Console.WriteLine(" ***********************************************************************"); System.Console.WriteLine(" * *"); - System.Console.WriteLine(" * WFFM Conversion Tool - v1.1.1 *"); + System.Console.WriteLine(" * WFFM Conversion Tool - v1.2.0 *"); System.Console.WriteLine(" * *"); System.Console.WriteLine(" ***********************************************************************"); System.Console.WriteLine(); diff --git a/src/WFFM.ConversionTool/Properties/AssemblyInfo.cs b/src/WFFM.ConversionTool/Properties/AssemblyInfo.cs index 460f339..3b81db5 100644 --- a/src/WFFM.ConversionTool/Properties/AssemblyInfo.cs +++ b/src/WFFM.ConversionTool/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 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.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] From 97f09e7636b5772c4499c0a9076585f3bff3bee9 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Thu, 10 Oct 2019 21:06:59 -0400 Subject: [PATCH 02/11] #8 - Added missing null check. --- .../Converters/ItemConverter.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Converters/ItemConverter.cs b/src/WFFM.ConversionTool.Library/Converters/ItemConverter.cs index fe665ee..f039967 100644 --- a/src/WFFM.ConversionTool.Library/Converters/ItemConverter.cs +++ b/src/WFFM.ConversionTool.Library/Converters/ItemConverter.cs @@ -234,10 +234,13 @@ private List ConvertFields(SCItem destItem, SCItem lastDescendantItem) } } - // Create new fields - foreach (var newField in _itemMetadataTemplate.fields.newFields) + if (_itemMetadataTemplate.fields.newFields != null) { - destFields.AddRange(_fieldFactory.CreateFields(newField, itemId, langVersions, languages)); + // Create new fields + foreach (var newField in _itemMetadataTemplate.fields.newFields) + { + destFields.AddRange(_fieldFactory.CreateFields(newField, itemId, langVersions, languages)); + } } destItem.Fields = destFields; From 4a9d4d4461d5ca7e7b356ac0e379f6fef48ca91e Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Thu, 10 Oct 2019 21:10:09 -0400 Subject: [PATCH 03/11] #7 - Fixed bug causing double creation of the Save Data submit action. --- .../Converters/SubmitConverter.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Converters/SubmitConverter.cs b/src/WFFM.ConversionTool.Library/Converters/SubmitConverter.cs index 0454863..cd40943 100644 --- a/src/WFFM.ConversionTool.Library/Converters/SubmitConverter.cs +++ b/src/WFFM.ConversionTool.Library/Converters/SubmitConverter.cs @@ -48,7 +48,7 @@ public void Convert(SCItem form, SCItem pageItem) string tracking = form.Fields.FirstOrDefault(field => field.FieldId == new Guid(FormConstants.FormTrackingFieldId))?.Value; // Save Data Action - ConvertSaveDataAction(form, buttonItem); + bool saveToDatabaseActionCreated = ConvertSaveDataAction(form, buttonItem); // Convert Submit Mode ConvertSubmitMode(form, buttonItem); @@ -57,7 +57,7 @@ public void Convert(SCItem form, SCItem pageItem) ConvertTriggerGoal(form, tracking, buttonItem); // Convert Other Save Actions - ConvertSaveActions(form, tracking, buttonItem); + ConvertSaveActions(form, tracking, buttonItem, saveToDatabaseActionCreated); } private SCItem ConvertSubmitButton(SCItem form, SCItem pageItem) @@ -92,12 +92,12 @@ private SCItem ConvertSubmitButton(SCItem form, SCItem pageItem) return buttonItem; } - private void ConvertSaveDataAction(SCItem form, SCItem buttonItem) + private bool ConvertSaveDataAction(SCItem form, SCItem buttonItem) { var saveDataValues = new Dictionary(); saveDataValues.Add(new Guid(SubmitActionConstants.SubmitActionFieldId), SubmitActionConstants.SubmitActionField_SaveActionValue); saveDataValues.Add(new Guid(BaseTemplateConstants.SortOrderFieldId), "0"); - ConvertSourceFieldToSubmitActionItem(form, new Guid(FormConstants.FormSaveToDatabaseFieldId), "1", "Save Data", saveDataValues, buttonItem); + return ConvertSourceFieldToSubmitActionItem(form, new Guid(FormConstants.FormSaveToDatabaseFieldId), "1", "Save Data", saveDataValues, buttonItem); } private void ConvertSubmitMode(SCItem form, SCItem buttonItem) @@ -196,7 +196,7 @@ private void ConvertTriggerGoal(SCItem form, string tracking, SCItem buttonItem) } } - private void ConvertSaveActions(SCItem form, string tracking, SCItem buttonItem) + private void ConvertSaveActions(SCItem form, string tracking, SCItem buttonItem, bool saveToDatabaseActionCreated) { var formSaveActionField = form.Fields .FirstOrDefault(field => field.FieldId == new Guid(FormConstants.FormSaveActionFieldId)); @@ -246,7 +246,7 @@ private void ConvertSaveActions(SCItem form, string tracking, SCItem buttonItem) } } } - else if (saveActionItem.Id == FormConstants.FormSaveAction_SaveToDatabaseValue) + else if (!saveToDatabaseActionCreated && saveActionItem.Id == FormConstants.FormSaveAction_SaveToDatabaseValue) { ConvertSaveDataAction(form, buttonItem); } @@ -328,7 +328,7 @@ private void CreateItem(string metadataTemplateName, string destItemName, Dictio WriteNewItem(metadataTemplate.destTemplateId, submitActionsFolder, destItemName, metadataTemplate); } - private void ConvertSourceFieldToSubmitActionItem(SCItem form, Guid sourceFieldId, + private bool ConvertSourceFieldToSubmitActionItem(SCItem form, Guid sourceFieldId, string sourceFieldValue, string destItemName, Dictionary destFieldValues, SCItem buttonItem) { SCField sourceFieldToConvert = null; @@ -340,7 +340,10 @@ private void ConvertSourceFieldToSubmitActionItem(SCItem form, Guid sourceFieldI if (sourceFieldToConvert == null || sourceFieldToConvert.Value == sourceFieldValue) { CreateItem("SubmitActionDefinition", destItemName, destFieldValues, buttonItem); + return true; } + + return false; } private void ConvertFieldsToSubmitActionItem(string destItemName, Dictionary destFieldValues, SCItem buttonItem) From ea68262228166af22c4f88ec26786cab5d869966 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Thu, 10 Oct 2019 21:12:03 -0400 Subject: [PATCH 04/11] Improved logging to report item ID of form when an exception is thrown. --- .../Processors/FormProcessor.cs | 110 ++++++++++-------- 1 file changed, 59 insertions(+), 51 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs index c8e2906..cedc83a 100644 --- a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs +++ b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs @@ -42,7 +42,7 @@ public class FormProcessor : ItemProcessor, IFormProcessor private readonly string ButtonTemplateName = "button"; public FormProcessor(ILogger logger, ISourceMasterRepository sourceMasterRepository, AppSettings appSettings, IMetadataProvider metadataProvider, - IDestMasterRepository destMasterRepository, IItemConverter itemConverter, IItemFactory itemFactory, SubmitConverter submitConverter, + IDestMasterRepository destMasterRepository, IItemConverter itemConverter, IItemFactory itemFactory, SubmitConverter submitConverter, FormAppearanceConverter formAppearanceConverter, SectionAppearanceConverter sectionAppearanceConverter, IReporter conversionReporter) : base(destMasterRepository, itemConverter, itemFactory, appSettings) { @@ -125,60 +125,68 @@ public List ConvertForms() foreach (var form in forms) { - // Convert and Migrate Form items - ConvertAndWriteItem(form, _appSettings.itemReferences["destFormFolderId"]); - - // Create Page item - var pageId = Guid.Empty; - SCItem pageItem = null; - if (!_destMasterRepository.ItemHasChildrenOfTemplate((Guid)destPageTemplateId, form)) - { - // Create Page items for each form (only once) - pageId = WriteNewItem((Guid)destPageTemplateId, form, "Page"); - } - else + try { - // Get Page Item Id - pageItem = _destMasterRepository.GetSitecoreChildrenItems((Guid)destPageTemplateId, form.ID).FirstOrDefault(item => string.Equals(item.Name, "Page", StringComparison.InvariantCultureIgnoreCase)); - pageId = pageItem?.ID ?? form.ID; + // Convert and Migrate Form items + ConvertAndWriteItem(form, _appSettings.itemReferences["destFormFolderId"]); + + // Create Page item + var pageId = Guid.Empty; + SCItem pageItem = null; + if (!_destMasterRepository.ItemHasChildrenOfTemplate((Guid)destPageTemplateId, form)) + { + // Create Page items for each form (only once) + pageId = WriteNewItem((Guid)destPageTemplateId, form, "Page"); + } + else + { + // Get Page Item Id + pageItem = _destMasterRepository.GetSitecoreChildrenItems((Guid)destPageTemplateId, form.ID).FirstOrDefault(item => string.Equals(item.Name, "Page", StringComparison.InvariantCultureIgnoreCase)); + pageId = pageItem?.ID ?? form.ID; + } + if (pageItem == null) pageItem = _destMasterRepository.GetSitecoreItem(pageId); + + // Convert and Migrate Section items + var sections = _sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceSectionTemplateId, form.ID); + foreach (var section in sections) + { + ConvertAndWriteItem(section, pageId); + _sectionAppearanceConverter.ConvertTitle(section); + _sectionAppearanceConverter.ConvertInformation(section); + } + + // Convert and Migrate Form Field items + List formFields = new List(); + formFields.AddRange(_sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceFieldTemplateId, form.ID)); + foreach (var section in sections) + { + formFields.AddRange(_sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceFieldTemplateId, section.ID)); + } + + foreach (var formField in formFields) + { + var parentItem = _sourceMasterRepository.GetSitecoreItem(formField.ParentID); + var destParentId = parentItem.TemplateID == sourceFormTemplateId ? pageId : parentItem.ID; + ConvertAndWriteItem(formField, destParentId); + } + + // Convert Submit form section fields + _submitConverter.Convert(form, pageItem); + + // Convert Form Appearance fields + _formAppearanceConverter.ConvertTitle(form, pageItem); + _formAppearanceConverter.ConvertIntroduction(form, pageItem); + _formAppearanceConverter.ConvertFooter(form, pageItem); + + formCounter++; + // Update progress bar + ProgressBar.DrawTextProgressBar(formCounter, forms.Count, $"forms {formAction}"); } - if (pageItem == null) pageItem = _destMasterRepository.GetSitecoreItem(pageId); - - // Convert and Migrate Section items - var sections = _sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceSectionTemplateId, form.ID); - foreach (var section in sections) - { - ConvertAndWriteItem(section, pageId); - _sectionAppearanceConverter.ConvertTitle(section); - _sectionAppearanceConverter.ConvertInformation(section); - } - - // Convert and Migrate Form Field items - List formFields = new List(); - formFields.AddRange(_sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceFieldTemplateId, form.ID)); - foreach (var section in sections) + catch (Exception ex) { - formFields.AddRange(_sourceMasterRepository.GetSitecoreChildrenItems((Guid)sourceFieldTemplateId, section.ID)); + _logger.Log(new LogEntry(LoggingEventType.Error, string.Format("Error processing form ItemID = {0}", form.ID), ex)); + throw; } - - foreach (var formField in formFields) - { - var parentItem = _sourceMasterRepository.GetSitecoreItem(formField.ParentID); - var destParentId = parentItem.TemplateID == sourceFormTemplateId ? pageId : parentItem.ID; - ConvertAndWriteItem(formField, destParentId); - } - - // Convert Submit form section fields - _submitConverter.Convert(form, pageItem); - - // Convert Form Appearance fields - _formAppearanceConverter.ConvertTitle(form, pageItem); - _formAppearanceConverter.ConvertIntroduction(form, pageItem); - _formAppearanceConverter.ConvertFooter(form, pageItem); - - formCounter++; - // Update progress bar - ProgressBar.DrawTextProgressBar(formCounter, forms.Count, $"forms {formAction}"); } if (_appSettings.enableOnlyAnalysisByDefault) From 162da632db1173ef6ddde62cd27fbb5736cde3f1 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Thu, 10 Oct 2019 21:12:21 -0400 Subject: [PATCH 05/11] Improved xml value processing. --- src/WFFM.ConversionTool.Library/Helpers/XmlHelper.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Helpers/XmlHelper.cs b/src/WFFM.ConversionTool.Library/Helpers/XmlHelper.cs index 25ff7f6..aace017 100644 --- a/src/WFFM.ConversionTool.Library/Helpers/XmlHelper.cs +++ b/src/WFFM.ConversionTool.Library/Helpers/XmlHelper.cs @@ -150,7 +150,7 @@ private static string AddParentNodeAndEncodeElementValue(string fieldValue) // Add parent xml element to value fieldValue = string.Format("{0}", fieldValue); // Escape special chars in text value - fieldValue = fieldValue.Replace(" &", " &"); + fieldValue = fieldValue.Replace(" & ", " & ").Replace(" &<"," &<"); } return fieldValue; @@ -163,7 +163,10 @@ private static string SanitizeFieldValue(string fieldValue) .Replace("<") .Replace("<") .Replace("<") - .Replace("<"); + .Replace("<") + .Replace("’", "’") + .Replace("‘", "‘") + .Replace(" "," "); } } } From 503ce77f38b98992583c5b377d08f2dcff24b50b Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Tue, 15 Oct 2019 21:31:35 -0400 Subject: [PATCH 06/11] #10 - Implemented excludeFormIds setting to exclude list of forms from being converted. --- README.md | 1 + .../Models/Metadata/AppSettings.cs | 1 + .../Processors/FormProcessor.cs | 6 ++++++ src/WFFM.ConversionTool/AppSettings.json | 7 +++++-- .../Schemas/appsettings-schema.json | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb6c42c..2ccb326 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ The tool needs to be configured before using it. The following steps describe th - `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. + - `excludeFormIds` - This setting is used to exclude a subset of source forms from the conversion process, 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. diff --git a/src/WFFM.ConversionTool.Library/Models/Metadata/AppSettings.cs b/src/WFFM.ConversionTool.Library/Models/Metadata/AppSettings.cs index 895ff3c..6748cef 100644 --- a/src/WFFM.ConversionTool.Library/Models/Metadata/AppSettings.cs +++ b/src/WFFM.ConversionTool.Library/Models/Metadata/AppSettings.cs @@ -22,6 +22,7 @@ public class AppSettings public bool analysis_ExcludeBaseStandardFields { get; set; } public bool excludeSampleWffmForms { get; set; } public List includeOnlyFormIds { get; set; } + public List excludeFormIds { get; set; } public Dictionary extensions { get; set; } diff --git a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs index cedc83a..06f1fd9 100644 --- a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs +++ b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs @@ -97,6 +97,12 @@ public List ConvertForms() forms = forms.Where(form => _appSettings.includeOnlyFormIds.Contains(form.ID)).ToList(); } + // Filter forms to exclude forms listed in appSettings "excludeFormIds" parameter + if (_appSettings.excludeFormIds != null && _appSettings.excludeFormIds.Any()) + { + forms = forms.Where(form => !_appSettings.excludeFormIds.Contains(form.ID)).ToList(); + } + // Filter sample forms out if (_appSettings.excludeSampleWffmForms) { diff --git a/src/WFFM.ConversionTool/AppSettings.json b/src/WFFM.ConversionTool/AppSettings.json index 2250ae6..aeac25a 100644 --- a/src/WFFM.ConversionTool/AppSettings.json +++ b/src/WFFM.ConversionTool/AppSettings.json @@ -59,8 +59,11 @@ "includeOnlyFormIds": [ //"{0E8906B3-99BA-421E-A74D-277ED17A32FD}" ], + "excludeFormIds": [ + //"{0E8906B3-99BA-421E-A74D-277ED17A32FD}" + ], "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. - } + "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. + } } diff --git a/src/WFFM.ConversionTool/Schemas/appsettings-schema.json b/src/WFFM.ConversionTool/Schemas/appsettings-schema.json index 0aba6ab..72a2283 100644 --- a/src/WFFM.ConversionTool/Schemas/appsettings-schema.json +++ b/src/WFFM.ConversionTool/Schemas/appsettings-schema.json @@ -184,6 +184,21 @@ ] } }, + "excludeFormIds": { + "$id": "#/properties/excludeFormIds", + "type": "array", + "required": true, + "title": "The ExcludeFormIds Schema", + "items": { + "$id": "#/properties/excludeFormIds/items", + "type": "string", + "title": "The Items Schema", + "default": "", + "examples": [ + "{4A937D74-7986-4E19-9D8E-EC14675B17F0}" + ] + } + }, "extensions": { "$id": "#/properties/extensions", "type": "object", From 21d845c1060e70b7905f0e3ee95b73699194f4a5 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Tue, 15 Oct 2019 21:39:29 -0400 Subject: [PATCH 07/11] #12 - Implemented new execution option to convert and migrate only forms data. --- README.md | 1 + src/WFFM.ConversionTool/Program.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ccb326..aa7b3df 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ In the context of a Sitecore upgrade project, if all Sitecore content items have - `WFFM.ConversionTool.exe help` or `WFFM.ConversionTool.exe ?` - Use this option to get a list of available input parameters. - `WFFM.ConversionTool.exe -convert` - Use this option to execute the conversion and migration of both forms items and their stored data to the destination databases. - `WFFM.ConversionTool.exe -convert -nodata` - Use this option to execute the conversion and migration of forms items only. Stored forms data will not be converted and migrated. + - `WFFM.ConversionTool.exe -convert -onlydata` - Use this option to execute the conversion and migration of forms data only. Only data of forms previously converted and migrated on the destination instance will be converted and migrated by this process. Data of forms that don't exist on the destination instance will not be converted and migrated. 4) After the tool execution is finished successfully, if the destination Sitecore instance was running in IIS while the tool was executed, recycle the app pool of the destination Sitecore web application to clear the Sitecore Items cache. 5) Once you login in the destination Sitecore instance, the migrated forms will not be listed in the Forms section (accessible from the Sitecore Desktop) until the `sitecore_master_index` index is rebuilt. Use the Indexing Manager in the Sitecore Control Panel to rebuild it. diff --git a/src/WFFM.ConversionTool/Program.cs b/src/WFFM.ConversionTool/Program.cs index 050dc79..deb42f2 100644 --- a/src/WFFM.ConversionTool/Program.cs +++ b/src/WFFM.ConversionTool/Program.cs @@ -28,6 +28,7 @@ class Program private static bool help = false; private static bool convert = false; private static bool nodata = false; + private static bool onlydata = false; static Program() { @@ -52,6 +53,7 @@ static void Main(string[] args) Console.WriteLine(); Console.WriteLine(" -convert to convert and migrate items and data in destination databases."); Console.WriteLine(" -convert -nodata to convert and migrate only items in destination database."); + Console.WriteLine(" -convert -onlydata to convert and migrate only forms data in destination database."); Console.WriteLine(); return; } @@ -84,10 +86,13 @@ static void Main(string[] args) appSettings.enableOnlyAnalysisByDefault = false; } - // Read and analyze source data - var formProcessor = container.GetInstance(); - formProcessor.ConvertForms(); - + if (!onlydata) + { + // Read and analyze source data + var formProcessor = container.GetInstance(); + formProcessor.ConvertForms(); + } + if (convert && !nodata) { // Convert & Migrate data @@ -119,6 +124,9 @@ private static void InitializeAppParameters(string[] args) case "nodata": nodata = true; break; + case "onlydata": + onlydata = true; + break; } } } From 35cd6582cf0ed8020d8779b79b29f83f1215603e Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Sat, 19 Oct 2019 11:23:17 -0400 Subject: [PATCH 08/11] #9 - Implemented FormId and FormName columns in conversion analytics report. --- .../Models/Reporting/ReportingRecord.cs | 2 ++ .../Processors/FormProcessor.cs | 4 ++++ .../Reporting/AnalysisReporter.cs | 7 +++++++ src/WFFM.ConversionTool.Library/Reporting/IReporter.cs | 3 +++ 4 files changed, 16 insertions(+) diff --git a/src/WFFM.ConversionTool.Library/Models/Reporting/ReportingRecord.cs b/src/WFFM.ConversionTool.Library/Models/Reporting/ReportingRecord.cs index 6bd32b2..1aa446e 100644 --- a/src/WFFM.ConversionTool.Library/Models/Reporting/ReportingRecord.cs +++ b/src/WFFM.ConversionTool.Library/Models/Reporting/ReportingRecord.cs @@ -17,6 +17,8 @@ public class ReportingRecord public string ItemLanguage { get; set; } public string ItemTemplateId { get; set; } public string ItemTemplateName { get; set; } + public string FormId { get; set; } + public string FormName { get; set; } public string FieldId { get; set; } public string FieldName { get; set; } public string FieldType { get; set; } diff --git a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs index 06f1fd9..f04cd62 100644 --- a/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs +++ b/src/WFFM.ConversionTool.Library/Processors/FormProcessor.cs @@ -133,6 +133,10 @@ public List ConvertForms() { try { + // Set current form being processed in a global variable for reporting + _conversionReporter.CurrentFormId = form.ID.ToString("B").ToUpper(); + _conversionReporter.CurrentFormName = form.Name; + // Convert and Migrate Form items ConvertAndWriteItem(form, _appSettings.itemReferences["destFormFolderId"]); diff --git a/src/WFFM.ConversionTool.Library/Reporting/AnalysisReporter.cs b/src/WFFM.ConversionTool.Library/Reporting/AnalysisReporter.cs index fd7ae41..b0acd10 100644 --- a/src/WFFM.ConversionTool.Library/Reporting/AnalysisReporter.cs +++ b/src/WFFM.ConversionTool.Library/Reporting/AnalysisReporter.cs @@ -20,6 +20,9 @@ public class AnalysisReporter : IReporter private ISourceMasterRepository _sourceMasterRepository; private AppSettings _appSettings; + public string CurrentFormId { get; set; } + public string CurrentFormName { get; set; } + private List _convertedFieldIds = new List() { FormConstants.FormTitleFieldId, @@ -119,6 +122,10 @@ public void AddUnmappedValueElementSourceField(SCField field, Guid itemId, strin private void AddReportingRecord(ReportingRecord reportingRecord) { + // Set global form processing values + reportingRecord.FormId = CurrentFormId; + reportingRecord.FormName = CurrentFormName; + _reportingRecords.Add(reportingRecord); } diff --git a/src/WFFM.ConversionTool.Library/Reporting/IReporter.cs b/src/WFFM.ConversionTool.Library/Reporting/IReporter.cs index 21e8762..1983965 100644 --- a/src/WFFM.ConversionTool.Library/Reporting/IReporter.cs +++ b/src/WFFM.ConversionTool.Library/Reporting/IReporter.cs @@ -11,6 +11,9 @@ namespace WFFM.ConversionTool.Library.Reporting { public interface IReporter { + string CurrentFormId { get; set; } + string CurrentFormName { get; set; } + void AddUnmappedItemField(SCField field, Guid itemId); void AddUnmappedFormFieldItem(Guid itemId, string sourceMappingFieldValue); void AddUnmappedSaveAction(SCField field, Guid itemId, Guid saveActionId); From 267f81716841e3eab4084b56903a14864da9a8e0 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Sat, 19 Oct 2019 13:20:53 -0400 Subject: [PATCH 09/11] #9 - Updated documentation. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index aa7b3df..8816000 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ The *analysis convertion report* contains the following columns for each record: - `ItemLanguage` - Language of the source item. - `ItemTemplateId` - Template Id of the source item. - `ItemTemplateName` - Template Name of the source item. +- `FormId` - Id of the related source form item. +- `FormName` - Name of the related source form item. - `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. From 9bd0a2a1b689c903d776c61219d54d925875591b Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Sun, 20 Oct 2019 19:32:38 -0400 Subject: [PATCH 10/11] Small changes to the tool documentation. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8816000..06e5598 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In the context of a Sitecore upgrade project, if all Sitecore content items have - `WFFM.ConversionTool.exe help` or `WFFM.ConversionTool.exe ?` - Use this option to get a list of available input parameters. - `WFFM.ConversionTool.exe -convert` - Use this option to execute the conversion and migration of both forms items and their stored data to the destination databases. - `WFFM.ConversionTool.exe -convert -nodata` - Use this option to execute the conversion and migration of forms items only. Stored forms data will not be converted and migrated. - - `WFFM.ConversionTool.exe -convert -onlydata` - Use this option to execute the conversion and migration of forms data only. Only data of forms previously converted and migrated on the destination instance will be converted and migrated by this process. Data of forms that don't exist on the destination instance will not be converted and migrated. + - `WFFM.ConversionTool.exe -convert -onlydata` - Use this option to execute the conversion and migration of forms data only. Only data of forms previously converted and migrated on the destination instance will be converted and migrated by this process. Data of forms which items don't exist on the destination instance will not be converted and migrated. 4) After the tool execution is finished successfully, if the destination Sitecore instance was running in IIS while the tool was executed, recycle the app pool of the destination Sitecore web application to clear the Sitecore Items cache. 5) Once you login in the destination Sitecore instance, the migrated forms will not be listed in the Forms section (accessible from the Sitecore Desktop) until the `sitecore_master_index` index is rebuilt. Use the Indexing Manager in the Sitecore Control Panel to rebuild it. @@ -131,7 +131,7 @@ 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 !!! +## WFFM Conversion Tool Extensions 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_.txt` file that describes step-by-step instructions to install each plugin. @@ -159,7 +159,7 @@ The `baseTemplateMetadataFileName` property should contain the name of the metad A useful online resource to validate the content of a metadata file is the [JSON Schema Validator](https://www.jsonschemavalidator.net/). The JSON schema of the metadata file is included in the tool `Schemas` folder and also available [here](https://github.com/afaniuolo/WFFM-Conversion-Tool/blob/master/src/WFFM.ConversionTool/Schemas/metadata-schema.json). ### How to Customize the Conversion of a Field Value -The *fieldConverter* property of *convertedField* mapping objects in metadata files allows to specify the name of a converter to process the source value of a field. Converters are defined in the `AppSettings.json` configuratio file in the *converters* property. This property is an array of *converter* objects that have the following properties: +The *fieldConverter* property of *convertedField* mapping objects in metadata files allows to specify the name of a converter to process the source value of a field. Converters are defined in the `AppSettings.json` configuration file in the *converters* property. This property is an array of *converter* objects that have the following properties: - `name` - Name of the converter, used as value in the *fieldConverter* property in metadata files. - `converterType` - Type of the class object that defines the converter. From ffea94131ccc6b4c88a7230b444e01f9aec3c112 Mon Sep 17 00:00:00 2001 From: Alessandro Faniuolo Date: Sun, 20 Oct 2019 19:48:20 -0400 Subject: [PATCH 11/11] Added null checks in data migrator code. --- .../Migrators/DataMigrator.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/WFFM.ConversionTool.Library/Migrators/DataMigrator.cs b/src/WFFM.ConversionTool.Library/Migrators/DataMigrator.cs index 509058a..b94a5af 100644 --- a/src/WFFM.ConversionTool.Library/Migrators/DataMigrator.cs +++ b/src/WFFM.ConversionTool.Library/Migrators/DataMigrator.cs @@ -89,6 +89,11 @@ private void MigrateFormData(Guid formId) // Get Field Data records data from forms data provider var fieldDataRecords = _dataProvider.GetFieldDataRecords(formDataRecord.Id); + if (fieldDataRecords == null || !fieldDataRecords.Any()) + { + continue; + } + // Convert the source field data records List fieldDataFormsRecords = fieldDataRecords.Select(data => ConvertFieldData(data, fieldValueTypeCollection)).ToList(); @@ -112,8 +117,8 @@ private FieldData ConvertFieldData(Database.WFFM.FieldData wffmFieldData, List f.fieldId == wffmFieldData.FieldItemId)?.dataValueConverter), - ValueType = collection.First(f => f.fieldId == wffmFieldData.FieldItemId)?.dataValueType ?? "System.String" + Value = ConvertFieldDataValue(wffmFieldData.Value, wffmFieldData.Data, collection.FirstOrDefault(f => f.fieldId == wffmFieldData.FieldItemId)?.dataValueConverter), + ValueType = collection.FirstOrDefault(f => f.fieldId == wffmFieldData.FieldItemId)?.dataValueType ?? "System.String" }; }