├── .gitattributes
├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── CONTRIBUTING.md
├── Capgemini.Xrm.CdsDataMigrator
├── Capgemini.Xrm.CdsDataMigrator.sln
├── Capgemini.Xrm.CdsDataMigrator
│ ├── Capgemini.Xrm.CdsDataMigrator.csproj
│ ├── Capgemini.Xrm.CdsDataMigrator.nuspec
│ ├── ILMerge.props
│ ├── ILMergeOrder.txt
│ ├── Plugin.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
├── Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit
│ ├── Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.csproj
│ ├── CdsMigratorPluginControlTests.cs
│ ├── CodeCoverage.runsettings
│ ├── Core
│ │ ├── AttributeTypeMappingTests.cs
│ │ ├── EntitySettingsTests.cs
│ │ ├── ListViewItemComparerTests.cs
│ │ ├── OrganisationsTests.cs
│ │ ├── SettingFileHandlerTest.cs
│ │ └── SettingsTests.cs
│ ├── Exceptions
│ │ └── OrganizationalServiceExceptionTests.cs
│ ├── Extensions
│ │ ├── CrmEntityExtensionsTests.cs
│ │ ├── ListViewItemExtensionsTests.cs
│ │ ├── MockWorkerHostExtensions.cs
│ │ ├── TreeNodeExtensionsTests.cs
│ │ ├── TreeViewExtensionsTests.cs
│ │ └── XrmMetadataExtensionsTests.cs
│ ├── Forms
│ │ ├── ExportFilterFormTests.cs
│ │ ├── ExportLookupMappingsFormTests.cs
│ │ └── ImportMappingsFormTests.cs
│ ├── Helpers
│ │ ├── CollectionHelpersTests.cs
│ │ └── ViewHelpersTests.cs
│ ├── Mocks
│ │ ├── MockEntityListView.cs
│ │ └── TestSynchronizationContext.cs
│ ├── Model
│ │ ├── MigratorEventArgsTests.cs
│ │ └── ServiceParametersTests.cs
│ ├── Presenters
│ │ ├── ExportFilterFormPresenterTests.cs
│ │ ├── ExportLookupMappingsFormPresenterTests.cs
│ │ ├── ExportPagePresenterTests.cs
│ │ ├── ImportMappingsFormPresenterTests.cs
│ │ ├── ImportPagePresenterTests.cs
│ │ ├── SchemaGeneratorParameterBagTests.cs
│ │ └── SchemaGeneratorPresenterTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Services
│ │ ├── CrmGenericMigratorFactoryTests.cs
│ │ ├── DataMigrationServiceTests.cs
│ │ ├── EntityRepositoryServiceTests.cs
│ │ ├── LogManagerContainerTests.cs
│ │ ├── LogToFileServiceTests.cs
│ │ └── MetadataServiceTests.cs
│ ├── TestBase.cs
│ ├── TestData
│ │ ├── BusinessUnitSchema.xml
│ │ ├── ContactSchemaWithOwner.xml
│ │ ├── ExportConfig.json
│ │ ├── ImportConfig.json
│ │ ├── ImportConfig2.json
│ │ ├── apointmentsSchema.xml
│ │ ├── testschemafile.xml
│ │ └── usersettingsschema.xml
│ ├── UserControls
│ │ ├── EntityListViewTests.cs
│ │ ├── ExportPageTests.cs
│ │ ├── ImportPageTests.cs
│ │ ├── ListManagerViewTests.cs
│ │ ├── SchemaGeneratorPageTests.cs
│ │ └── ToggleCheckBoxTests.cs
│ ├── app.config
│ └── packages.config
├── Capgemini.Xrm.CdsDataMigratorLibrary
│ ├── Attributes
│ │ └── ValidatedNotNullAttribute.cs
│ ├── Capgemini.Xrm.CdsDataMigratorLibrary.csproj
│ ├── CdsMigratorPluginControl.cs
│ ├── CdsMigratorPluginControl.designer.cs
│ ├── CdsMigratorPluginControl.resx
│ ├── Core
│ │ ├── AttributeTypeMapping.cs
│ │ ├── EntitySettings.cs
│ │ ├── Item.cs
│ │ ├── ListViewItemComparer.cs
│ │ ├── Organisations.cs
│ │ ├── SettingFileHandler.cs
│ │ └── Settings.cs
│ ├── Enums
│ │ ├── DataFormat.cs
│ │ └── LogLevel.cs
│ ├── Exceptions
│ │ ├── ExceptionService.cs
│ │ ├── IExceptionService.cs
│ │ └── OrganizationalServiceException.cs
│ ├── Extensions
│ │ ├── CrmEntityExtensions.cs
│ │ ├── ListViewItemExtensions.cs
│ │ ├── TreeNodeExtensions.cs
│ │ ├── TreeViewExtensions.cs
│ │ └── XrmMetadataExtensions.cs
│ ├── Forms
│ │ ├── ExportFilterForm.Designer.cs
│ │ ├── ExportFilterForm.cs
│ │ ├── ExportFilterForm.resx
│ │ ├── ExportLookupMappingsForm.Designer.cs
│ │ ├── ExportLookupMappingsForm.cs
│ │ ├── ImportMappingsForm.Designer.cs
│ │ ├── ImportMappingsForm.cs
│ │ └── ImportMappingsForm.resx
│ ├── Helpers
│ │ ├── CollectionHelpers.cs
│ │ ├── IViewHelpers.cs
│ │ └── ViewHelpers.cs
│ ├── Models
│ │ ├── ListBoxItem.cs
│ │ ├── MigratorEventArgs.cs
│ │ ├── SchemaExtension.cs
│ │ └── ServiceParameters.cs
│ ├── Presenters
│ │ ├── ExportFilterFormPresenter.cs
│ │ ├── ExportMappingsFormPresenter.cs
│ │ ├── ExportPagePresenter.cs
│ │ ├── IExportFilterFormView.cs
│ │ ├── IExportLookupMappingsView.cs
│ │ ├── IExportPageView.cs
│ │ ├── IExportView.cs
│ │ ├── IImportMappingsFormView.cs
│ │ ├── IImportPageView.cs
│ │ ├── ISchemaGeneratorView.cs
│ │ ├── ImportMappingsFormPresenter.cs
│ │ ├── ImportPagePresenter.cs
│ │ ├── SchemaGeneratorParameterBag.cs
│ │ └── SchemaGeneratorPresenter.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resource.Designer.cs
│ │ ├── Resource.resx
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── btImport.Image.png
│ │ ├── entities.gif
│ │ └── export1.png
│ ├── Services
│ │ ├── AbstractLogger.cs
│ │ ├── CrmGenericMigratorFactory.cs
│ │ ├── DataMigrationService.cs
│ │ ├── EntityRepositoryService.cs
│ │ ├── ICrmGenericMigratorFactory.cs
│ │ ├── IDataMigrationService.cs
│ │ ├── IEntityRepositoryService.cs
│ │ ├── ILogManagerContainer.cs
│ │ ├── IMetadataService.cs
│ │ ├── INotificationService.cs
│ │ ├── LogManagerContainer.cs
│ │ ├── LogToFileService.cs
│ │ ├── MetadataService.cs
│ │ └── NotificationService.cs
│ ├── UserControls
│ │ ├── DataverseEnvironmentSelector.Designer.cs
│ │ ├── DataverseEnvironmentSelector.cs
│ │ ├── DataverseEnvironmentSelector.resx
│ │ ├── EntityListView.Designer.cs
│ │ ├── EntityListView.cs
│ │ ├── EntityListView.resx
│ │ ├── ExportPage.Designer.cs
│ │ ├── ExportPage.cs
│ │ ├── ExportPage.resx
│ │ ├── FileInputSelector.Designer.cs
│ │ ├── FileInputSelector.cs
│ │ ├── FileInputSelector.resx
│ │ ├── FolderInputSelector.Designer.cs
│ │ ├── FolderInputSelector.cs
│ │ ├── FolderInputSelector.resx
│ │ ├── ImportPage.Designer.cs
│ │ ├── ImportPage.cs
│ │ ├── ImportPage.resx
│ │ ├── ListManagerView.Designer.cs
│ │ ├── ListManagerView.cs
│ │ ├── ListManagerView.resx
│ │ ├── SchemaGeneratorPage.Designer.cs
│ │ ├── SchemaGeneratorPage.cs
│ │ ├── SchemaGeneratorPage.resx
│ │ └── ToggleBox.cs
│ ├── app.config
│ └── packages.config
└── GlobalSuppressions.cs
├── GitVersion.yml
├── LICENSE
├── README.md
├── images
├── CDSDataMigrator.png
├── ConnectingToDynamics.png
├── ConnectionStringPrompt.png
├── D365Accounts.png
├── DataExportOutput.png
├── EditedExportConfigs.png
├── EditedImportConfigs.png
├── ExportConfigExample.png
├── ExportDataComplete.png
├── ImportConfigExample.png
├── ImportDataComplete.png
├── InitialExportPage.png
├── InitialImportPage.png
├── InitialSchemaConfig.png
├── LoadExportConfig.png
├── LoadImportConfig.png
├── RunExport.png
├── RunImport.png
├── SaveExportConfigs.png
├── SaveImportConfigs.png
├── SaveSchemaConfigs.png
├── SchemaConfigExample.png
├── SearchForCDSDatamigration.png
├── SelectSchemaConfigs.png
├── SelectToolLibrary.png
├── no.png
└── yes.png
├── nuget.config
└── pipelines
├── azure-pipelines-pull-request.yml
├── azure-pipelines.yml
└── templates
└── build-and-test-job.yml
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Provide steps and screenshots which demonstrate the usage scenario to reproduce the behavior.
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Additional context**
20 | Add any other context about the problem here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Please first discuss the change you wish to make via an issue before making a change.
4 |
5 | ## Pull request process
6 |
7 | 1. Ensure that there are automated tests that cover any changes
8 | 2. Update the README.md with details of any significant changes to functionality
9 | 3. Ensure that your commit messages increment the version using [GitVersion syntax](https://gitversion.readthedocs.io/en/latest/input/docs/more-info/version-increments/). If no message is found then the patch version will be incremented by default.
10 | 4. You may merge the pull request once it meets all of the required checks. If you do not have permision, a reviewer will do it for you
11 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29418.71
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BECE6860-D066-4502-AB89-204DA979BED5}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{5E6BB39C-47C6-4920-9B0A-E8433BF144B2}"
9 | ProjectSection(SolutionItems) = preProject
10 | ..\CONTRIBUTING.md = ..\CONTRIBUTING.md
11 | ..\README.md = ..\README.md
12 | EndProjectSection
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit", "Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit\Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.csproj", "{02FE1C61-34F2-4F47-9860-CE4B67BE915E}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capgemini.Xrm.CdsDataMigrator", "Capgemini.Xrm.CdsDataMigrator\Capgemini.Xrm.CdsDataMigrator.csproj", "{94CFA298-B643-477B-A329-F184EBF68CF6}"
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capgemini.Xrm.CdsDataMigratorLibrary", "Capgemini.Xrm.CdsDataMigratorLibrary\Capgemini.Xrm.CdsDataMigratorLibrary.csproj", "{A801DF1A-367D-42E8-8AFF-CB03179A774E}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|Any CPU = Debug|Any CPU
23 | Release|Any CPU = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {02FE1C61-34F2-4F47-9860-CE4B67BE915E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {02FE1C61-34F2-4F47-9860-CE4B67BE915E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {02FE1C61-34F2-4F47-9860-CE4B67BE915E}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {02FE1C61-34F2-4F47-9860-CE4B67BE915E}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {94CFA298-B643-477B-A329-F184EBF68CF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {94CFA298-B643-477B-A329-F184EBF68CF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {94CFA298-B643-477B-A329-F184EBF68CF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {94CFA298-B643-477B-A329-F184EBF68CF6}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {A801DF1A-367D-42E8-8AFF-CB03179A774E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {A801DF1A-367D-42E8-8AFF-CB03179A774E}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {A801DF1A-367D-42E8-8AFF-CB03179A774E}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {A801DF1A-367D-42E8-8AFF-CB03179A774E}.Release|Any CPU.Build.0 = Release|Any CPU
38 | EndGlobalSection
39 | GlobalSection(SolutionProperties) = preSolution
40 | HideSolutionNode = FALSE
41 | EndGlobalSection
42 | GlobalSection(NestedProjects) = preSolution
43 | {02FE1C61-34F2-4F47-9860-CE4B67BE915E} = {BECE6860-D066-4502-AB89-204DA979BED5}
44 | EndGlobalSection
45 | GlobalSection(ExtensibilityGlobals) = postSolution
46 | SolutionGuid = {661BCCDD-E1AB-402B-8CD2-C1E9980E0D9A}
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Capgemini.DataMigration.XrmToolBoxPlugin
5 | 0.0.0
6 | CDS Data Migrator
7 | Capgemini
8 | Capgemini
9 | https://github.com/Capgemini/xrm-datamigration-xrmtoolbox
10 | https://icon.com
11 | false
12 |
13 | The CDS Data Migrator tool provides an easy to use interface that enables you to generate an XML schema file that can be used to export data from one Dataverse environment and import into another. The tool not only supports the ability to add entity attributes and many-to-many relationships to the schema, but beyond that, it supports the creation of filters and GUID mappings which are stored as JSON file formats.
14 | Its key features include:
15 | 1) Generation of Dynamics 365 data import and/or export schema file. Both JSON and CSV formats are supported,
16 | 2) Export of data from one Dynamics 365 instance into JSON or CSV files,
17 | 3) Import of data contained with either JSON or CSV file into a Dynamics 365 instance,
18 | 4) Colour coded sorting applied to attributes,
19 | 5) Apply GUID Mappings included in export / import process,
20 | 6) Apply Filters included in the export / import process,
21 | 7) Ability to migrate Calendars.
22 |
23 | CDS Data Migrator - Export/Import of Dynamics 365 entities into JSON\CSV files
24 |
25 | 1) Changed versioning strategy to semantic versioning
26 |
27 | Capgemini Copyright © 2021
28 | XrmToolBox Plugins
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/ILMerge.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | true
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/ILMergeOrder.txt:
--------------------------------------------------------------------------------
1 | # this file contains the partial list of the merged assemblies in the merge order
2 | # you can fill it from the obj\CONFIG\PROJECT.ilmerge generated on every build
3 | # and finetune merge order to your satisfaction
4 |
5 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Capgemini.Xrm.CdsDataMigrator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Capgemini.Xrm.CdsDataMigrator")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("94cfa298-b643-477b-a329-f184ebf68cf6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.1.0.1")]
36 | [assembly: AssemblyFileVersion("1.1.0.1")]
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/CdsMigratorPluginControlTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary;
2 | using FluentAssertions;
3 | using McTools.Xrm.Connection;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using Microsoft.Xrm.Sdk;
6 | using Moq;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit
9 | {
10 | [TestClass]
11 | public class CdsMigratorPluginControlTests
12 | {
13 | [Ignore("To be fixed!")]
14 | [TestMethod]
15 | public void CdsDataMigratorPluginControl()
16 | {
17 | FluentActions.Invoking(() => new CdsMigratorPluginControl())
18 | .Should()
19 | .NotThrow();
20 | }
21 |
22 | [Ignore("To be fixed!")]
23 | [TestMethod]
24 | public void UpdateConnectionNullConnectionDetail()
25 | {
26 | var organisationService = new Mock().Object;
27 | ConnectionDetail detail = null;
28 | string actionName = "Custom";
29 | object parameter = null;
30 |
31 | using (var systemUnderTest = new CdsMigratorPluginControl())
32 | {
33 | FluentActions.Invoking(() => systemUnderTest.UpdateConnection(organisationService, detail, actionName, parameter))
34 | .Should()
35 | .NotThrow();
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/CodeCoverage.runsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | .*\.CdsDataMigratorLibrary.dll
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Core/EntitySettingsTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
2 | using FluentAssertions;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Core
6 | {
7 | [TestClass]
8 | public class EntitySettingsTests
9 | {
10 | [TestMethod]
11 | public void EntitySettingsInstantiation()
12 | {
13 | var systemUnderTest = new EntitySettings();
14 |
15 | systemUnderTest.UnmarkedAttributes.Should().NotBeNull();
16 | systemUnderTest.Filter.Should().BeNullOrEmpty();
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Core/ListViewItemComparerTests.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Core
7 | {
8 | [TestClass]
9 | public class ListViewItemComparerTests
10 | {
11 | private ListViewItemComparer systemUnderTest;
12 |
13 | [TestInitialize]
14 | public void Setup()
15 | {
16 | systemUnderTest = new ListViewItemComparer();
17 | }
18 |
19 | [TestMethod]
20 | public void ListViewItemComparerInstantiation()
21 | {
22 | FluentActions.Invoking(() => new ListViewItemComparer())
23 | .Should()
24 | .NotThrow();
25 | }
26 |
27 | [TestMethod]
28 | public void ListViewItemComparerInstantiationWithParameters()
29 | {
30 | int column = 12;
31 | SortOrder order = SortOrder.Ascending;
32 |
33 | FluentActions.Invoking(() => new ListViewItemComparer(column, order))
34 | .Should()
35 | .NotThrow();
36 | }
37 |
38 | [TestMethod]
39 | public void CompareDescending()
40 | {
41 | ListViewItem firstItem = new ListViewItem();
42 | ListViewItem secondItem = new ListViewItem();
43 |
44 | firstItem.SubItems.Add(new ListViewItem.ListViewSubItem(firstItem, "Hello"));
45 | secondItem.SubItems.Add(new ListViewItem.ListViewSubItem(secondItem, "World"));
46 |
47 | systemUnderTest = new ListViewItemComparer(0, SortOrder.Descending);
48 |
49 | var actual = systemUnderTest.Compare(firstItem, secondItem);
50 |
51 | actual.Should().Be(0);
52 | }
53 |
54 | [TestMethod]
55 | public void CompareAscending()
56 | {
57 | ListViewItem firstItem = new ListViewItem();
58 | ListViewItem secondItem = new ListViewItem();
59 |
60 | firstItem.SubItems.Add(new ListViewItem.ListViewSubItem(firstItem, "Hello"));
61 | secondItem.SubItems.Add(new ListViewItem.ListViewSubItem(secondItem, "World"));
62 |
63 | systemUnderTest = new ListViewItemComparer(0, SortOrder.Ascending);
64 |
65 | var actual = systemUnderTest.Compare(firstItem, secondItem);
66 |
67 | actual.Should().Be(0);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Core/OrganisationsTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
2 | using FluentAssertions;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Core
6 | {
7 | [TestClass]
8 | public class OrganisationsTests
9 | {
10 | [TestMethod]
11 | public void OrganisationsInstantiation()
12 | {
13 | var systemUnderTest = new Organisations();
14 |
15 | systemUnderTest.Sortcolumns.Count.Should().Be(0);
16 | systemUnderTest.Mappings.Count.Should().Be(0);
17 | systemUnderTest.Entities.Count.Should().Be(0);
18 | }
19 |
20 | [TestMethod]
21 | public void OrganisationsEntitySettings()
22 | {
23 | var key1 = "item1";
24 |
25 | Organisations systemUnderTest = new Organisations();
26 | var sampleEntitySetting = new EntitySettings();
27 | sampleEntitySetting.Filter = "Testfilter";
28 |
29 | var item = new Item(key1, sampleEntitySetting);
30 |
31 | systemUnderTest.Entities.Add(new Item("item2", new EntitySettings()));
32 | systemUnderTest.Entities.Add(item);
33 | systemUnderTest.Entities.Add(new Item("item3", new EntitySettings()));
34 |
35 | var actual = systemUnderTest[key1];
36 |
37 | actual.Filter.Should().Be("Testfilter");
38 | }
39 |
40 | [TestMethod]
41 | public void OrganisationsNpnExistingEntitySettings()
42 | {
43 | var key1 = "item1";
44 |
45 | Organisations systemUnderTest = new Organisations();
46 | var sampleEntitySetting = new EntitySettings();
47 | sampleEntitySetting.Filter = "Testfilter";
48 |
49 | var item = new Item(key1, sampleEntitySetting);
50 |
51 | systemUnderTest.Entities.Add(new Item("item2", new EntitySettings()));
52 | systemUnderTest.Entities.Add(item);
53 | systemUnderTest.Entities.Add(new Item("item3", new EntitySettings()));
54 |
55 | var actual = systemUnderTest["item4"];
56 |
57 | actual.Filter.Should().BeNullOrEmpty();
58 | actual.UnmarkedAttributes.Count.Should().Be(0);
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Core/SettingFileHandlerTest.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Controllers;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
4 | using FluentAssertions;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Core
8 | {
9 | [TestClass]
10 | public class SettingFileHandlerTest
11 | {
12 | [TestMethod]
13 | public void GetConfigData()
14 | {
15 | SettingFileHandler.GetConfigData(out Settings actual);
16 |
17 | actual.Should().NotBeNull();
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Core/SettingsTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
4 | using FluentAssertions;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using Microsoft.Xrm.Sdk;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Core
9 | {
10 | [TestClass]
11 | public class SettingsTests
12 | {
13 | [TestMethod]
14 | public void GetOrganisations()
15 | {
16 | var systemUnderTest = new Settings();
17 |
18 | var actual = systemUnderTest.Organisations;
19 |
20 | actual.Count.Should().Be(0);
21 | }
22 |
23 | [TestMethod]
24 | public void IndexerForOrganisationsWithoutItems()
25 | {
26 | var systemUnderTest = new Settings();
27 | var key = Guid.NewGuid();
28 |
29 | var actual = systemUnderTest[key.ToString()];
30 |
31 | actual.Entities.Count.Should().Be(0);
32 | actual.Mappings.Count.Should().Be(0);
33 | actual.Sortcolumns.Count.Should().Be(0);
34 | }
35 |
36 | [TestMethod]
37 | public void IndexerForOrganisationsWithItems()
38 | {
39 | var systemUnderTest = new Settings();
40 | var organisation = new Organisations();
41 |
42 | for (var counter = 0; counter < 4; counter++)
43 | {
44 | var entityRef = new EntityReference($"TestEntity{counter}", Guid.NewGuid());
45 | var mapping = new Item(entityRef, entityRef);
46 | organisation.Mappings.Add(mapping);
47 | }
48 |
49 | systemUnderTest.Organisations.Add(new KeyValuePair(Guid.NewGuid(), new Organisations() { }));
50 | systemUnderTest.Organisations.Add(new KeyValuePair(organisation.Mappings[1].Key.Id, organisation));
51 | systemUnderTest.Organisations.Add(new KeyValuePair(Guid.NewGuid(), new Organisations() { }));
52 |
53 | var actual = systemUnderTest[organisation.Mappings[1].Key.Id.ToString()];
54 |
55 | actual.Entities.Count.Should().Be(0);
56 | actual.Mappings.Count.Should().Be(organisation.Mappings.Count);
57 | actual.Sortcolumns.Count.Should().Be(0);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Exceptions/OrganizationalServiceExceptionTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.Serialization.Formatters.Binary;
4 | using Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions;
5 | using FluentAssertions;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Exceptions
9 | {
10 | [TestClass]
11 | public class OrganizationalServiceExceptionTests
12 | {
13 | private OrganizationalServiceException systemUnderTest;
14 |
15 | [TestMethod]
16 | public void OrganizationalServiceExceptionConstructWithMessageParameter()
17 | {
18 | var message = "Test message";
19 |
20 | FluentActions.Invoking(() => systemUnderTest = new OrganizationalServiceException(message))
21 | .Should()
22 | .NotThrow();
23 |
24 | Assert.AreEqual(message, systemUnderTest.Message);
25 | }
26 |
27 | [TestMethod]
28 | public void OrganizationalServiceExceptionSerialization()
29 | {
30 | var message = "Test message";
31 |
32 | var exception = new OrganizationalServiceException(message);
33 |
34 | var actual = SerializeToBytes(exception);
35 |
36 | actual.Length.Should().BeGreaterThan(0);
37 | }
38 |
39 | private static byte[] SerializeToBytes(OrganizationalServiceException e)
40 | {
41 | using (var stream = new MemoryStream())
42 | {
43 | new BinaryFormatter().Serialize(stream, e);
44 | return stream.GetBuffer();
45 | }
46 | }
47 |
48 | private static OrganizationalServiceException DeserializeFromBytes(byte[] bytes)
49 | {
50 | using (var stream = new MemoryStream(bytes))
51 | {
52 | return (OrganizationalServiceException)new BinaryFormatter().Deserialize(stream);
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Extensions/MockWorkerHostExtensions.cs:
--------------------------------------------------------------------------------
1 | using FluentAssertions;
2 | using Moq;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ComponentModel;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using XrmToolBox.Extensibility;
10 | using XrmToolBox.Extensibility.Interfaces;
11 |
12 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Extensions
13 | {
14 | internal static class MockWorkerHostExtensions
15 | {
16 | public static void ExecuteWork(this Mock mockWorkerHost, int invocationIndex)
17 | {
18 | var workInfo = mockWorkerHost.Invocations[invocationIndex].Arguments[0].As();
19 |
20 | var doWorkArgs = new DoWorkEventArgs(workInfo.AsyncArgument);
21 | Exception error = null;
22 | try
23 | {
24 | workInfo?.Work(null, doWorkArgs);
25 | }
26 | catch (Exception ex)
27 | {
28 | error = ex;
29 | }
30 |
31 | workInfo?.PostWorkCallBack(new RunWorkerCompletedEventArgs(doWorkArgs.Result, error, false));
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Extensions/TreeViewExtensionsTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using System.Collections.Generic;
3 | using FluentAssertions;
4 | using Moq;
5 | using Capgemini.Xrm.CdsDataMigrator.Tests.Unit;
6 | using System.Windows.Forms;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions.Tests
9 | {
10 | [TestClass]
11 | public class TreeViewExtensionsTests : TestBase
12 | {
13 | [TestInitialize]
14 | public void Setup()
15 | {
16 | SetupServiceMocks();
17 | }
18 |
19 | [TestMethod]
20 | public void PopulateEntitiesListViewWithMoreThanZeroNodes()
21 | {
22 | var items = new List
23 | {
24 | new System.Windows.Forms.TreeNode("Item1"),
25 | new System.Windows.Forms.TreeNode("Item2")
26 | };
27 |
28 | using (var treeView = new System.Windows.Forms.TreeView())
29 | {
30 | FluentActions.Invoking(() => treeView.PopulateEntitiesTreeView(items, null, NotificationServiceMock.Object))
31 | .Should()
32 | .NotThrow();
33 |
34 | treeView.Nodes.Count.Should().Be(items.Count);
35 | NotificationServiceMock.Verify(a => a.DisplayWarningFeedback(It.IsAny(), "The system does not contain any entities"), Times.Never);
36 | }
37 | }
38 |
39 | [TestMethod]
40 | public void PopulateEntitiesListViewWithMoreZeroNodes()
41 | {
42 | var items = new List();
43 |
44 | NotificationServiceMock.Setup(a => a.DisplayWarningFeedback(It.IsAny(), "The system does not contain any entities"));
45 |
46 | using (var treeView = new System.Windows.Forms.TreeView())
47 | {
48 | FluentActions.Invoking(() => treeView.PopulateEntitiesTreeView(items, null, NotificationServiceMock.Object))
49 | .Should()
50 | .NotThrow();
51 |
52 | treeView.Nodes.Count.Should().Be(0);
53 | NotificationServiceMock.Verify(a => a.DisplayWarningFeedback(It.IsAny(), "The system does not contain any entities"), Times.Once);
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Extensions/XrmMetadataExtensionsTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using System.Collections.Generic;
3 | using Microsoft.Xrm.Sdk.Metadata;
4 | using Capgemini.Xrm.CdsDataMigrator.Tests.Unit;
5 | using FluentAssertions;
6 | using Microsoft.Xrm.Sdk;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions.Tests
9 | {
10 | [TestClass()]
11 | public class XrmMetadataExtensionsTests : TestBase
12 | {
13 | private Dictionary> inputEntityAttributes;
14 |
15 | [TestInitialize]
16 | public void Setup()
17 | {
18 | SetupServiceMocks();
19 | inputEntityAttributes = new Dictionary>();
20 | }
21 |
22 | [TestMethod]
23 | public void FilterAttributes()
24 | {
25 | var entityMetadata = new EntityMetadata();
26 | InsertAttributeList(entityMetadata, new List { "contactattnoentity1" });
27 | bool showSystemAttributes = true;
28 |
29 | var actual = entityMetadata.FilterAttributes(showSystemAttributes);
30 |
31 | actual.Count.Should().Be(entityMetadata.Attributes.Length);
32 | }
33 |
34 | [TestMethod]
35 | public void FilterAttributesHideSystemAttributes()
36 | {
37 | var entityMetadata = new EntityMetadata();
38 | InsertAttributeList(entityMetadata, new List { "contactattnoentity1" });
39 | bool showSystemAttributes = false;
40 |
41 | var actual = entityMetadata.FilterAttributes(showSystemAttributes);
42 |
43 | actual.Count.Should().Be(0);
44 | }
45 |
46 | [TestMethod]
47 | public void ProcessAllAttributeMetadata()
48 | {
49 | string entityLogicalName = "account_contact";
50 | List unmarkedattributes = new List();
51 |
52 | var attributeList = new List()
53 | {
54 | new AttributeMetadata
55 | {
56 | LogicalName = "contactattnoentity1",
57 | DisplayName = new Label
58 | {
59 | UserLocalizedLabel = new LocalizedLabel { Label = "Test" }
60 | }
61 | }
62 | };
63 |
64 | var actual = attributeList.ProcessAllAttributeMetadata(unmarkedattributes, entityLogicalName, inputEntityAttributes);
65 |
66 | actual.Count.Should().BeGreaterThan(0);
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Forms/ExportLookupMappingsFormTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Forms;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using Microsoft.Xrm.Sdk.Metadata;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Windows.Forms;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Forms
11 | {
12 | [TestClass]
13 | public class ExportLookupMappingsFormTest
14 | {
15 | [TestMethod]
16 | public void EntityList_GetSet()
17 | {
18 | // Arrange
19 | var value = new List();
20 | using (var systemUnderTest = new ExportLookupMappings())
21 | {
22 | // Act
23 | systemUnderTest.As().EntityListDataSource = value;
24 |
25 | // Assert
26 | systemUnderTest.As().EntityListDataSource.Should().BeEquivalentTo(value);
27 |
28 | }
29 | }
30 |
31 | [TestMethod]
32 | public void FirstCellInRow_GetSet()
33 | {
34 | // Arrange
35 | var value = "account";
36 | using (var systemUnderTest = new ExportLookupMappings())
37 | {
38 | // Act
39 | systemUnderTest.As().CurrentRowEntityName = value;
40 |
41 | // Assert
42 | systemUnderTest.As().CurrentRowEntityName.Should().BeEquivalentTo(value);
43 |
44 | }
45 | }
46 |
47 | [TestMethod]
48 | public void Mappings_GetSet()
49 | {
50 | // Arrange
51 | var value = new List();
52 | using (var systemUnderTest = new ExportLookupMappings())
53 | {
54 | // Act
55 | systemUnderTest.Mappings = value;
56 |
57 | // Assert
58 | systemUnderTest.Mappings.Count.Should().Be(1);
59 |
60 | }
61 | }
62 |
63 | [TestMethod]
64 | public void OnVisibleChanged_ShouldNotifyPresenterWhenTrue()
65 | {
66 | // Arrange
67 | using (var systemUnderTest = new ExportLookupMappings())
68 | {
69 | var isCalled = false;
70 | systemUnderTest.OnVisible += (object sender, EventArgs e) => isCalled = true;
71 |
72 | // Act
73 | systemUnderTest.Visible = true;
74 |
75 | // Assert
76 | isCalled.Should().BeTrue();
77 | }
78 | }
79 |
80 | [TestMethod]
81 | public void OnVisibleChanged_ShouldNotifyPresenterWhenFalse()
82 | {
83 | // Arrange
84 | using (var systemUnderTest = new ExportLookupMappings())
85 | {
86 | var isCalled = false;
87 | systemUnderTest.OnVisible += (object sender, EventArgs e) => isCalled = true;
88 |
89 | // Act
90 | systemUnderTest.Visible = false;
91 |
92 | // Assert
93 | isCalled.Should().BeFalse();
94 | }
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Forms/ImportMappingsFormTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Forms;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Forms
9 | {
10 | [TestClass]
11 | public class ImportMappingsFormTest
12 | {
13 | [TestMethod]
14 | public void EntityList_GetSet()
15 | {
16 | // Arrange
17 | var value = new List();
18 | using (var systemUnderTest = new ImportMappingsForm())
19 | {
20 | // Act
21 | systemUnderTest.As().EntityListDataSource = value;
22 |
23 | // Assert
24 | systemUnderTest.As().EntityListDataSource.Should().BeEquivalentTo(value);
25 |
26 | }
27 | }
28 |
29 | [TestMethod]
30 | public void OnVisibleChanged_ShouldNotifyPresenterWhenTrue()
31 | {
32 | // Arrange
33 | using (var systemUnderTest = new ImportMappingsForm())
34 | {
35 | var isCalled = false;
36 | systemUnderTest.OnVisible += (object sender, EventArgs e) => isCalled = true;
37 |
38 | // Act
39 | systemUnderTest.Visible = true;
40 |
41 | // Assert
42 | isCalled.Should().BeTrue();
43 | }
44 | }
45 |
46 | [TestMethod]
47 | public void OnVisibleChanged_ShouldNotifyPresenterWhenFalse()
48 | {
49 | // Arrange
50 | using (var systemUnderTest = new ImportMappingsForm())
51 | {
52 | var isCalled = false;
53 | systemUnderTest.OnVisible += (object sender,EventArgs e) => isCalled = true;
54 |
55 | // Act
56 | systemUnderTest.Visible = false;
57 |
58 | // Assert
59 | isCalled.Should().BeFalse();
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Helpers/ViewHelpersTests.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows.Forms;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
4 | using FluentAssertions;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace Capgemini.Xrm.DataMigration.XrmToolBox.Helpers.Tests
8 | {
9 | [TestClass]
10 | public class ViewHelpersTests
11 | {
12 |
13 | private IViewHelpers systemUnderTest;
14 |
15 | [TestInitialize]
16 | public void Setup()
17 | {
18 | systemUnderTest = new ViewHelpers();
19 | }
20 |
21 | [TestMethod]
22 | public void AreAllCellsPopulated_RowWithoutEmptyCellShouldReturnTrue()
23 | {
24 | var rowWithBlankCell = GetRowWithoutBlankCell();
25 | var allCellsArePopulated = systemUnderTest.AreAllCellsPopulated(rowWithBlankCell);
26 |
27 | Assert.AreEqual(true, allCellsArePopulated);
28 | }
29 |
30 |
31 | [TestMethod]
32 | public void AreAllCellsPopulated_RowWithEmptyCellShouldReturnFalse()
33 | {
34 | var rowWithBlankCell = GetRowWithBlankCell();
35 | var allCellsArePopulated = systemUnderTest.AreAllCellsPopulated(rowWithBlankCell);
36 |
37 | Assert.AreEqual(false, allCellsArePopulated);
38 | }
39 |
40 | [TestMethod]
41 | public void GetMappingsFromViewWithEmptyRowsRemoved_EmptyRowsShouldBeCorrectlyRemoved()
42 | {
43 | var lookUpMappings = new List();
44 | var rowWithoutBlankCell = GetRowWithoutBlankCell();
45 | var rowWithBlankCell = GetRowWithBlankCell();
46 | lookUpMappings.Add(rowWithoutBlankCell);
47 | lookUpMappings.Add(rowWithBlankCell);
48 | var updatedLookupMappings = systemUnderTest.GetMappingsFromViewWithEmptyRowsRemoved(lookUpMappings);
49 | Assert.AreEqual(1, updatedLookupMappings.Count);
50 | }
51 |
52 | [TestMethod]
53 | public void GetMappingsFromViewWithEmptyRowsRemoved_NoRowsShouldBeRemoved()
54 | {
55 | var lookUpMappings = new List();
56 | var rowWithoutBlankCell = GetRowWithoutBlankCell();
57 | var anotherRowWithoutBlankCell = GetRowWithoutBlankCell();
58 | lookUpMappings.Add(rowWithoutBlankCell);
59 | lookUpMappings.Add(anotherRowWithoutBlankCell);
60 | var updatedLookupMappings = systemUnderTest.GetMappingsFromViewWithEmptyRowsRemoved(lookUpMappings);
61 | Assert.AreEqual(2, updatedLookupMappings.Count);
62 | }
63 |
64 | private static DataGridViewRow GetRowWithoutBlankCell()
65 | {
66 | DataGridViewRow dataGridViewRow = new DataGridViewRow();
67 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "Account" });
68 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "accountrelated" });
69 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "accountid" });
70 | return dataGridViewRow;
71 | }
72 |
73 | private static DataGridViewRow GetRowWithBlankCell()
74 | {
75 | DataGridViewRow dataGridViewRow = new DataGridViewRow();
76 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "Account" });
77 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "" });
78 | dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell { Value = "accountid" });
79 | return dataGridViewRow;
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Mocks/MockEntityListView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.UserControls;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Windows.Forms;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Mocks
7 | {
8 | public class MockEntityListView : EntityListView
9 | {
10 | public void SelectTreeViewNodes(List nodesToSelect)
11 | {
12 | var field = GetType().BaseType.GetField("treeViewEntities", BindingFlags.NonPublic |
13 | BindingFlags.Instance);
14 |
15 | var treeView = (TreeView)field.GetValue(this);
16 |
17 |
18 | foreach (var nodeIndex in nodesToSelect)
19 | {
20 | if (treeView.Nodes.Count > nodeIndex)
21 | {
22 | treeView.Nodes[nodeIndex].Checked = true;
23 | }
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Mocks/TestSynchronizationContext.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Mocks
4 | {
5 | public sealed class TestSynchronizationContext : SynchronizationContext
6 | {
7 | public override void Post(SendOrPostCallback d, object state)
8 | {
9 | d(state);
10 | }
11 |
12 | public override void Send(SendOrPostCallback d, object state)
13 | {
14 | d(state);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Model/MigratorEventArgsTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using FluentAssertions;
9 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
10 |
11 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Models.Tests
12 | {
13 | [TestClass]
14 | public class MigratorEventArgsTests
15 | {
16 | [TestMethod]
17 | public void MigratorEventArgs()
18 | {
19 | MigratorEventArgs migratorEventArgs = null;
20 | var input = "MigratorEventArgs";
21 |
22 | FluentActions.Invoking(() => migratorEventArgs = new MigratorEventArgs(input))
23 | .Should()
24 | .NotThrow();
25 |
26 | migratorEventArgs.Input.Should().Be(input);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Presenters/ExportLookupMappingsFormPresenterTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigrator.Tests.Unit;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
4 | using FluentAssertions;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using Microsoft.Xrm.Sdk.Metadata;
7 | using Moq;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Windows.Forms;
11 |
12 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Presenters
13 | {
14 | [TestClass]
15 | public class ExportLookupMappingsFormPresenterTests : TestBase
16 | {
17 | private Mock mockExportView;
18 | private ExportLookupMappingsFormPresenter systemUnderTest;
19 |
20 | [TestInitialize]
21 | public void TestSetup()
22 | {
23 | SetupServiceMocks();
24 | mockExportView = new Mock();
25 | systemUnderTest = new ExportLookupMappingsFormPresenter(mockExportView.Object);
26 | systemUnderTest.OrganizationService = ServiceMock.Object;
27 | systemUnderTest.MetaDataService = MetadataServiceMock.Object;
28 | systemUnderTest.ExceptionService = ExceptionServicerMock.Object;
29 | systemUnderTest.ViewHelpers = ViewHelpersMock.Object;
30 | }
31 |
32 | [TestMethod]
33 | public void ExportLookupMappingsFormInstantiation()
34 | {
35 | FluentActions.Invoking(() => new ExportLookupMappingsFormPresenter(mockExportView.Object))
36 | .Should()
37 | .NotThrow();
38 | }
39 |
40 | [TestMethod]
41 | public void OnVisible_ShouldShowMessageAndCloseWhenNullOrgServiceProvided()
42 | {
43 | // Act
44 | systemUnderTest.OrganizationService = null;
45 | mockExportView.Raise(x => x.OnVisible += null, EventArgs.Empty);
46 |
47 | // Assert
48 | ViewHelpersMock.Verify(x => x.ShowMessage(
49 | "Please make sure you are connected to an organisation", "No connection made",
50 | MessageBoxButtons.OK,
51 | MessageBoxIcon.Error), Times.Once);
52 | mockExportView.Verify(x => x.Close(), Times.Once);
53 | mockExportView.VerifySet(x => x.EntityListDataSource = It.IsAny>(), Times.Never);
54 | }
55 |
56 | [TestMethod]
57 | public void OnVisible()
58 | {
59 | string entityLogicalName = "account";
60 | SetupMockObjects(entityLogicalName);
61 | mockExportView.Raise(x => x.OnVisible += null, EventArgs.Empty);
62 | mockExportView.VerifySet(x => x.EntityListDataSource = It.IsAny>(), Times.Once);
63 | }
64 |
65 | [TestMethod]
66 | public void OnMapFieldChanged()
67 | {
68 | string entityLogicalName = "account";
69 | SetupMockObjects(entityLogicalName);
70 | mockExportView
71 | .SetupGet(x => x.CurrentCell)
72 | .Returns("account");
73 |
74 | mockExportView.Raise(x => x.OnEntityColumnChanged += null, EventArgs.Empty);
75 | mockExportView.Verify(x => x.SetRefFieldDataSource(It.IsAny()), Times.Once);
76 | }
77 |
78 | [TestMethod]
79 | public void OnRefFieldChanged()
80 | {
81 | string entityLogicalName = "account";
82 | SetupMockObjects(entityLogicalName);
83 | mockExportView
84 | .SetupGet(x => x.CurrentRowEntityName)
85 | .Returns("account");
86 |
87 | mockExportView.Raise(x => x.OnRefFieldChanged += null, EventArgs.Empty);
88 | mockExportView.Verify(x => x.SetMapFieldDataSource(It.IsAny()), Times.Once);
89 | }
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Presenters/ImportMappingsFormPresenterTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigrator.Tests.Unit;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using Moq;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Windows.Forms;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Presenters
11 | {
12 | [TestClass]
13 | public class ImportMappingsFormPresenterTests : TestBase
14 | {
15 | private Mock mockImportView;
16 | private ImportMappingsFormPresenter systemUnderTest;
17 |
18 | [TestInitialize]
19 | public void TestSetup()
20 | {
21 | SetupServiceMocks();
22 | mockImportView = new Mock();
23 | systemUnderTest = new ImportMappingsFormPresenter(mockImportView.Object);
24 | systemUnderTest.OrganizationService = ServiceMock.Object;
25 | systemUnderTest.MetaDataService = MetadataServiceMock.Object;
26 | systemUnderTest.ViewHelpers = ViewHelpersMock.Object;
27 | }
28 |
29 | [TestMethod]
30 | public void ImportLookupMappingsFormPresenterInstantiation()
31 | {
32 | FluentActions.Invoking(() => new ImportMappingsFormPresenter(mockImportView.Object))
33 | .Should()
34 | .NotThrow();
35 | }
36 |
37 | [TestMethod]
38 | public void OnVisible_ShouldShowMessageAndCloseWhenNullOrgServiceProvided()
39 | {
40 | // Act
41 | systemUnderTest.OrganizationService = null;
42 | mockImportView.Raise(x => x.OnVisible += null, EventArgs.Empty);
43 |
44 | // Assert
45 | ViewHelpersMock.Verify(x => x.ShowMessage("Please make sure you are connected to an organisation", "No connection made", MessageBoxButtons.OK, MessageBoxIcon.Information), Times.Once);
46 | mockImportView.Verify(x => x.Close(), Times.Once);
47 | mockImportView.VerifySet(x => x.EntityListDataSource = It.IsAny>(), Times.Never);
48 | }
49 |
50 | [TestMethod]
51 | public void OnVisible_ShouldPopulateEntityListAndSelectedEntity()
52 | {
53 | string entityLogicalName = "account";
54 | SetupMockObjects(entityLogicalName);
55 | mockImportView.Raise(x => x.OnVisible += null, EventArgs.Empty);
56 | mockImportView.VerifySet(x => x.EntityListDataSource = It.IsAny>(), Times.Once);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Presenters/SchemaGeneratorParameterBagTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using FluentAssertions;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters.Tests
5 | {
6 | [TestClass]
7 | public class SchemaGeneratorParameterBagTests
8 | {
9 | private SchemaGeneratorParameterBag systemUnderTest;
10 |
11 | [TestMethod]
12 | public void SchemaGeneratorParameterBag_CachedMetadata()
13 | {
14 | systemUnderTest = new SchemaGeneratorParameterBag();
15 |
16 | systemUnderTest.CachedMetadata.Count.Should().Be(0);
17 | }
18 |
19 | [TestMethod]
20 | public void SchemaGeneratorParameterBag_AttributeMapping()
21 | {
22 | systemUnderTest = new SchemaGeneratorParameterBag();
23 |
24 | systemUnderTest.AttributeMapping.Should().NotBeNull();
25 | }
26 |
27 | [TestMethod]
28 | public void SchemaGeneratorParameterBag_EntityAttributes()
29 | {
30 | systemUnderTest = new SchemaGeneratorParameterBag();
31 |
32 | systemUnderTest.EntityAttributes.Count.Should().Be(0);
33 | }
34 |
35 | [TestMethod]
36 | public void SchemaGeneratorParameterBag_EntityRelationships()
37 | {
38 | systemUnderTest = new SchemaGeneratorParameterBag();
39 |
40 | systemUnderTest.EntityRelationships.Count.Should().Be(0);
41 | }
42 |
43 | [TestMethod]
44 | public void SchemaGeneratorParameterBag_CheckedEntity()
45 | {
46 | systemUnderTest = new SchemaGeneratorParameterBag();
47 |
48 | systemUnderTest.CheckedEntity.Count.Should().Be(0);
49 | }
50 |
51 | [TestMethod]
52 | public void SchemaGeneratorParameterBag_SelectedEntity()
53 | {
54 | systemUnderTest = new SchemaGeneratorParameterBag();
55 |
56 |
57 | systemUnderTest.SelectedEntity.Count.Should().Be(0);
58 | }
59 |
60 | [TestMethod]
61 | public void SchemaGeneratorParameterBag_CheckedRelationship()
62 | {
63 | systemUnderTest = new SchemaGeneratorParameterBag();
64 |
65 | systemUnderTest.CheckedRelationship.Count.Should().Be(0);
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("Capgemini.Xrm.DataMigration.XrmToolBoxPlugin.Tests.Unit")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("Capgemini.Xrm.DataMigration.XrmToolBoxPlugin.Tests.Unit")]
10 | [assembly: AssemblyCopyright("Copyright © 2020")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: Guid("02fe1c61-34f2-4f47-9860-ce4b67be915e")]
15 |
16 | // [assembly: AssemblyVersion("1.0.*")]
17 | [assembly: AssemblyVersion("1.0.0.0")]
18 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Services/EntityRepositoryServiceTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using Microsoft.Xrm.Sdk;
6 | using Moq;
7 |
8 | namespace Capgemini.Xrm.DataMigration.XrmToolBox.Services.Tests
9 | {
10 | [TestClass]
11 | public class EntityRepositoryServiceTests
12 | {
13 | private Mock serviceMock;
14 |
15 | private EntityRepositoryService systemUnderTest;
16 |
17 | [TestInitialize]
18 | public void Setup()
19 | {
20 | serviceMock = new Mock();
21 |
22 | systemUnderTest = new EntityRepositoryService(serviceMock.Object);
23 | }
24 |
25 | [TestMethod]
26 | public void EntityRepositoryServiceTest()
27 | {
28 | systemUnderTest = new EntityRepositoryService(serviceMock.Object);
29 |
30 | systemUnderTest.Should().NotBeNull();
31 | }
32 |
33 | [TestMethod]
34 | public void InstantiateEntityRepository()
35 | {
36 | var actual = systemUnderTest.InstantiateEntityRepository(false);
37 |
38 | actual.Should().NotBeNull();
39 | }
40 |
41 | [TestMethod]
42 | public void InstantiateEntityRepositoryCloneConnection()
43 | {
44 | FluentActions.Invoking(() => systemUnderTest.InstantiateEntityRepository(true))
45 | .Should()
46 | .Throw();
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/Services/LogManagerContainerTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
3 | using FluentAssertions;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using XrmToolBox.Extensibility;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.Services
8 | {
9 | [Ignore("To be fixed!")]
10 | [TestClass]
11 | public class LogManagerContainerTests
12 | {
13 | private LogManagerContainer systemUnderTest;
14 | private readonly string message = "Sample message";
15 |
16 | [TestMethod]
17 | public void CanInstantiate()
18 | {
19 | FluentActions.Invoking(() => systemUnderTest = new LogManagerContainer(new LogManager(typeof(LogManagerContainerTests))))
20 | .Should()
21 | .NotThrow();
22 | }
23 |
24 | [TestMethod]
25 | public void WriteLineVerbose()
26 | {
27 | systemUnderTest = new LogManagerContainer(new LogManager(typeof(LogManagerContainerTests)));
28 |
29 | FluentActions.Invoking(() => systemUnderTest.WriteLine(message, LogLevel.Verbose))
30 | .Should()
31 | .NotThrow();
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/BusinessUnitSchema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/ContactSchemaWithOwner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/ExportConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "ExcludedFields": [
3 | "systemuserid",
4 | "roleid",
5 | "teamid",
6 | "fieldsecurityprofileid",
7 | "systemuserprofilesid",
8 | "systemuserrolesid",
9 | "teammembershipid",
10 | "businessunitid"
11 | ],
12 | "CrmMigrationToolSchemaPaths": [
13 | "TestData\\usersettingsschema.xml"
14 | ],
15 | "PageSize": 500,
16 | "BatchSize": 500,
17 | "TopCount": 100000,
18 | "OnlyActiveRecords": false,
19 | "JsonFolderPath": "TestData",
20 | "OneEntityPerBatch": true,
21 | "FilePrefix": "ExportedData",
22 | "SeperateFilesPerEntity": true,
23 | "LookupMapping": {
24 | "systemuser": {
25 | "businessunitid": [
26 | "name"
27 | ]
28 | },
29 | "systemuserroles": {
30 | "systemuserid": [
31 | "domainname"
32 | ],
33 | "roleid": [
34 | "name",
35 | "businessunitid"
36 | ]
37 | },
38 | "teammembership": {
39 | "systemuserid": [
40 | "domainname"
41 | ],
42 | "teamid": [
43 | "name",
44 | "businessunitid"
45 | ]
46 | },
47 | "systemuserprofiles": {
48 | "systemuserid": [
49 | "domainname"
50 | ],
51 | "fieldsecurityprofileid": [
52 | "name"
53 | ]
54 | },
55 | "usersettings": {
56 | "systemuserid": [
57 | "domainname"
58 | ]
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/ImportConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "ExcludedFields": [
3 | "systemuserid",
4 | "roleid",
5 | "teamid",
6 | "fieldsecurityprofileid",
7 | "systemuserprofilesid",
8 | "systemuserrolesid",
9 | "teammembershipid",
10 | "businessunitid"
11 | ],
12 | "CrmMigrationToolSchemaPaths": [
13 | "TestData\\usersettingsschema.xml"
14 | ],
15 | "PageSize": 500,
16 | "BatchSize": 500,
17 | "TopCount": 100000,
18 | "OnlyActiveRecords": false,
19 | "JsonFolderPath": "ExtractedData",
20 | "OneEntityPerBatch": true,
21 | "FilePrefix": "ExportedData",
22 | "SeperateFilesPerEntity": true,
23 | "MigrationConfig": {
24 | "ApplyAliasMapping": true,
25 | "Mappings": {
26 | "Account": {
27 | "00000000-0000-0000-0000-000000000003": "00000000-0000-0000-0000-000000000004"
28 | },
29 | "App Action": {
30 | "00000000-0000-0000-0000-000000000004": "00000000-0000-0000-0000-000000000005"
31 | },
32 | "AAD User": {
33 | "00000000-0000-0000-0000-000000000006": "00000000-0000-0000-0000-000000000007"
34 | }
35 | },
36 | "systemuserprofiles": {
37 | "systemuserid": [
38 | "domainname"
39 | ],
40 | "fieldsecurityprofileid": [
41 | "name"
42 | ]
43 | },
44 | "usersettings": {
45 | "systemuserid": [
46 | "domainname"
47 | ]
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/ImportConfig2.json:
--------------------------------------------------------------------------------
1 | {
2 | "IgnoreStatuses": true,
3 | "IgnoreSystemFields": true,
4 | "MigrationConfig": {
5 | "ApplyAliasMapping": true,
6 | "Mappings": {}
7 | },
8 | "SaveBatchSize": 200,
9 | "JsonFolderPath": "D:\\PackageTester\\Sample1\\ExtractedData",
10 | "DeactivateAllProcesses": false,
11 | "FilePrefix": "ExportedData",
12 | "PassOneReferences": [
13 | "businessunit",
14 | "uom",
15 | "uomschedule",
16 | "queue"
17 | ]
18 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/apointmentsSchema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/testschemafile.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/TestData/usersettingsschema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/UserControls/EntityListViewTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigrator.Tests.Unit;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.UserControls;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 | using FluentAssertions;
5 | using Microsoft.Xrm.Sdk.Metadata;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.Mocks;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit.UserControls
11 | {
12 | [TestClass]
13 | public class EntityListViewTests : TestBase
14 | {
15 | [TestMethod]
16 | public void SetEntitiesToNull()
17 | {
18 | using (var systemUnderTest = new EntityListView())
19 | {
20 | systemUnderTest.Entities = null;
21 |
22 | systemUnderTest.Entities.Should().BeNull();
23 | }
24 | }
25 |
26 | [TestMethod]
27 | public void SetEntitiesToEntityMetadata()
28 | {
29 | var entityCount = 10;
30 | var entityList = new List();
31 |
32 | for (int counter = 0; counter < entityCount; counter++)
33 | {
34 | entityList.Add(InstantiateEntityMetaData($"TestEnity{counter}"));
35 | }
36 |
37 |
38 | using (var systemUnderTest = new EntityListView())
39 | {
40 | systemUnderTest.Entities = entityList;
41 |
42 | systemUnderTest.Entities.Count.Should().Be(entityCount);
43 | systemUnderTest.Entities
44 | .All(x => x.GetType().Name == "EntityMetadata")
45 | .Should()
46 | .BeTrue();
47 | }
48 | }
49 |
50 | [TestMethod]
51 | public void SelectedEntitiesWhenEntitiesIsNull()
52 | {
53 | using (var systemUnderTest = new EntityListView())
54 | {
55 | systemUnderTest.Entities = null;
56 |
57 | var actual = systemUnderTest.SelectedEntities;
58 |
59 | actual.Count.Should().Be(0);
60 | }
61 | }
62 |
63 |
64 | [TestMethod]
65 | public void SelectedEntitiesWhenEntitiesIsNotNullAndNoItemSelected()
66 | {
67 | var entityCount = 10;
68 | var entityList = new List();
69 |
70 | for (int counter = 0; counter < entityCount; counter++)
71 | {
72 | entityList.Add(InstantiateEntityMetaData($"TestEnity{counter}"));
73 | }
74 |
75 | using (var systemUnderTest = new EntityListView())
76 | {
77 | systemUnderTest.Entities = entityList;
78 |
79 | var actual = systemUnderTest.SelectedEntities;
80 |
81 | actual.Count.Should().Be(0);
82 | }
83 | }
84 |
85 | [TestMethod]
86 | public void SelectedEntitiesWhenEntitiesIsNotNullAndItemSelected()
87 | {
88 | var entityCount = 10;
89 | var nodesToSelect = new List { 3, 7, 9 };
90 | var entityList = new List();
91 |
92 | for (int counter = 0; counter < entityCount; counter++)
93 | {
94 | entityList.Add(InstantiateEntityMetaData($"TestEnity{counter}"));
95 | }
96 |
97 | using (var systemUnderTest = new MockEntityListView())
98 | {
99 | systemUnderTest.Entities = entityList;
100 | systemUnderTest.SelectTreeViewNodes(nodesToSelect);
101 |
102 | // Act
103 | var actual = systemUnderTest.SelectedEntities;
104 |
105 | actual.Count.Should().Be(nodesToSelect.Count);
106 | }
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/UserControls/ListManagerViewTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.UserControls;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using FluentAssertions;
9 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
10 |
11 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls.Tests
12 | {
13 | [TestClass]
14 | public class ListManagerViewTests
15 | {
16 | [TestMethod]
17 | public void ListManagerView()
18 | {
19 | using (var systemUnderTest = new ListManagerView())
20 | {
21 | systemUnderTest.ListView.Items.Count.Should().Be(0);
22 | }
23 | }
24 |
25 | [TestMethod]
26 | public void SetDisplayedItemsName()
27 | {
28 | var displayName = "Test value";
29 |
30 | using (var systemUnderTest = new ListManagerView())
31 | {
32 | systemUnderTest.DisplayedItemsName = displayName;
33 |
34 | systemUnderTest.DisplayedItemsName.Should().Be(displayName);
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/UserControls/SchemaGeneratorPageTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.UserControls;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using FluentAssertions;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls.Tests
11 | {
12 | [TestClass]
13 | public class SchemaGeneratorPageTests
14 | {
15 | [TestMethod]
16 | public void SchemaGeneratorPage()
17 | {
18 | using (var systemUnderTest = new SchemaGeneratorPage())
19 | {
20 | systemUnderTest.EntityMetadataList.Should().BeNull();
21 | }
22 | }
23 |
24 | [TestMethod]
25 | public void ShowInformationPanel()
26 | {
27 | string mesage = "test message";
28 | int width = 340;
29 | int height = 150;
30 |
31 | using (var systemUnderTest = new SchemaGeneratorPage())
32 | {
33 | FluentActions.Invoking(() =>
34 | {
35 | systemUnderTest.ShowInformationPanel(mesage, width, height);
36 | })
37 | .Should()
38 | .NotThrow();
39 | }
40 | }
41 |
42 | [TestMethod]
43 | public void CloseInformationPanel()
44 | {
45 | using (var systemUnderTest = new SchemaGeneratorPage())
46 | {
47 | FluentActions.Invoking(() =>
48 | {
49 | systemUnderTest.CloseInformationPanel();
50 | })
51 | .Should()
52 | .NotThrow();
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/UserControls/ToggleCheckBoxTests.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.UserControls;
2 | using FluentAssertions;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigrator.Tests.Unit.UserControls
6 | {
7 | [TestClass]
8 | public class ToggleCheckBoxTests
9 | {
10 | [TestMethod]
11 | public void ToggleCheckBoxInitialization()
12 | {
13 | FluentActions.Invoking(() => new ToggleCheckBox())
14 | .Should()
15 | .NotThrow();
16 | }
17 |
18 | [TestMethod]
19 | public void ToggleOnPaint()
20 | {
21 | using (var systemUnderTest = new ToggleCheckBox())
22 | {
23 | using (var image = new System.Drawing.Bitmap(5, 5))
24 | {
25 | using (var graphics = System.Drawing.Graphics.FromImage(image))
26 | {
27 | using (var pevent = new System.Windows.Forms.PaintEventArgs(graphics, new System.Drawing.Rectangle(2, 2, 4, 4)))
28 | {
29 | FluentActions.Invoking(() => systemUnderTest.ProcessPaintRequest(pevent))
30 | .Should()
31 | .NotThrow();
32 | }
33 | }
34 | }
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Attributes/ValidatedNotNullAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Attributes
4 | {
5 | [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
6 | public sealed class ValidatedNotNullAttribute : Attribute
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/CdsMigratorPluginControl.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
4 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
5 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
6 | using McTools.Xrm.Connection;
7 | using Microsoft.Xrm.Sdk;
8 | using System;
9 | using System.Diagnostics.CodeAnalysis;
10 | using System.Threading;
11 | using XrmToolBox.Extensibility;
12 | using XrmToolBox.Extensibility.Args;
13 | using XrmToolBox.Extensibility.Interfaces;
14 |
15 | namespace Capgemini.Xrm.CdsDataMigratorLibrary
16 | {
17 | [ExcludeFromCodeCoverage]
18 | public partial class CdsMigratorPluginControl : PluginControlBase, IStatusBarMessenger
19 | {
20 | private readonly Settings settings;
21 | private ImportPagePresenter ImportPagePresenter;
22 | private ExportPagePresenter ExportPagePresenter;
23 | private SchemaGeneratorPresenter schemaGeneratorPresenter;
24 |
25 | public CdsMigratorPluginControl()
26 | {
27 | SettingFileHandler.GetConfigData(out settings);
28 | InitializeComponent();
29 | }
30 |
31 | public event EventHandler SendMessageToStatusBar;
32 |
33 | public override async void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName, object parameter)
34 | {
35 | if (detail != null)
36 | {
37 | var logger = new LogToFileService(new LogManagerContainer(new LogManager(typeof(CdsMigratorPluginControl))));
38 | var dataMigrationService = new DataMigrationService(logger, new CrmGenericMigratorFactory());
39 | var metaDataService = new MetadataService();
40 | var exceptionService = new ExceptionService();
41 | var viewHelpers = new ViewHelpers();
42 | var entityRepositoryService = new EntityRepositoryService(detail.ServiceClient);
43 | ImportPagePresenter = new ImportPagePresenter(this.importPage1, this, dataMigrationService, detail.ServiceClient, metaDataService, viewHelpers, entityRepositoryService);
44 | ExportPagePresenter = new ExportPagePresenter(this.exportPage1, this, dataMigrationService, detail.ServiceClient, metaDataService, exceptionService, viewHelpers);
45 | this.importPage1.SetServices(metaDataService, detail.ServiceClient, viewHelpers);
46 | this.exportPage1.SetServices(metaDataService, detail.ServiceClient, exceptionService, viewHelpers);
47 | schemaGeneratorPresenter = new SchemaGeneratorPresenter(sgpManageSchema, detail.ServiceClient, new MetadataService(), new NotificationService(), new ExceptionService(), settings);
48 | await schemaGeneratorPresenter.OnConnectionUpdated(detail.ServiceClient.ConnectedOrgId, detail.ServiceClient.ConnectedOrgFriendlyName);
49 | }
50 | base.UpdateConnection(newService, detail, actionName, parameter);
51 | }
52 |
53 | private void OnActionCompleted(object sender, EventArgs e)
54 | {
55 | SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(100, $"Completed!"));
56 | }
57 |
58 | private void OnActionProgressed(object sender, EventArgs e)
59 | {
60 | SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(50, $"Progressing..."));
61 | }
62 |
63 | private void OnActionStarted(object sender, EventArgs e)
64 | {
65 | SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(0, $"Starting..."));
66 | }
67 |
68 | private void OnConnectionRequestedHandler(object sender, RequestConnectionEventArgs e)
69 | {
70 | RaiseRequestConnectionEvent(e);
71 | }
72 |
73 | private void ShowExportPage_Click(object sender, EventArgs e)
74 | {
75 | exportPage1.BringToFront();
76 | }
77 |
78 | private void ShowSchemaManager(object sender, EventArgs e)
79 | {
80 | sgpManageSchema.BringToFront();
81 | }
82 |
83 | private void ShowImportPage_Click(object sender, EventArgs e)
84 | {
85 | importPage1.BringToFront();
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/AttributeTypeMapping.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
4 | {
5 | public class AttributeTypeMapping
6 | {
7 | public string AttributeMetadataType { get; set; }
8 |
9 | public string AttributeMetadataTypeResult { get; set; }
10 |
11 | public void GetMapping(INotificationService notificationService)
12 | {
13 | AttributeMetadataTypeResult = GetAttributeMetadataTypeResult(AttributeMetadataType, notificationService);
14 | }
15 |
16 | private static string GetAttributeMetadataTypeResult(string input, INotificationService notificationService)
17 | {
18 | var result = "Unknown";
19 |
20 | switch (input)
21 | {
22 | case "StringType":
23 | result = "string";
24 | break;
25 |
26 | case "UniqueidentifierType":
27 | result = "guid";
28 | break;
29 |
30 | case "PicklistType":
31 | result = "optionsetvalue";
32 | break;
33 |
34 | case "MoneyType":
35 | result = "money";
36 | break;
37 |
38 | case "BooleanType":
39 | result = "bool";
40 | break;
41 |
42 | case "LookupType":
43 | result = "entityreference";
44 | break;
45 |
46 | case "IntegerType":
47 | result = "integer";
48 | break;
49 |
50 | case "DateTimeType":
51 | result = "datetime";
52 | break;
53 |
54 | case "DoubleType":
55 | result = "double";
56 | break;
57 |
58 | case "DecimalType":
59 | result = "decimal";
60 | break;
61 |
62 | case "MemoType":
63 | result = "memo";
64 | break;
65 |
66 | case "ImageType":
67 | result = "image";
68 | break;
69 |
70 | case "EntityName":
71 | result = "entityname";
72 | break;
73 |
74 | case "StateType":
75 | result = "state";
76 | break;
77 |
78 | case "StatusType":
79 | result = "status";
80 | break;
81 |
82 | case "OwnerType":
83 | case "Owner":
84 | result = "entityreference";
85 | break;
86 |
87 | default:
88 | notificationService.DisplayFeedback($"Unable to map attribute - {input}.");
89 | break;
90 | }
91 |
92 | return result;
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/EntitySettings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
4 | {
5 | public class EntitySettings
6 | {
7 | public EntitySettings()
8 | {
9 | UnmarkedAttributes = new List();
10 | Filter = string.Empty;
11 | }
12 |
13 | public List UnmarkedAttributes { get; private set; }
14 |
15 | public string Filter { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/Item.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
2 | {
3 | public class Item
4 | {
5 | public Item(TKey key, TValue value)
6 | {
7 | Key = key;
8 | Value = value;
9 | }
10 |
11 | public TKey Key { get; set; }
12 |
13 | public TValue Value { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/ListViewItemComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Windows.Forms;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
6 | {
7 | public class ListViewItemComparer : IComparer
8 | {
9 | private readonly int col;
10 | private readonly SortOrder order;
11 |
12 | public ListViewItemComparer()
13 | {
14 | col = 0;
15 | order = SortOrder.Ascending;
16 | }
17 |
18 | public ListViewItemComparer(int column, SortOrder order)
19 | {
20 | col = column;
21 | this.order = order;
22 | }
23 |
24 | public int Compare(object x, object y)
25 | {
26 | var returnVal = string.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text, StringComparison.InvariantCulture);
27 |
28 | // Determine whether the sort order is descending.
29 | if (order == SortOrder.Descending)
30 | {
31 | // Invert the value returned by String.Compare.
32 | returnVal *= -1;
33 | }
34 |
35 | return returnVal;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/Organisations.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Microsoft.Xrm.Sdk;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
6 | {
7 | public class Organisations
8 | {
9 | public Organisations()
10 | {
11 | Sortcolumns = new List- >();
12 | Mappings = new List
- >();
13 | Entities = new List
- >();
14 | }
15 |
16 | public List
- > Sortcolumns { get; }
17 |
18 | public List
- > Mappings { get; }
19 |
20 | public List
- > Entities { get; }
21 |
22 | public EntitySettings this[string logicalname]
23 | {
24 | get
25 | {
26 | if (!Entities.Any(o => o.Key == logicalname))
27 | {
28 | Entities.Add(new Item(logicalname, new EntitySettings()));
29 | }
30 |
31 | return Entities.Where(o => o.Key == logicalname).Select(o => o.Value).FirstOrDefault();
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/SettingFileHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using XrmToolBox.Extensibility;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
5 | {
6 | public static class SettingFileHandler
7 | {
8 | public static bool GetConfigData(out Settings config)
9 | {
10 | var allok = SettingsManager.Instance.TryLoad(typeof(T), out config);
11 |
12 | if (config == null)
13 | {
14 | config = new Settings();
15 | }
16 |
17 | return allok;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Core/Settings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Core
6 | {
7 | public class Settings
8 | {
9 | public List> Organisations { get; } = new List>();
10 |
11 | public Organisations this[string organisationid]
12 | {
13 | get
14 | {
15 | var orgId = Guid.Parse(organisationid);
16 | if (!Organisations.Any(o => o.Key == orgId))
17 | {
18 | Organisations.Add(new KeyValuePair(orgId, new Organisations()));
19 | }
20 |
21 | return Organisations.Where(o => o.Key == orgId).Select(o => o.Value).FirstOrDefault();
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Enums/DataFormat.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Enums
2 | {
3 | public enum DataFormat
4 | {
5 | Json = 0,
6 | Csv = 1,
7 | Unknown = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Enums/LogLevel.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Enums
2 | {
3 | public enum LogLevel
4 | {
5 | Error = 0,
6 | Warning = 1,
7 | Info = 2,
8 | Verbose = 3
9 | }
10 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Exceptions/ExceptionService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using McTools.Xrm.Connection;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions
5 | {
6 | public class ExceptionService : IExceptionService
7 | {
8 | public string GetErrorMessage(Exception error, bool returnWithStackTrace)
9 | {
10 | return CrmExceptionHelper.GetErrorMessage(error, false);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Exceptions/IExceptionService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions
8 | {
9 | public interface IExceptionService
10 | {
11 | string GetErrorMessage(Exception error, bool returnWithStackTrace);
12 | }
13 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Exceptions/OrganizationalServiceException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions
5 | {
6 | [Serializable]
7 | public class OrganizationalServiceException : Exception
8 | {
9 | public OrganizationalServiceException()
10 | {
11 | }
12 |
13 | public OrganizationalServiceException(string message)
14 | : base(message)
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Extensions/CrmEntityExtensions.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.DataMigration.Model;
2 | using System.Collections.Generic;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions
5 | {
6 | public static class CrmEntityExtensions
7 | {
8 | public static void StoreEntityData(this List crmEntity, Dictionary> inputEntityAttributes, Dictionary> inputEntityRelationships)
9 | {
10 | inputEntityAttributes.Clear();
11 | inputEntityRelationships.Clear();
12 | if (crmEntity != null)
13 | {
14 | foreach (var entities in crmEntity)
15 | {
16 | var logicalName = entities.Name;
17 | var attributeSet = new HashSet();
18 | var relationShipSet = new HashSet();
19 | ExtractAttributes(entities, attributeSet);
20 | ExtractRelationships(entities, relationShipSet);
21 |
22 | inputEntityAttributes.Add(logicalName, attributeSet);
23 | inputEntityRelationships.Add(logicalName, relationShipSet);
24 | }
25 | }
26 | }
27 | private static void ExtractRelationships(CrmEntity entities, HashSet relationShipSet)
28 | {
29 | if (entities.CrmRelationships != null)
30 | {
31 | foreach (var relationship in entities.CrmRelationships)
32 | {
33 | relationShipSet.Add(relationship.RelationshipName);
34 | }
35 | }
36 | }
37 |
38 | private static void ExtractAttributes(CrmEntity entities, HashSet attributeSet)
39 | {
40 | if (entities.CrmFields != null)
41 | {
42 | foreach (var attributes in entities.CrmFields)
43 | {
44 | attributeSet.Add(attributes.FieldName);
45 | }
46 | }
47 | }
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Extensions/TreeNodeExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk.Metadata;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions
6 | {
7 | public static class TreeNodeExtensions
8 | {
9 |
10 | public static string GetEntityLogicalName(this TreeNode entityitem)
11 | {
12 | string logicalName = null;
13 | if (entityitem != null && entityitem.Tag != null)
14 | {
15 | var entity = (EntityMetadata)entityitem.Tag;
16 | logicalName = entity.LogicalName;
17 | }
18 | return logicalName;
19 | }
20 |
21 | public static void IsInvalidForCustomization(this TreeNode item, EntityMetadata entity)
22 | {
23 | if (entity != null)
24 | {
25 | if (entity.IsCustomEntity != null && entity.IsCustomEntity.Value)
26 | {
27 | item.ForeColor = Color.DarkGreen;
28 | }
29 |
30 | if (entity.IsIntersect != null && entity.IsIntersect.Value)
31 | {
32 | item.ForeColor = Color.Red;
33 | item.ToolTipText = "Intersect Entity, ";
34 | }
35 |
36 | if (entity.IsLogicalEntity != null && entity.IsLogicalEntity.Value)
37 | {
38 | item.ForeColor = Color.Red;
39 | item.ToolTipText = "Logical Entity";
40 | }
41 | }
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Extensions/TreeViewExtensions.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions
10 | {
11 | public static class TreeViewExtensions
12 | {
13 | public static void PopulateEntitiesTreeView(this TreeView treeView, List items, IWin32Window owner, INotificationService notificationService)
14 | {
15 | if (items != null && items.Count > 0)
16 | {
17 | treeView.Nodes.AddRange(items.ToArray());
18 | }
19 | else
20 | {
21 | notificationService.DisplayWarningFeedback(owner, "The system does not contain any entities");
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Extensions/XrmMetadataExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk.Metadata;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Windows.Forms;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Extensions
8 | {
9 | public static class XrmMetadataExtensions
10 | {
11 | public static List FilterAttributes(this EntityMetadata entityMetadata, bool showSystemAttributes)
12 | {
13 | var attributes = entityMetadata.Attributes?.ToList();
14 |
15 | if (attributes != null && !showSystemAttributes)
16 | {
17 | attributes = attributes.Where(p => p.IsLogical != null
18 | && !p.IsLogical.Value
19 | && p.IsValidForRead != null
20 | && p.IsValidForRead.Value
21 | && (p.IsValidForCreate != null && p.IsValidForCreate.Value || p.IsValidForUpdate != null && p.IsValidForUpdate.Value))
22 | .ToList();
23 | }
24 |
25 | return attributes;
26 | }
27 |
28 | public static List ProcessAllAttributeMetadata(this List attributes, List unmarkedattributes, string inputEntityLogicalName, Dictionary> inputEntityAttributes)
29 | {
30 | List sourceAttributesList = new List();
31 | foreach (AttributeMetadata attribute in attributes)
32 | {
33 | var name = attribute.DisplayName.UserLocalizedLabel == null ? string.Empty : attribute.DisplayName.UserLocalizedLabel.Label;
34 | var typename = attribute.AttributeTypeName == null ? string.Empty : attribute.AttributeTypeName.Value;
35 | var item = new ListViewItem(name);
36 | AddAttribute(attribute, item, typename);
37 | item.InvalidUpdate(attribute);
38 | item.Checked = unmarkedattributes.Contains(attribute.LogicalName);
39 | item.UpdateAttributeMetadataCheckBoxes(attribute.LogicalName, inputEntityAttributes, inputEntityLogicalName);
40 | sourceAttributesList.Add(item);
41 | }
42 |
43 | return sourceAttributesList;
44 | }
45 |
46 | private static void AddAttribute(AttributeMetadata attribute, ListViewItem item, string typename)
47 | {
48 | item.Tag = attribute;
49 | item.SubItems.Add(attribute.LogicalName);
50 | item.SubItems.Add(typename.EndsWith("Type", StringComparison.Ordinal) ? typename.Substring(0, typename.LastIndexOf("Type", StringComparison.Ordinal)) : typename);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Forms/ExportFilterForm.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
3 | using Capgemini.Xrm.DataMigration.Config;
4 | using Capgemini.Xrm.DataMigration.Model;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Data;
8 | using System.Diagnostics.CodeAnalysis;
9 | using System.Linq;
10 | using System.Windows.Forms;
11 |
12 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Forms
13 | {
14 | public partial class ExportFilterForm : Form, IExportFilterFormView
15 | {
16 |
17 | public event EventHandler OnVisible;
18 | public event EventHandler OnEntitySelected;
19 | public event EventHandler OnFilterTextChanged;
20 |
21 | public ExportFilterForm()
22 | {
23 | InitializeComponent();
24 |
25 | StartPosition = FormStartPosition.CenterParent;
26 | }
27 |
28 | #region data mappings
29 |
30 | public Dictionary EntityFilters { get; set; } = new Dictionary();
31 |
32 | public CrmSchemaConfiguration SchemaConfiguration { get; set; }
33 |
34 | IEnumerable> IExportFilterFormView.EntityList
35 | {
36 | get => lbxEntityNames.Items.Cast>();
37 | set
38 | {
39 | lbxEntityNames.Items.Clear();
40 | lbxEntityNames.Items.AddRange(value.ToArray());
41 | }
42 | }
43 |
44 | CrmEntity IExportFilterFormView.SelectedEntity
45 | {
46 | get => ((ListBoxItem)lbxEntityNames.SelectedItem).Item;
47 | set => lbxEntityNames.SelectedItem = ((IExportFilterFormView)this).EntityList.First(x => x.Item == value);
48 | }
49 |
50 | string IExportFilterFormView.FilterText
51 | {
52 | get => tbxFetchXmlFilter.Text;
53 | set => tbxFetchXmlFilter.Text = value;
54 | }
55 |
56 | #endregion
57 |
58 | #region event mappings
59 |
60 | protected override void OnVisibleChanged(EventArgs e)
61 | {
62 | if (Visible)
63 | {
64 | this.OnVisible?.Invoke(this, e);
65 | }
66 |
67 | base.OnVisibleChanged(e);
68 | }
69 |
70 | private void lbxEntityNames_SelectedIndexChanged(object sender, EventArgs e)
71 | {
72 | this.OnEntitySelected?.Invoke(sender, e);
73 | }
74 |
75 | private void tbxFilterText_TextChanged(object sender, EventArgs e)
76 | {
77 | this.OnFilterTextChanged?.Invoke(sender, e);
78 | }
79 |
80 | [ExcludeFromCodeCoverage]
81 | private void btnSave_Click(object sender, EventArgs e)
82 | {
83 | Close();
84 | }
85 |
86 | #endregion
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Forms/ImportMappingsForm.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Presenters;
2 | using Capgemini.Xrm.DataMigration.Config;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Data;
6 | using System.Diagnostics.CodeAnalysis;
7 | using System.Linq;
8 | using System.Windows.Forms;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Forms
11 | {
12 | public partial class ImportMappingsForm : Form, IImportMappingsFormView
13 | {
14 | public event EventHandler OnVisible;
15 |
16 | public ImportMappingsForm()
17 | {
18 | InitializeComponent();
19 |
20 | StartPosition = FormStartPosition.CenterParent;
21 | }
22 |
23 | #region data mappings
24 |
25 | public CrmSchemaConfiguration SchemaConfiguration { get; set; }
26 |
27 | IEnumerable IImportMappingsFormView.EntityListDataSource
28 | {
29 | get => clEntity.Items.Cast();
30 | set
31 | {
32 | clEntity.Items.Clear();
33 | clEntity.Items.AddRange(value.ToArray());
34 | }
35 | }
36 |
37 | public List Mappings
38 | {
39 | get
40 | {
41 | List mappings = new List();
42 | foreach (DataGridViewRow row in dgvMappings.Rows)
43 | {
44 | mappings.Add(row);
45 | }
46 | return mappings;
47 | }
48 | set
49 | {
50 | dgvMappings.Rows.Clear();
51 | foreach (DataGridViewRow row in value)
52 | {
53 | dgvMappings.Rows.Add(row);
54 | }
55 | }
56 | }
57 |
58 | #endregion
59 |
60 | #region event mappings
61 |
62 | [ExcludeFromCodeCoverage]
63 | protected override void OnVisibleChanged(EventArgs e)
64 | {
65 | if (Visible)
66 | {
67 | this.OnVisible?.Invoke(this, e);
68 | }
69 |
70 | base.OnVisibleChanged(e);
71 | }
72 |
73 | [ExcludeFromCodeCoverage]
74 | private void DataGridViewMappingsDefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
75 | {
76 | var defaultValues = new object[] { clEntity.Items[0], Guid.Empty.ToString(), Guid.Empty.ToString() };
77 | e.Row.SetValues(defaultValues);
78 | }
79 |
80 | [ExcludeFromCodeCoverage]
81 | private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
82 | {
83 | var cell = dgvMappings.CurrentCell;
84 | if (cell.IsInEditMode)
85 | {
86 | dgvMappings.CommitEdit(DataGridViewDataErrorContexts.Commit);
87 | }
88 | }
89 |
90 | [ExcludeFromCodeCoverage]
91 | private void ButtonCloseClick(object sender, EventArgs e)
92 | {
93 | Close();
94 | }
95 |
96 | #endregion
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Helpers/CollectionHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows.Forms;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Helpers
5 | {
6 | public static class CollectionHelpers
7 | {
8 | public static void StoreRelationshipIfRequiresKey(string logicalName, ItemCheckEventArgs e, string inputEntityLogicalName, Dictionary> inputEntityRelationships)
9 | {
10 | var relationshipSet = new HashSet();
11 | if (e.CurrentValue.ToString() != "Checked")
12 | {
13 | relationshipSet.Add(logicalName);
14 | }
15 |
16 | inputEntityRelationships.Add(inputEntityLogicalName, relationshipSet);
17 | }
18 |
19 | public static void StoreRelationshipIfKeyExists(string logicalName, ItemCheckEventArgs e, string inputEntityLogicalName, Dictionary> inputEntityRelationships)
20 | {
21 | var relationshipSet = inputEntityRelationships[inputEntityLogicalName];
22 |
23 | if (e.CurrentValue.ToString() == "Checked")
24 | {
25 | if (relationshipSet.Contains(logicalName))
26 | {
27 | relationshipSet.Remove(logicalName);
28 | }
29 | }
30 | else
31 | {
32 | relationshipSet.Add(logicalName);
33 | }
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Helpers/IViewHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows.Forms;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Helpers
5 | {
6 | public interface IViewHelpers
7 | {
8 | bool AreAllCellsPopulated(DataGridViewRow row);
9 | List GetMappingsFromViewWithEmptyRowsRemoved(List viewLookupMappings);
10 | DialogResult ShowMessage(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Helpers/ViewHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Windows.Forms;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Helpers
6 | {
7 | public class ViewHelpers : IViewHelpers
8 | {
9 | public bool AreAllCellsPopulated(DataGridViewRow row)
10 | {
11 | foreach (DataGridViewCell cell in row.Cells)
12 | {
13 | if (string.IsNullOrEmpty(cell.Value as string))
14 | {
15 | return false;
16 | }
17 | }
18 | return true;
19 | }
20 |
21 | public List GetMappingsFromViewWithEmptyRowsRemoved(List viewLookupMappings)
22 | {
23 | var filteredViewLookupMappings = new List();
24 | foreach (DataGridViewRow viewLookupRow in viewLookupMappings)
25 | {
26 | if (AreAllCellsPopulated(viewLookupRow))
27 | {
28 | filteredViewLookupMappings.Add(viewLookupRow);
29 | }
30 | }
31 | return filteredViewLookupMappings;
32 | }
33 |
34 | [ExcludeFromCodeCoverage]
35 | public DialogResult ShowMessage(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
36 | {
37 | return MessageBox.Show(message, caption, buttons, icon);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Models/ListBoxItem.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Models
2 | {
3 | public class ListBoxItem
4 | {
5 | public string DisplayName { get; set; }
6 | public T Item { get; set; }
7 |
8 | public override string ToString()
9 | {
10 | return DisplayName;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Models/MigratorEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Models
4 | {
5 | public class MigratorEventArgs : EventArgs
6 | {
7 | public MigratorEventArgs(T input)
8 | {
9 | Input = input;
10 | }
11 |
12 | public T Input { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/ExportFilterFormPresenter.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
3 | using Capgemini.Xrm.DataMigration.Model;
4 | using System;
5 | using System.Diagnostics.CodeAnalysis;
6 | using System.Linq;
7 | using System.Windows.Forms;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
10 | {
11 | public class ExportFilterFormPresenter : IDisposable
12 | {
13 | public readonly IExportFilterFormView view;
14 |
15 | public ExportFilterFormPresenter(IExportFilterFormView view)
16 | {
17 | this.view = view;
18 |
19 | this.view.OnVisible += OnVisible;
20 | this.view.OnEntitySelected += OnEntitySelected;
21 | this.view.OnFilterTextChanged += UpdateFilterForEntity;
22 | }
23 | [ExcludeFromCodeCoverage]
24 | public IViewHelpers ViewHelpers { get; set; }
25 |
26 | public void OnVisible(object sender, EventArgs e)
27 | {
28 | if (view.SchemaConfiguration == null || !view.SchemaConfiguration.Entities.Any())
29 | {
30 | view.Close();
31 | ViewHelpers.ShowMessage("Please specify a schema file with atleast one entity defined.", "No entities available", MessageBoxButtons.OK, MessageBoxIcon.Error);
32 | return;
33 | }
34 |
35 | view.EntityList = view.SchemaConfiguration.Entities
36 | .Select(x => new ListBoxItem { DisplayName = x.DisplayName, Item = x });
37 | view.SelectedEntity = view.EntityList.First().Item;
38 |
39 | var entitiesNoLongerInSchema = view.EntityFilters.Keys
40 | .Where(entityName => !view.SchemaConfiguration.Entities.Exists(entity => entity.Name == entityName))
41 | .ToList();
42 |
43 | foreach (var entityName in entitiesNoLongerInSchema)
44 | {
45 | view.EntityFilters.Remove(entityName);
46 | }
47 | }
48 |
49 | public void OnEntitySelected(object sender, EventArgs e)
50 | {
51 | view.FilterText = view.EntityFilters.TryGetValue(view.SelectedEntity.Name, out var filters) ? filters : string.Empty;
52 | }
53 |
54 | public void UpdateFilterForEntity(object sender, EventArgs e)
55 | {
56 | view.EntityFilters[view.SelectedEntity.Name] = view.FilterText;
57 | }
58 |
59 | [ExcludeFromCodeCoverage]
60 | public void Dispose()
61 | {
62 | Dispose(true);
63 | GC.SuppressFinalize(this);
64 | }
65 |
66 | [ExcludeFromCodeCoverage]
67 | protected virtual void Dispose(bool disposing)
68 | {
69 | this.view.OnVisible -= OnVisible;
70 | this.view.OnEntitySelected -= OnEntitySelected;
71 | this.view.OnFilterTextChanged -= UpdateFilterForEntity;
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/ExportMappingsFormPresenter.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
4 | using Microsoft.Xrm.Sdk;
5 | using Microsoft.Xrm.Sdk.Metadata;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Diagnostics.CodeAnalysis;
9 | using System.Linq;
10 | using System.Windows.Forms;
11 |
12 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
13 | {
14 | public class ExportLookupMappingsFormPresenter : IDisposable
15 | {
16 | public readonly IExportLookupMappingsView view;
17 |
18 | public ExportLookupMappingsFormPresenter(IExportLookupMappingsView view)
19 | {
20 | this.view = view;
21 |
22 | this.view.OnVisible += OnVisible;
23 | this.view.OnEntityColumnChanged += OnEntityColumnChanged;
24 | this.view.OnRefFieldChanged += OnRefFieldChanged;
25 | }
26 |
27 | [ExcludeFromCodeCoverage]
28 | public IMetadataService MetaDataService { get; set; }
29 |
30 | [ExcludeFromCodeCoverage]
31 | public IOrganizationService OrganizationService { get; set; }
32 |
33 | [ExcludeFromCodeCoverage]
34 | public IExceptionService ExceptionService { get; set; }
35 |
36 | [ExcludeFromCodeCoverage]
37 | public IViewHelpers ViewHelpers { get; set; }
38 |
39 | public void OnVisible(object sender, EventArgs e)
40 | {
41 | if (OrganizationService == null)
42 | {
43 | ShowErrorMessage();
44 | return;
45 | }
46 | if (!view.EntityListDataSource.Any())
47 | {
48 | var entities = MetaDataService.RetrieveEntities(OrganizationService);
49 | view.EntityListDataSource = entities.Select(x => x.LogicalName).OrderBy(n => n);
50 | }
51 | }
52 |
53 | public void OnEntityColumnChanged(object sender, EventArgs e)
54 | {
55 | if (OrganizationService == null)
56 | {
57 | ShowErrorMessage();
58 | return;
59 | }
60 | view.SetBothMappingFieldsToNull();
61 | var entityMeta = MetaDataService.RetrieveEntities(view.CurrentCell, OrganizationService, ExceptionService);
62 | AttributeMetadata[] refFieldAttributes = entityMeta.Attributes.Where(a => a.AttributeType == AttributeTypeCode.Lookup || a.AttributeType == AttributeTypeCode.Owner || a.AttributeType == AttributeTypeCode.Uniqueidentifier).OrderBy(p => p.LogicalName).ToArray();
63 | view.SetRefFieldDataSource(refFieldAttributes);
64 | }
65 |
66 | public void OnRefFieldChanged(object sender, EventArgs e)
67 | {
68 | if (OrganizationService == null)
69 | {
70 | ShowErrorMessage();
71 | return;
72 | }
73 | view.SetMapFieldToNull();
74 | var entityMeta = MetaDataService.RetrieveEntities(view.CurrentRowEntityName, OrganizationService, ExceptionService);
75 | AttributeMetadata[] mapFieldAttributes = entityMeta.Attributes.OrderBy(p => p.LogicalName).ToArray();
76 | view.SetMapFieldDataSource(mapFieldAttributes);
77 | }
78 |
79 | private void ShowErrorMessage()
80 | {
81 | view.Close();
82 | ViewHelpers.ShowMessage("Please make sure you are connected to an organisation", "No connection made", MessageBoxButtons.OK, MessageBoxIcon.Error);
83 | }
84 |
85 | [ExcludeFromCodeCoverage]
86 | public void Dispose()
87 | {
88 | Dispose(true);
89 | GC.SuppressFinalize(this);
90 | }
91 |
92 | [ExcludeFromCodeCoverage]
93 | protected virtual void Dispose(bool disposing)
94 | {
95 | this.view.OnVisible -= OnVisible;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IExportFilterFormView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
2 | using Capgemini.Xrm.DataMigration.Config;
3 | using Capgemini.Xrm.DataMigration.Model;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Windows.Forms;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
9 | {
10 | public interface IExportFilterFormView
11 | {
12 | Dictionary EntityFilters { get; }
13 | CrmSchemaConfiguration SchemaConfiguration { get; }
14 | IEnumerable> EntityList { get; set; }
15 | CrmEntity SelectedEntity { get; set; }
16 | string FilterText { get; set; }
17 |
18 | event EventHandler OnVisible;
19 | event EventHandler OnEntitySelected;
20 | event EventHandler OnFilterTextChanged;
21 |
22 | void Close();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IExportLookupMappingsView.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk.Metadata;
2 | using System;
3 | using System.Collections.Generic;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
6 | {
7 | public interface IExportLookupMappingsView
8 | {
9 | event EventHandler OnVisible;
10 | event EventHandler OnEntityColumnChanged;
11 | event EventHandler OnRefFieldChanged;
12 |
13 | string CurrentRowEntityName { get; set; }
14 | IEnumerable EntityListDataSource { get; set; }
15 | string CurrentCell { get; set; }
16 |
17 | void SetMapFieldToNull();
18 | void SetRefFieldDataSource(AttributeMetadata[] refFieldAttributes);
19 | void SetMapFieldDataSource(AttributeMetadata[] mapFieldAttributes);
20 | void SetBothMappingFieldsToNull();
21 | void Close();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IExportPageView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 | using Capgemini.Xrm.DataMigration.Config;
3 | using Microsoft.Xrm.Sdk;
4 | using Microsoft.Xrm.Sdk.Metadata;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Windows.Forms;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
10 | {
11 | public interface IExportPageView
12 | {
13 | //TODO: List ExcludedFields { get; set; }
14 | //TODO: string FetchXMLFolderPath { get; set; }
15 | //TODO: List FieldsToObfuscate { get; set; }
16 | string CrmMigrationToolSchemaPath { get; set; }
17 | Dictionary CrmMigrationToolSchemaFilters { get; set; }
18 | CrmSchemaConfiguration SchemaConfiguration { get; set; }
19 | int PageSize { get; set; }
20 | int BatchSize { get; set; }
21 | int TopCount { get; set; }
22 | bool OnlyActiveRecords { get; set; }
23 | string JsonFolderPath { get; set; }
24 | bool OneEntityPerBatch { get; set; }
25 | string FilePrefix { get; set; }
26 | bool SeperateFilesPerEntity { get; set; }
27 | List LookupMappings { get; set; }
28 | DataFormat DataFormat { get; set; }
29 | IOrganizationService Service { get; }
30 |
31 | event EventHandler LoadConfigClicked;
32 | event EventHandler SaveConfigClicked;
33 | event EventHandler RunConfigClicked;
34 | event EventHandler SchemaConfigPathChanged;
35 |
36 | string AskForFilePathToOpen();
37 | string AskForFilePathToSave(string existingFileName = "");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IExportView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Xrm.Sdk;
3 | using XrmToolBox.Extensibility;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
6 | {
7 | public interface IExportView
8 | {
9 | event EventHandler SelectExportLocationHandler;
10 |
11 | event EventHandler SelectExportConfigFileHandler;
12 |
13 | event EventHandler SelectSchemaFileHandler;
14 |
15 | event EventHandler ExportDataHandler;
16 |
17 | event EventHandler CancelHandler;
18 |
19 | event EventHandler OnConnectionRequested;
20 |
21 | bool FormatJsonSelected { get; set; }
22 |
23 | bool FormatCsvSelected { get; set; }
24 |
25 | string SaveExportLocation { get; set; }
26 |
27 | string ExportConfigFileLocation { get; set; }
28 |
29 | string ExportSchemaFileLocation { get; set; }
30 |
31 | bool ExportInactiveRecordsChecked { get; set; }
32 |
33 | bool MinimizeJsonChecked { get; set; }
34 |
35 | decimal BatchSize { get; set; }
36 |
37 | IOrganizationService OrganizationService { get; set; }
38 |
39 | string ShowFolderBrowserDialog();
40 |
41 | string ShowFileDialog();
42 | }
43 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IImportMappingsFormView.cs:
--------------------------------------------------------------------------------
1 |
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
4 | using Capgemini.Xrm.DataMigration.Config;
5 | using Capgemini.Xrm.DataMigration.Model;
6 | using Microsoft.Xrm.Sdk;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Windows.Forms;
10 |
11 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
12 | {
13 | public interface IImportMappingsFormView
14 | {
15 | CrmSchemaConfiguration SchemaConfiguration { get; }
16 | event EventHandler OnVisible;
17 |
18 | IEnumerable EntityListDataSource { get; set; }
19 | List Mappings { get; set; }
20 |
21 | void Close();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/IImportPageView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 | using Capgemini.Xrm.DataMigration.Config;
3 | using Microsoft.Xrm.Sdk;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Windows.Forms;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
9 | {
10 | public interface IImportPageView
11 | {
12 | int SaveBatchSize { get; set; }
13 | bool IgnoreStatuses { get; set; }
14 | bool IgnoreSystemFields { get; set; }
15 | string JsonFolderPath { get; set; }
16 | decimal MaxThreads { get; set; }
17 |
18 | CrmSchemaConfiguration SchemaConfiguration { get; set; }
19 | List Mappings { get; set; }
20 | string CrmMigrationToolSchemaPath { get; set; }
21 |
22 | string AskForFilePathToOpen();
23 | string AskForFilePathToSave(string existingFileName = "");
24 |
25 | DataFormat DataFormat { get; set; }
26 | IOrganizationService Service { get; }
27 |
28 | event EventHandler LoadConfigClicked;
29 | event EventHandler SaveConfigClicked;
30 | event EventHandler RunConfigClicked;
31 | event EventHandler SchemaConfigPathChanged;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/ISchemaGeneratorView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
2 | using Microsoft.Xrm.Sdk.Metadata;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Windows.Forms;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
8 | {
9 | public interface ISchemaGeneratorView
10 | {
11 | bool ShowSystemAttributes { get; set; }
12 | List EntityMetadataList { get; set; }
13 | ListView EntityAttributeList { get; }
14 | ListView EntityRelationshipList { get; }
15 | TreeView EntityList { get; }
16 | List SelectedEntities { get; }
17 | Cursor Cursor { get; set; }
18 | string CurrentConnection { get; set; }
19 |
20 | event EventHandler RetrieveEntities;
21 | event EventHandler ShowSystemEntitiesChanged;
22 | event EventHandler> LoadSchema;
23 | event EventHandler> SaveSchema;
24 | event EventHandler> CurrentSelectedEntityChanged;
25 | event EventHandler> SortAttributesList;
26 | event EventHandler> AttributeSelected;
27 | event EventHandler> SortRelationshipList;
28 | event EventHandler> RelationshipSelected;
29 | event EventHandler> EntitySelected;
30 |
31 | void ShowInformationPanel(string message, int width= 340, int height= 150);
32 | void CloseInformationPanel();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/ImportMappingsFormPresenter.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Helpers;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Services;
3 | using Microsoft.Xrm.Sdk;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Diagnostics.CodeAnalysis;
7 | using System.Linq;
8 | using System.Windows.Forms;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
11 | {
12 | public class ImportMappingsFormPresenter : IDisposable
13 | {
14 | public readonly IImportMappingsFormView view;
15 |
16 | [ExcludeFromCodeCoverage]
17 | public IMetadataService MetaDataService { get; set; }
18 |
19 | [ExcludeFromCodeCoverage]
20 | public IOrganizationService OrganizationService { get; set; }
21 |
22 | public ImportMappingsFormPresenter(IImportMappingsFormView view)
23 | {
24 | this.view = view;
25 | this.view.OnVisible += OnVisible;
26 | }
27 |
28 | [ExcludeFromCodeCoverage]
29 | public IViewHelpers ViewHelpers { get; set; }
30 |
31 | public void OnVisible(object sender, EventArgs e)
32 | {
33 | if (OrganizationService == null)
34 | {
35 | view.Close();
36 | ViewHelpers.ShowMessage("Please make sure you are connected to an organisation", "No connection made", MessageBoxButtons.OK, MessageBoxIcon.Information);
37 | return;
38 | }
39 | if (!view.EntityListDataSource.Any())
40 | {
41 | var entities = MetaDataService.RetrieveEntities(OrganizationService);
42 | view.EntityListDataSource = entities.Select(x => x.LogicalName).OrderBy(n => n);
43 | }
44 | }
45 |
46 | [ExcludeFromCodeCoverage]
47 | public void Dispose()
48 | {
49 | Dispose(true);
50 | GC.SuppressFinalize(this);
51 | }
52 |
53 | [ExcludeFromCodeCoverage]
54 | protected virtual void Dispose(bool disposing)
55 | {
56 | this.view.OnVisible -= OnVisible;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Presenters/SchemaGeneratorParameterBag.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk.Metadata;
2 | using System.Collections.Generic;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Core;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Presenters
6 | {
7 | public class SchemaGeneratorParameterBag
8 | {
9 | public SchemaGeneratorParameterBag()
10 | {
11 | CachedMetadata = new List();
12 | AttributeMapping = new AttributeTypeMapping();
13 | EntityAttributes = new Dictionary>();
14 | EntityRelationships = new Dictionary>();
15 |
16 | CheckedEntity = new HashSet();
17 | SelectedEntity = new HashSet();
18 | CheckedRelationship = new HashSet();
19 | }
20 |
21 | public List CachedMetadata { get; }
22 | public AttributeTypeMapping AttributeMapping { get; }
23 | public HashSet CheckedEntity { get; }
24 | public HashSet SelectedEntity { get; }
25 | public HashSet CheckedRelationship { get; }
26 | public Dictionary> EntityAttributes { get; }
27 | public Dictionary> EntityRelationships { get; }
28 | }
29 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Capgemini.Xrm.CdsDataMigratorLibrary")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Capgemini.Xrm.CdsDataMigratorLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a801df1a-367d-42e8-8aff-cb03179a774e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Capgemini.Xrm.CdsDataMigratorLibrary.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/btImport.Image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/btImport.Image.png
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/entities.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/entities.gif
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/export1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Resources/export1.png
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/AbstractLogger.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.DataMigration.Core;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
3 | using System;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
6 | {
7 | abstract public class AbstractLoggerService : ILogger
8 | {
9 | public LogLevel LogLevel { get; set; } = LogLevel.Verbose;
10 |
11 | public void LogError(string message)
12 | {
13 | WriteLine($"Error:{message}", LogLevel.Error);
14 | }
15 |
16 | public void LogError(string message, Exception ex)
17 | {
18 | WriteLine($"Error:{message},Ex:{ex}", LogLevel.Error);
19 | }
20 |
21 | public void LogInfo(string message)
22 | {
23 | if ((int)LogLevel > 1)
24 | {
25 | WriteLine($"Info:{message}", LogLevel.Info);
26 | }
27 | }
28 |
29 | public void LogVerbose(string message)
30 | {
31 | if ((int)LogLevel > 2)
32 | {
33 | WriteLine($"Verbose:{message}", LogLevel.Verbose);
34 | }
35 | }
36 |
37 | public void LogWarning(string message)
38 | {
39 | if (LogLevel > 0)
40 | {
41 | WriteLine($"Warning:{message}", LogLevel.Warning);
42 | }
43 | }
44 |
45 | abstract protected void WriteLine(string message, LogLevel logLevel);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/CrmGenericMigratorFactory.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.DataMigration.Core;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
3 | using Capgemini.Xrm.DataMigration.Config;
4 | using Capgemini.Xrm.DataMigration.Core;
5 | using Capgemini.Xrm.DataMigration.CrmStore.Config;
6 | using Capgemini.Xrm.DataMigration.Engine;
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Threading;
10 |
11 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
12 | {
13 | public class CrmGenericMigratorFactory : ICrmGenericMigratorFactory
14 | {
15 | public IGenericCrmDataMigrator GetCrmExportDataMigrator(DataFormat dataFormat, ILogger logger, IEntityRepository repo, CrmExporterConfig exportConfig, CancellationToken token, CrmSchemaConfiguration schema)
16 | {
17 | switch (dataFormat)
18 | {
19 | case DataFormat.Json:
20 | return new CrmFileDataExporter(logger, repo, exportConfig, token);
21 |
22 | case DataFormat.Csv:
23 | return new CrmFileDataExporterCsv(logger, repo, exportConfig, schema, token);
24 |
25 | default:
26 | throw new NotSupportedException($"Data format: '{dataFormat}' is not supported.");
27 | }
28 | }
29 |
30 | public IGenericCrmDataMigrator GetCrmImportDataMigrator(DataFormat dataFormat, ILogger logger, IEntityRepository repo, CrmImportConfig importConfig, CancellationToken token, CrmSchemaConfiguration schema)
31 | {
32 | switch (dataFormat)
33 | {
34 | case DataFormat.Json:
35 | return new CrmFileDataImporter(logger, repo, importConfig, token);
36 |
37 | case DataFormat.Csv:
38 | return new CrmFileDataImporterCsv(logger, repo, importConfig, schema, token);
39 |
40 | default:
41 | throw new NotSupportedException($"Data format: '{dataFormat}' is not supported.");
42 | }
43 | }
44 |
45 | public IGenericCrmDataMigrator GetCrmImportDataMigrator(DataFormat dataFormat, ILogger logger, List repos, CrmImportConfig importConfig, CancellationToken token, CrmSchemaConfiguration schema)
46 | {
47 | switch (dataFormat)
48 | {
49 | case DataFormat.Json:
50 | return new CrmFileDataImporter(logger, repos, importConfig, token);
51 |
52 | case DataFormat.Csv:
53 | return new CrmFileDataImporterCsv(logger, repos, importConfig, schema, token);
54 |
55 | default:
56 | throw new NotSupportedException($"Data format: '{dataFormat}' is not supported.");
57 | }
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/DataMigrationService.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.DataMigration.Core;
2 | using Capgemini.DataMigration.Resiliency.Polly;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
4 | using Capgemini.Xrm.DataMigration.Config;
5 | using Capgemini.Xrm.DataMigration.Core;
6 | using Capgemini.Xrm.DataMigration.CrmStore.Config;
7 | using Capgemini.Xrm.DataMigration.Repositories;
8 | using Microsoft.Xrm.Sdk;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Threading;
13 |
14 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
15 | {
16 | public class DataMigrationService : IDataMigrationService
17 | {
18 | private readonly ILogger logger;
19 | private readonly ICrmGenericMigratorFactory migratorFactory;
20 | private CancellationTokenSource tokenSource;
21 |
22 | public DataMigrationService(ILogger logger, ICrmGenericMigratorFactory migratorFactory)
23 | {
24 | this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
25 | this.migratorFactory = migratorFactory ?? throw new ArgumentNullException(nameof(migratorFactory));
26 | }
27 |
28 | public void ExportData(IOrganizationService service, DataFormat format, CrmExporterConfig config)
29 | {
30 | try
31 | {
32 | tokenSource = new CancellationTokenSource();
33 |
34 | var repo = new EntityRepository(service, new ServiceRetryExecutor());
35 |
36 | var schema = CrmSchemaConfiguration.ReadFromFile(config.CrmMigrationToolSchemaPaths.FirstOrDefault());
37 |
38 | var exporter = migratorFactory.GetCrmExportDataMigrator(format, logger, repo, config, tokenSource.Token, schema);
39 |
40 | exporter.MigrateData();
41 | }
42 | catch (Exception error)
43 | {
44 | logger.LogError(error.Message);
45 | throw;
46 | }
47 | }
48 |
49 | public void ImportData(IOrganizationService service, DataFormat format, CrmSchemaConfiguration schema, CrmImportConfig config, decimal maxThreads, IEntityRepositoryService entityRepositoryService)
50 | {
51 | tokenSource = new CancellationTokenSource();
52 |
53 | if (maxThreads > 1)
54 | {
55 | logger.LogInfo($"Starting MultiThreaded Processing, using {maxThreads} threads");
56 | var repos = new List();
57 | decimal threadCount = maxThreads;
58 |
59 | while (threadCount > 0)
60 | {
61 | threadCount--;
62 | repos.Add(entityRepositoryService.InstantiateEntityRepository(true));
63 | }
64 |
65 | var multiThreadimporter = migratorFactory.GetCrmImportDataMigrator(format, logger, repos, config, tokenSource.Token, schema);
66 | multiThreadimporter.MigrateData();
67 | return;
68 | }
69 |
70 | var repo = new EntityRepository(service, new ServiceRetryExecutor());
71 |
72 | var singleThreadimporter = migratorFactory.GetCrmImportDataMigrator(format, logger, repo, config, tokenSource.Token, schema);
73 |
74 | singleThreadimporter.MigrateData();
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/EntityRepositoryService.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.DataMigration.Resiliency;
2 | using Capgemini.DataMigration.Resiliency.Polly;
3 | using Capgemini.Xrm.DataMigration.Core;
4 | using Capgemini.Xrm.DataMigration.Repositories;
5 | using Microsoft.Xrm.Sdk;
6 | using Microsoft.Xrm.Tooling.Connector;
7 |
8 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
9 | {
10 | public class EntityRepositoryService : IEntityRepositoryService
11 | {
12 | public EntityRepositoryService(IOrganizationService orgService)
13 | {
14 | OrganizationService = orgService;
15 | }
16 |
17 | public IOrganizationService OrganizationService { get; set; }
18 |
19 | public IEntityRepository InstantiateEntityRepository(bool useCloneConnection)
20 | {
21 | if (useCloneConnection)
22 | {
23 | return new EntityRepository(((CrmServiceClient)OrganizationService).Clone(), new ServiceRetryExecutor());
24 | }
25 | else
26 | {
27 | return new EntityRepository(OrganizationService, new ServiceRetryExecutor());
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/ICrmGenericMigratorFactory.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.DataMigration.Core;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
3 | using Capgemini.Xrm.DataMigration.Config;
4 | using Capgemini.Xrm.DataMigration.Core;
5 | using Capgemini.Xrm.DataMigration.CrmStore.Config;
6 | using System.Collections.Generic;
7 | using System.Threading;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
10 | {
11 | public interface ICrmGenericMigratorFactory
12 | {
13 | IGenericCrmDataMigrator GetCrmExportDataMigrator(DataFormat dataFormat, ILogger logger, IEntityRepository repo, CrmExporterConfig exportConfig, CancellationToken token, CrmSchemaConfiguration schema);
14 | IGenericCrmDataMigrator GetCrmImportDataMigrator(DataFormat dataFormat, ILogger logger, IEntityRepository repo, CrmImportConfig importConfig, CancellationToken token, CrmSchemaConfiguration schema);
15 | IGenericCrmDataMigrator GetCrmImportDataMigrator(DataFormat dataFormat, ILogger logger, List repos, CrmImportConfig importConfig, CancellationToken token, CrmSchemaConfiguration schema);
16 | }
17 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/IDataMigrationService.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
3 | using Capgemini.Xrm.DataMigration.Config;
4 | using Capgemini.Xrm.DataMigration.CrmStore.Config;
5 | using Microsoft.Xrm.Sdk;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
8 | {
9 | public interface IDataMigrationService
10 | {
11 | void ExportData(IOrganizationService service, DataFormat format, CrmExporterConfig config);
12 |
13 | void ImportData(IOrganizationService service, DataFormat format, CrmSchemaConfiguration schema, CrmImportConfig config, decimal maxThreads, IEntityRepositoryService entityRepositoryService);
14 | }
15 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/IEntityRepositoryService.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.DataMigration.Core;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
4 | {
5 | public interface IEntityRepositoryService
6 | {
7 | IEntityRepository InstantiateEntityRepository(bool useCloneConnection);
8 | }
9 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/ILogManagerContainer.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
4 | {
5 | public interface ILogManagerContainer
6 | {
7 | void WriteLine(string message, LogLevel logLevel);
8 | }
9 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/IMetadataService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions;
3 | using Microsoft.Xrm.Sdk;
4 | using Microsoft.Xrm.Sdk.Metadata;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
7 | {
8 | public interface IMetadataService
9 | {
10 | List RetrieveEntities(IOrganizationService orgService);
11 |
12 | EntityMetadata RetrieveEntities(string logicalName, IOrganizationService orgService, IExceptionService dataMigratorExceptionHelper);
13 | }
14 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/INotificationService.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 |
3 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
4 | {
5 | public interface INotificationService
6 | {
7 | void DisplayFeedback(string message);
8 |
9 | void DisplayErrorFeedback(IWin32Window owner, string message);
10 |
11 | void DisplayWarningFeedback(IWin32Window owner, string message);
12 | }
13 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/LogManagerContainer.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
2 | using System.Diagnostics.CodeAnalysis;
3 | using XrmToolBox.Extensibility;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
6 | {
7 | [ExcludeFromCodeCoverage]
8 | public class LogManagerContainer : ILogManagerContainer
9 | {
10 | private readonly LogManager xrmToolBoxLogManager;
11 |
12 | public LogManagerContainer(LogManager logManager)
13 | {
14 | xrmToolBoxLogManager = logManager;
15 | }
16 |
17 | public void WriteLine(string message, LogLevel logLevel)
18 | {
19 | switch (logLevel)
20 | {
21 | case LogLevel.Error:
22 | xrmToolBoxLogManager.LogError(message);
23 | break;
24 | case LogLevel.Warning:
25 | xrmToolBoxLogManager.LogWarning(message);
26 | break;
27 |
28 | case LogLevel.Info:
29 | case LogLevel.Verbose:
30 | xrmToolBoxLogManager.LogInfo(message);
31 | break;
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/LogToFileService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Windows.Forms;
4 | using Capgemini.Xrm.CdsDataMigratorLibrary.Enums;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
7 | {
8 | public class LogToFileService : AbstractLoggerService
9 | {
10 | private readonly ILogManagerContainer logManagerContainer;
11 |
12 | public LogToFileService(ILogManagerContainer logManagerContainer)
13 | {
14 | this.logManagerContainer = logManagerContainer;
15 | }
16 |
17 | protected override void WriteLine(string message, LogLevel logLevel)
18 | {
19 | var logMessage = $"{DateTime.Now:dd-MMM-yyyy HH:mm:ss} - {message}{Environment.NewLine}";
20 | logManagerContainer.WriteLine(logMessage, logLevel);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/MetadataService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Capgemini.Xrm.CdsDataMigratorLibrary.Exceptions;
4 | using Capgemini.Xrm.CdsDataMigratorLibrary.Extensions;
5 | using McTools.Xrm.Connection;
6 | using Microsoft.Xrm.Sdk;
7 | using Microsoft.Xrm.Sdk.Messages;
8 | using Microsoft.Xrm.Sdk.Metadata;
9 |
10 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
11 | {
12 | public class MetadataService : IMetadataService
13 | {
14 | private readonly static Dictionary EntityMetadataCache = new Dictionary();
15 |
16 | public List RetrieveEntities(IOrganizationService orgService)
17 | {
18 | EntityMetadataCache.Clear();
19 |
20 | var entities = new List();
21 |
22 | if (orgService == null)
23 | {
24 | return entities;
25 | }
26 |
27 | var request = new RetrieveAllEntitiesRequest
28 | {
29 | RetrieveAsIfPublished = true,
30 | EntityFilters = EntityFilters.Entity
31 | };
32 |
33 | var response = (RetrieveAllEntitiesResponse)orgService.Execute(request);
34 |
35 | if (response != null && response.EntityMetadata != null)
36 | {
37 | foreach (EntityMetadata emd in response.EntityMetadata)
38 | {
39 | if (emd.DisplayName.UserLocalizedLabel != null)
40 | {
41 | entities.Add(emd);
42 | }
43 | }
44 | }
45 |
46 | EntityMetadataCache.Clear();
47 |
48 | return entities;
49 | }
50 |
51 | public EntityMetadata RetrieveEntities(string logicalName, IOrganizationService orgService, IExceptionService dataMigratorExceptionHelper)
52 | {
53 | if (orgService == null)
54 | {
55 | throw new ArgumentNullException(nameof(orgService));
56 | }
57 |
58 | try
59 | {
60 | lock (EntityMetadataCache)
61 | {
62 | if (EntityMetadataCache.ContainsKey(logicalName))
63 | {
64 | return EntityMetadataCache[logicalName];
65 | }
66 |
67 | var request = new RetrieveEntityRequest
68 | {
69 | LogicalName = logicalName,
70 | EntityFilters = EntityFilters.Attributes | EntityFilters.Relationships
71 | };
72 |
73 | var response = (RetrieveEntityResponse)orgService.Execute(request);
74 |
75 | EntityMetadataCache.Add(logicalName, response.EntityMetadata);
76 | return response.EntityMetadata;
77 | }
78 | }
79 | catch (Exception error)
80 | {
81 | string errorMessage = dataMigratorExceptionHelper.GetErrorMessage(error, false);
82 | throw new OrganizationalServiceException($"Error while retrieving entity: {errorMessage}");
83 | }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/Services/NotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.Services
5 | {
6 | public class NotificationService : INotificationService
7 | {
8 | public void DisplayFeedback(string message)
9 | {
10 | MessageBox.Show(message);
11 | }
12 |
13 | public void DisplayErrorFeedback(IWin32Window owner, string message)
14 | {
15 | MessageBox.Show(owner, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
16 | }
17 |
18 | public void DisplayWarningFeedback(IWin32Window owner, string message)
19 | {
20 | MessageBox.Show(owner, message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/DataverseEnvironmentSelector.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
2 | {
3 | partial class DataverseEnvironmentSelector
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnSelect = new System.Windows.Forms.Button();
32 | this.lblConnectionName = new System.Windows.Forms.Label();
33 | this.SuspendLayout();
34 | //
35 | // btnSelect
36 | //
37 | this.btnSelect.AutoSize = true;
38 | this.btnSelect.Dock = System.Windows.Forms.DockStyle.Right;
39 | this.btnSelect.Location = new System.Drawing.Point(172, 0);
40 | this.btnSelect.Margin = new System.Windows.Forms.Padding(0);
41 | this.btnSelect.MinimumSize = new System.Drawing.Size(30, 24);
42 | this.btnSelect.Name = "btnSelect";
43 | this.btnSelect.Size = new System.Drawing.Size(30, 24);
44 | this.btnSelect.TabIndex = 2;
45 | this.btnSelect.Text = "...";
46 | this.btnSelect.UseVisualStyleBackColor = true;
47 | this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
48 | //
49 | // lblConnectionName
50 | //
51 | this.lblConnectionName.AutoSize = true;
52 | this.lblConnectionName.Dock = System.Windows.Forms.DockStyle.Fill;
53 | this.lblConnectionName.Location = new System.Drawing.Point(0, 0);
54 | this.lblConnectionName.Name = "lblConnectionName";
55 | this.lblConnectionName.Padding = new System.Windows.Forms.Padding(0, 5, 5, 5);
56 | this.lblConnectionName.Size = new System.Drawing.Size(151, 23);
57 | this.lblConnectionName.TabIndex = 3;
58 | this.lblConnectionName.Text = "Please select an environment";
59 | //
60 | // DataverseEnvironmentSelector
61 | //
62 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
63 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
64 | this.Controls.Add(this.lblConnectionName);
65 | this.Controls.Add(this.btnSelect);
66 | this.MinimumSize = new System.Drawing.Size(0, 20);
67 | this.Name = "DataverseEnvironmentSelector";
68 | this.Size = new System.Drawing.Size(202, 24);
69 | this.ResumeLayout(false);
70 | this.PerformLayout();
71 |
72 | }
73 |
74 | #endregion
75 |
76 | private System.Windows.Forms.Button btnSelect;
77 | private System.Windows.Forms.Label lblConnectionName;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/DataverseEnvironmentSelector.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Xrm.Sdk;
2 | using Microsoft.Xrm.Tooling.Connector;
3 | using System;
4 | using System.Diagnostics.CodeAnalysis;
5 | using System.Windows.Forms;
6 | using XrmToolBox.Extensibility;
7 | using static XrmToolBox.Extensibility.PluginControlBase;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
10 | {
11 | [ExcludeFromCodeCoverage]
12 | public partial class DataverseEnvironmentSelector : UserControl
13 | {
14 | private PluginControlBase xrmToolBoxControl;
15 |
16 | public DataverseEnvironmentSelector()
17 | {
18 | InitializeComponent();
19 | }
20 |
21 | public enum Scope
22 | {
23 | ///
24 | /// Any time a connection is changed, this updates.
25 | ///
26 | Global,
27 |
28 | ///
29 | /// This changes only when specifically requested to via the button.
30 | ///
31 | Local
32 | }
33 |
34 | ///
35 | /// Determine when the value will get updated.
36 | ///
37 | /// Global - Any time a connection is changed, this updates.
38 | /// Local - This changes only when specifically requested to via the button.
39 | ///
40 | public Scope ConnectionUpdatedScope { get; set; } = Scope.Local;
41 |
42 | public IOrganizationService Service { get; private set; }
43 |
44 | protected override void OnLoad(EventArgs e)
45 | {
46 | xrmToolBoxControl = FindPluginControlBase();
47 |
48 | if (xrmToolBoxControl is null) return;
49 |
50 | if (ConnectionUpdatedScope == Scope.Global)
51 | {
52 | xrmToolBoxControl.ConnectionUpdated += OnConnectionUpdated;
53 | }
54 |
55 | OnConnectionUpdated(null, new ConnectionUpdatedEventArgs(xrmToolBoxControl.Service, xrmToolBoxControl.ConnectionDetail));
56 | }
57 |
58 | private void btnSelect_Click(object sender, EventArgs e)
59 | {
60 | if (xrmToolBoxControl is null) return;
61 |
62 | xrmToolBoxControl.ConnectionUpdated += OnConnectionUpdated;
63 | xrmToolBoxControl.RaiseRequestConnectionEvent(new RequestConnectionEventArgs
64 | {
65 | ActionName = "",
66 | Control = xrmToolBoxControl
67 | });
68 | }
69 |
70 | private void OnConnectionUpdated(object sender, ConnectionUpdatedEventArgs e)
71 | {
72 | Service = e?.Service;
73 | lblConnectionName.Text = e?.ConnectionDetail?.OrganizationFriendlyName ?? "No environment selected.";
74 |
75 | if (ConnectionUpdatedScope != Scope.Global)
76 | {
77 | xrmToolBoxControl.ConnectionUpdated -= OnConnectionUpdated;
78 | }
79 | }
80 |
81 | private PluginControlBase FindPluginControlBase()
82 | {
83 | var parent = Parent;
84 |
85 | while (!(parent is PluginControlBase || parent is null))
86 | {
87 | parent = parent.Parent;
88 | }
89 |
90 | return parent as PluginControlBase;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/EntityListView.cs:
--------------------------------------------------------------------------------
1 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
2 | using Microsoft.Xrm.Sdk.Metadata;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Windows.Forms;
8 |
9 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
10 | {
11 | public partial class EntityListView : UserControl
12 | {
13 | private List entities;
14 |
15 | public EntityListView()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | public event EventHandler ShowSystemEntitiesChanged;
21 | public event EventHandler> CurrentSelectedEntityChanged;
22 | public event EventHandler> EntitySelected;
23 |
24 | public List SelectedEntities
25 | {
26 | get
27 | {
28 | var list = new List();
29 |
30 | if (treeViewEntities?.Nodes != null)
31 | {
32 | list = treeViewEntities.Nodes.Cast()
33 | .Where(x => x.Checked)
34 | .Select(x => (EntityMetadata)x.Tag).ToList();
35 | }
36 |
37 | return list;
38 | }
39 | }
40 |
41 | public bool ShowSystemEntities
42 | {
43 | get
44 | {
45 | return checkBoxShowSystemAttributes.Checked;
46 | }
47 | set
48 | {
49 | checkBoxShowSystemAttributes.Checked = value;
50 | }
51 | }
52 |
53 | public TreeView EntityList => treeViewEntities;
54 |
55 | public List Entities
56 | {
57 | get
58 | {
59 | return entities;
60 | }
61 | set
62 | {
63 | entities = value;
64 |
65 | treeViewEntities.Nodes.Clear();
66 |
67 | if (entities != null)
68 | {
69 | foreach (var item in entities)
70 | {
71 | var displayName = item.DisplayName.UserLocalizedLabel == null ? string.Empty : item.DisplayName.UserLocalizedLabel.Label;
72 |
73 | var entityNode = new TreeNode($"{displayName} ({item.LogicalName})")
74 | {
75 | Tag = item
76 | };
77 |
78 | treeViewEntities.Nodes.Add(entityNode);
79 | }
80 | }
81 | }
82 | }
83 |
84 | private void ShowSystemAttributesCheckedChanged(object sender, EventArgs e)
85 | {
86 | if (ShowSystemEntitiesChanged != null)
87 | {
88 | ShowSystemEntitiesChanged(this, e);
89 | }
90 | }
91 |
92 | private void SelectUnselectAllCheckedChanged(object sender, EventArgs e)
93 | {
94 | foreach (TreeNode item in treeViewEntities.Nodes)
95 | {
96 | item.Checked = checkBoxSelectUnselectAll.Checked;
97 | }
98 | }
99 | private void HandleTreeViewEntitiesAfterSelect(object sender, TreeViewEventArgs e)
100 | {
101 | CurrentSelectedEntityChanged?.Invoke(this, new MigratorEventArgs(e.Node.Tag as EntityMetadata));
102 | }
103 |
104 | private void HandleTreeViewEntitiesAfterCheck(object sender, TreeViewEventArgs e)
105 | {
106 | EntitySelected?.Invoke(this, new MigratorEventArgs(e.Node));
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/FileInputSelector.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
2 | {
3 | partial class FileInputSelector
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.tbxInput = new System.Windows.Forms.TextBox();
32 | this.btnSelect = new System.Windows.Forms.Button();
33 | this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
34 | this.SuspendLayout();
35 | //
36 | // tbxInput
37 | //
38 | this.tbxInput.Dock = System.Windows.Forms.DockStyle.Fill;
39 | this.tbxInput.Location = new System.Drawing.Point(0, 0);
40 | this.tbxInput.Margin = new System.Windows.Forms.Padding(0);
41 | this.tbxInput.Name = "tbxInput";
42 | this.tbxInput.Size = new System.Drawing.Size(292, 20);
43 | this.tbxInput.TabIndex = 0;
44 | //
45 | // btnSelect
46 | //
47 | this.btnSelect.AutoSize = true;
48 | this.btnSelect.Dock = System.Windows.Forms.DockStyle.Right;
49 | this.btnSelect.Location = new System.Drawing.Point(292, 0);
50 | this.btnSelect.Margin = new System.Windows.Forms.Padding(10, 0, 0, 0);
51 | this.btnSelect.MinimumSize = new System.Drawing.Size(30, 24);
52 | this.btnSelect.Name = "btnSelect";
53 | this.btnSelect.Size = new System.Drawing.Size(30, 24);
54 | this.btnSelect.TabIndex = 1;
55 | this.btnSelect.Text = "...";
56 | this.btnSelect.UseVisualStyleBackColor = true;
57 | this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
58 | //
59 | // openFileDialog
60 | //
61 | this.openFileDialog.FileName = "openFileDialog1";
62 | this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk);
63 | //
64 | // FileInputSelector
65 | //
66 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
68 | this.AutoSize = true;
69 | this.Controls.Add(this.tbxInput);
70 | this.Controls.Add(this.btnSelect);
71 | this.MinimumSize = new System.Drawing.Size(100, 20);
72 | this.Name = "FileInputSelector";
73 | this.Size = new System.Drawing.Size(322, 24);
74 | this.ResumeLayout(false);
75 | this.PerformLayout();
76 |
77 | }
78 |
79 | #endregion
80 |
81 | private System.Windows.Forms.TextBox tbxInput;
82 | private System.Windows.Forms.Button btnSelect;
83 | private System.Windows.Forms.OpenFileDialog openFileDialog;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/FileInputSelector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics.CodeAnalysis;
4 | using System.Windows.Forms;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
7 | {
8 | [ExcludeFromCodeCoverage]
9 | public partial class FileInputSelector : UserControl
10 | {
11 | public FileInputSelector()
12 | {
13 | InitializeComponent();
14 | tbxInput.TextChanged += (object sender, EventArgs ee) => OnChange?.Invoke(this, EventArgs.Empty);
15 | }
16 |
17 | public event EventHandler OnChange;
18 |
19 | public string Value {
20 | get => tbxInput.Text;
21 | set { tbxInput.Text = value; openFileDialog.FileName = value; }
22 | }
23 |
24 | private void openFileDialog_FileOk(object sender, CancelEventArgs e)
25 | {
26 | tbxInput.Text = openFileDialog.FileName;
27 | }
28 |
29 | private void btnSelect_Click(object sender, EventArgs e)
30 | {
31 | openFileDialog.ShowDialog();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/FolderInputSelector.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
2 | {
3 | partial class FolderInputSelector
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.tbxInput = new System.Windows.Forms.TextBox();
32 | this.btnSelect = new System.Windows.Forms.Button();
33 | this.folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
34 | this.SuspendLayout();
35 | //
36 | // tbxInput
37 | //
38 | this.tbxInput.Dock = System.Windows.Forms.DockStyle.Fill;
39 | this.tbxInput.Location = new System.Drawing.Point(0, 0);
40 | this.tbxInput.Margin = new System.Windows.Forms.Padding(0);
41 | this.tbxInput.Name = "tbxInput";
42 | this.tbxInput.Size = new System.Drawing.Size(292, 20);
43 | this.tbxInput.TabIndex = 0;
44 | //
45 | // btnSelect
46 | //
47 | this.btnSelect.Dock = System.Windows.Forms.DockStyle.Right;
48 | this.btnSelect.Location = new System.Drawing.Point(292, 0);
49 | this.btnSelect.Name = "btnSelect";
50 | this.btnSelect.Size = new System.Drawing.Size(30, 25);
51 | this.btnSelect.TabIndex = 1;
52 | this.btnSelect.Text = "...";
53 | this.btnSelect.UseVisualStyleBackColor = true;
54 | this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
55 | //
56 | // FolderInputSelector
57 | //
58 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
59 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
60 | this.AutoSize = true;
61 | this.Controls.Add(this.tbxInput);
62 | this.Controls.Add(this.btnSelect);
63 | this.MinimumSize = new System.Drawing.Size(100, 24);
64 | this.Name = "FolderInputSelector";
65 | this.Size = new System.Drawing.Size(322, 25);
66 | this.ResumeLayout(false);
67 | this.PerformLayout();
68 |
69 | }
70 |
71 | #endregion
72 |
73 | private System.Windows.Forms.TextBox tbxInput;
74 | private System.Windows.Forms.Button btnSelect;
75 | private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/FolderInputSelector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Windows.Forms;
4 |
5 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
6 | {
7 | [ExcludeFromCodeCoverage]
8 | public partial class FolderInputSelector : UserControl
9 | {
10 | public FolderInputSelector()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | public string Value
16 | {
17 | get => tbxInput.Text;
18 | set { tbxInput.Text = value; folderBrowserDialog.SelectedPath = value; }
19 | }
20 |
21 | private void btnSelect_Click(object sender, EventArgs e)
22 | {
23 | folderBrowserDialog.ShowDialog();
24 | tbxInput.Text = folderBrowserDialog.SelectedPath;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/ListManagerView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows.Forms;
4 | using Capgemini.Xrm.CdsDataMigratorLibrary.Models;
5 |
6 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
7 | {
8 | public partial class ListManagerView : UserControl
9 | {
10 | public ListManagerView()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | public event EventHandler> ListViewColumnClick;
16 | public event EventHandler> ListViewItemCheck;
17 |
18 | public string DisplayedItemsName
19 | {
20 | get
21 | {
22 | return labelDisplayedItemsName.Text;
23 | }
24 | set
25 | {
26 | labelDisplayedItemsName.Text = value;
27 | }
28 | }
29 |
30 | public ListView ListView => listViewItems;
31 |
32 | private void SelectUnselectAllCheckedChanged(object sender, EventArgs e)
33 | {
34 | listViewItems.Items.OfType().ToList().ForEach(item => item.Checked = checkBoxSelectUnselectAll.Checked);
35 | }
36 |
37 | private void listViewItems_ColumnClick(object sender, ColumnClickEventArgs e)
38 | {
39 | ListViewColumnClick?.Invoke(this, new MigratorEventArgs(e.Column));
40 | }
41 |
42 | private void listViewItems_ItemCheck(object sender, ItemCheckEventArgs e)
43 | {
44 | ListViewItemCheck?.Invoke(this, new MigratorEventArgs(e));
45 | }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/UserControls/ToggleBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Capgemini.Xrm.CdsDataMigratorLibrary.UserControls
8 | {
9 | using System.Drawing;
10 | using System.Drawing.Drawing2D;
11 | using System.Windows.Forms;
12 |
13 | public class ToggleCheckBox : CheckBox
14 | {
15 | public ToggleCheckBox()
16 | {
17 | SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
18 | Padding = new Padding(4);
19 | }
20 |
21 | protected override void OnPaint(PaintEventArgs pevent)
22 | {
23 | ProcessPaintRequest(pevent);
24 | }
25 |
26 | public void ProcessPaintRequest(PaintEventArgs pevent)
27 | {
28 | OnPaintBackground(pevent);
29 | pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
30 | using (var path = new GraphicsPath())
31 | {
32 | var d = Padding.All;
33 | var r = Height - 2 * d;
34 | path.AddArc(d, d, r, r, 90, 180);
35 | path.AddArc(Width - r - d, d, r, r, -90, 180);
36 | path.CloseFigure();
37 | pevent.Graphics.FillPath(Brushes.LightGray, path);
38 | r = Height - 1;
39 | var rect = Checked ? new Rectangle(Width - r - 1, 0, r, r)
40 | : new Rectangle(0, 0, r, r);
41 | pevent.Graphics.FillEllipse(Checked ? SystemBrushes.ActiveCaption : Brushes.DarkGray, rect);
42 | }
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigratorLibrary/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Capgemini.Xrm.CdsDataMigrator/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "Reviewed.")]
7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1413:Use trailing comma in multi-line initializers", Justification = "Too strict")]
8 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:Using directives should be placed correctly", Justification = "Seems to ignore the stylecop.json saying we don't want this.")]
9 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "We do not currently support localization.")]
10 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "We don't currently need the file header.")]
11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "We do not need to state the obvious.")]
12 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "Static member on generic type is required for the 'smart constructors'")]
13 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1111:Closing parenthesis should be on line of last parameter", Justification = "This rule breaks 'Should not be preceeded by a space' so disabling it.")]
14 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1131:Constant values should appear on the right-hand side of comparisons", Justification = "That depends on your background...")]
15 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Reviewed.")]
16 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA0001:XML comment", Justification = "Reviewed.")]
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | assembly-versioning-scheme: MajorMinorPatch
2 | mode: Mainline
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Capgemini
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/images/CDSDataMigrator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/CDSDataMigrator.png
--------------------------------------------------------------------------------
/images/ConnectingToDynamics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ConnectingToDynamics.png
--------------------------------------------------------------------------------
/images/ConnectionStringPrompt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ConnectionStringPrompt.png
--------------------------------------------------------------------------------
/images/D365Accounts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/D365Accounts.png
--------------------------------------------------------------------------------
/images/DataExportOutput.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/DataExportOutput.png
--------------------------------------------------------------------------------
/images/EditedExportConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/EditedExportConfigs.png
--------------------------------------------------------------------------------
/images/EditedImportConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/EditedImportConfigs.png
--------------------------------------------------------------------------------
/images/ExportConfigExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ExportConfigExample.png
--------------------------------------------------------------------------------
/images/ExportDataComplete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ExportDataComplete.png
--------------------------------------------------------------------------------
/images/ImportConfigExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ImportConfigExample.png
--------------------------------------------------------------------------------
/images/ImportDataComplete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/ImportDataComplete.png
--------------------------------------------------------------------------------
/images/InitialExportPage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/InitialExportPage.png
--------------------------------------------------------------------------------
/images/InitialImportPage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/InitialImportPage.png
--------------------------------------------------------------------------------
/images/InitialSchemaConfig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/InitialSchemaConfig.png
--------------------------------------------------------------------------------
/images/LoadExportConfig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/LoadExportConfig.png
--------------------------------------------------------------------------------
/images/LoadImportConfig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/LoadImportConfig.png
--------------------------------------------------------------------------------
/images/RunExport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/RunExport.png
--------------------------------------------------------------------------------
/images/RunImport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/RunImport.png
--------------------------------------------------------------------------------
/images/SaveExportConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SaveExportConfigs.png
--------------------------------------------------------------------------------
/images/SaveImportConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SaveImportConfigs.png
--------------------------------------------------------------------------------
/images/SaveSchemaConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SaveSchemaConfigs.png
--------------------------------------------------------------------------------
/images/SchemaConfigExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SchemaConfigExample.png
--------------------------------------------------------------------------------
/images/SearchForCDSDatamigration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SearchForCDSDatamigration.png
--------------------------------------------------------------------------------
/images/SelectSchemaConfigs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SelectSchemaConfigs.png
--------------------------------------------------------------------------------
/images/SelectToolLibrary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/SelectToolLibrary.png
--------------------------------------------------------------------------------
/images/no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/no.png
--------------------------------------------------------------------------------
/images/yes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Capgemini/xrm-datamigration-xrmtoolbox/a8b65c91c451c6f1868b61ec0ab670a18b2528b1/images/yes.png
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pipelines/azure-pipelines-pull-request.yml:
--------------------------------------------------------------------------------
1 | name: $(GITVERSION_FullSemVer)
2 | trigger: none
3 | pr:
4 | - master
5 | - refactor/*
6 | pool:
7 | vmImage: 'windows-latest'
8 | stages:
9 | - stage: BuildAndTest
10 | displayName: Build and Test
11 | jobs:
12 | - template: templates/build-and-test-job.yml
--------------------------------------------------------------------------------
/pipelines/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | name: $(GITVERSION_FullSemVer)
2 | trigger:
3 | batch: true
4 | branches:
5 | include:
6 | - master
7 | pr: none
8 | pool:
9 | vmImage: 'windows-latest'
10 | variables:
11 | - name: GitVersion.SemVer
12 | value: ''
13 | - name: solution
14 | value: '**/*.sln'
15 | - name: buildPlatform
16 | value: 'anycpu'
17 | - name: buildConfiguration
18 | value: 'Release'
19 | stages:
20 | - stage: BuildAndTest
21 | displayName: Build and Test
22 | jobs:
23 | - template: templates/build-and-test-job.yml
24 | - stage: Publish
25 | displayName: Publish
26 | jobs:
27 | - job: PublishJob
28 | displayName: Publish
29 | variables:
30 | SemVer: $[ stageDependencies.BuildAndTest.BuildAndTestJob.outputs['OutputSemVerTask.SemVer'] ]
31 | steps:
32 | - checkout: none
33 | - download: current
34 | displayName: Download NuGet package artifact
35 | artifact: Capgemini.Xrm.DataMigration.XrmToolBoxPlugin
36 | - task: NuGetCommand@2
37 | displayName: Push to NuGet.org
38 | inputs:
39 | command: push
40 | packagesToPush: '$(Pipeline.Workspace)/Capgemini.Xrm.DataMigration.XrmToolBoxPlugin/*.nupkg'
41 | nuGetFeedType: external
42 | publishFeedCredentials: Capgemini_UK
43 | - task: GitHubRelease@1
44 | displayName: Create GitHub releaes
45 | condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
46 | inputs:
47 | gitHubConnection: 'github.com_tdashworth'
48 | repositoryName: '$(Build.Repository.Name)'
49 | action: 'create'
50 | target: '$(Build.SourceVersion)'
51 | tagSource: 'userSpecifiedTag'
52 | tag: 'v$(SemVer)'
53 | releaseNotesSource: 'inline'
54 | assets: '$(Pipeline.Workspace)/Capgemini.Xrm.DataMigration.XrmToolBoxPlugin/*'
55 | changeLogCompareToRelease: 'lastNonDraftRelease'
56 | changeLogType: commitBased
--------------------------------------------------------------------------------
/pipelines/templates/build-and-test-job.yml:
--------------------------------------------------------------------------------
1 | jobs:
2 | - job: BuildAndTestJob
3 | variables:
4 | - name: GitVersion.SemVer
5 | value: ''
6 | - name: solution
7 | value: '**/*.sln'
8 | - name: buildPlatform
9 | value: 'Any CPU'
10 | - name: buildConfiguration
11 | value: 'Release'
12 | displayName: Build and Test
13 |
14 | steps:
15 | - task: gitversion/setup@0
16 | displayName: Install GitVersion
17 | inputs:
18 | versionSpec: '5.x'
19 |
20 | - task: gitversion/execute@0
21 | displayName: Execute GitVersion
22 | inputs:
23 | useConfigFile: true
24 | configFilePath: '$(Build.SourcesDirectory)\GitVersion.yml'
25 | updateAssemblyInfo: true
26 |
27 | - pwsh: Write-Host '##vso[task.setvariable variable=SemVer;isOutput=true]$(GitVersion.SemVer)'
28 | name: OutputSemVerTask
29 | displayName: Output SemVer
30 |
31 | - task: NuGetToolInstaller@0
32 | displayName: 'Use NuGet 4.4.1'
33 | inputs:
34 | versionSpec: 4.4.1
35 |
36 | - task: NuGetCommand@2
37 | displayName: 'NuGet restore'
38 | inputs:
39 | restoreSolution: '$(solution)'
40 | restoreDirectory: ../packages
41 |
42 | - task: SonarCloudPrepare@1
43 | displayName: Prepare SonarCloud
44 | inputs:
45 | SonarCloud: 'SonarCloud'
46 | organization: 'capgemini-1'
47 | scannerMode: 'MSBuild'
48 | projectKey: 'xrm-datamigration-xrmtoolbox'
49 | projectName: 'xrm-datamigration-xrmtoolbox'
50 | projectVersion: '$(GitVersion.SemVer)'
51 |
52 | - task: VSBuild@1
53 | displayName: 'Build solution'
54 | inputs:
55 | solution: '$(solution)'
56 | platform: '$(buildPlatform)'
57 | configuration: '$(buildConfiguration)'
58 |
59 | - task: VSTest@2
60 | displayName: Run tests
61 | inputs:
62 | codeCoverageEnabled: true
63 | platform: '$(buildPlatform)'
64 | configuration: '$(buildConfiguration)'
65 | runSettingsFile: '$(Build.SourcesDirectory)\Capgemini.Xrm.CdsDataMigrator\Capgemini.Xrm.CdsDataMigratorLibrary.Tests.Unit\CodeCoverage.runsettings'
66 | searchFolder: Capgemini.Xrm.CdsDataMigrator
67 | testAssemblyVer2: |
68 | **\*Tests*.dll
69 | !**\*Integration*.dll
70 | !**\obj\**
71 |
72 | - task: SonarCloudAnalyze@1
73 | displayName: Analyse with SonarCloud
74 |
75 | - task: SonarCloudPublish@1
76 | displayName: Publish SonarCloud results
77 | inputs:
78 | pollingTimeoutSec: '300'
79 |
80 | - task: WhiteSource@21
81 | displayName: Detect security and licence issues
82 | inputs:
83 | cwd: '$(Build.SourcesDirectory)'
84 | enabled: false
85 |
86 | - task: PublishSymbols@2
87 | displayName: Publish symbols
88 | inputs:
89 | SearchPattern: '**\bin\**\*.pdb'
90 | PublishSymbols: false
91 | continueOnError: true
92 |
93 | - task: NuGetCommand@2
94 | displayName: Pack NuGet package
95 | inputs:
96 | command: pack
97 | packagesToPack: Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator/Capgemini.Xrm.CdsDataMigrator.nuspec
98 | packDestination: '$(Build.ArtifactStagingDirectory)/out'
99 | versioningScheme: byEnvVar
100 | versionEnvVar: GitVersion.NuGetVersionV2
101 |
102 | - publish: $(Build.ArtifactStagingDirectory)/out
103 | displayName: Publish NuGet artifact
104 | artifact: Capgemini.Xrm.DataMigration.XrmToolBoxPlugin
105 |
--------------------------------------------------------------------------------