diff --git a/KVA/Migration.Toolkit.Source/Auxiliary/EntityIdentityImpl.cs b/KVA/Migration.Toolkit.Source/Auxiliary/EntityIdentityImpl.cs new file mode 100644 index 00000000..326dd911 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Auxiliary/EntityIdentityImpl.cs @@ -0,0 +1,96 @@ +using System.Collections.Frozen; +using CMS.DataEngine; +using Microsoft.Extensions.Logging; +using Migration.Toolkit.Common.Helpers; + +namespace Migration.Toolkit.Source.Auxiliary; + +public interface ISourceGuidContext +{ + int[]? GetSiteIds(Guid entityGuid) where T : ISourceGuidEntity; +} + +public class SourceGuidContext(ModelFacade modelFacade, ILogger logger) : ISourceGuidContext +{ + private static class Cache + { + // ReSharper disable once StaticMemberInGenericType + public static FrozenDictionary? SourceGuidSites; + } + + public int[]? GetSiteIds(Guid entityGuid) where T : ISourceGuidEntity + { + var cache = Cache.SourceGuidSites ??= T.Load(modelFacade); + int[]? result = cache.GetValueOrDefault(entityGuid); + switch (result) + { + case { Length: 0 }: + { + logger.LogDebug("Guid {Guid} has no site at all", entityGuid); + return []; + } + case { Length: 1 }: + { + return result; + } + case null: + { + logger.LogDebug("Guid {Guid} is not found at all", entityGuid); + return null; + } + default: + { + logger.LogDebug("Guid {Guid} is present on multiple sites {Sites}", entityGuid, string.Join("|", result)); + return result; + } + } + } +} + +public record EntityIdentityGuidResult(bool IsFixed, Guid Identity); +public class EntityIdentityFacade(ISourceGuidContext sourceGuidContext) +{ + public EntityIdentityGuidResult Translate(Guid guid, int? siteId) where T : ISourceGuidEntity => + sourceGuidContext.GetSiteIds(guid) switch + { + // not found => leave it as it is or throw + { Length: 0 } => new EntityIdentityGuidResult(false, guid), + // OK! lets leave guid unchanged + { Length: 1 } => new EntityIdentityGuidResult(false, guid), + // BAD, guid is not unique, we cannot use it in XbyK + _ => new EntityIdentityGuidResult(true, GuidV5.NewNameBased(T.NewGuidNs, $"{guid}|{siteId ?? -1}")) + }; + + public EntityIdentityGuidResult Translate(T s) where T : ISourceGuidEntity => + s.GetIdentity() is var (guid, siteId) + ? Translate(guid, siteId) + : throw new InvalidOperationException($"Unable to determine source entity identity: {s}"); +} + +public class IdentityLocator(EntityIdentityFacade entityIdentityFacade, ILogger logger) +{ + public (TTarget target, bool guidIsFixed) LocateTarget(Guid entityGuid, int? siteId) + where TTarget : AbstractInfoBase, IInfoWithGuid, new() + where TSource : ISourceGuidEntity + { + (bool isFixed, var safeAttachmentGuid) = entityIdentityFacade.Translate(entityGuid, siteId); + var target = Provider.Instance.Get(safeAttachmentGuid); + + logger.LogTrace("Located {Target} from source {Source}", + new { ID = target.Generalized.ObjectID, CodeName = target.Generalized.ObjectCodeName, type = target.TypeInfo.ObjectClassName }, + new { type = typeof(TSource).Name, entityGuid, siteId } + ); + + return (target, isFixed); + } + + public (TTarget target, bool guidIsFixed) LocateTarget(TSource s) + where TTarget : AbstractInfoBase, IInfoWithGuid, new() + where TSource : ISourceGuidEntity + { + // TODO tomas.krch: 2024-07-23 specialized approach for CMS_USER and CMS_MEMBER + + (var entityGuid, int? siteId) = s.GetIdentity(); + return LocateTarget(entityGuid, siteId); + } +} diff --git a/KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs b/KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs index ddbc8f05..2173d11c 100644 --- a/KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs +++ b/KVA/Migration.Toolkit.Source/Contexts/SourceInstanceContext.cs @@ -12,6 +12,9 @@ public class SourceInstanceContext( ToolkitConfiguration configuration, ModelFacade modelFacade) { + /// + /// key is SiteName + /// private readonly Dictionary cachedInfos = new(StringComparer.InvariantCultureIgnoreCase); private bool sourceInfoLoaded; diff --git a/KVA/Migration.Toolkit.Source/Exceptions.cs b/KVA/Migration.Toolkit.Source/Exceptions.cs index 82d0bec0..213fc741 100644 --- a/KVA/Migration.Toolkit.Source/Exceptions.cs +++ b/KVA/Migration.Toolkit.Source/Exceptions.cs @@ -1,13 +1,7 @@ namespace Migration.Toolkit.Source; -public class MappingFailureException : InvalidOperationException +public class MappingFailureException(string keyName, string reason) : InvalidOperationException($"Key '{keyName}' mapping failed: {reason}") { - public MappingFailureException(string keyName, string reason) : base($"Key '{keyName}' mapping failed: {reason}") - { - KeyName = keyName; - Reason = reason; - } - - public string KeyName { get; } - public string Reason { get; } + public string KeyName { get; } = keyName; + public string Reason { get; } = reason; } diff --git a/KVA/Migration.Toolkit.Source/Handlers/MigrateAttachmentsCommandHandler.cs b/KVA/Migration.Toolkit.Source/Handlers/MigrateAttachmentsCommandHandler.cs index e6056898..659a912f 100644 --- a/KVA/Migration.Toolkit.Source/Handlers/MigrateAttachmentsCommandHandler.cs +++ b/KVA/Migration.Toolkit.Source/Handlers/MigrateAttachmentsCommandHandler.cs @@ -10,10 +10,10 @@ namespace Migration.Toolkit.Source.Handlers; // ReSharper disable once UnusedMember.Global [implicit use] public class MigrateAttachmentsCommandHandler( ModelFacade modelFacade, - AttachmentMigrator attachmentMigrator + IAttachmentMigrator attachmentMigrator ) : IRequestHandler { - public Task Handle(MigrateAttachmentsCommand request, CancellationToken cancellationToken) + public async Task Handle(MigrateAttachmentsCommand request, CancellationToken cancellationToken) { var ksCmsAttachments = modelFacade.SelectAll(); @@ -25,13 +25,13 @@ public Task Handle(MigrateAttachmentsCommand request, Cancellatio continue; } - (_, bool canContinue, _, _) = attachmentMigrator.MigrateAttachment(ksCmsAttachment); + (_, bool canContinue) = await attachmentMigrator.MigrateAttachment(ksCmsAttachment); if (!canContinue) { break; } } - return Task.FromResult(new GenericCommandResult()); + return new GenericCommandResult(); } } diff --git a/KVA/Migration.Toolkit.Source/Handlers/MigrateFormsCommandHandler.cs b/KVA/Migration.Toolkit.Source/Handlers/MigrateFormsCommandHandler.cs index a2e0ad07..2c7d1349 100644 --- a/KVA/Migration.Toolkit.Source/Handlers/MigrateFormsCommandHandler.cs +++ b/KVA/Migration.Toolkit.Source/Handlers/MigrateFormsCommandHandler.cs @@ -122,8 +122,6 @@ public async Task Handle(MigrateFormsCommand request, Cancellatio .Select(x => x.Attribute("name")?.Value).ToImmutableHashSet(); Debug.Assert(autoIncrementColumns.Count == 1, "autoIncrementColumns.Count == 1"); - // TODO tk: 2022-07-08 not true : autoIncrementColumns.First() == csi.IDColumn - // Debug.Assert(autoIncrementColumns.First() == csi.IDColumn, "autoIncrementColumns.First() == csi.IDColumn"); var r = (ksClass.ClassTableName, ksClass.ClassGUID, autoIncrementColumns); logger.LogTrace("Class '{ClassGuild}' Resolved as: {Result}", ksClass.ClassGUID, r); diff --git a/KVA/Migration.Toolkit.Source/Handlers/MigrateMediaLibrariesCommandHandler.cs b/KVA/Migration.Toolkit.Source/Handlers/MigrateMediaLibrariesCommandHandler.cs index fedd3ae2..bd7901ad 100644 --- a/KVA/Migration.Toolkit.Source/Handlers/MigrateMediaLibrariesCommandHandler.cs +++ b/KVA/Migration.Toolkit.Source/Handlers/MigrateMediaLibrariesCommandHandler.cs @@ -1,303 +1,14 @@ -using CMS.Base; -using CMS.MediaLibrary; - using MediatR; - -using Microsoft.Data.SqlClient; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - using Migration.Toolkit.Common; using Migration.Toolkit.Common.Abstractions; -using Migration.Toolkit.Common.MigrationProtocol; -using Migration.Toolkit.KXP.Api; -using Migration.Toolkit.KXP.Api.Auxiliary; -using Migration.Toolkit.KXP.Context; -using Migration.Toolkit.KXP.Models; -using Migration.Toolkit.Source.Contexts; -using Migration.Toolkit.Source.Helpers; -using Migration.Toolkit.Source.Mappers; -using Migration.Toolkit.Source.Model; +using Migration.Toolkit.Source.Services; namespace Migration.Toolkit.Source.Handlers; public class MigrateMediaLibrariesCommandHandler( - ILogger logger, - IDbContextFactory kxpContextFactory, - ModelFacade modelFacade, - KxpMediaFileFacade mediaFileFacade, - IEntityMapper mediaFileInfoMapper, - IEntityMapper mediaLibraryInfoMapper, - ToolkitConfiguration toolkitConfiguration, - PrimaryKeyMappingContext primaryKeyMappingContext, - IProtocol protocol) - : IRequestHandler, IDisposable + IMediaFileMigrator mediaFileMigrator + ) + : IRequestHandler { - private const string DirMedia = "media"; - - private KxpContext kxpContext = kxpContextFactory.CreateDbContext(); - - public void Dispose() => kxpContext.Dispose(); - - public async Task Handle(MigrateMediaLibrariesCommand request, CancellationToken cancellationToken) - { - var skippedMediaLibraries = new HashSet(); - var unsuitableMediaLibraries = - modelFacade.Select(""" - SELECT LibraryName, LibraryGUID FROM Media_Library [ML] - WHERE EXISTS( - SELECT 1 - FROM Media_Library [MLI] - WHERE MLI.LibraryName = ML.LibraryName - GROUP BY LibraryName - HAVING COUNT(*) > 1 - ) - """, - (reader, _) => new - { - LibraryName = reader.Unbox("LibraryName"), - LibraryGuid = reader.Unbox("LibraryGUID") - }); - - var groupedMls = unsuitableMediaLibraries - .GroupBy(x => x.LibraryName) - .Select(x => new { LibraryGuids = x.Select(y => y.LibraryGuid).ToArray(), LibraryName = x.Key }); - - foreach (var mlg in groupedMls) - { - logger.LogError( - "Media libraries with LibraryGuid ({LibraryGuids}) have same LibraryName '{LibraryName}', due to removal of sites and media library globalization it is required to set unique LibraryName and LibraryFolder", - string.Join(",", mlg.LibraryGuids), mlg.LibraryName); - - foreach (var libraryGuid in mlg.LibraryGuids) - { - if (libraryGuid is { } lg) - { - skippedMediaLibraries.Add(lg); - - protocol.Append(HandbookReferences.NotCurrentlySupportedSkip() - .WithMessage($"Media library '{mlg.LibraryName}' with LibraryGuid '{libraryGuid}' doesn't satisfy unique LibraryName and LibraryFolder condition for migration") - .WithData(new { LibraryGuid = libraryGuid, mlg.LibraryName }) - ); - } - } - } - - var ksMediaLibraries = modelFacade.SelectAll(" ORDER BY LibraryID"); - - var migratedMediaLibraries = new List<(IMediaLibrary sourceLibrary, ICmsSite sourceSite, MediaLibraryInfo targetLibrary)>(); - foreach (var ksMediaLibrary in ksMediaLibraries) - { - if (ksMediaLibrary.LibraryGUID is { } libraryGuid && skippedMediaLibraries.Contains(libraryGuid)) - { - continue; - } - - protocol.FetchedSource(ksMediaLibrary); - - if (ksMediaLibrary.LibraryGUID is not { } mediaLibraryGuid) - { - protocol.Append(HandbookReferences - .InvalidSourceData() - .WithId(nameof(MediaLibrary.LibraryId), ksMediaLibrary.LibraryID) - .WithMessage("Media library has missing MediaLibraryGUID") - ); - continue; - } - - var mediaLibraryInfo = mediaFileFacade.GetMediaLibraryInfo(mediaLibraryGuid); - - protocol.FetchedTarget(mediaLibraryInfo); - - if (modelFacade.SelectById(ksMediaLibrary.LibrarySiteID) is not { } ksSite) - { - protocol.Append(HandbookReferences - .InvalidSourceData() - .WithId(nameof(MediaLibrary.LibraryId), ksMediaLibrary.LibraryID) - .WithMessage("Media library has missing site assigned") - ); - logger.LogError("Missing site, SiteID=={SiteId}", ksMediaLibrary.LibrarySiteID); - continue; - } - - var mapped = mediaLibraryInfoMapper.Map(new MediaLibraryInfoMapperSource(ksMediaLibrary, ksSite), mediaLibraryInfo); - protocol.MappedTarget(mapped); - - if (mapped is { Success: true } result) - { - (var mfi, bool newInstance) = result; - ArgumentNullException.ThrowIfNull(mfi, nameof(mfi)); - - try - { - mediaFileFacade.SetMediaLibrary(mfi); - - protocol.Success(ksMediaLibrary, mfi, mapped); - logger.LogEntitySetAction(newInstance, mfi); - } - catch (Exception ex) - { - await kxpContext.DisposeAsync(); // reset context errors - kxpContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); - - protocol.Append(HandbookReferences - .ErrorCreatingTargetInstance(ex) - .NeedsManualAction() - .WithIdentityPrint(mfi) - ); - logger.LogEntitySetError(ex, newInstance, mfi); - continue; - } - - primaryKeyMappingContext.SetMapping( - r => r.LibraryId, - ksMediaLibrary.LibraryID, - mfi.LibraryID - ); - - migratedMediaLibraries.Add((ksMediaLibrary, ksSite, mfi)); - } - } - - await RequireMigratedMediaFiles(migratedMediaLibraries, cancellationToken); - - return new GenericCommandResult(); - } - - private LoadMediaFileResult LoadMediaFileBinary(string? sourceMediaLibraryPath, string relativeFilePath, string contentType) - { - if (sourceMediaLibraryPath == null) - { - return new LoadMediaFileResult(false, null); - } - - string filePath = Path.Combine(sourceMediaLibraryPath, relativeFilePath); - if (File.Exists(filePath)) - { - byte[] data = File.ReadAllBytes(filePath); - var dummyFile = DummyUploadedFile.FromByteArray(data, contentType, data.LongLength, Path.GetFileName(filePath)); - return new LoadMediaFileResult(true, dummyFile); - } - - return new LoadMediaFileResult(false, null); - } - - private async Task RequireMigratedMediaFiles(List<(IMediaLibrary sourceLibrary, ICmsSite sourceSite, MediaLibraryInfo targetLibrary)> migratedMediaLibraries, CancellationToken cancellationToken) - { - var kxoDbContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); - try - { - foreach (var (ksMediaLibrary, ksSite, targetMediaLibrary) in migratedMediaLibraries) - { - string? sourceMediaLibraryPath = null; - bool loadMediaFileData = false; - if (!toolkitConfiguration.MigrateOnlyMediaFileInfo.GetValueOrDefault(true) && - !string.IsNullOrWhiteSpace(toolkitConfiguration.KxCmsDirPath)) - { - string? cmsMediaLibrariesFolder = KenticoHelper.GetSettingsKey(modelFacade, ksSite.SiteID, "CMSMediaLibrariesFolder"); - if (cmsMediaLibrariesFolder != null) - { - if (Path.IsPathRooted(cmsMediaLibrariesFolder)) - { - sourceMediaLibraryPath = Path.Combine(cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); - loadMediaFileData = true; - } - else - { - if (cmsMediaLibrariesFolder.StartsWith("~/")) - { - string cleared = $"{cmsMediaLibrariesFolder[2..]}".Replace("/", "\\"); - sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cleared, ksSite.SiteName, ksMediaLibrary.LibraryFolder); - loadMediaFileData = true; - } - else - { - sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); - loadMediaFileData = true; - } - } - } - else - { - sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, ksSite.SiteName, DirMedia, ksMediaLibrary.LibraryFolder); - loadMediaFileData = true; - } - } - - var ksMediaFiles = modelFacade.SelectWhere("FileLibraryID = @FileLibraryId", new SqlParameter("FileLibraryId", ksMediaLibrary.LibraryID)); - - foreach (var ksMediaFile in ksMediaFiles) - { - protocol.FetchedSource(ksMediaFile); - - bool found = false; - IUploadedFile? uploadedFile = null; - if (loadMediaFileData) - { - (found, uploadedFile) = LoadMediaFileBinary(sourceMediaLibraryPath, ksMediaFile.FilePath, ksMediaFile.FileMimeType); - if (!found) - { - // report missing file (currently reported in mapper) - } - } - - string? librarySubfolder = Path.GetDirectoryName(ksMediaFile.FilePath); - - var kxoMediaFile = mediaFileFacade.GetMediaFile(ksMediaFile.FileGUID); - - protocol.FetchedTarget(kxoMediaFile); - - var source = new MediaFileInfoMapperSource(ksMediaFile, targetMediaLibrary.LibraryID, found ? uploadedFile : null, - librarySubfolder, toolkitConfiguration.MigrateOnlyMediaFileInfo.GetValueOrDefault(false)); - var mapped = mediaFileInfoMapper.Map(source, kxoMediaFile); - protocol.MappedTarget(mapped); - - if (mapped is { Success: true } result) - { - (var mf, bool newInstance) = result; - ArgumentNullException.ThrowIfNull(mf, nameof(mf)); - - try - { - if (newInstance) - { - mediaFileFacade.EnsureMediaFilePathExistsInLibrary(mf, targetMediaLibrary.LibraryID); - } - - mediaFileFacade.SetMediaFile(mf, newInstance); - await kxpContext.SaveChangesAsync(cancellationToken); - - protocol.Success(ksMediaFile, mf, mapped); - logger.LogEntitySetAction(newInstance, mf); - } - catch (Exception ex) - { - await kxoDbContext.DisposeAsync(); // reset context errors - kxoDbContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); - - protocol.Append(HandbookReferences - .ErrorCreatingTargetInstance(ex) - .NeedsManualAction() - .WithIdentityPrint(mf) - ); - logger.LogEntitySetError(ex, newInstance, mf); - continue; - } - - primaryKeyMappingContext.SetMapping( - r => r.FileId, - ksMediaFile.FileID, - mf.FileID - ); - } - } - } - } - finally - { - await kxoDbContext.DisposeAsync(); - } - } - - private record LoadMediaFileResult(bool Found, IUploadedFile? File); + public async Task Handle(MigrateMediaLibrariesCommand request, CancellationToken cancellationToken) => await mediaFileMigrator.Handle(request, cancellationToken); } diff --git a/KVA/Migration.Toolkit.Source/Handlers/MigratePageTypesCommandHandler.cs b/KVA/Migration.Toolkit.Source/Handlers/MigratePageTypesCommandHandler.cs index 67a30e66..45904836 100644 --- a/KVA/Migration.Toolkit.Source/Handlers/MigratePageTypesCommandHandler.cs +++ b/KVA/Migration.Toolkit.Source/Handlers/MigratePageTypesCommandHandler.cs @@ -47,7 +47,7 @@ public async Task Handle(MigratePageTypesCommand request, Cancell { var (_, ksClass) = di; - if (ksClass.ClassInheritsFromClassID is { } classInheritsFromClassId && !primaryKeyMappingContext.HasMapping(c => c.ClassId, classInheritsFromClassId)) + if (ksClass.ClassInheritsFromClassID is { } classInheritsFromClassId && !primaryKeyMappingContext.HasMapping(c => c.ClassID, classInheritsFromClassId)) { // defer migration to later stage if (ksClasses.TryDeferItem(di)) diff --git a/KVA/Migration.Toolkit.Source/Handlers/MigratePagesCommandHandler.cs b/KVA/Migration.Toolkit.Source/Handlers/MigratePagesCommandHandler.cs index f645b5ed..1cdfe308 100644 --- a/KVA/Migration.Toolkit.Source/Handlers/MigratePagesCommandHandler.cs +++ b/KVA/Migration.Toolkit.Source/Handlers/MigratePagesCommandHandler.cs @@ -202,7 +202,8 @@ public async Task Handle(MigratePagesCommand request, Cancellatio cultureCodeToLanguageGuid, targetClass.ClassFormDefinition, ksNodeClass.ClassFormDefinition, - migratedDocuments + migratedDocuments, + ksSite )); try { @@ -378,7 +379,7 @@ private async Task MigratePageUrlPaths(Guid webPageItemGuid, int webPageItemId, WebPageUrlPathGUID = contentItemCommonDataInfo.ContentItemCommonDataVersionStatus == VersionStatus.Draft ? Guid.NewGuid() : ksPath.PageUrlPathGUID, - WebPageUrlPath = ksPath.PageUrlPathUrlPath, + WebPageUrlPath = ksPath.PageUrlPathUrlPath.TrimStart('/'), WebPageUrlPathHash = ksPath.PageUrlPathUrlPathHash, WebPageUrlPathWebPageItemGuid = webPageItemGuid, WebPageUrlPathWebsiteChannelGuid = webSiteChannelGuid, @@ -419,7 +420,7 @@ private async Task MigratePageUrlPaths(Guid webPageItemGuid, int webPageItemId, WebPageUrlPathGUID = contentItemCommonDataInfo.ContentItemCommonDataVersionStatus == VersionStatus.Draft ? GuidHelper.CreateWebPageUrlPathGuid($"{ksDocument!.DocumentGUID}|{documentCulture}|{ksTree.NodeAliasPath}|DRAFT|{ksTree.NodeID}") : GuidHelper.CreateWebPageUrlPathGuid($"{ksDocument!.DocumentGUID}|{ksTree.NodeAliasPath}|{ksTree.NodeID}"), - WebPageUrlPath = ksTree.NodeAliasPath, //ksPath.PageUrlPathUrlPath, + WebPageUrlPath = ksTree.NodeAliasPath.TrimStart('/'), //ksPath.PageUrlPathUrlPath, // WebPageUrlPathHash = ksPath.PageUrlPathUrlPathHash, WebPageUrlPathWebPageItemGuid = webPageItemGuid, WebPageUrlPathWebsiteChannelGuid = webSiteChannelGuid, @@ -459,13 +460,13 @@ private async Task MigratePageUrlPaths(Guid webPageItemGuid, int webPageItemId, logger.LogTrace("Page url path common data info: CIID={ContentItemId} CLID={Language} ID={Id}", contentItemCommonDataInfo.ContentItemCommonDataContentItemID, contentItemCommonDataInfo.ContentItemCommonDataContentLanguageID, contentItemCommonDataInfo.ContentItemCommonDataID); - string urlPath = (ksDocument switch + string urlPath = ((ksDocument switch { CmsDocumentK11 doc => isLinkedNode ? $"{languageInfo.ContentLanguageName}{ksTree.NodeAliasPath}" : doc.DocumentUrlPath, CmsDocumentK12 doc => isLinkedNode ? $"{languageInfo.ContentLanguageName}{ksTree.NodeAliasPath}" : doc.DocumentUrlPath, null => $"{languageInfo.ContentLanguageName}{ksTree.NodeAliasPath}", _ => null - }).NullIf(string.Empty) ?? $"{ksTree.NodeAliasPath}"; + }).NullIf(string.Empty) ?? $"{ksTree.NodeAliasPath}").TrimStart('/'); var webPageUrlPath = new WebPageUrlPathModel { diff --git a/KVA/Migration.Toolkit.Source/ISourceModel.cs b/KVA/Migration.Toolkit.Source/ISourceModel.cs index c9c71277..16aab42b 100644 --- a/KVA/Migration.Toolkit.Source/ISourceModel.cs +++ b/KVA/Migration.Toolkit.Source/ISourceModel.cs @@ -1,3 +1,4 @@ +using System.Collections.Frozen; using System.Data; using Migration.Toolkit.Common; @@ -12,3 +13,10 @@ public interface ISourceModel static abstract string GetPrimaryKeyName(SemanticVersion version); static abstract T FromReader(IDataReader reader, SemanticVersion version); } + +public interface ISourceGuidEntity +{ + (Guid EntityGuid, int? SiteId) GetIdentity(); + static abstract FrozenDictionary Load(ModelFacade modelFacade); + static abstract Guid NewGuidNs { get; } +} diff --git a/KVA/Migration.Toolkit.Source/KsCoreDiExtensions.cs b/KVA/Migration.Toolkit.Source/KsCoreDiExtensions.cs index b917140e..c2328aa2 100644 --- a/KVA/Migration.Toolkit.Source/KsCoreDiExtensions.cs +++ b/KVA/Migration.Toolkit.Source/KsCoreDiExtensions.cs @@ -19,6 +19,7 @@ using Migration.Toolkit.Common.Services.BulkCopy; using Migration.Toolkit.Common.Services.Ipc; using Migration.Toolkit.KXP.Models; +using Migration.Toolkit.Source.Auxiliary; using Migration.Toolkit.Source.Behaviors; using Migration.Toolkit.Source.Contexts; using Migration.Toolkit.Source.Helpers; @@ -33,7 +34,7 @@ public static class KsCoreDiExtensions public static IServiceProvider ServiceProvider { get; private set; } = null!; public static void InitServiceProvider(IServiceProvider serviceProvider) => ServiceProvider = serviceProvider; - public static IServiceCollection UseKsToolkitCore(this IServiceCollection services) + public static IServiceCollection UseKsToolkitCore(this IServiceCollection services, bool? migrateMediaToMediaLibrary = false) { var printService = new PrintService(); services.AddSingleton(printService); @@ -46,10 +47,24 @@ public static IServiceCollection UseKsToolkitCore(this IServiceCollection servic services.AddSingleton(); services.AddSingleton(s => s.GetRequiredService() as SpoiledGuidContext ?? throw new InvalidOperationException()); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddScoped(); + if (migrateMediaToMediaLibrary ?? false) + { + services.AddScoped(); + services.AddScoped(); + } + else + { + services.AddScoped(); + services.AddScoped(); + } services.AddScoped(); services.AddScoped(); diff --git a/KVA/Migration.Toolkit.Source/Mappers/CmsAttachmentMapper.cs b/KVA/Migration.Toolkit.Source/Mappers/CmsAttachmentMapper.cs index c57086f8..b9df0d81 100644 --- a/KVA/Migration.Toolkit.Source/Mappers/CmsAttachmentMapper.cs +++ b/KVA/Migration.Toolkit.Source/Mappers/CmsAttachmentMapper.cs @@ -11,7 +11,7 @@ namespace Migration.Toolkit.Source.Mappers; -public record CmsAttachmentMapperSource(ICmsAttachment Attachment, int TargetLibraryId, IUploadedFile File, string LibrarySubFolder, ICmsTree? AttachmentNode); +public record CmsAttachmentMapperSource(ICmsAttachment Attachment, Guid NewAttachmentGuid, int TargetLibraryId, IUploadedFile File, string LibrarySubFolder, ICmsTree? AttachmentNode); public class CmsAttachmentMapper(ILogger logger, PrimaryKeyMappingContext pkContext, IProtocol protocol) : EntityMapperBase(logger, pkContext, protocol) @@ -24,7 +24,7 @@ public class CmsAttachmentMapper(ILogger logger, PrimaryKey protected override MediaFileInfo MapInternal(CmsAttachmentMapperSource args, MediaFileInfo target, bool newInstance, MappingHelper mappingHelper, AddFailure addFailure) { - (var cmsAttachment, int targetLibraryId, _, _, var attachmentNode) = args; + (var cmsAttachment, var newAttachmentGuid, int targetLibraryId, _, _, var attachmentNode) = args; target.FileName = Path.GetFileNameWithoutExtension(cmsAttachment.AttachmentName); target.FileTitle = cmsAttachment.AttachmentTitle ?? cmsAttachment.AttachmentName; @@ -34,7 +34,7 @@ protected override MediaFileInfo MapInternal(CmsAttachmentMapperSource args, Med target.FileSize = cmsAttachment.AttachmentSize; target.FileImageWidth = cmsAttachment.AttachmentImageWidth ?? 0; target.FileImageHeight = cmsAttachment.AttachmentImageHeight ?? 0; - target.FileGUID = cmsAttachment.AttachmentGUID; + target.FileGUID = newAttachmentGuid; target.FileLibraryID = targetLibraryId; // target.FileCreatedByUserID = cmsAttachment.?; diff --git a/KVA/Migration.Toolkit.Source/Mappers/ContentItemMapper.cs b/KVA/Migration.Toolkit.Source/Mappers/ContentItemMapper.cs index 90b3e109..9ffd9f86 100644 --- a/KVA/Migration.Toolkit.Source/Mappers/ContentItemMapper.cs +++ b/KVA/Migration.Toolkit.Source/Mappers/ContentItemMapper.cs @@ -1,5 +1,4 @@ using System.Diagnostics; - using CMS.ContentEngine; using CMS.ContentEngine.Internal; using CMS.Core; @@ -9,9 +8,8 @@ using CMS.Websites; using CMS.Websites.Internal; using Kentico.Xperience.UMT.Model; - +using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; - using Migration.Toolkit.Common; using Migration.Toolkit.Common.Abstractions; using Migration.Toolkit.Common.Enumerations; @@ -26,7 +24,6 @@ using Migration.Toolkit.Source.Model; using Migration.Toolkit.Source.Services; using Migration.Toolkit.Source.Services.Model; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -40,14 +37,15 @@ public record CmsTreeMapperSource( Dictionary CultureToLanguageGuid, string TargetFormDefinition, string SourceFormDefinition, - List MigratedDocuments + List MigratedDocuments, + ICmsSite SourceSite ); public class ContentItemMapper( ILogger logger, CoupledDataService coupledDataService, ClassService classService, - AttachmentMigrator attachmentMigrator, + IAttachmentMigrator attachmentMigrator, CmsRelationshipService relationshipService, SourceInstanceContext sourceInstanceContext, FieldMigrationService fieldMigrationService, @@ -55,14 +53,19 @@ public class ContentItemMapper( ModelFacade modelFacade, ReusableSchemaService reusableSchemaService, DeferredPathService deferredPathService, - SpoiledGuidContext spoiledGuidContext + SpoiledGuidContext spoiledGuidContext, + EntityIdentityFacade entityIdentityFacade, + IAssetFacade assetFacade, + ToolkitConfiguration configuration ) : UmtMapperBase { private const string CLASS_FIELD_CONTROL_NAME = "controlname"; protected override IEnumerable MapInternal(CmsTreeMapperSource source) { - (var cmsTree, string safeNodeName, var siteGuid, var nodeParentGuid, var cultureToLanguageGuid, string targetFormDefinition, string sourceFormDefinition, var migratedDocuments) = source; + (var cmsTree, string safeNodeName, var siteGuid, var nodeParentGuid, var cultureToLanguageGuid, string targetFormDefinition, string sourceFormDefinition, var migratedDocuments, var sourceSite) = source; + + logger.LogTrace("Mapping {Value}", new { cmsTree.NodeAliasPath, cmsTree.NodeName, cmsTree.NodeGUID, cmsTree.NodeSiteID }); var nodeClass = modelFacade.SelectById(cmsTree.NodeClassID) ?? throw new InvalidOperationException($"Fatal: node class is missing, class id '{cmsTree.NodeClassID}'"); @@ -97,7 +100,7 @@ protected override IEnumerable MapInternal(CmsTreeMapperSource source { if (!cultureToLanguageGuid.TryGetValue(cmsDocument.DocumentCulture, out var languageGuid)) { - // TODO tomas.krch: 2023-11-15 WARN about skipped document + logger.LogWarning("Document '{DocumentGUID}' was skipped, unknown culture", cmsDocument.DocumentGUID); continue; } @@ -114,7 +117,7 @@ protected override IEnumerable MapInternal(CmsTreeMapperSource source List? migratedDraft = null; try { - migratedDraft = MigrateDraft(draftVersion, cmsTree, sourceFormDefinition, targetFormDefinition, contentItemGuid, languageGuid, nodeClass, websiteChannelInfo).ToList(); + migratedDraft = MigrateDraft(draftVersion, cmsTree, sourceFormDefinition, targetFormDefinition, contentItemGuid, languageGuid, nodeClass, websiteChannelInfo, sourceSite).ToList(); draftMigrated = true; } catch @@ -253,11 +256,12 @@ protected override IEnumerable MapInternal(CmsTreeMapperSource source .ToList(); var coupledDataRow = coupledDataService.GetSourceCoupledDataRow(nodeClass.ClassTableName, primaryKeyName, cmsDocument.DocumentForeignKeyValue); + // TODO tomas.krch: 2024-09-05 propagate async to root MapCoupledDataFieldValues(dataModel.CustomProperties, columnName => coupledDataRow?[columnName], columnName => coupledDataRow?.ContainsKey(columnName) ?? false, - cmsTree, cmsDocument.DocumentID, sourceColumns, sfi, fi, false, nodeClass - ); + cmsTree, cmsDocument.DocumentID, sourceColumns, sfi, fi, false, nodeClass, sourceSite + ).GetAwaiter().GetResult(); foreach (var formFieldInfo in commonFields) { @@ -379,7 +383,7 @@ private void PatchJsonDefinitions(int sourceSiteId, ref string? pageTemplateConf } private IEnumerable MigrateDraft(ICmsVersionHistory checkoutVersion, ICmsTree cmsTree, string sourceFormClassDefinition, string targetFormDefinition, Guid contentItemGuid, - Guid contentLanguageGuid, ICmsClass nodeClass, WebsiteChannelInfo websiteChannelInfo) + Guid contentLanguageGuid, ICmsClass nodeClass, WebsiteChannelInfo websiteChannelInfo, ICmsSite sourceSite) { var adapter = new NodeXmlAdapter(checkoutVersion.NodeXML); @@ -460,10 +464,11 @@ private IEnumerable MigrateDraft(ICmsVersionHistory checkoutVersion, .Except([CmsClassMapper.GetLegacyDocumentName(fi, nodeClass.ClassName)]) .ToList(); + // TODO tomas.krch: 2024-09-05 propagate async to root MapCoupledDataFieldValues(dataModel.CustomProperties, s => adapter.GetValue(s), s => adapter.HasValueSet(s) - , cmsTree, adapter.DocumentID, sourceColumns, sfi, fi, true, nodeClass); + , cmsTree, adapter.DocumentID, sourceColumns, sfi, fi, true, nodeClass, sourceSite).GetAwaiter().GetResult(); foreach (var formFieldInfo in commonFields) { @@ -506,7 +511,7 @@ private IEnumerable MigrateDraft(ICmsVersionHistory checkoutVersion, } } - private void MapCoupledDataFieldValues( + private async Task MapCoupledDataFieldValues( Dictionary target, Func getSourceValue, Func containsSourceValue, @@ -516,7 +521,8 @@ private void MapCoupledDataFieldValues( FormInfo oldFormInfo, FormInfo newFormInfo, bool migratingFromVersionHistory, - ICmsClass nodeClass + ICmsClass nodeClass, + ICmsSite site ) { Debug.Assert(nodeClass.ClassTableName != null, "cmsTree.NodeClass.ClassTableName != null"); @@ -530,6 +536,7 @@ ICmsClass nodeClass columnName.Equals(CmsClassMapper.GetLegacyDocumentName(newFormInfo, nodeClass.ClassName), StringComparison.InvariantCultureIgnoreCase) ) { + logger.LogTrace("Skipping '{FieldName}'", columnName); continue; } @@ -537,6 +544,7 @@ ICmsClass nodeClass if (oldFormInfo.GetFormField(columnName)?.External is true) #pragma warning restore CS0618 // Type or member is obsolete { + logger.LogTrace("Skipping '{FieldName}' - is external", columnName); continue; } @@ -561,165 +569,287 @@ ICmsClass nodeClass object? value = getSourceValue(columnName); target[columnName] = value; - MediaFileInfo?[]? mfis = null; - bool hasMigratedMediaFile = false; - var fieldMigration = fieldMigrationService.GetFieldMigration(field.DataType, controlName, columnName); if (fieldMigration?.Actions?.Contains(TcaDirective.ConvertToAsset) ?? false) { - if (value is string link && - MediaHelper.MatchMediaLink(link) is (true, var mediaLinkKind, var mediaKind, var path, var mediaGuid)) + await ConvertToAsset(target, cmsTree, documentId, value, columnName, controlName, field, fieldMigration, site); + continue; + } + + if (controlName != null) + { + if (fieldMigration.Actions?.Contains(TcaDirective.ConvertToPages) ?? false) + { + // relation to other document + var convertedRelation = relationshipService.GetNodeRelationships(cmsTree.NodeID, nodeClass.ClassName, field.Guid) + .Select(r => new WebPageRelatedItem { WebPageGuid = spoiledGuidContext.EnsureNodeGuid(r.RightNode.NodeGUID, r.RightNode.NodeSiteID, r.RightNode.NodeID) }); + + target.SetValueAsJson(columnName, convertedRelation); + } + else + { + // leave as is + target[columnName] = value; + } + + if (fieldMigration.TargetFormComponent == "webpages") { - if (mediaLinkKind == MediaLinkKind.Path) + if (value is string pageReferenceJson) { - // path needs to be converted to GUID - if (mediaKind == MediaKind.Attachment && path != null) + var parsed = JObject.Parse(pageReferenceJson); + foreach (var jToken in parsed.DescendantsAndSelf()) { - switch (attachmentMigrator.TryMigrateAttachmentByPath(path, $"__{columnName}")) + if (jToken.Path.EndsWith("NodeGUID", StringComparison.InvariantCultureIgnoreCase)) { - case (true, _, var mediaFileInfo, _): - { - mfis = new[] { mediaFileInfo }; - hasMigratedMediaFile = true; - break; - } - default: - { - logger.LogTrace("Unsuccessful attachment migration '{Field}': '{Value}'", columnName, path); - break; - } + var patchedGuid = spoiledGuidContext.EnsureNodeGuid(jToken.Value(), cmsTree.NodeSiteID); + jToken.Replace(JToken.FromObject(patchedGuid)); } } - if (mediaKind == MediaKind.MediaFile) - { - // _mediaFileFacade.GetMediaFile() - // TODO tomas.krch: 2023-03-07 get media file by path - // attachmentDocument.DocumentNode.NodeAliasPath - } + target[columnName] = parsed.ToString().Replace("\"NodeGuid\"", "\"WebPageGuid\""); } + } + } + else + { + target[columnName] = value; + } + } + } - if (mediaGuid is { } mg) + private async Task ConvertToAsset(Dictionary target, ICmsTree cmsTree, int? documentId, object? value, string columnName, string? controlName, FormFieldInfo field, FieldMigration fieldMigration, ICmsSite site) + { + List mfis = []; + bool hasMigratedAsset = false; + if (value is string link && + MediaHelper.MatchMediaLink(link) is (true, var mediaLinkKind, var mediaKind, var path, var mediaGuid) result) + { + if (mediaLinkKind == MediaLinkKind.Path) + { + // path needs to be converted to GUID + if (mediaKind == MediaKind.Attachment && path != null) + { + switch (await attachmentMigrator.TryMigrateAttachmentByPath(path, $"__{columnName}")) { - if (mediaKind == MediaKind.Attachment && - attachmentMigrator.MigrateAttachment(mg, $"__{columnName}") is (_, _, var mediaFileInfo, _) { Success: true }) + case MigrateAttachmentResultMediaFile(true, _, var x, _): { - mfis = new[] { mediaFileInfo }; - hasMigratedMediaFile = true; - logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}'", columnName, mg); + mfis = [new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }]; + hasMigratedAsset = true; + logger.LogTrace("'{FieldName}' migrated Match={Value}", columnName, result); + break; } - - if (mediaKind == MediaKind.MediaFile && mediaFileFacade.GetMediaFile(mg) is { } mfi) + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: { - mfis = new[] { mfi }; - hasMigratedMediaFile = true; - logger.LogTrace("MediaFile migrated from media file '{Field}': '{Value}'", columnName, mg); + mfis = + [ + new ContentItemReference { Identifier = contentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("'{FieldName}' migrated Match={Value}", columnName, result); + break; + } + default: + { + logger.LogTrace("Unsuccessful attachment migration '{Field}': '{Value}' - {Match}", columnName, path, result); + break; } } } - else if (classService.GetFormControlDefinition(controlName) is { } formControl) + + if (mediaKind == MediaKind.MediaFile) + { + logger.LogTrace("'{FieldName}' Skipped Match={Value}", columnName, result); + } + } + + if (mediaGuid is { } mg) + { + if (mediaKind == MediaKind.Attachment) { - switch (formControl) + switch (await attachmentMigrator.MigrateAttachment(mg, $"__{columnName}", cmsTree.NodeSiteID)) { - case { UserControlForFile: true }: + case MigrateAttachmentResultMediaFile(true, _, var x, _): { - if (value is Guid attachmentGuid) - { - (bool success, _, var mediaFileInfo, var mediaLibraryInfo) = attachmentMigrator.MigrateAttachment(attachmentGuid, $"__{columnName}"); - if (success && mediaFileInfo != null) - { - mfis = new[] { mediaFileInfo }; - hasMigratedMediaFile = true; - logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}'", columnName, attachmentGuid); - } - } - else if (value is string attachmentGuidStr && Guid.TryParse(attachmentGuidStr, out attachmentGuid)) - { - (bool success, _, var mediaFileInfo, var mediaLibraryInfo) = attachmentMigrator.MigrateAttachment(attachmentGuid, $"__{columnName}"); - if (success && mediaFileInfo != null) - { - mfis = new[] { mediaFileInfo }; - hasMigratedMediaFile = true; - logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}' (parsed)", columnName, attachmentGuid); - } - } - + mfis = [new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }]; + hasMigratedAsset = true; + logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}'", columnName, mg); break; } - case { UserControlForDocAttachments: true }: + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: { - if (documentId is { } docId) - { - var migratedAttachments = - attachmentMigrator.MigrateGroupedAttachments(docId, field.Guid, field.Name); - - mfis = migratedAttachments - .Where(x => x.MediaFileInfo != null) - .Select(x => x.MediaFileInfo).ToArray(); - hasMigratedMediaFile = true; - } - + mfis = + [ + new ContentItemReference { Identifier = contentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("Content item migrated from attachment '{Field}': '{Value}' to {ContentItemGUID}", columnName, mg, contentItemGuid); break; } - default: + { break; + } } } - else - { - logger.LogWarning("Unable to map value based on selected migration '{Migration}', value: '{Value}'", fieldMigration, value); - continue; - } - if (hasMigratedMediaFile && mfis is { Length: > 0 }) + if (mediaKind == MediaKind.MediaFile) { - target.SetValueAsJson(columnName, - mfis.Select(x => new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }) - ); + var sourceMediaFile = modelFacade.SelectWhere("FileGUID = @mediaFileGuid AND FileSiteID = @fileSiteID", new SqlParameter("mediaFileGuid", mg), new SqlParameter("fileSiteID", site.SiteID)) + .FirstOrDefault(); + if (sourceMediaFile != null) + { + if (configuration.MigrateMediaToMediaLibrary) + { + if (entityIdentityFacade.Translate(sourceMediaFile) is { } mf && mediaFileFacade.GetMediaFile(mf.Identity) is { } mfi) + { + mfis = [mfi]; + } + } + else + { + var (ownerContentItemGuid, _) = assetFacade.GetRef(sourceMediaFile); + mfis = + [ + new ContentItemReference { Identifier = ownerContentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("MediaFile migrated from media file '{Field}': '{Value}'", columnName, mg); + } + } } - - continue; } - - if (controlName != null) + } + else if (classService.GetFormControlDefinition(controlName) is { } formControl) + { + switch (formControl) { - if (fieldMigration.Actions?.Contains(TcaDirective.ConvertToPages) ?? false) + case { UserControlForFile: true }: { - // relation to other document - var convertedRelation = relationshipService.GetNodeRelationships(cmsTree.NodeID, nodeClass.ClassName, field.Guid) - .Select(r => new WebPageRelatedItem { WebPageGuid = spoiledGuidContext.EnsureNodeGuid(r.RightNode.NodeGUID, r.RightNode.NodeSiteID, r.RightNode.NodeID) }); + if (value is Guid attachmentGuid) + { + switch (await attachmentMigrator.MigrateAttachment(attachmentGuid, $"__{columnName}", cmsTree.NodeSiteID)) + { + case MigrateAttachmentResultMediaFile(true, _, var mfi, _): + { + mfis = [new AssetRelatedItem { Identifier = mfi.FileGUID, Dimensions = new AssetDimensions { Height = mfi.FileImageHeight, Width = mfi.FileImageWidth }, Name = mfi.FileName, Size = mfi.FileSize }]; + hasMigratedAsset = true; + logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}'", columnName, attachmentGuid); + break; + } + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: + { + mfis = + [ + new ContentItemReference { Identifier = contentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("Content item migrated from attachment '{Field}': '{Value}' to {ContentItemGUID}", columnName, attachmentGuid, contentItemGuid); + break; + } + default: + { + logger.LogTrace("'{FieldName}' UserControlForFile Success={Success} AttachmentGUID={attachmentGuid}", columnName, false, attachmentGuid); + break; + } + } + } + else if (value is string attachmentGuidStr && Guid.TryParse(attachmentGuidStr, out attachmentGuid)) + { + switch (await attachmentMigrator.MigrateAttachment(attachmentGuid, $"__{columnName}", cmsTree.NodeSiteID)) + { + case MigrateAttachmentResultMediaFile { Success: true, MediaFileInfo: { } x }: + { + mfis = [new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }]; + hasMigratedAsset = true; + logger.LogTrace("MediaFile migrated from attachment '{Field}': '{Value}' (parsed)", columnName, attachmentGuid); + break; + } + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: + { + mfis = + [ + new ContentItemReference { Identifier = contentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("Content item migrated from attachment '{Field}': '{Value}' to {ContentItemGUID}", columnName, attachmentGuid, contentItemGuid); + break; + } + default: + { + logger.LogTrace("'{FieldName}' UserControlForFile Success={Success} AttachmentGUID={attachmentGuid}", columnName, false, attachmentGuid); + break; + } + } + } + else + { + logger.LogTrace("'{FieldName}' UserControlForFile AttachmentGUID={Value}", columnName, value); + } - target.SetValueAsJson(columnName, convertedRelation); - } - else - { - // leave as is - target[columnName] = value; + break; } - - if (fieldMigration.TargetFormComponent == "webpages") + case { UserControlForDocAttachments: true }: { - if (value is string pageReferenceJson) + // new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize } + if (documentId is { } docId) { - var parsed = JObject.Parse(pageReferenceJson); - foreach (var jToken in parsed.DescendantsAndSelf()) + var mfisl = new List(); + await foreach (var migResult in attachmentMigrator.MigrateGroupedAttachments(docId, field.Guid, field.Name)) { - if (jToken.Path.EndsWith("NodeGUID", StringComparison.InvariantCultureIgnoreCase)) + switch (migResult) { - var patchedGuid = spoiledGuidContext.EnsureNodeGuid(jToken.Value(), cmsTree.NodeSiteID); - jToken.Replace(JToken.FromObject(patchedGuid)); + case MigrateAttachmentResultMediaFile { Success: true, MediaFileInfo: { } x }: + { + mfisl.Add(new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }); + hasMigratedAsset = true; + break; + } + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: + { + mfis = + [ + new ContentItemReference { Identifier = contentItemGuid } + ]; + hasMigratedAsset = true; + logger.LogTrace("Content item migrated from document '{DocumentID}' attachment '{FiledName}' to {ContentItemGUID}", docId, field.Name, contentItemGuid); + break; + } + default: + { + hasMigratedAsset = false; + break; + } } } - target[columnName] = parsed.ToString().Replace("\"NodeGuid\"", "\"WebPageGuid\""); + mfis = mfisl; + } + else + { + logger.LogTrace("'{FieldName}' UserControlForDocAttachments DocumentID={Value}", columnName, documentId); } + + break; } + + default: + break; } - else - { - target[columnName] = value; - } + } + else + { + logger.LogWarning("Unable to map value based on selected migration '{Migration}', value: '{Value}'", fieldMigration, value); + return; + } + + if (hasMigratedAsset && mfis is { Count: > 0 }) + { + target.SetValueAsJson(columnName, mfis); + logger.LogTrace("'{FieldName}' setting '{Value}'", columnName, target.GetValueOrDefault(columnName)); + } + else + { + logger.LogTrace("'{FieldName}' leaving '{Value}'", columnName, target.GetValueOrDefault(columnName)); } } @@ -747,8 +877,6 @@ private static IEnumerable UnpackReusableFieldSchemas(IEnumerable #region "Page template & page widget walkers" - private record WalkerContext(int SiteId); - private void WalkAreas(int siteId, List areas, out bool needsDeferredPatch) { needsDeferredPatch = false; @@ -771,7 +899,6 @@ private void WalkSections(int siteId, List sections, out b { logger.LogTrace("Walk section {TypeIdentifier}|{Identifier}", section.TypeIdentifier, section.Identifier); - // TODO tk: 2022-09-14 find other acronym for FormComponents var sectionFcs = sourceInstanceContext.GetSectionFormComponents(siteId, section.TypeIdentifier); WalkProperties(siteId, section.Properties, sectionFcs, out bool ndp1); needsDeferredPatch = ndp1 || needsDeferredPatch; @@ -837,14 +964,44 @@ private void WalkProperties(int siteId, JObject properties, List(); + if (value?.ToObject>() is { Count: > 0 } items) + { + foreach (var mfsi in items) + { + if (configuration.MigrateMediaToMediaLibrary) + { + if (entityIdentityFacade.Translate(mfsi.FileGuid, siteId) is { } mf && mediaFileFacade.GetMediaFile(mf.Identity) is { } mfi) + { + mfis.Add(new Kentico.Components.Web.Mvc.FormComponents.MediaFilesSelectorItem { FileGuid = mfi.FileGUID }); + } + } + else + { + var sourceMediaFile = modelFacade.SelectWhere("FileGUID = @mediaFileGuid AND FileSiteID = @fileSiteID", new SqlParameter("mediaFileGuid", mfsi.FileGuid), new SqlParameter("fileSiteID", siteId)) + .FirstOrDefault(); + if (sourceMediaFile != null) + { + var (ownerContentItemGuid, _) = assetFacade.GetRef(sourceMediaFile); + mfis.Add(new ContentItemReference { Identifier = ownerContentItemGuid }); + } + } + } + + + properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.MediaFilesSelectorItem { FileGuid = entityIdentityFacade.Translate(x.FileGuid, siteId).Identity }) + .ToList()); + } + + break; + } case Kx13FormComponents.Kentico_PathSelector: { if (value?.ToObject>() is { Count: > 0 } items) { - properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.PathSelectorItem - { - TreePath = x.NodeAliasPath - }).ToList()); + properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.PathSelectorItem { TreePath = x.NodeAliasPath }).ToList()); } break; @@ -853,7 +1010,40 @@ private void WalkProperties(int siteId, JObject properties, List>() is { Count: > 0 } items) { - properties[key] = JToken.FromObject(items.Select(x => new AssetRelatedItem { Identifier = x.FileGuid }).ToList()); + var nv = new List(); + foreach (var asi in items) + { + var attachment = modelFacade.SelectWhere("AttachmentSiteID = @siteId AND AttachmentGUID = @attachmentGUID", new SqlParameter("attachmentSiteID", siteId), + new SqlParameter("attachmentGUID", asi.FileGuid)) + .FirstOrDefault(); + if (attachment != null) + { + switch (attachmentMigrator.MigrateAttachment(attachment).GetAwaiter().GetResult()) + { + case MigrateAttachmentResultMediaFile { Success: true, MediaFileInfo: { } x }: + { + nv.Add(new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }); + break; + } + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: + { + nv.Add(new ContentItemReference { Identifier = contentItemGuid }); + break; + } + default: + { + logger.LogWarning("Attachment '{AttachmentGUID}' failed to migrate", asi.FileGuid); + break; + } + } + } + else + { + logger.LogWarning("Attachment '{AttachmentGUID}' not found", asi.FileGuid); + } + } + + properties[key] = JToken.FromObject(nv); } logger.LogTrace("Value migrated from {Old} model to {New} model", oldFormComponent, newFormComponent); diff --git a/KVA/Migration.Toolkit.Source/Mappers/MediaFileInfoMapper.cs b/KVA/Migration.Toolkit.Source/Mappers/MediaFileInfoMapper.cs index c342aea0..21700f15 100644 --- a/KVA/Migration.Toolkit.Source/Mappers/MediaFileInfoMapper.cs +++ b/KVA/Migration.Toolkit.Source/Mappers/MediaFileInfoMapper.cs @@ -17,19 +17,21 @@ namespace Migration.Toolkit.Source.Mappers; public record MediaFileInfoMapperSource( + string? FullMediaFilePath, IMediaFile MediaFile, int TargetLibraryId, IUploadedFile? File, string? LibrarySubFolder, - bool MigrateOnlyMediaFileInfo); + bool MigrateOnlyMediaFileInfo, + Guid SafeMediaFileGuid +); public class MediaFileInfoMapper( ILogger logger, PrimaryKeyMappingContext primaryKeyMappingContext, KxpClassFacade classFacade, IProtocol protocol, - ToolkitConfiguration toolkitConfiguration, - ModelFacade modelFacade + ToolkitConfiguration toolkitConfiguration ) : EntityMapperBase(logger, primaryKeyMappingContext, protocol) { @@ -47,7 +49,7 @@ ModelFacade modelFacade protected override MediaFileInfo MapInternal(MediaFileInfoMapperSource args, MediaFileInfo target, bool newInstance, MappingHelper mappingHelper, AddFailure addFailure) { - (var mediaFile, int targetLibraryId, var file, _, bool migrateOnlyMediaFileInfo) = args; + (string fullMediaFilePath, var mediaFile, int targetLibraryId, var file, _, bool migrateOnlyMediaFileInfo, var safeMediaFileGuid) = args; target.FileName = mediaFile.FileName; target.FileTitle = mediaFile.FileTitle; @@ -57,7 +59,7 @@ protected override MediaFileInfo MapInternal(MediaFileInfoMapperSource args, Med target.FileSize = mediaFile.FileSize; target.FileImageWidth = mediaFile.FileImageWidth ?? 0; target.FileImageHeight = mediaFile.FileImageHeight ?? 0; - target.FileGUID = mediaFile.FileGUID; + target.FileGUID = safeMediaFileGuid; target.FileCreatedWhen = mediaFile.FileCreatedWhen; target.FileModifiedWhen = mediaFile.FileModifiedWhen; KenticoHelper.CopyCustomData(target.FileCustomData, mediaFile.FileCustomData); @@ -97,7 +99,7 @@ protected override MediaFileInfo MapInternal(MediaFileInfoMapperSource args, Med { addFailure(HandbookReferences.MediaFileIsMissingOnSourceFilesystem .WithId(nameof(mediaFile.FileID), mediaFile.FileID) - .WithData(new { mediaFile.FilePath, mediaFile.FileGUID, mediaFile.FileLibraryID, mediaFile.FileSiteID }) + .WithData(new { mediaFile.FilePath, mediaFile.FileGUID, mediaFile.FileLibraryID, mediaFile.FileSiteID, SearchedPath = fullMediaFilePath }) .AsFailure() ); } diff --git a/KVA/Migration.Toolkit.Source/Mappers/MediaLibraryInfoMapper.cs b/KVA/Migration.Toolkit.Source/Mappers/MediaLibraryInfoMapper.cs index 4ffdaebe..af2a89cf 100644 --- a/KVA/Migration.Toolkit.Source/Mappers/MediaLibraryInfoMapper.cs +++ b/KVA/Migration.Toolkit.Source/Mappers/MediaLibraryInfoMapper.cs @@ -10,7 +10,7 @@ namespace Migration.Toolkit.Source.Mappers; -public record MediaLibraryInfoMapperSource(IMediaLibrary MediaLibrary, ICmsSite Site); +public record MediaLibraryInfoMapperSource(IMediaLibrary MediaLibrary, ICmsSite Site, Guid SafeLibraryGuid, string SafeLibraryName); public class MediaLibraryInfoMapper(ILogger logger, PrimaryKeyMappingContext primaryKeyMappingContext, IProtocol protocol) : EntityMapperBase(logger, primaryKeyMappingContext, protocol) @@ -21,14 +21,14 @@ public class MediaLibraryInfoMapper(ILogger logger, Prim private static readonly Regex allowedCharactersForLibraryName = new(@"[^a-zA-Z0-9_]", RegexOptions.Compiled | RegexOptions.Singleline); protected override MediaLibraryInfo MapInternal(MediaLibraryInfoMapperSource s, MediaLibraryInfo target, bool newInstance, MappingHelper mappingHelper, AddFailure addFailure) { - var (ksLibrary, ksSite) = s; + var (ksLibrary, ksSite, safeLibraryGuid, safeLibraryName) = s; string ksSiteNameSafe = allowedCharactersForLibraryName.Replace(ksSite.SiteName, "_"); // Sets the library properties target.LibraryDisplayName = ksLibrary.LibraryDisplayName; - target.LibraryName = ksLibrary.LibraryName; + target.LibraryName = safeLibraryName; target.LibraryDescription = ksLibrary.LibraryDescription; target.LibraryFolder = ksLibrary.LibraryFolder; - target.LibraryGUID = mappingHelper.Require(ksLibrary.LibraryGUID, nameof(ksLibrary.LibraryGUID)); + target.LibraryGUID = safeLibraryGuid; target.LibraryDisplayName = ksLibrary.LibraryDisplayName; target.LibraryDescription = ksLibrary.LibraryDescription; diff --git a/KVA/Migration.Toolkit.Source/Mappers/PageTemplateConfigurationMapper.cs b/KVA/Migration.Toolkit.Source/Mappers/PageTemplateConfigurationMapper.cs index 589eb5ca..fafa90ee 100644 --- a/KVA/Migration.Toolkit.Source/Mappers/PageTemplateConfigurationMapper.cs +++ b/KVA/Migration.Toolkit.Source/Mappers/PageTemplateConfigurationMapper.cs @@ -1,21 +1,22 @@ using AngleSharp.Text; - +using CMS.ContentEngine; using CMS.MediaLibrary; using CMS.Websites; - +using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; - +using Migration.Toolkit.Common; using Migration.Toolkit.Common.Abstractions; using Migration.Toolkit.Common.Enumerations; using Migration.Toolkit.Common.MigrationProtocol; using Migration.Toolkit.Common.Services.Ipc; +using Migration.Toolkit.KXP.Api; using Migration.Toolkit.KXP.Api.Auxiliary; using Migration.Toolkit.KXP.Api.Services.CmsClass; +using Migration.Toolkit.Source.Auxiliary; using Migration.Toolkit.Source.Contexts; using Migration.Toolkit.Source.Model; using Migration.Toolkit.Source.Services; using Migration.Toolkit.Source.Services.Model; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -26,7 +27,14 @@ public class PageTemplateConfigurationMapper( PrimaryKeyMappingContext pkContext, IProtocol protocol, SourceInstanceContext sourceInstanceContext, - SpoiledGuidContext spoiledGuidContext) + EntityIdentityFacade entityIdentityFacade, + SpoiledGuidContext spoiledGuidContext, + ModelFacade modelFacade, + IAttachmentMigrator attachmentMigrator, + IAssetFacade assetFacade, + ToolkitConfiguration configuration, + KxpMediaFileFacade mediaFileFacade + ) : EntityMapperBase(logger, pkContext, protocol) { protected override PageTemplateConfigurationInfo? CreateNewInstance(ICmsPageTemplateConfiguration source, MappingHelper mappingHelper, AddFailure addFailure) @@ -46,7 +54,7 @@ protected override PageTemplateConfigurationInfo MapInternal(ICmsPageTemplateCon target.PageTemplateConfigurationDescription = source.PageTemplateConfigurationDescription; target.PageTemplateConfigurationName = source.PageTemplateConfigurationName; target.PageTemplateConfigurationLastModified = source.PageTemplateConfigurationLastModified; - target.PageTemplateConfigurationIcon = "xp-custom-element"; // TODO tomas.krch: 2023-11-27 some better default icon pick? + target.PageTemplateConfigurationIcon = "xp-custom-element"; if (newInstance) { @@ -179,14 +187,44 @@ private void WalkProperties(int siteId, JObject properties, List(); + if (value?.ToObject>() is { Count: > 0 } items) + { + foreach (var mfsi in items) + { + if (configuration.MigrateMediaToMediaLibrary) + { + if (entityIdentityFacade.Translate(mfsi.FileGuid, siteId) is { } mf && mediaFileFacade.GetMediaFile(mf.Identity) is { } mfi) + { + mfis.Add(new Kentico.Components.Web.Mvc.FormComponents.MediaFilesSelectorItem { FileGuid = mfi.FileGUID }); + } + } + else + { + var sourceMediaFile = modelFacade.SelectWhere("FileGUID = @mediaFileGuid AND FileSiteID = @fileSiteID", new SqlParameter("mediaFileGuid", mfsi.FileGuid), new SqlParameter("fileSiteID", siteId)) + .FirstOrDefault(); + if (sourceMediaFile != null) + { + var (ownerContentItemGuid, _) = assetFacade.GetRef(sourceMediaFile); + mfis.Add(new ContentItemReference { Identifier = ownerContentItemGuid }); + } + } + } + + + properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.MediaFilesSelectorItem { FileGuid = entityIdentityFacade.Translate(x.FileGuid, siteId).Identity }) + .ToList()); + } + + break; + } case Kx13FormComponents.Kentico_PathSelector: { if (value?.ToObject>() is { Count: > 0 } items) { - properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.PathSelectorItem - { - TreePath = x.NodeAliasPath - }).ToList()); + properties[key] = JToken.FromObject(items.Select(x => new Kentico.Components.Web.Mvc.FormComponents.PathSelectorItem { TreePath = x.NodeAliasPath }).ToList()); } break; @@ -195,7 +233,40 @@ private void WalkProperties(int siteId, JObject properties, List>() is { Count: > 0 } items) { - properties[key] = JToken.FromObject(items.Select(x => new AssetRelatedItem { Identifier = x.FileGuid }).ToList()); + var nv = new List(); + foreach (var asi in items) + { + var attachment = modelFacade.SelectWhere("AttachmentSiteID = @siteId AND AttachmentGUID = @attachmentGUID", new SqlParameter("attachmentSiteID", siteId), + new SqlParameter("attachmentGUID", asi.FileGuid)) + .FirstOrDefault(); + if (attachment != null) + { + switch (attachmentMigrator.MigrateAttachment(attachment).GetAwaiter().GetResult()) + { + case MigrateAttachmentResultMediaFile { Success: true, MediaFileInfo: { } x }: + { + nv.Add(new AssetRelatedItem { Identifier = x.FileGUID, Dimensions = new AssetDimensions { Height = x.FileImageHeight, Width = x.FileImageWidth }, Name = x.FileName, Size = x.FileSize }); + break; + } + case MigrateAttachmentResultContentItem { Success: true, ContentItemGuid: { } contentItemGuid }: + { + nv.Add(new ContentItemReference { Identifier = contentItemGuid }); + break; + } + default: + { + logger.LogWarning("Attachment '{AttachmentGUID}' failed to migrate", asi.FileGuid); + break; + } + } + } + else + { + logger.LogWarning("Attachment '{AttachmentGUID}' not found", asi.FileGuid); + } + } + + properties[key] = JToken.FromObject(nv); } logger.LogTrace("Value migrated from {Old} model to {New} model", oldFormComponent, newFormComponent); @@ -213,7 +284,6 @@ private void WalkProperties(int siteId, JObject properties, List - + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsAlternativeForm.cs b/KVA/Migration.Toolkit.Source/Model/CmsAlternativeForm.cs index 3492adec..4f93a639 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsAlternativeForm.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsAlternativeForm.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsAlternativeForm : ISourceModel +public partial interface ICmsAlternativeForm : ISourceModel { int FormID { get; } string FormDisplayName { get; } @@ -30,7 +28,6 @@ public interface ICmsAlternativeForm : ISourceModel { Major: 13 } => CmsAlternativeFormK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsAlternativeFormK11.IsAvailable(version), @@ -38,10 +35,8 @@ public interface ICmsAlternativeForm : ISourceModel { Major: 13 } => CmsAlternativeFormK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_AlternativeForm"; static string ISourceModel.GuidColumnName => "FormGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsAlternativeForm ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsAlternativeFormK11.FromReader(reader, version), @@ -50,105 +45,43 @@ public interface ICmsAlternativeForm : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsAlternativeFormK11( - int FormID, - string FormDisplayName, - string FormName, - int FormClassID, - string? FormDefinition, - string? FormLayout, - Guid FormGUID, - DateTime FormLastModified, - int? FormCoupledClassID, - bool? FormHideNewParentFields, - string? FormLayoutType, - string? FormVersionGUID, - string? FormCustomizedColumns, - bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel +public partial record CmsAlternativeFormK11(int FormID, string FormDisplayName, string FormName, int FormClassID, string? FormDefinition, string? FormLayout, Guid FormGUID, DateTime FormLastModified, int? FormCoupledClassID, bool? FormHideNewParentFields, string? FormLayoutType, string? FormVersionGUID, string? FormCustomizedColumns, bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_AlternativeForm"; public static string GuidColumnName => "FormGUID"; - static CmsAlternativeFormK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); public static CmsAlternativeFormK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); -} - -public record CmsAlternativeFormK12( - int FormID, - string FormDisplayName, - string FormName, - int FormClassID, - string? FormDefinition, - string? FormLayout, - Guid FormGUID, - DateTime FormLastModified, - int? FormCoupledClassID, - bool? FormHideNewParentFields, - string? FormLayoutType, - string? FormVersionGUID, - string? FormCustomizedColumns, - bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); +}; +public partial record CmsAlternativeFormK12(int FormID, string FormDisplayName, string FormName, int FormClassID, string? FormDefinition, string? FormLayout, Guid FormGUID, DateTime FormLastModified, int? FormCoupledClassID, bool? FormHideNewParentFields, string? FormLayoutType, string? FormVersionGUID, string? FormCustomizedColumns, bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_AlternativeForm"; public static string GuidColumnName => "FormGUID"; - static CmsAlternativeFormK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); public static CmsAlternativeFormK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); -} - -public record CmsAlternativeFormK13( - int FormID, - string FormDisplayName, - string FormName, - int FormClassID, - string? FormDefinition, - string? FormLayout, - Guid FormGUID, - DateTime FormLastModified, - int? FormCoupledClassID, - bool? FormHideNewParentFields, - string? FormLayoutType, - string? FormVersionGUID, - string? FormCustomizedColumns, - bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); +}; +public partial record CmsAlternativeFormK13(int FormID, string FormDisplayName, string FormName, int FormClassID, string? FormDefinition, string? FormLayout, Guid FormGUID, DateTime FormLastModified, int? FormCoupledClassID, bool? FormHideNewParentFields, string? FormLayoutType, string? FormVersionGUID, string? FormCustomizedColumns, bool? FormIsCustom) : ICmsAlternativeForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_AlternativeForm"; public static string GuidColumnName => "FormGUID"; - static CmsAlternativeFormK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); public static CmsAlternativeFormK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), - reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), - reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") - ); -} + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormClassID"), reader.Unbox("FormDefinition"), reader.Unbox("FormLayout"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormCoupledClassID"), reader.Unbox("FormHideNewParentFields"), reader.Unbox("FormLayoutType"), reader.Unbox("FormVersionGUID"), reader.Unbox("FormCustomizedColumns"), reader.Unbox("FormIsCustom") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsAlternativeUrl.cs b/KVA/Migration.Toolkit.Source/Model/CmsAlternativeUrl.cs index e605e960..7fe9acb0 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsAlternativeUrl.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsAlternativeUrl.cs @@ -1,13 +1,13 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsAlternativeUrl : ISourceModel +public partial interface ICmsAlternativeUrl : ISourceModel { + + static string ISourceModel.GetPrimaryKeyName(SemanticVersion version) => version switch { { Major: 11 } => CmsAlternativeUrlK11.GetPrimaryKeyName(version), @@ -15,7 +15,6 @@ public interface ICmsAlternativeUrl : ISourceModel { Major: 13 } => CmsAlternativeUrlK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsAlternativeUrlK11.IsAvailable(version), @@ -23,10 +22,8 @@ public interface ICmsAlternativeUrl : ISourceModel { Major: 13 } => CmsAlternativeUrlK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_AlternativeUrl"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsAlternativeUrl ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsAlternativeUrlK11.FromReader(reader, version), @@ -35,55 +32,43 @@ public interface ICmsAlternativeUrl : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsAlternativeUrlK11 : ICmsAlternativeUrl, ISourceModel +public partial record CmsAlternativeUrlK11() : ICmsAlternativeUrl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_AlternativeUrl"; public static string GuidColumnName => ""; - static CmsAlternativeUrlK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsAlternativeUrlK11 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public record CmsAlternativeUrlK12(int AlternativeUrlID, Guid AlternativeUrlGUID, int AlternativeUrlDocumentID, int AlternativeUrlSiteID, string AlternativeUrlUrl, DateTime AlternativeUrlLastModified) - : ICmsAlternativeUrl, ISourceModel + ); +}; +public partial record CmsAlternativeUrlK12(int AlternativeUrlID, Guid AlternativeUrlGUID, int AlternativeUrlDocumentID, int AlternativeUrlSiteID, string AlternativeUrlUrl, DateTime AlternativeUrlLastModified) : ICmsAlternativeUrl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "AlternativeUrlID"; public static string TableName => "CMS_AlternativeUrl"; public static string GuidColumnName => "AlternativeUrlGUID"; - static CmsAlternativeUrlK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), - reader.Unbox("AlternativeUrlLastModified") - ); - + reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), reader.Unbox("AlternativeUrlLastModified") + ); public static CmsAlternativeUrlK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), - reader.Unbox("AlternativeUrlLastModified") - ); -} - -public record CmsAlternativeUrlK13(int AlternativeUrlID, Guid AlternativeUrlGUID, int AlternativeUrlDocumentID, int AlternativeUrlSiteID, string AlternativeUrlUrl, DateTime AlternativeUrlLastModified) - : ICmsAlternativeUrl, ISourceModel + reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), reader.Unbox("AlternativeUrlLastModified") + ); +}; +public partial record CmsAlternativeUrlK13(int AlternativeUrlID, Guid AlternativeUrlGUID, int AlternativeUrlDocumentID, int AlternativeUrlSiteID, string AlternativeUrlUrl, DateTime AlternativeUrlLastModified) : ICmsAlternativeUrl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "AlternativeUrlID"; public static string TableName => "CMS_AlternativeUrl"; public static string GuidColumnName => "AlternativeUrlGUID"; - static CmsAlternativeUrlK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), - reader.Unbox("AlternativeUrlLastModified") - ); - + reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), reader.Unbox("AlternativeUrlLastModified") + ); public static CmsAlternativeUrlK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), - reader.Unbox("AlternativeUrlLastModified") - ); -} + reader.Unbox("AlternativeUrlID"), reader.Unbox("AlternativeUrlGUID"), reader.Unbox("AlternativeUrlDocumentID"), reader.Unbox("AlternativeUrlSiteID"), reader.Unbox("AlternativeUrlUrl"), reader.Unbox("AlternativeUrlLastModified") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsAttachment.cs b/KVA/Migration.Toolkit.Source/Model/CmsAttachment.cs index 2e92214d..ff0077a7 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsAttachment.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsAttachment.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsAttachment : ISourceModel +public partial interface ICmsAttachment : ISourceModel { int AttachmentID { get; } string AttachmentName { get; } @@ -39,7 +37,6 @@ public interface ICmsAttachment : ISourceModel { Major: 13 } => CmsAttachmentK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsAttachmentK11.IsAvailable(version), @@ -47,10 +44,8 @@ public interface ICmsAttachment : ISourceModel { Major: 13 } => CmsAttachmentK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Attachment"; static string ISourceModel.GuidColumnName => "AttachmentGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsAttachment ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsAttachmentK11.FromReader(reader, version), @@ -59,144 +54,43 @@ public interface ICmsAttachment : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsAttachmentK11( - int AttachmentID, - string AttachmentName, - string AttachmentExtension, - int AttachmentSize, - string AttachmentMimeType, - byte[]? AttachmentBinary, - int? AttachmentImageWidth, - int? AttachmentImageHeight, - int? AttachmentDocumentID, - Guid AttachmentGUID, - int AttachmentSiteID, - DateTime AttachmentLastModified, - bool? AttachmentIsUnsorted, - int? AttachmentOrder, - Guid? AttachmentGroupGUID, - Guid? AttachmentFormGUID, - string? AttachmentHash, - string? AttachmentTitle, - string? AttachmentDescription, - string? AttachmentCustomData, - string? AttachmentSearchContent, - string? AttachmentVariantDefinitionIdentifier, - int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel +public partial record CmsAttachmentK11(int AttachmentID, string AttachmentName, string AttachmentExtension, int AttachmentSize, string AttachmentMimeType, byte[]? AttachmentBinary, int? AttachmentImageWidth, int? AttachmentImageHeight, int? AttachmentDocumentID, Guid AttachmentGUID, int AttachmentSiteID, DateTime AttachmentLastModified, bool? AttachmentIsUnsorted, int? AttachmentOrder, Guid? AttachmentGroupGUID, Guid? AttachmentFormGUID, string? AttachmentHash, string? AttachmentTitle, string? AttachmentDescription, string? AttachmentCustomData, string? AttachmentSearchContent, string? AttachmentVariantDefinitionIdentifier, int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "AttachmentID"; public static string TableName => "CMS_Attachment"; public static string GuidColumnName => "AttachmentGUID"; - static CmsAttachmentK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); - + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); public static CmsAttachmentK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); -} - -public record CmsAttachmentK12( - int AttachmentID, - string AttachmentName, - string AttachmentExtension, - int AttachmentSize, - string AttachmentMimeType, - byte[]? AttachmentBinary, - int? AttachmentImageWidth, - int? AttachmentImageHeight, - int? AttachmentDocumentID, - Guid AttachmentGUID, - int AttachmentSiteID, - DateTime AttachmentLastModified, - bool? AttachmentIsUnsorted, - int? AttachmentOrder, - Guid? AttachmentGroupGUID, - Guid? AttachmentFormGUID, - string? AttachmentHash, - string? AttachmentTitle, - string? AttachmentDescription, - string? AttachmentCustomData, - string? AttachmentSearchContent, - string? AttachmentVariantDefinitionIdentifier, - int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); +}; +public partial record CmsAttachmentK12(int AttachmentID, string AttachmentName, string AttachmentExtension, int AttachmentSize, string AttachmentMimeType, byte[]? AttachmentBinary, int? AttachmentImageWidth, int? AttachmentImageHeight, int? AttachmentDocumentID, Guid AttachmentGUID, int AttachmentSiteID, DateTime AttachmentLastModified, bool? AttachmentIsUnsorted, int? AttachmentOrder, Guid? AttachmentGroupGUID, Guid? AttachmentFormGUID, string? AttachmentHash, string? AttachmentTitle, string? AttachmentDescription, string? AttachmentCustomData, string? AttachmentSearchContent, string? AttachmentVariantDefinitionIdentifier, int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "AttachmentID"; public static string TableName => "CMS_Attachment"; public static string GuidColumnName => "AttachmentGUID"; - static CmsAttachmentK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); - + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); public static CmsAttachmentK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); -} - -public record CmsAttachmentK13( - int AttachmentID, - string AttachmentName, - string AttachmentExtension, - int AttachmentSize, - string AttachmentMimeType, - byte[]? AttachmentBinary, - int? AttachmentImageWidth, - int? AttachmentImageHeight, - int? AttachmentDocumentID, - Guid AttachmentGUID, - int AttachmentSiteID, - DateTime AttachmentLastModified, - bool? AttachmentIsUnsorted, - int? AttachmentOrder, - Guid? AttachmentGroupGUID, - Guid? AttachmentFormGUID, - string? AttachmentHash, - string? AttachmentTitle, - string? AttachmentDescription, - string? AttachmentCustomData, - string? AttachmentSearchContent, - string? AttachmentVariantDefinitionIdentifier, - int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); +}; +public partial record CmsAttachmentK13(int AttachmentID, string AttachmentName, string AttachmentExtension, int AttachmentSize, string AttachmentMimeType, byte[]? AttachmentBinary, int? AttachmentImageWidth, int? AttachmentImageHeight, int? AttachmentDocumentID, Guid AttachmentGUID, int AttachmentSiteID, DateTime AttachmentLastModified, bool? AttachmentIsUnsorted, int? AttachmentOrder, Guid? AttachmentGroupGUID, Guid? AttachmentFormGUID, string? AttachmentHash, string? AttachmentTitle, string? AttachmentDescription, string? AttachmentCustomData, string? AttachmentSearchContent, string? AttachmentVariantDefinitionIdentifier, int? AttachmentVariantParentID) : ICmsAttachment, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "AttachmentID"; public static string TableName => "CMS_Attachment"; public static string GuidColumnName => "AttachmentGUID"; - static CmsAttachmentK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); - + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); public static CmsAttachmentK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), - reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), - reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), - reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), - reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") - ); -} + reader.Unbox("AttachmentID"), reader.Unbox("AttachmentName"), reader.Unbox("AttachmentExtension"), reader.Unbox("AttachmentSize"), reader.Unbox("AttachmentMimeType"), reader.Unbox("AttachmentBinary"), reader.Unbox("AttachmentImageWidth"), reader.Unbox("AttachmentImageHeight"), reader.Unbox("AttachmentDocumentID"), reader.Unbox("AttachmentGUID"), reader.Unbox("AttachmentSiteID"), reader.Unbox("AttachmentLastModified"), reader.Unbox("AttachmentIsUnsorted"), reader.Unbox("AttachmentOrder"), reader.Unbox("AttachmentGroupGUID"), reader.Unbox("AttachmentFormGUID"), reader.Unbox("AttachmentHash"), reader.Unbox("AttachmentTitle"), reader.Unbox("AttachmentDescription"), reader.Unbox("AttachmentCustomData"), reader.Unbox("AttachmentSearchContent"), reader.Unbox("AttachmentVariantDefinitionIdentifier"), reader.Unbox("AttachmentVariantParentID") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsCategory.cs b/KVA/Migration.Toolkit.Source/Model/CmsCategory.cs index 152503e1..18944168 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsCategory.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsCategory.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsCategory : ISourceModel +public partial interface ICmsCategory : ISourceModel { int CategoryID { get; } string CategoryDisplayName { get; } @@ -31,7 +29,6 @@ public interface ICmsCategory : ISourceModel { Major: 13 } => CmsCategoryK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsCategoryK11.IsAvailable(version), @@ -39,10 +36,8 @@ public interface ICmsCategory : ISourceModel { Major: 13 } => CmsCategoryK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Category"; static string ISourceModel.GuidColumnName => "CategoryGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsCategory ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsCategoryK11.FromReader(reader, version), @@ -51,108 +46,43 @@ public interface ICmsCategory : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsCategoryK11( - int CategoryID, - string CategoryDisplayName, - string? CategoryName, - string? CategoryDescription, - int? CategoryCount, - bool CategoryEnabled, - int? CategoryUserID, - Guid CategoryGUID, - DateTime CategoryLastModified, - int? CategorySiteID, - int? CategoryParentID, - string? CategoryIDPath, - string? CategoryNamePath, - int? CategoryLevel, - int? CategoryOrder) : ICmsCategory, ISourceModel +public partial record CmsCategoryK11(int CategoryID, string CategoryDisplayName, string? CategoryName, string? CategoryDescription, int? CategoryCount, bool CategoryEnabled, int? CategoryUserID, Guid CategoryGUID, DateTime CategoryLastModified, int? CategorySiteID, int? CategoryParentID, string? CategoryIDPath, string? CategoryNamePath, int? CategoryLevel, int? CategoryOrder) : ICmsCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_Category"; public static string GuidColumnName => "CategoryGUID"; - static CmsCategoryK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); - + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); public static CmsCategoryK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); -} - -public record CmsCategoryK12( - int CategoryID, - string CategoryDisplayName, - string? CategoryName, - string? CategoryDescription, - int? CategoryCount, - bool CategoryEnabled, - int? CategoryUserID, - Guid CategoryGUID, - DateTime CategoryLastModified, - int? CategorySiteID, - int? CategoryParentID, - string? CategoryIDPath, - string? CategoryNamePath, - int? CategoryLevel, - int? CategoryOrder) : ICmsCategory, ISourceModel + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); +}; +public partial record CmsCategoryK12(int CategoryID, string CategoryDisplayName, string? CategoryName, string? CategoryDescription, int? CategoryCount, bool CategoryEnabled, int? CategoryUserID, Guid CategoryGUID, DateTime CategoryLastModified, int? CategorySiteID, int? CategoryParentID, string? CategoryIDPath, string? CategoryNamePath, int? CategoryLevel, int? CategoryOrder) : ICmsCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_Category"; public static string GuidColumnName => "CategoryGUID"; - static CmsCategoryK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); - + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); public static CmsCategoryK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); -} - -public record CmsCategoryK13( - int CategoryID, - string CategoryDisplayName, - string? CategoryName, - string? CategoryDescription, - int? CategoryCount, - bool CategoryEnabled, - int? CategoryUserID, - Guid CategoryGUID, - DateTime CategoryLastModified, - int? CategorySiteID, - int? CategoryParentID, - string? CategoryIDPath, - string? CategoryNamePath, - int? CategoryLevel, - int? CategoryOrder) : ICmsCategory, ISourceModel + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); +}; +public partial record CmsCategoryK13(int CategoryID, string CategoryDisplayName, string? CategoryName, string? CategoryDescription, int? CategoryCount, bool CategoryEnabled, int? CategoryUserID, Guid CategoryGUID, DateTime CategoryLastModified, int? CategorySiteID, int? CategoryParentID, string? CategoryIDPath, string? CategoryNamePath, int? CategoryLevel, int? CategoryOrder) : ICmsCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_Category"; public static string GuidColumnName => "CategoryGUID"; - static CmsCategoryK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); - + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); public static CmsCategoryK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), - reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), - reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") - ); -} + reader.Unbox("CategoryID"), reader.Unbox("CategoryDisplayName"), reader.Unbox("CategoryName"), reader.Unbox("CategoryDescription"), reader.Unbox("CategoryCount"), reader.Unbox("CategoryEnabled"), reader.Unbox("CategoryUserID"), reader.Unbox("CategoryGUID"), reader.Unbox("CategoryLastModified"), reader.Unbox("CategorySiteID"), reader.Unbox("CategoryParentID"), reader.Unbox("CategoryIDPath"), reader.Unbox("CategoryNamePath"), reader.Unbox("CategoryLevel"), reader.Unbox("CategoryOrder") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsClass.cs b/KVA/Migration.Toolkit.Source/Model/CmsClass.cs index 9b8f086a..a8bfab2b 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsClass.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsClass.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsClass : ISourceModel +public partial interface ICmsClass : ISourceModel { int ClassID { get; } string ClassDisplayName { get; } @@ -62,7 +60,6 @@ public interface ICmsClass : ISourceModel { Major: 13 } => CmsClassK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsClassK11.IsAvailable(version), @@ -70,10 +67,8 @@ public interface ICmsClass : ISourceModel { Major: 13 } => CmsClassK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Class"; static string ISourceModel.GuidColumnName => "ClassGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsClass ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsClassK11.FromReader(reader, version), @@ -82,270 +77,43 @@ public interface ICmsClass : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsClassK11( - int ClassID, - string ClassDisplayName, - string ClassName, - bool ClassUsesVersioning, - bool ClassIsDocumentType, - bool ClassIsCoupledClass, - string ClassXmlSchema, - string ClassFormDefinition, - string? ClassEditingPageUrl, - string? ClassListPageUrl, - string ClassNodeNameSource, - string? ClassTableName, - string? ClassViewPageUrl, - string? ClassPreviewPageUrl, - string? ClassFormLayout, - string? ClassNewPageUrl, - bool? ClassShowAsSystemTable, - bool? ClassUsePublishFromTo, - bool? ClassShowTemplateSelection, - string? ClassSKUMappings, - bool? ClassIsMenuItemType, - string? ClassNodeAliasSource, - int? ClassDefaultPageTemplateID, - DateTime ClassLastModified, - Guid ClassGUID, - bool? ClassCreateSKU, - bool? ClassIsProduct, - bool ClassIsCustomTable, - string? ClassShowColumns, - string? ClassSearchTitleColumn, - string? ClassSearchContentColumn, - string? ClassSearchImageColumn, - string? ClassSearchCreationDateColumn, - string? ClassSearchSettings, - int? ClassInheritsFromClassID, - bool? ClassSearchEnabled, - string? ClassSKUDefaultDepartmentName, - int? ClassSKUDefaultDepartmentID, - string? ClassContactMapping, - bool? ClassContactOverwriteEnabled, - string? ClassSKUDefaultProductType, - string? ClassConnectionString, - bool? ClassIsProductSection, - int? ClassPageTemplateCategoryID, - string? ClassFormLayoutType, - string? ClassVersionGUID, - string? ClassDefaultObjectType, - bool? ClassIsForm, - int? ClassResourceID, - string? ClassCustomizedColumns, - string? ClassCodeGenerationSettings, - string? ClassIconClass, - bool? ClassIsContentOnly, - string? ClassURLPattern) : ICmsClass, ISourceModel +public partial record CmsClassK11(int ClassID, string ClassDisplayName, string ClassName, bool ClassUsesVersioning, bool ClassIsDocumentType, bool ClassIsCoupledClass, string ClassXmlSchema, string ClassFormDefinition, string? ClassEditingPageUrl, string? ClassListPageUrl, string ClassNodeNameSource, string? ClassTableName, string? ClassViewPageUrl, string? ClassPreviewPageUrl, string? ClassFormLayout, string? ClassNewPageUrl, bool? ClassShowAsSystemTable, bool? ClassUsePublishFromTo, bool? ClassShowTemplateSelection, string? ClassSKUMappings, bool? ClassIsMenuItemType, string? ClassNodeAliasSource, int? ClassDefaultPageTemplateID, DateTime ClassLastModified, Guid ClassGUID, bool? ClassCreateSKU, bool? ClassIsProduct, bool ClassIsCustomTable, string? ClassShowColumns, string? ClassSearchTitleColumn, string? ClassSearchContentColumn, string? ClassSearchImageColumn, string? ClassSearchCreationDateColumn, string? ClassSearchSettings, int? ClassInheritsFromClassID, bool? ClassSearchEnabled, string? ClassSKUDefaultDepartmentName, int? ClassSKUDefaultDepartmentID, string? ClassContactMapping, bool? ClassContactOverwriteEnabled, string? ClassSKUDefaultProductType, string? ClassConnectionString, bool? ClassIsProductSection, int? ClassPageTemplateCategoryID, string? ClassFormLayoutType, string? ClassVersionGUID, string? ClassDefaultObjectType, bool? ClassIsForm, int? ClassResourceID, string? ClassCustomizedColumns, string? ClassCodeGenerationSettings, string? ClassIconClass, bool? ClassIsContentOnly, string? ClassURLPattern) : ICmsClass, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_Class"; public static string GuidColumnName => "ClassGUID"; - static CmsClassK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), - reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), - reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), - reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), - reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), - reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") - ); - + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") + ); public static CmsClassK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), - reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), - reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), - reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), - reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), - reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") - ); -} - -public record CmsClassK12( - int ClassID, - string ClassDisplayName, - string ClassName, - bool ClassUsesVersioning, - bool ClassIsDocumentType, - bool ClassIsCoupledClass, - string ClassXmlSchema, - string ClassFormDefinition, - string? ClassEditingPageUrl, - string? ClassListPageUrl, - string ClassNodeNameSource, - string? ClassTableName, - string? ClassViewPageUrl, - string? ClassPreviewPageUrl, - string? ClassFormLayout, - string? ClassNewPageUrl, - bool? ClassShowAsSystemTable, - bool? ClassUsePublishFromTo, - bool? ClassShowTemplateSelection, - string? ClassSKUMappings, - bool? ClassIsMenuItemType, - string? ClassNodeAliasSource, - int? ClassDefaultPageTemplateID, - DateTime ClassLastModified, - Guid ClassGUID, - bool? ClassCreateSKU, - bool? ClassIsProduct, - bool ClassIsCustomTable, - string? ClassShowColumns, - string? ClassSearchTitleColumn, - string? ClassSearchContentColumn, - string? ClassSearchImageColumn, - string? ClassSearchCreationDateColumn, - string? ClassSearchSettings, - int? ClassInheritsFromClassID, - bool? ClassSearchEnabled, - string? ClassSKUDefaultDepartmentName, - int? ClassSKUDefaultDepartmentID, - string? ClassContactMapping, - bool? ClassContactOverwriteEnabled, - string? ClassSKUDefaultProductType, - string? ClassConnectionString, - bool? ClassIsProductSection, - int? ClassPageTemplateCategoryID, - string? ClassFormLayoutType, - string? ClassVersionGUID, - string? ClassDefaultObjectType, - bool? ClassIsForm, - int? ClassResourceID, - string? ClassCustomizedColumns, - string? ClassCodeGenerationSettings, - string? ClassIconClass, - bool? ClassIsContentOnly, - string? ClassURLPattern) : ICmsClass, ISourceModel + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") + ); +}; +public partial record CmsClassK12(int ClassID, string ClassDisplayName, string ClassName, bool ClassUsesVersioning, bool ClassIsDocumentType, bool ClassIsCoupledClass, string ClassXmlSchema, string ClassFormDefinition, string? ClassEditingPageUrl, string? ClassListPageUrl, string ClassNodeNameSource, string? ClassTableName, string? ClassViewPageUrl, string? ClassPreviewPageUrl, string? ClassFormLayout, string? ClassNewPageUrl, bool? ClassShowAsSystemTable, bool? ClassUsePublishFromTo, bool? ClassShowTemplateSelection, string? ClassSKUMappings, bool? ClassIsMenuItemType, string? ClassNodeAliasSource, int? ClassDefaultPageTemplateID, DateTime ClassLastModified, Guid ClassGUID, bool? ClassCreateSKU, bool? ClassIsProduct, bool ClassIsCustomTable, string? ClassShowColumns, string? ClassSearchTitleColumn, string? ClassSearchContentColumn, string? ClassSearchImageColumn, string? ClassSearchCreationDateColumn, string? ClassSearchSettings, int? ClassInheritsFromClassID, bool? ClassSearchEnabled, string? ClassSKUDefaultDepartmentName, int? ClassSKUDefaultDepartmentID, string? ClassContactMapping, bool? ClassContactOverwriteEnabled, string? ClassSKUDefaultProductType, string? ClassConnectionString, bool? ClassIsProductSection, int? ClassPageTemplateCategoryID, string? ClassFormLayoutType, string? ClassVersionGUID, string? ClassDefaultObjectType, bool? ClassIsForm, int? ClassResourceID, string? ClassCustomizedColumns, string? ClassCodeGenerationSettings, string? ClassIconClass, bool? ClassIsContentOnly, string? ClassURLPattern) : ICmsClass, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_Class"; public static string GuidColumnName => "ClassGUID"; - static CmsClassK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), - reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), - reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), - reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), - reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), - reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") - ); - + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") + ); public static CmsClassK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), - reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), - reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), - reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), - reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), - reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") - ); -} - -public record CmsClassK13( - int ClassID, - string ClassDisplayName, - string ClassName, - bool ClassUsesVersioning, - bool ClassIsDocumentType, - bool ClassIsCoupledClass, - string ClassXmlSchema, - string ClassFormDefinition, - string ClassNodeNameSource, - string? ClassTableName, - string? ClassFormLayout, - bool? ClassShowAsSystemTable, - bool? ClassUsePublishFromTo, - bool? ClassShowTemplateSelection, - string? ClassSKUMappings, - bool? ClassIsMenuItemType, - string? ClassNodeAliasSource, - DateTime ClassLastModified, - Guid ClassGUID, - bool? ClassCreateSKU, - bool? ClassIsProduct, - bool ClassIsCustomTable, - string? ClassShowColumns, - string? ClassSearchTitleColumn, - string? ClassSearchContentColumn, - string? ClassSearchImageColumn, - string? ClassSearchCreationDateColumn, - string? ClassSearchSettings, - int? ClassInheritsFromClassID, - bool? ClassSearchEnabled, - string? ClassSKUDefaultDepartmentName, - int? ClassSKUDefaultDepartmentID, - string? ClassContactMapping, - bool? ClassContactOverwriteEnabled, - string? ClassSKUDefaultProductType, - string? ClassConnectionString, - bool? ClassIsProductSection, - string? ClassFormLayoutType, - string? ClassVersionGUID, - string? ClassDefaultObjectType, - bool? ClassIsForm, - int? ClassResourceID, - string? ClassCustomizedColumns, - string? ClassCodeGenerationSettings, - string? ClassIconClass, - string? ClassURLPattern, - bool ClassUsesPageBuilder, - bool ClassIsNavigationItem, - bool ClassHasURL, - bool ClassHasMetadata, - int? ClassSearchIndexDataSource) : ICmsClass, ISourceModel + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassEditingPageUrl"), reader.Unbox("ClassListPageUrl"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassViewPageUrl"), reader.Unbox("ClassPreviewPageUrl"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassNewPageUrl"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassDefaultPageTemplateID"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassPageTemplateCategoryID"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassIsContentOnly"), reader.Unbox("ClassURLPattern") + ); +}; +public partial record CmsClassK13(int ClassID, string ClassDisplayName, string ClassName, bool ClassUsesVersioning, bool ClassIsDocumentType, bool ClassIsCoupledClass, string ClassXmlSchema, string ClassFormDefinition, string ClassNodeNameSource, string? ClassTableName, string? ClassFormLayout, bool? ClassShowAsSystemTable, bool? ClassUsePublishFromTo, bool? ClassShowTemplateSelection, string? ClassSKUMappings, bool? ClassIsMenuItemType, string? ClassNodeAliasSource, DateTime ClassLastModified, Guid ClassGUID, bool? ClassCreateSKU, bool? ClassIsProduct, bool ClassIsCustomTable, string? ClassShowColumns, string? ClassSearchTitleColumn, string? ClassSearchContentColumn, string? ClassSearchImageColumn, string? ClassSearchCreationDateColumn, string? ClassSearchSettings, int? ClassInheritsFromClassID, bool? ClassSearchEnabled, string? ClassSKUDefaultDepartmentName, int? ClassSKUDefaultDepartmentID, string? ClassContactMapping, bool? ClassContactOverwriteEnabled, string? ClassSKUDefaultProductType, string? ClassConnectionString, bool? ClassIsProductSection, string? ClassFormLayoutType, string? ClassVersionGUID, string? ClassDefaultObjectType, bool? ClassIsForm, int? ClassResourceID, string? ClassCustomizedColumns, string? ClassCodeGenerationSettings, string? ClassIconClass, string? ClassURLPattern, bool ClassUsesPageBuilder, bool ClassIsNavigationItem, bool ClassHasURL, bool ClassHasMetadata, int? ClassSearchIndexDataSource) : ICmsClass, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_Class"; public static string GuidColumnName => "ClassGUID"; - static CmsClassK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassFormLayout"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), - reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), - reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), - reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), - reader.Unbox("ClassIconClass"), reader.Unbox("ClassURLPattern"), reader.Unbox("ClassUsesPageBuilder"), reader.Unbox("ClassIsNavigationItem"), reader.Unbox("ClassHasURL"), - reader.Unbox("ClassHasMetadata"), reader.Unbox("ClassSearchIndexDataSource") - ); - + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassURLPattern"), reader.Unbox("ClassUsesPageBuilder"), reader.Unbox("ClassIsNavigationItem"), reader.Unbox("ClassHasURL"), reader.Unbox("ClassHasMetadata"), reader.Unbox("ClassSearchIndexDataSource") + ); public static CmsClassK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), - reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassFormLayout"), - reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), - reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), - reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), - reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), - reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), - reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), - reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), - reader.Unbox("ClassIconClass"), reader.Unbox("ClassURLPattern"), reader.Unbox("ClassUsesPageBuilder"), reader.Unbox("ClassIsNavigationItem"), reader.Unbox("ClassHasURL"), - reader.Unbox("ClassHasMetadata"), reader.Unbox("ClassSearchIndexDataSource") - ); -} + reader.Unbox("ClassID"), reader.Unbox("ClassDisplayName"), reader.Unbox("ClassName"), reader.Unbox("ClassUsesVersioning"), reader.Unbox("ClassIsDocumentType"), reader.Unbox("ClassIsCoupledClass"), reader.Unbox("ClassXmlSchema"), reader.Unbox("ClassFormDefinition"), reader.Unbox("ClassNodeNameSource"), reader.Unbox("ClassTableName"), reader.Unbox("ClassFormLayout"), reader.Unbox("ClassShowAsSystemTable"), reader.Unbox("ClassUsePublishFromTo"), reader.Unbox("ClassShowTemplateSelection"), reader.Unbox("ClassSKUMappings"), reader.Unbox("ClassIsMenuItemType"), reader.Unbox("ClassNodeAliasSource"), reader.Unbox("ClassLastModified"), reader.Unbox("ClassGUID"), reader.Unbox("ClassCreateSKU"), reader.Unbox("ClassIsProduct"), reader.Unbox("ClassIsCustomTable"), reader.Unbox("ClassShowColumns"), reader.Unbox("ClassSearchTitleColumn"), reader.Unbox("ClassSearchContentColumn"), reader.Unbox("ClassSearchImageColumn"), reader.Unbox("ClassSearchCreationDateColumn"), reader.Unbox("ClassSearchSettings"), reader.Unbox("ClassInheritsFromClassID"), reader.Unbox("ClassSearchEnabled"), reader.Unbox("ClassSKUDefaultDepartmentName"), reader.Unbox("ClassSKUDefaultDepartmentID"), reader.Unbox("ClassContactMapping"), reader.Unbox("ClassContactOverwriteEnabled"), reader.Unbox("ClassSKUDefaultProductType"), reader.Unbox("ClassConnectionString"), reader.Unbox("ClassIsProductSection"), reader.Unbox("ClassFormLayoutType"), reader.Unbox("ClassVersionGUID"), reader.Unbox("ClassDefaultObjectType"), reader.Unbox("ClassIsForm"), reader.Unbox("ClassResourceID"), reader.Unbox("ClassCustomizedColumns"), reader.Unbox("ClassCodeGenerationSettings"), reader.Unbox("ClassIconClass"), reader.Unbox("ClassURLPattern"), reader.Unbox("ClassUsesPageBuilder"), reader.Unbox("ClassIsNavigationItem"), reader.Unbox("ClassHasURL"), reader.Unbox("ClassHasMetadata"), reader.Unbox("ClassSearchIndexDataSource") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsClassSite.cs b/KVA/Migration.Toolkit.Source/Model/CmsClassSite.cs index d46f8d05..ccfcd9a7 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsClassSite.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsClassSite.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsClassSite : ISourceModel +public partial interface ICmsClassSite : ISourceModel { int ClassID { get; } int SiteID { get; } @@ -18,7 +16,6 @@ public interface ICmsClassSite : ISourceModel { Major: 13 } => CmsClassSiteK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsClassSiteK11.IsAvailable(version), @@ -26,10 +23,8 @@ public interface ICmsClassSite : ISourceModel { Major: 13 } => CmsClassSiteK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_ClassSite"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsClassSite ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsClassSiteK11.FromReader(reader, version), @@ -38,51 +33,43 @@ public interface ICmsClassSite : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsClassSiteK11(int ClassID, int SiteID) : ICmsClassSite, ISourceModel +public partial record CmsClassSiteK11(int ClassID, int SiteID) : ICmsClassSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_ClassSite"; public static string GuidColumnName => ""; - static CmsClassSiteK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); - + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); public static CmsClassSiteK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); -} - -public record CmsClassSiteK12(int ClassID, int SiteID) : ICmsClassSite, ISourceModel + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); +}; +public partial record CmsClassSiteK12(int ClassID, int SiteID) : ICmsClassSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_ClassSite"; public static string GuidColumnName => ""; - static CmsClassSiteK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); - + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); public static CmsClassSiteK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); -} - -public record CmsClassSiteK13(int ClassID, int SiteID) : ICmsClassSite, ISourceModel + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); +}; +public partial record CmsClassSiteK13(int ClassID, int SiteID) : ICmsClassSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ClassID"; public static string TableName => "CMS_ClassSite"; public static string GuidColumnName => ""; - static CmsClassSiteK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); - + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); public static CmsClassSiteK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ClassID"), reader.Unbox("SiteID") - ); -} + reader.Unbox("ClassID"), reader.Unbox("SiteID") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsConsent.cs b/KVA/Migration.Toolkit.Source/Model/CmsConsent.cs index c85a52d2..a60d77c1 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsConsent.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsConsent.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsConsent : ISourceModel +public partial interface ICmsConsent : ISourceModel { int ConsentID { get; } string ConsentDisplayName { get; } @@ -23,7 +21,6 @@ public interface ICmsConsent : ISourceModel { Major: 13 } => CmsConsentK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsConsentK11.IsAvailable(version), @@ -31,10 +28,8 @@ public interface ICmsConsent : ISourceModel { Major: 13 } => CmsConsentK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Consent"; static string ISourceModel.GuidColumnName => "ConsentGuid"; //assumtion, class Guid column doesn't change between versions - static ICmsConsent ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsConsentK11.FromReader(reader, version), @@ -43,57 +38,43 @@ public interface ICmsConsent : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsConsentK11(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel +public partial record CmsConsentK11(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentID"; public static string TableName => "CMS_Consent"; public static string GuidColumnName => "ConsentGuid"; - static CmsConsentK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); - + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); public static CmsConsentK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); -} - -public record CmsConsentK12(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); +}; +public partial record CmsConsentK12(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentID"; public static string TableName => "CMS_Consent"; public static string GuidColumnName => "ConsentGuid"; - static CmsConsentK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); - + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); public static CmsConsentK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); -} - -public record CmsConsentK13(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); +}; +public partial record CmsConsentK13(int ConsentID, string ConsentDisplayName, string ConsentName, string ConsentContent, Guid ConsentGuid, DateTime ConsentLastModified, string ConsentHash) : ICmsConsent, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentID"; public static string TableName => "CMS_Consent"; public static string GuidColumnName => "ConsentGuid"; - static CmsConsentK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); - + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); public static CmsConsentK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), - reader.Unbox("ConsentHash") - ); -} + reader.Unbox("ConsentID"), reader.Unbox("ConsentDisplayName"), reader.Unbox("ConsentName"), reader.Unbox("ConsentContent"), reader.Unbox("ConsentGuid"), reader.Unbox("ConsentLastModified"), reader.Unbox("ConsentHash") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsConsentAgreement.cs b/KVA/Migration.Toolkit.Source/Model/CmsConsentAgreement.cs index b511c54c..d45ca6eb 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsConsentAgreement.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsConsentAgreement.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsConsentAgreement : ISourceModel +public partial interface ICmsConsentAgreement : ISourceModel { int ConsentAgreementID { get; } Guid ConsentAgreementGuid { get; } @@ -23,7 +21,6 @@ public interface ICmsConsentAgreement : ISourceModel { Major: 13 } => CmsConsentAgreementK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsConsentAgreementK11.IsAvailable(version), @@ -31,10 +28,8 @@ public interface ICmsConsentAgreement : ISourceModel { Major: 13 } => CmsConsentAgreementK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_ConsentAgreement"; static string ISourceModel.GuidColumnName => "ConsentAgreementGuid"; //assumtion, class Guid column doesn't change between versions - static ICmsConsentAgreement ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsConsentAgreementK11.FromReader(reader, version), @@ -43,60 +38,43 @@ public interface ICmsConsentAgreement : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsConsentAgreementK11(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) - : ICmsConsentAgreement, ISourceModel +public partial record CmsConsentAgreementK11(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) : ICmsConsentAgreement, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentAgreementID"; public static string TableName => "CMS_ConsentAgreement"; public static string GuidColumnName => "ConsentAgreementGuid"; - static CmsConsentAgreementK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); - + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); public static CmsConsentAgreementK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); -} - -public record CmsConsentAgreementK12(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) - : ICmsConsentAgreement, ISourceModel + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); +}; +public partial record CmsConsentAgreementK12(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) : ICmsConsentAgreement, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentAgreementID"; public static string TableName => "CMS_ConsentAgreement"; public static string GuidColumnName => "ConsentAgreementGuid"; - static CmsConsentAgreementK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); - + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); public static CmsConsentAgreementK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); -} - -public record CmsConsentAgreementK13(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) - : ICmsConsentAgreement, ISourceModel + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); +}; +public partial record CmsConsentAgreementK13(int ConsentAgreementID, Guid ConsentAgreementGuid, bool ConsentAgreementRevoked, int ConsentAgreementContactID, int ConsentAgreementConsentID, string? ConsentAgreementConsentHash, DateTime ConsentAgreementTime) : ICmsConsentAgreement, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentAgreementID"; public static string TableName => "CMS_ConsentAgreement"; public static string GuidColumnName => "ConsentAgreementGuid"; - static CmsConsentAgreementK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); - + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); public static CmsConsentAgreementK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), - reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") - ); -} + reader.Unbox("ConsentAgreementID"), reader.Unbox("ConsentAgreementGuid"), reader.Unbox("ConsentAgreementRevoked"), reader.Unbox("ConsentAgreementContactID"), reader.Unbox("ConsentAgreementConsentID"), reader.Unbox("ConsentAgreementConsentHash"), reader.Unbox("ConsentAgreementTime") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsConsentArchive.cs b/KVA/Migration.Toolkit.Source/Model/CmsConsentArchive.cs index 042944bf..67ac2667 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsConsentArchive.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsConsentArchive.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsConsentArchive : ISourceModel +public partial interface ICmsConsentArchive : ISourceModel { int ConsentArchiveID { get; } Guid ConsentArchiveGuid { get; } @@ -22,7 +20,6 @@ public interface ICmsConsentArchive : ISourceModel { Major: 13 } => CmsConsentArchiveK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsConsentArchiveK11.IsAvailable(version), @@ -30,10 +27,8 @@ public interface ICmsConsentArchive : ISourceModel { Major: 13 } => CmsConsentArchiveK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_ConsentArchive"; static string ISourceModel.GuidColumnName => "ConsentArchiveGuid"; //assumtion, class Guid column doesn't change between versions - static ICmsConsentArchive ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsConsentArchiveK11.FromReader(reader, version), @@ -42,60 +37,43 @@ public interface ICmsConsentArchive : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsConsentArchiveK11(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) - : ICmsConsentArchive, ISourceModel +public partial record CmsConsentArchiveK11(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) : ICmsConsentArchive, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentArchiveID"; public static string TableName => "CMS_ConsentArchive"; public static string GuidColumnName => "ConsentArchiveGuid"; - static CmsConsentArchiveK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); - + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); public static CmsConsentArchiveK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); -} - -public record CmsConsentArchiveK12(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) - : ICmsConsentArchive, ISourceModel + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); +}; +public partial record CmsConsentArchiveK12(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) : ICmsConsentArchive, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentArchiveID"; public static string TableName => "CMS_ConsentArchive"; public static string GuidColumnName => "ConsentArchiveGuid"; - static CmsConsentArchiveK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); - + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); public static CmsConsentArchiveK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); -} - -public record CmsConsentArchiveK13(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) - : ICmsConsentArchive, ISourceModel + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); +}; +public partial record CmsConsentArchiveK13(int ConsentArchiveID, Guid ConsentArchiveGuid, DateTime ConsentArchiveLastModified, int ConsentArchiveConsentID, string ConsentArchiveHash, string ConsentArchiveContent) : ICmsConsentArchive, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ConsentArchiveID"; public static string TableName => "CMS_ConsentArchive"; public static string GuidColumnName => "ConsentArchiveGuid"; - static CmsConsentArchiveK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); - + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); public static CmsConsentArchiveK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), - reader.Unbox("ConsentArchiveContent") - ); -} + reader.Unbox("ConsentArchiveID"), reader.Unbox("ConsentArchiveGuid"), reader.Unbox("ConsentArchiveLastModified"), reader.Unbox("ConsentArchiveConsentID"), reader.Unbox("ConsentArchiveHash"), reader.Unbox("ConsentArchiveContent") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsCountry.cs b/KVA/Migration.Toolkit.Source/Model/CmsCountry.cs index 28ea12b0..790a6256 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsCountry.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsCountry.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsCountry : ISourceModel +public partial interface ICmsCountry : ISourceModel { int CountryID { get; } string CountryDisplayName { get; } @@ -23,7 +21,6 @@ public interface ICmsCountry : ISourceModel { Major: 13 } => CmsCountryK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsCountryK11.IsAvailable(version), @@ -31,10 +28,8 @@ public interface ICmsCountry : ISourceModel { Major: 13 } => CmsCountryK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Country"; static string ISourceModel.GuidColumnName => "CountryGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsCountry ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsCountryK11.FromReader(reader, version), @@ -43,57 +38,43 @@ public interface ICmsCountry : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsCountryK11(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel +public partial record CmsCountryK11(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CountryID"; public static string TableName => "CMS_Country"; public static string GuidColumnName => "CountryGUID"; - static CmsCountryK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); - + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); public static CmsCountryK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); -} - -public record CmsCountryK12(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); +}; +public partial record CmsCountryK12(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CountryID"; public static string TableName => "CMS_Country"; public static string GuidColumnName => "CountryGUID"; - static CmsCountryK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); - + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); public static CmsCountryK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); -} - -public record CmsCountryK13(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); +}; +public partial record CmsCountryK13(int CountryID, string CountryDisplayName, string CountryName, Guid CountryGUID, DateTime CountryLastModified, string? CountryTwoLetterCode, string? CountryThreeLetterCode) : ICmsCountry, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CountryID"; public static string TableName => "CMS_Country"; public static string GuidColumnName => "CountryGUID"; - static CmsCountryK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); - + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); public static CmsCountryK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), - reader.Unbox("CountryThreeLetterCode") - ); -} + reader.Unbox("CountryID"), reader.Unbox("CountryDisplayName"), reader.Unbox("CountryName"), reader.Unbox("CountryGUID"), reader.Unbox("CountryLastModified"), reader.Unbox("CountryTwoLetterCode"), reader.Unbox("CountryThreeLetterCode") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsCulture.cs b/KVA/Migration.Toolkit.Source/Model/CmsCulture.cs index 71aa6546..6e02c889 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsCulture.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsCulture.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsCulture : ISourceModel +public partial interface ICmsCulture : ISourceModel { int CultureID { get; } string CultureName { get; } @@ -24,7 +22,6 @@ public interface ICmsCulture : ISourceModel { Major: 13 } => CmsCultureK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsCultureK11.IsAvailable(version), @@ -32,10 +29,8 @@ public interface ICmsCulture : ISourceModel { Major: 13 } => CmsCultureK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Culture"; static string ISourceModel.GuidColumnName => "CultureGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsCulture ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsCultureK11.FromReader(reader, version), @@ -44,57 +39,43 @@ public interface ICmsCulture : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsCultureK11(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel +public partial record CmsCultureK11(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_Culture"; public static string GuidColumnName => "CultureGUID"; - static CmsCultureK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); - + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); public static CmsCultureK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); -} - -public record CmsCultureK12(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); +}; +public partial record CmsCultureK12(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_Culture"; public static string GuidColumnName => "CultureGUID"; - static CmsCultureK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); - + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); public static CmsCultureK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); -} - -public record CmsCultureK13(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); +}; +public partial record CmsCultureK13(int CultureID, string CultureName, string CultureCode, string CultureShortName, Guid CultureGUID, DateTime CultureLastModified, string? CultureAlias, bool? CultureIsUICulture) : ICmsCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_Culture"; public static string GuidColumnName => "CultureGUID"; - static CmsCultureK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); - + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); public static CmsCultureK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), - reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") - ); -} + reader.Unbox("CultureID"), reader.Unbox("CultureName"), reader.Unbox("CultureCode"), reader.Unbox("CultureShortName"), reader.Unbox("CultureGUID"), reader.Unbox("CultureLastModified"), reader.Unbox("CultureAlias"), reader.Unbox("CultureIsUICulture") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsDocument.cs b/KVA/Migration.Toolkit.Source/Model/CmsDocument.cs index c62b9659..253e04a6 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsDocument.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsDocument.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsDocument : ISourceModel +public partial interface ICmsDocument : ISourceModel { int DocumentID { get; } string DocumentName { get; } @@ -51,7 +49,6 @@ public interface ICmsDocument : ISourceModel { Major: 13 } => CmsDocumentK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsDocumentK11.IsAvailable(version), @@ -59,10 +56,8 @@ public interface ICmsDocument : ISourceModel { Major: 13 } => CmsDocumentK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Document"; static string ISourceModel.GuidColumnName => "DocumentGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsDocument ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsDocumentK11.FromReader(reader, version), @@ -71,319 +66,43 @@ public interface ICmsDocument : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsDocumentK11( - int DocumentID, - string DocumentName, - string? DocumentNamePath, - DateTime? DocumentModifiedWhen, - int? DocumentModifiedByUserID, - int? DocumentForeignKeyValue, - int? DocumentCreatedByUserID, - DateTime? DocumentCreatedWhen, - int? DocumentCheckedOutByUserID, - DateTime? DocumentCheckedOutWhen, - int? DocumentCheckedOutVersionHistoryID, - int? DocumentPublishedVersionHistoryID, - int? DocumentWorkflowStepID, - DateTime? DocumentPublishFrom, - DateTime? DocumentPublishTo, - string? DocumentUrlPath, - string DocumentCulture, - int DocumentNodeID, - string? DocumentPageTitle, - string? DocumentPageKeyWords, - string? DocumentPageDescription, - bool DocumentShowInSiteMap, - bool DocumentMenuItemHideInNavigation, - string? DocumentMenuCaption, - string? DocumentMenuStyle, - string? DocumentMenuItemImage, - string? DocumentMenuItemLeftImage, - string? DocumentMenuItemRightImage, - int? DocumentPageTemplateID, - string? DocumentMenuJavascript, - string? DocumentMenuRedirectUrl, - bool? DocumentUseNamePathForUrlPath, - int? DocumentStylesheetID, - string? DocumentContent, - string? DocumentMenuClass, - string? DocumentMenuStyleHighlighted, - string? DocumentMenuClassHighlighted, - string? DocumentMenuItemImageHighlighted, - string? DocumentMenuItemLeftImageHighlighted, - string? DocumentMenuItemRightImageHighlighted, - bool? DocumentMenuItemInactive, - string? DocumentCustomData, - string? DocumentExtensions, - string? DocumentTags, - int? DocumentTagGroupID, - string? DocumentWildcardRule, - string? DocumentWebParts, - double? DocumentRatingValue, - int? DocumentRatings, - int? DocumentPriority, - string? DocumentType, - DateTime? DocumentLastPublished, - bool? DocumentUseCustomExtensions, - string? DocumentGroupWebParts, - bool? DocumentCheckedOutAutomatically, - string? DocumentTrackConversionName, - string? DocumentConversionValue, - bool? DocumentSearchExcluded, - string? DocumentLastVersionNumber, - bool? DocumentIsArchived, - string? DocumentHash, - bool? DocumentLogVisitActivity, - Guid? DocumentGUID, - Guid? DocumentWorkflowCycleGUID, - string? DocumentSitemapSettings, - bool? DocumentIsWaitingForTranslation, - string? DocumentSKUName, - string? DocumentSKUDescription, - string? DocumentSKUShortDescription, - string? DocumentWorkflowActionStatus, - bool? DocumentMenuRedirectToFirstChild, - bool DocumentCanBePublished, - bool DocumentInheritsStylesheet) : ICmsDocument, ISourceModel +public partial record CmsDocumentK11(int DocumentID, string DocumentName, string? DocumentNamePath, DateTime? DocumentModifiedWhen, int? DocumentModifiedByUserID, int? DocumentForeignKeyValue, int? DocumentCreatedByUserID, DateTime? DocumentCreatedWhen, int? DocumentCheckedOutByUserID, DateTime? DocumentCheckedOutWhen, int? DocumentCheckedOutVersionHistoryID, int? DocumentPublishedVersionHistoryID, int? DocumentWorkflowStepID, DateTime? DocumentPublishFrom, DateTime? DocumentPublishTo, string? DocumentUrlPath, string DocumentCulture, int DocumentNodeID, string? DocumentPageTitle, string? DocumentPageKeyWords, string? DocumentPageDescription, bool DocumentShowInSiteMap, bool DocumentMenuItemHideInNavigation, string? DocumentMenuCaption, string? DocumentMenuStyle, string? DocumentMenuItemImage, string? DocumentMenuItemLeftImage, string? DocumentMenuItemRightImage, int? DocumentPageTemplateID, string? DocumentMenuJavascript, string? DocumentMenuRedirectUrl, bool? DocumentUseNamePathForUrlPath, int? DocumentStylesheetID, string? DocumentContent, string? DocumentMenuClass, string? DocumentMenuStyleHighlighted, string? DocumentMenuClassHighlighted, string? DocumentMenuItemImageHighlighted, string? DocumentMenuItemLeftImageHighlighted, string? DocumentMenuItemRightImageHighlighted, bool? DocumentMenuItemInactive, string? DocumentCustomData, string? DocumentExtensions, string? DocumentTags, int? DocumentTagGroupID, string? DocumentWildcardRule, string? DocumentWebParts, double? DocumentRatingValue, int? DocumentRatings, int? DocumentPriority, string? DocumentType, DateTime? DocumentLastPublished, bool? DocumentUseCustomExtensions, string? DocumentGroupWebParts, bool? DocumentCheckedOutAutomatically, string? DocumentTrackConversionName, string? DocumentConversionValue, bool? DocumentSearchExcluded, string? DocumentLastVersionNumber, bool? DocumentIsArchived, string? DocumentHash, bool? DocumentLogVisitActivity, Guid? DocumentGUID, Guid? DocumentWorkflowCycleGUID, string? DocumentSitemapSettings, bool? DocumentIsWaitingForTranslation, string? DocumentSKUName, string? DocumentSKUDescription, string? DocumentSKUShortDescription, string? DocumentWorkflowActionStatus, bool? DocumentMenuRedirectToFirstChild, bool DocumentCanBePublished, bool DocumentInheritsStylesheet) : ICmsDocument, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "DocumentID"; public static string TableName => "CMS_Document"; public static string GuidColumnName => "DocumentGUID"; - static CmsDocumentK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), - reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), - reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), - reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), - reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), - reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), - reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), - reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), - reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), - reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), - reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), - reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), - reader.Unbox("DocumentInheritsStylesheet") - ); - + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentInheritsStylesheet") + ); public static CmsDocumentK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), - reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), - reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), - reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), - reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), - reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), - reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), - reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), - reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), - reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), - reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), - reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), - reader.Unbox("DocumentInheritsStylesheet") - ); -} - -public record CmsDocumentK12( - int DocumentID, - string DocumentName, - string? DocumentNamePath, - DateTime? DocumentModifiedWhen, - int? DocumentModifiedByUserID, - int? DocumentForeignKeyValue, - int? DocumentCreatedByUserID, - DateTime? DocumentCreatedWhen, - int? DocumentCheckedOutByUserID, - DateTime? DocumentCheckedOutWhen, - int? DocumentCheckedOutVersionHistoryID, - int? DocumentPublishedVersionHistoryID, - int? DocumentWorkflowStepID, - DateTime? DocumentPublishFrom, - DateTime? DocumentPublishTo, - string? DocumentUrlPath, - string DocumentCulture, - int DocumentNodeID, - string? DocumentPageTitle, - string? DocumentPageKeyWords, - string? DocumentPageDescription, - bool DocumentShowInSiteMap, - bool DocumentMenuItemHideInNavigation, - string? DocumentMenuCaption, - string? DocumentMenuStyle, - string? DocumentMenuItemImage, - string? DocumentMenuItemLeftImage, - string? DocumentMenuItemRightImage, - int? DocumentPageTemplateID, - string? DocumentMenuJavascript, - string? DocumentMenuRedirectUrl, - bool? DocumentUseNamePathForUrlPath, - int? DocumentStylesheetID, - string? DocumentContent, - string? DocumentMenuClass, - string? DocumentMenuStyleHighlighted, - string? DocumentMenuClassHighlighted, - string? DocumentMenuItemImageHighlighted, - string? DocumentMenuItemLeftImageHighlighted, - string? DocumentMenuItemRightImageHighlighted, - bool? DocumentMenuItemInactive, - string? DocumentCustomData, - string? DocumentExtensions, - string? DocumentTags, - int? DocumentTagGroupID, - string? DocumentWildcardRule, - string? DocumentWebParts, - double? DocumentRatingValue, - int? DocumentRatings, - int? DocumentPriority, - string? DocumentType, - DateTime? DocumentLastPublished, - bool? DocumentUseCustomExtensions, - string? DocumentGroupWebParts, - bool? DocumentCheckedOutAutomatically, - string? DocumentTrackConversionName, - string? DocumentConversionValue, - bool? DocumentSearchExcluded, - string? DocumentLastVersionNumber, - bool? DocumentIsArchived, - string? DocumentHash, - bool? DocumentLogVisitActivity, - Guid? DocumentGUID, - Guid? DocumentWorkflowCycleGUID, - string? DocumentSitemapSettings, - bool? DocumentIsWaitingForTranslation, - string? DocumentSKUName, - string? DocumentSKUDescription, - string? DocumentSKUShortDescription, - string? DocumentWorkflowActionStatus, - bool? DocumentMenuRedirectToFirstChild, - bool DocumentCanBePublished, - bool DocumentInheritsStylesheet, - string? DocumentPageBuilderWidgets, - string? DocumentPageTemplateConfiguration, - string? DocumentABTestConfiguration) : ICmsDocument, ISourceModel + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentInheritsStylesheet") + ); +}; +public partial record CmsDocumentK12(int DocumentID, string DocumentName, string? DocumentNamePath, DateTime? DocumentModifiedWhen, int? DocumentModifiedByUserID, int? DocumentForeignKeyValue, int? DocumentCreatedByUserID, DateTime? DocumentCreatedWhen, int? DocumentCheckedOutByUserID, DateTime? DocumentCheckedOutWhen, int? DocumentCheckedOutVersionHistoryID, int? DocumentPublishedVersionHistoryID, int? DocumentWorkflowStepID, DateTime? DocumentPublishFrom, DateTime? DocumentPublishTo, string? DocumentUrlPath, string DocumentCulture, int DocumentNodeID, string? DocumentPageTitle, string? DocumentPageKeyWords, string? DocumentPageDescription, bool DocumentShowInSiteMap, bool DocumentMenuItemHideInNavigation, string? DocumentMenuCaption, string? DocumentMenuStyle, string? DocumentMenuItemImage, string? DocumentMenuItemLeftImage, string? DocumentMenuItemRightImage, int? DocumentPageTemplateID, string? DocumentMenuJavascript, string? DocumentMenuRedirectUrl, bool? DocumentUseNamePathForUrlPath, int? DocumentStylesheetID, string? DocumentContent, string? DocumentMenuClass, string? DocumentMenuStyleHighlighted, string? DocumentMenuClassHighlighted, string? DocumentMenuItemImageHighlighted, string? DocumentMenuItemLeftImageHighlighted, string? DocumentMenuItemRightImageHighlighted, bool? DocumentMenuItemInactive, string? DocumentCustomData, string? DocumentExtensions, string? DocumentTags, int? DocumentTagGroupID, string? DocumentWildcardRule, string? DocumentWebParts, double? DocumentRatingValue, int? DocumentRatings, int? DocumentPriority, string? DocumentType, DateTime? DocumentLastPublished, bool? DocumentUseCustomExtensions, string? DocumentGroupWebParts, bool? DocumentCheckedOutAutomatically, string? DocumentTrackConversionName, string? DocumentConversionValue, bool? DocumentSearchExcluded, string? DocumentLastVersionNumber, bool? DocumentIsArchived, string? DocumentHash, bool? DocumentLogVisitActivity, Guid? DocumentGUID, Guid? DocumentWorkflowCycleGUID, string? DocumentSitemapSettings, bool? DocumentIsWaitingForTranslation, string? DocumentSKUName, string? DocumentSKUDescription, string? DocumentSKUShortDescription, string? DocumentWorkflowActionStatus, bool? DocumentMenuRedirectToFirstChild, bool DocumentCanBePublished, bool DocumentInheritsStylesheet, string? DocumentPageBuilderWidgets, string? DocumentPageTemplateConfiguration, string? DocumentABTestConfiguration) : ICmsDocument, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "DocumentID"; public static string TableName => "CMS_Document"; public static string GuidColumnName => "DocumentGUID"; - static CmsDocumentK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), - reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), - reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), - reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), - reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), - reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), - reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), - reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), - reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), - reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), - reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), - reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), - reader.Unbox("DocumentInheritsStylesheet"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration") - ); - + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentInheritsStylesheet"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration") + ); public static CmsDocumentK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), - reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), - reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), - reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), - reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), - reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), - reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), - reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), - reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), - reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), - reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), - reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), - reader.Unbox("DocumentInheritsStylesheet"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration") - ); -} - -public record CmsDocumentK13( - int DocumentID, - string DocumentName, - DateTime? DocumentModifiedWhen, - int? DocumentModifiedByUserID, - int? DocumentForeignKeyValue, - int? DocumentCreatedByUserID, - DateTime? DocumentCreatedWhen, - int? DocumentCheckedOutByUserID, - DateTime? DocumentCheckedOutWhen, - int? DocumentCheckedOutVersionHistoryID, - int? DocumentPublishedVersionHistoryID, - int? DocumentWorkflowStepID, - DateTime? DocumentPublishFrom, - DateTime? DocumentPublishTo, - string DocumentCulture, - int DocumentNodeID, - string? DocumentPageTitle, - string? DocumentPageKeyWords, - string? DocumentPageDescription, - string? DocumentContent, - string? DocumentCustomData, - string? DocumentTags, - int? DocumentTagGroupID, - DateTime? DocumentLastPublished, - bool? DocumentSearchExcluded, - string? DocumentLastVersionNumber, - bool? DocumentIsArchived, - Guid? DocumentGUID, - Guid? DocumentWorkflowCycleGUID, - bool? DocumentIsWaitingForTranslation, - string? DocumentSKUName, - string? DocumentSKUDescription, - string? DocumentSKUShortDescription, - string? DocumentWorkflowActionStatus, - bool DocumentCanBePublished, - string? DocumentPageBuilderWidgets, - string? DocumentPageTemplateConfiguration, - string? DocumentABTestConfiguration, - bool DocumentShowInMenu) : ICmsDocument, ISourceModel + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentNamePath"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentUrlPath"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentShowInSiteMap"), reader.Unbox("DocumentMenuItemHideInNavigation"), reader.Unbox("DocumentMenuCaption"), reader.Unbox("DocumentMenuStyle"), reader.Unbox("DocumentMenuItemImage"), reader.Unbox("DocumentMenuItemLeftImage"), reader.Unbox("DocumentMenuItemRightImage"), reader.Unbox("DocumentPageTemplateID"), reader.Unbox("DocumentMenuJavascript"), reader.Unbox("DocumentMenuRedirectUrl"), reader.Unbox("DocumentUseNamePathForUrlPath"), reader.Unbox("DocumentStylesheetID"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentMenuClass"), reader.Unbox("DocumentMenuStyleHighlighted"), reader.Unbox("DocumentMenuClassHighlighted"), reader.Unbox("DocumentMenuItemImageHighlighted"), reader.Unbox("DocumentMenuItemLeftImageHighlighted"), reader.Unbox("DocumentMenuItemRightImageHighlighted"), reader.Unbox("DocumentMenuItemInactive"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentExtensions"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentWildcardRule"), reader.Unbox("DocumentWebParts"), reader.Unbox("DocumentRatingValue"), reader.Unbox("DocumentRatings"), reader.Unbox("DocumentPriority"), reader.Unbox("DocumentType"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentUseCustomExtensions"), reader.Unbox("DocumentGroupWebParts"), reader.Unbox("DocumentCheckedOutAutomatically"), reader.Unbox("DocumentTrackConversionName"), reader.Unbox("DocumentConversionValue"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentHash"), reader.Unbox("DocumentLogVisitActivity"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentSitemapSettings"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentMenuRedirectToFirstChild"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentInheritsStylesheet"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration") + ); +}; +public partial record CmsDocumentK13(int DocumentID, string DocumentName, DateTime? DocumentModifiedWhen, int? DocumentModifiedByUserID, int? DocumentForeignKeyValue, int? DocumentCreatedByUserID, DateTime? DocumentCreatedWhen, int? DocumentCheckedOutByUserID, DateTime? DocumentCheckedOutWhen, int? DocumentCheckedOutVersionHistoryID, int? DocumentPublishedVersionHistoryID, int? DocumentWorkflowStepID, DateTime? DocumentPublishFrom, DateTime? DocumentPublishTo, string DocumentCulture, int DocumentNodeID, string? DocumentPageTitle, string? DocumentPageKeyWords, string? DocumentPageDescription, string? DocumentContent, string? DocumentCustomData, string? DocumentTags, int? DocumentTagGroupID, DateTime? DocumentLastPublished, bool? DocumentSearchExcluded, string? DocumentLastVersionNumber, bool? DocumentIsArchived, Guid? DocumentGUID, Guid? DocumentWorkflowCycleGUID, bool? DocumentIsWaitingForTranslation, string? DocumentSKUName, string? DocumentSKUDescription, string? DocumentSKUShortDescription, string? DocumentWorkflowActionStatus, bool DocumentCanBePublished, string? DocumentPageBuilderWidgets, string? DocumentPageTemplateConfiguration, string? DocumentABTestConfiguration, bool DocumentShowInMenu) : ICmsDocument, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "DocumentID"; public static string TableName => "CMS_Document"; public static string GuidColumnName => "DocumentGUID"; - static CmsDocumentK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), - reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), - reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentGUID"), - reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentPageBuilderWidgets"), - reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration"), reader.Unbox("DocumentShowInMenu") - ); - + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration"), reader.Unbox("DocumentShowInMenu") + ); public static CmsDocumentK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), - reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), - reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), - reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), - reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), - reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentGUID"), - reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), - reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentPageBuilderWidgets"), - reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration"), reader.Unbox("DocumentShowInMenu") - ); -} + reader.Unbox("DocumentID"), reader.Unbox("DocumentName"), reader.Unbox("DocumentModifiedWhen"), reader.Unbox("DocumentModifiedByUserID"), reader.Unbox("DocumentForeignKeyValue"), reader.Unbox("DocumentCreatedByUserID"), reader.Unbox("DocumentCreatedWhen"), reader.Unbox("DocumentCheckedOutByUserID"), reader.Unbox("DocumentCheckedOutWhen"), reader.Unbox("DocumentCheckedOutVersionHistoryID"), reader.Unbox("DocumentPublishedVersionHistoryID"), reader.Unbox("DocumentWorkflowStepID"), reader.Unbox("DocumentPublishFrom"), reader.Unbox("DocumentPublishTo"), reader.Unbox("DocumentCulture"), reader.Unbox("DocumentNodeID"), reader.Unbox("DocumentPageTitle"), reader.Unbox("DocumentPageKeyWords"), reader.Unbox("DocumentPageDescription"), reader.Unbox("DocumentContent"), reader.Unbox("DocumentCustomData"), reader.Unbox("DocumentTags"), reader.Unbox("DocumentTagGroupID"), reader.Unbox("DocumentLastPublished"), reader.Unbox("DocumentSearchExcluded"), reader.Unbox("DocumentLastVersionNumber"), reader.Unbox("DocumentIsArchived"), reader.Unbox("DocumentGUID"), reader.Unbox("DocumentWorkflowCycleGUID"), reader.Unbox("DocumentIsWaitingForTranslation"), reader.Unbox("DocumentSKUName"), reader.Unbox("DocumentSKUDescription"), reader.Unbox("DocumentSKUShortDescription"), reader.Unbox("DocumentWorkflowActionStatus"), reader.Unbox("DocumentCanBePublished"), reader.Unbox("DocumentPageBuilderWidgets"), reader.Unbox("DocumentPageTemplateConfiguration"), reader.Unbox("DocumentABTestConfiguration"), reader.Unbox("DocumentShowInMenu") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsDocumentCategory.cs b/KVA/Migration.Toolkit.Source/Model/CmsDocumentCategory.cs index 9ca50cb1..874637e7 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsDocumentCategory.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsDocumentCategory.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsDocumentCategory : ISourceModel +public partial interface ICmsDocumentCategory : ISourceModel { int DocumentID { get; } int CategoryID { get; } @@ -18,7 +16,6 @@ public interface ICmsDocumentCategory : ISourceModel { Major: 13 } => CmsDocumentCategoryK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsDocumentCategoryK11.IsAvailable(version), @@ -26,10 +23,8 @@ public interface ICmsDocumentCategory : ISourceModel { Major: 13 } => CmsDocumentCategoryK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_DocumentCategory"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsDocumentCategory ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsDocumentCategoryK11.FromReader(reader, version), @@ -38,51 +33,43 @@ public interface ICmsDocumentCategory : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsDocumentCategoryK11(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel +public partial record CmsDocumentCategoryK11(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_DocumentCategory"; public static string GuidColumnName => ""; - static CmsDocumentCategoryK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); - + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); public static CmsDocumentCategoryK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); -} - -public record CmsDocumentCategoryK12(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); +}; +public partial record CmsDocumentCategoryK12(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_DocumentCategory"; public static string GuidColumnName => ""; - static CmsDocumentCategoryK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); - + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); public static CmsDocumentCategoryK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); -} - -public record CmsDocumentCategoryK13(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); +}; +public partial record CmsDocumentCategoryK13(int DocumentID, int CategoryID) : ICmsDocumentCategory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CategoryID"; public static string TableName => "CMS_DocumentCategory"; public static string GuidColumnName => ""; - static CmsDocumentCategoryK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); - + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); public static CmsDocumentCategoryK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("DocumentID"), reader.Unbox("CategoryID") - ); -} + reader.Unbox("DocumentID"), reader.Unbox("CategoryID") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsForm.cs b/KVA/Migration.Toolkit.Source/Model/CmsForm.cs index 2f26c6cc..23ef0e6c 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsForm.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsForm.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsForm : ISourceModel +public partial interface ICmsForm : ISourceModel { int FormID { get; } string FormDisplayName { get; } @@ -40,7 +38,6 @@ public interface ICmsForm : ISourceModel { Major: 13 } => CmsFormK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsFormK11.IsAvailable(version), @@ -48,10 +45,8 @@ public interface ICmsForm : ISourceModel { Major: 13 } => CmsFormK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Form"; static string ISourceModel.GuidColumnName => "FormGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsForm ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsFormK11.FromReader(reader, version), @@ -60,155 +55,43 @@ public interface ICmsForm : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsFormK11( - int FormID, - string FormDisplayName, - string FormName, - string? FormSendToEmail, - string? FormSendFromEmail, - string? FormEmailSubject, - string? FormEmailTemplate, - bool? FormEmailAttachUploadedDocs, - int FormClassID, - int FormItems, - string? FormReportFields, - string? FormRedirectToUrl, - string? FormDisplayText, - bool FormClearAfterSave, - string? FormSubmitButtonText, - int FormSiteID, - string? FormConfirmationEmailField, - string? FormConfirmationTemplate, - string? FormConfirmationSendFromEmail, - string? FormConfirmationEmailSubject, - int? FormAccess, - string? FormSubmitButtonImage, - Guid FormGUID, - DateTime FormLastModified, - bool? FormLogActivity) : ICmsForm, ISourceModel +public partial record CmsFormK11(int FormID, string FormDisplayName, string FormName, string? FormSendToEmail, string? FormSendFromEmail, string? FormEmailSubject, string? FormEmailTemplate, bool? FormEmailAttachUploadedDocs, int FormClassID, int FormItems, string? FormReportFields, string? FormRedirectToUrl, string? FormDisplayText, bool FormClearAfterSave, string? FormSubmitButtonText, int FormSiteID, string? FormConfirmationEmailField, string? FormConfirmationTemplate, string? FormConfirmationSendFromEmail, string? FormConfirmationEmailSubject, int? FormAccess, string? FormSubmitButtonImage, Guid FormGUID, DateTime FormLastModified, bool? FormLogActivity) : ICmsForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_Form"; public static string GuidColumnName => "FormGUID"; - static CmsFormK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity") + ); public static CmsFormK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity") - ); -} - -public record CmsFormK12( - int FormID, - string FormDisplayName, - string FormName, - string? FormSendToEmail, - string? FormSendFromEmail, - string? FormEmailSubject, - string? FormEmailTemplate, - bool? FormEmailAttachUploadedDocs, - int FormClassID, - int FormItems, - string? FormReportFields, - string? FormRedirectToUrl, - string? FormDisplayText, - bool FormClearAfterSave, - string? FormSubmitButtonText, - int FormSiteID, - string? FormConfirmationEmailField, - string? FormConfirmationTemplate, - string? FormConfirmationSendFromEmail, - string? FormConfirmationEmailSubject, - int? FormAccess, - string? FormSubmitButtonImage, - Guid FormGUID, - DateTime FormLastModified, - bool? FormLogActivity, - int FormDevelopmentModel, - string? FormBuilderLayout) : ICmsForm, ISourceModel + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity") + ); +}; +public partial record CmsFormK12(int FormID, string FormDisplayName, string FormName, string? FormSendToEmail, string? FormSendFromEmail, string? FormEmailSubject, string? FormEmailTemplate, bool? FormEmailAttachUploadedDocs, int FormClassID, int FormItems, string? FormReportFields, string? FormRedirectToUrl, string? FormDisplayText, bool FormClearAfterSave, string? FormSubmitButtonText, int FormSiteID, string? FormConfirmationEmailField, string? FormConfirmationTemplate, string? FormConfirmationSendFromEmail, string? FormConfirmationEmailSubject, int? FormAccess, string? FormSubmitButtonImage, Guid FormGUID, DateTime FormLastModified, bool? FormLogActivity, int FormDevelopmentModel, string? FormBuilderLayout) : ICmsForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_Form"; public static string GuidColumnName => "FormGUID"; - static CmsFormK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormDevelopmentModel"), - reader.Unbox("FormBuilderLayout") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormDevelopmentModel"), reader.Unbox("FormBuilderLayout") + ); public static CmsFormK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormDevelopmentModel"), - reader.Unbox("FormBuilderLayout") - ); -} - -public record CmsFormK13( - int FormID, - string FormDisplayName, - string FormName, - string? FormSendToEmail, - string? FormSendFromEmail, - string? FormEmailSubject, - string? FormEmailTemplate, - bool? FormEmailAttachUploadedDocs, - int FormClassID, - int FormItems, - string? FormReportFields, - string? FormRedirectToUrl, - string? FormDisplayText, - bool FormClearAfterSave, - string? FormSubmitButtonText, - int FormSiteID, - string? FormConfirmationEmailField, - string? FormConfirmationTemplate, - string? FormConfirmationSendFromEmail, - string? FormConfirmationEmailSubject, - int? FormAccess, - string? FormSubmitButtonImage, - Guid FormGUID, - DateTime FormLastModified, - bool FormLogActivity, - string? FormBuilderLayout) : ICmsForm, ISourceModel + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormDevelopmentModel"), reader.Unbox("FormBuilderLayout") + ); +}; +public partial record CmsFormK13(int FormID, string FormDisplayName, string FormName, string? FormSendToEmail, string? FormSendFromEmail, string? FormEmailSubject, string? FormEmailTemplate, bool? FormEmailAttachUploadedDocs, int FormClassID, int FormItems, string? FormReportFields, string? FormRedirectToUrl, string? FormDisplayText, bool FormClearAfterSave, string? FormSubmitButtonText, int FormSiteID, string? FormConfirmationEmailField, string? FormConfirmationTemplate, string? FormConfirmationSendFromEmail, string? FormConfirmationEmailSubject, int? FormAccess, string? FormSubmitButtonImage, Guid FormGUID, DateTime FormLastModified, bool FormLogActivity, string? FormBuilderLayout) : ICmsForm, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FormID"; public static string TableName => "CMS_Form"; public static string GuidColumnName => "FormGUID"; - static CmsFormK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormBuilderLayout") - ); - + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormBuilderLayout") + ); public static CmsFormK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), - reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), - reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), - reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), - reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormBuilderLayout") - ); -} + reader.Unbox("FormID"), reader.Unbox("FormDisplayName"), reader.Unbox("FormName"), reader.Unbox("FormSendToEmail"), reader.Unbox("FormSendFromEmail"), reader.Unbox("FormEmailSubject"), reader.Unbox("FormEmailTemplate"), reader.Unbox("FormEmailAttachUploadedDocs"), reader.Unbox("FormClassID"), reader.Unbox("FormItems"), reader.Unbox("FormReportFields"), reader.Unbox("FormRedirectToUrl"), reader.Unbox("FormDisplayText"), reader.Unbox("FormClearAfterSave"), reader.Unbox("FormSubmitButtonText"), reader.Unbox("FormSiteID"), reader.Unbox("FormConfirmationEmailField"), reader.Unbox("FormConfirmationTemplate"), reader.Unbox("FormConfirmationSendFromEmail"), reader.Unbox("FormConfirmationEmailSubject"), reader.Unbox("FormAccess"), reader.Unbox("FormSubmitButtonImage"), reader.Unbox("FormGUID"), reader.Unbox("FormLastModified"), reader.Unbox("FormLogActivity"), reader.Unbox("FormBuilderLayout") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsFormUserControl.cs b/KVA/Migration.Toolkit.Source/Model/CmsFormUserControl.cs index 0a397719..53906ec0 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsFormUserControl.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsFormUserControl.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsFormUserControl : ISourceModel +public partial interface ICmsFormUserControl : ISourceModel { int UserControlID { get; } string UserControlDisplayName { get; } @@ -46,7 +44,6 @@ public interface ICmsFormUserControl : ISourceModel { Major: 13 } => CmsFormUserControlK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsFormUserControlK11.IsAvailable(version), @@ -54,10 +51,8 @@ public interface ICmsFormUserControl : ISourceModel { Major: 13 } => CmsFormUserControlK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_FormUserControl"; static string ISourceModel.GuidColumnName => "UserControlGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsFormUserControl ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsFormUserControlK11.FromReader(reader, version), @@ -66,193 +61,43 @@ public interface ICmsFormUserControl : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsFormUserControlK11( - int UserControlID, - string UserControlDisplayName, - string UserControlCodeName, - string UserControlFileName, - bool UserControlForText, - bool UserControlForLongText, - bool UserControlForInteger, - bool UserControlForDecimal, - bool UserControlForDateTime, - bool UserControlForBoolean, - bool UserControlForFile, - bool UserControlShowInBizForms, - string UserControlDefaultDataType, - int? UserControlDefaultDataTypeSize, - bool? UserControlShowInDocumentTypes, - bool? UserControlShowInSystemTables, - bool? UserControlShowInWebParts, - bool? UserControlShowInReports, - Guid UserControlGUID, - DateTime UserControlLastModified, - bool UserControlForGuid, - bool? UserControlShowInCustomTables, - bool UserControlForVisibility, - string? UserControlParameters, - bool UserControlForDocAttachments, - int? UserControlResourceID, - int? UserControlType, - int? UserControlParentID, - string? UserControlDescription, - Guid? UserControlThumbnailGUID, - int? UserControlPriority, - bool? UserControlIsSystem, - bool UserControlForBinary, - bool UserControlForDocRelationships, - string? UserControlAssemblyName, - string? UserControlClassName) : ICmsFormUserControl, ISourceModel +public partial record CmsFormUserControlK11(int UserControlID, string UserControlDisplayName, string UserControlCodeName, string UserControlFileName, bool UserControlForText, bool UserControlForLongText, bool UserControlForInteger, bool UserControlForDecimal, bool UserControlForDateTime, bool UserControlForBoolean, bool UserControlForFile, bool UserControlShowInBizForms, string UserControlDefaultDataType, int? UserControlDefaultDataTypeSize, bool? UserControlShowInDocumentTypes, bool? UserControlShowInSystemTables, bool? UserControlShowInWebParts, bool? UserControlShowInReports, Guid UserControlGUID, DateTime UserControlLastModified, bool UserControlForGuid, bool? UserControlShowInCustomTables, bool UserControlForVisibility, string? UserControlParameters, bool UserControlForDocAttachments, int? UserControlResourceID, int? UserControlType, int? UserControlParentID, string? UserControlDescription, Guid? UserControlThumbnailGUID, int? UserControlPriority, bool? UserControlIsSystem, bool UserControlForBinary, bool UserControlForDocRelationships, string? UserControlAssemblyName, string? UserControlClassName) : ICmsFormUserControl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserControlID"; public static string TableName => "CMS_FormUserControl"; public static string GuidColumnName => "UserControlGUID"; - static CmsFormUserControlK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), - reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), - reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), - reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), - reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") - ); - + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); public static CmsFormUserControlK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), - reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), - reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), - reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), - reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") - ); -} - -public record CmsFormUserControlK12( - int UserControlID, - string UserControlDisplayName, - string UserControlCodeName, - string UserControlFileName, - bool UserControlForText, - bool UserControlForLongText, - bool UserControlForInteger, - bool UserControlForDecimal, - bool UserControlForDateTime, - bool UserControlForBoolean, - bool UserControlForFile, - bool UserControlShowInBizForms, - string UserControlDefaultDataType, - int? UserControlDefaultDataTypeSize, - bool? UserControlShowInDocumentTypes, - bool? UserControlShowInSystemTables, - bool? UserControlShowInWebParts, - bool? UserControlShowInReports, - Guid UserControlGUID, - DateTime UserControlLastModified, - bool UserControlForGuid, - bool? UserControlShowInCustomTables, - bool UserControlForVisibility, - string? UserControlParameters, - bool UserControlForDocAttachments, - int? UserControlResourceID, - int? UserControlType, - int? UserControlParentID, - string? UserControlDescription, - Guid? UserControlThumbnailGUID, - int? UserControlPriority, - bool? UserControlIsSystem, - bool UserControlForBinary, - bool UserControlForDocRelationships, - string? UserControlAssemblyName, - string? UserControlClassName) : ICmsFormUserControl, ISourceModel + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); +}; +public partial record CmsFormUserControlK12(int UserControlID, string UserControlDisplayName, string UserControlCodeName, string UserControlFileName, bool UserControlForText, bool UserControlForLongText, bool UserControlForInteger, bool UserControlForDecimal, bool UserControlForDateTime, bool UserControlForBoolean, bool UserControlForFile, bool UserControlShowInBizForms, string UserControlDefaultDataType, int? UserControlDefaultDataTypeSize, bool? UserControlShowInDocumentTypes, bool? UserControlShowInSystemTables, bool? UserControlShowInWebParts, bool? UserControlShowInReports, Guid UserControlGUID, DateTime UserControlLastModified, bool UserControlForGuid, bool? UserControlShowInCustomTables, bool UserControlForVisibility, string? UserControlParameters, bool UserControlForDocAttachments, int? UserControlResourceID, int? UserControlType, int? UserControlParentID, string? UserControlDescription, Guid? UserControlThumbnailGUID, int? UserControlPriority, bool? UserControlIsSystem, bool UserControlForBinary, bool UserControlForDocRelationships, string? UserControlAssemblyName, string? UserControlClassName) : ICmsFormUserControl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserControlID"; public static string TableName => "CMS_FormUserControl"; public static string GuidColumnName => "UserControlGUID"; - static CmsFormUserControlK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), - reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), - reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), - reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), - reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") - ); - + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); public static CmsFormUserControlK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), - reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), - reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), - reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), - reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") - ); -} - -public record CmsFormUserControlK13( - int UserControlID, - string UserControlDisplayName, - string UserControlCodeName, - string UserControlFileName, - bool UserControlForText, - bool UserControlForLongText, - bool UserControlForInteger, - bool UserControlForDecimal, - bool UserControlForDateTime, - bool UserControlForBoolean, - bool UserControlForFile, - bool? UserControlShowInDocumentTypes, - bool? UserControlShowInSystemTables, - bool? UserControlShowInWebParts, - bool? UserControlShowInReports, - Guid UserControlGUID, - DateTime UserControlLastModified, - bool UserControlForGuid, - bool? UserControlShowInCustomTables, - string? UserControlParameters, - bool UserControlForDocAttachments, - int? UserControlResourceID, - int? UserControlParentID, - string? UserControlDescription, - int? UserControlPriority, - bool? UserControlIsSystem, - bool UserControlForBinary, - bool UserControlForDocRelationships, - string? UserControlAssemblyName, - string? UserControlClassName) : ICmsFormUserControl, ISourceModel + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInBizForms"), reader.Unbox("UserControlDefaultDataType"), reader.Unbox("UserControlDefaultDataTypeSize"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlForVisibility"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlType"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlThumbnailGUID"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); +}; +public partial record CmsFormUserControlK13(int UserControlID, string UserControlDisplayName, string UserControlCodeName, string UserControlFileName, bool UserControlForText, bool UserControlForLongText, bool UserControlForInteger, bool UserControlForDecimal, bool UserControlForDateTime, bool UserControlForBoolean, bool UserControlForFile, bool? UserControlShowInDocumentTypes, bool? UserControlShowInSystemTables, bool? UserControlShowInWebParts, bool? UserControlShowInReports, Guid UserControlGUID, DateTime UserControlLastModified, bool UserControlForGuid, bool? UserControlShowInCustomTables, string? UserControlParameters, bool UserControlForDocAttachments, int? UserControlResourceID, int? UserControlParentID, string? UserControlDescription, int? UserControlPriority, bool? UserControlIsSystem, bool UserControlForBinary, bool UserControlForDocRelationships, string? UserControlAssemblyName, string? UserControlClassName) : ICmsFormUserControl, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserControlID"; public static string TableName => "CMS_FormUserControl"; public static string GuidColumnName => "UserControlGUID"; - static CmsFormUserControlK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), - reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), - reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), - reader.Unbox("UserControlClassName") - ); - + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); public static CmsFormUserControlK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), - reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), - reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), - reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), - reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), - reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), - reader.Unbox("UserControlClassName") - ); -} + reader.Unbox("UserControlID"), reader.Unbox("UserControlDisplayName"), reader.Unbox("UserControlCodeName"), reader.Unbox("UserControlFileName"), reader.Unbox("UserControlForText"), reader.Unbox("UserControlForLongText"), reader.Unbox("UserControlForInteger"), reader.Unbox("UserControlForDecimal"), reader.Unbox("UserControlForDateTime"), reader.Unbox("UserControlForBoolean"), reader.Unbox("UserControlForFile"), reader.Unbox("UserControlShowInDocumentTypes"), reader.Unbox("UserControlShowInSystemTables"), reader.Unbox("UserControlShowInWebParts"), reader.Unbox("UserControlShowInReports"), reader.Unbox("UserControlGUID"), reader.Unbox("UserControlLastModified"), reader.Unbox("UserControlForGuid"), reader.Unbox("UserControlShowInCustomTables"), reader.Unbox("UserControlParameters"), reader.Unbox("UserControlForDocAttachments"), reader.Unbox("UserControlResourceID"), reader.Unbox("UserControlParentID"), reader.Unbox("UserControlDescription"), reader.Unbox("UserControlPriority"), reader.Unbox("UserControlIsSystem"), reader.Unbox("UserControlForBinary"), reader.Unbox("UserControlForDocRelationships"), reader.Unbox("UserControlAssemblyName"), reader.Unbox("UserControlClassName") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsPageFormerUrlPath.cs b/KVA/Migration.Toolkit.Source/Model/CmsPageFormerUrlPath.cs index a14d5561..5a110e73 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsPageFormerUrlPath.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsPageFormerUrlPath.cs @@ -1,13 +1,13 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsPageFormerUrlPath : ISourceModel +public partial interface ICmsPageFormerUrlPath : ISourceModel { + + static string ISourceModel.GetPrimaryKeyName(SemanticVersion version) => version switch { { Major: 11 } => CmsPageFormerUrlPathK11.GetPrimaryKeyName(version), @@ -15,7 +15,6 @@ public interface ICmsPageFormerUrlPath : ISourceModel { Major: 13 } => CmsPageFormerUrlPathK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsPageFormerUrlPathK11.IsAvailable(version), @@ -23,10 +22,8 @@ public interface ICmsPageFormerUrlPath : ISourceModel { Major: 13 } => CmsPageFormerUrlPathK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_PageFormerUrlPath"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsPageFormerUrlPath ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsPageFormerUrlPathK11.FromReader(reader, version), @@ -35,56 +32,43 @@ public interface ICmsPageFormerUrlPath : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsPageFormerUrlPathK11 : ICmsPageFormerUrlPath, ISourceModel +public partial record CmsPageFormerUrlPathK11() : ICmsPageFormerUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_PageFormerUrlPath"; public static string GuidColumnName => ""; - static CmsPageFormerUrlPathK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsPageFormerUrlPathK11 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public record CmsPageFormerUrlPathK12 : ICmsPageFormerUrlPath, ISourceModel + ); +}; +public partial record CmsPageFormerUrlPathK12() : ICmsPageFormerUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_PageFormerUrlPath"; public static string GuidColumnName => ""; - static CmsPageFormerUrlPathK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsPageFormerUrlPathK12 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public record CmsPageFormerUrlPathK13( - int PageFormerUrlPathID, - string PageFormerUrlPathUrlPath, - string PageFormerUrlPathUrlPathHash, - string PageFormerUrlPathCulture, - int PageFormerUrlPathNodeID, - int PageFormerUrlPathSiteID, - DateTime PageFormerUrlPathLastModified) : ICmsPageFormerUrlPath, ISourceModel + ); +}; +public partial record CmsPageFormerUrlPathK13(int PageFormerUrlPathID, string PageFormerUrlPathUrlPath, string PageFormerUrlPathUrlPathHash, string PageFormerUrlPathCulture, int PageFormerUrlPathNodeID, int PageFormerUrlPathSiteID, DateTime PageFormerUrlPathLastModified) : ICmsPageFormerUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "PageFormerUrlPathID"; public static string TableName => "CMS_PageFormerUrlPath"; public static string GuidColumnName => ""; - static CmsPageFormerUrlPathK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageFormerUrlPathID"), reader.Unbox("PageFormerUrlPathUrlPath"), reader.Unbox("PageFormerUrlPathUrlPathHash"), reader.Unbox("PageFormerUrlPathCulture"), reader.Unbox("PageFormerUrlPathNodeID"), - reader.Unbox("PageFormerUrlPathSiteID"), reader.Unbox("PageFormerUrlPathLastModified") - ); - + reader.Unbox("PageFormerUrlPathID"), reader.Unbox("PageFormerUrlPathUrlPath"), reader.Unbox("PageFormerUrlPathUrlPathHash"), reader.Unbox("PageFormerUrlPathCulture"), reader.Unbox("PageFormerUrlPathNodeID"), reader.Unbox("PageFormerUrlPathSiteID"), reader.Unbox("PageFormerUrlPathLastModified") + ); public static CmsPageFormerUrlPathK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageFormerUrlPathID"), reader.Unbox("PageFormerUrlPathUrlPath"), reader.Unbox("PageFormerUrlPathUrlPathHash"), reader.Unbox("PageFormerUrlPathCulture"), reader.Unbox("PageFormerUrlPathNodeID"), - reader.Unbox("PageFormerUrlPathSiteID"), reader.Unbox("PageFormerUrlPathLastModified") - ); -} + reader.Unbox("PageFormerUrlPathID"), reader.Unbox("PageFormerUrlPathUrlPath"), reader.Unbox("PageFormerUrlPathUrlPathHash"), reader.Unbox("PageFormerUrlPathCulture"), reader.Unbox("PageFormerUrlPathNodeID"), reader.Unbox("PageFormerUrlPathSiteID"), reader.Unbox("PageFormerUrlPathLastModified") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsPageTemplateConfiguration.cs b/KVA/Migration.Toolkit.Source/Model/CmsPageTemplateConfiguration.cs index 3b7f8be4..857bf381 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsPageTemplateConfiguration.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsPageTemplateConfiguration.cs @@ -1,13 +1,13 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsPageTemplateConfiguration : ISourceModel +public partial interface ICmsPageTemplateConfiguration : ISourceModel { + + static string ISourceModel.GetPrimaryKeyName(SemanticVersion version) => version switch { { Major: 11 } => CmsPageTemplateConfigurationK11.GetPrimaryKeyName(version), @@ -15,7 +15,6 @@ public interface ICmsPageTemplateConfiguration : ISourceModel CmsPageTemplateConfigurationK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsPageTemplateConfigurationK11.IsAvailable(version), @@ -23,10 +22,8 @@ public interface ICmsPageTemplateConfiguration : ISourceModel CmsPageTemplateConfigurationK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_PageTemplateConfiguration"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsPageTemplateConfiguration ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsPageTemplateConfigurationK11.FromReader(reader, version), @@ -35,75 +32,43 @@ public interface ICmsPageTemplateConfiguration : ISourceModel throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsPageTemplateConfigurationK11 : ICmsPageTemplateConfiguration, ISourceModel +public partial record CmsPageTemplateConfigurationK11() : ICmsPageTemplateConfiguration, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_PageTemplateConfiguration"; public static string GuidColumnName => ""; - static CmsPageTemplateConfigurationK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsPageTemplateConfigurationK11 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public partial record CmsPageTemplateConfigurationK12( - int PageTemplateConfigurationID, - Guid PageTemplateConfigurationGUID, - int PageTemplateConfigurationSiteID, - DateTime PageTemplateConfigurationLastModified, - string PageTemplateConfigurationName, - string? PageTemplateConfigurationDescription, - Guid? PageTemplateConfigurationThumbnailGUID, - string PageTemplateConfigurationTemplate, - string? PageTemplateConfigurationWidgets) : ICmsPageTemplateConfiguration, ISourceModel + ); +}; +public partial record CmsPageTemplateConfigurationK12(int PageTemplateConfigurationID, Guid PageTemplateConfigurationGUID, int PageTemplateConfigurationSiteID, DateTime PageTemplateConfigurationLastModified, string PageTemplateConfigurationName, string? PageTemplateConfigurationDescription, Guid? PageTemplateConfigurationThumbnailGUID, string PageTemplateConfigurationTemplate, string? PageTemplateConfigurationWidgets) : ICmsPageTemplateConfiguration, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "PageTemplateConfigurationID"; public static string TableName => "CMS_PageTemplateConfiguration"; public static string GuidColumnName => "PageTemplateConfigurationGUID"; - static CmsPageTemplateConfigurationK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), - reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), - reader.Unbox("PageTemplateConfigurationWidgets") - ); - + reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), reader.Unbox("PageTemplateConfigurationWidgets") + ); public static CmsPageTemplateConfigurationK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), - reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), - reader.Unbox("PageTemplateConfigurationWidgets") - ); -} - -public partial record CmsPageTemplateConfigurationK13( - int PageTemplateConfigurationID, - Guid PageTemplateConfigurationGUID, - int PageTemplateConfigurationSiteID, - DateTime PageTemplateConfigurationLastModified, - string PageTemplateConfigurationName, - string? PageTemplateConfigurationDescription, - Guid? PageTemplateConfigurationThumbnailGUID, - string PageTemplateConfigurationTemplate, - string? PageTemplateConfigurationWidgets) : ICmsPageTemplateConfiguration, ISourceModel + reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), reader.Unbox("PageTemplateConfigurationWidgets") + ); +}; +public partial record CmsPageTemplateConfigurationK13(int PageTemplateConfigurationID, Guid PageTemplateConfigurationGUID, int PageTemplateConfigurationSiteID, DateTime PageTemplateConfigurationLastModified, string PageTemplateConfigurationName, string? PageTemplateConfigurationDescription, Guid? PageTemplateConfigurationThumbnailGUID, string PageTemplateConfigurationTemplate, string? PageTemplateConfigurationWidgets) : ICmsPageTemplateConfiguration, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "PageTemplateConfigurationID"; public static string TableName => "CMS_PageTemplateConfiguration"; public static string GuidColumnName => "PageTemplateConfigurationGUID"; - static CmsPageTemplateConfigurationK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), - reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), - reader.Unbox("PageTemplateConfigurationWidgets") - ); - + reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), reader.Unbox("PageTemplateConfigurationWidgets") + ); public static CmsPageTemplateConfigurationK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), - reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), - reader.Unbox("PageTemplateConfigurationWidgets") - ); -} + reader.Unbox("PageTemplateConfigurationID"), reader.Unbox("PageTemplateConfigurationGUID"), reader.Unbox("PageTemplateConfigurationSiteID"), reader.Unbox("PageTemplateConfigurationLastModified"), reader.Unbox("PageTemplateConfigurationName"), reader.Unbox("PageTemplateConfigurationDescription"), reader.Unbox("PageTemplateConfigurationThumbnailGUID"), reader.Unbox("PageTemplateConfigurationTemplate"), reader.Unbox("PageTemplateConfigurationWidgets") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsPageUrlPath.cs b/KVA/Migration.Toolkit.Source/Model/CmsPageUrlPath.cs index d3d6b0d9..4f155075 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsPageUrlPath.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsPageUrlPath.cs @@ -1,13 +1,13 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsPageUrlPath : ISourceModel +public partial interface ICmsPageUrlPath : ISourceModel { + + static string ISourceModel.GetPrimaryKeyName(SemanticVersion version) => version switch { { Major: 11 } => CmsPageUrlPathK11.GetPrimaryKeyName(version), @@ -15,7 +15,6 @@ public interface ICmsPageUrlPath : ISourceModel { Major: 13 } => CmsPageUrlPathK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsPageUrlPathK11.IsAvailable(version), @@ -23,10 +22,8 @@ public interface ICmsPageUrlPath : ISourceModel { Major: 13 } => CmsPageUrlPathK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_PageUrlPath"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsPageUrlPath ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsPageUrlPathK11.FromReader(reader, version), @@ -35,50 +32,43 @@ public interface ICmsPageUrlPath : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsPageUrlPathK11 : ICmsPageUrlPath, ISourceModel +public partial record CmsPageUrlPathK11() : ICmsPageUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_PageUrlPath"; public static string GuidColumnName => ""; - static CmsPageUrlPathK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsPageUrlPathK11 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public record CmsPageUrlPathK12 : ICmsPageUrlPath, ISourceModel + ); +}; +public partial record CmsPageUrlPathK12() : ICmsPageUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => false; public static string GetPrimaryKeyName(SemanticVersion version) => ""; public static string TableName => "CMS_PageUrlPath"; public static string GuidColumnName => ""; - static CmsPageUrlPathK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - ); + ); public static CmsPageUrlPathK12 FromReader(IDataReader reader, SemanticVersion version) => new( - ); -} -public record CmsPageUrlPathK13(int PageUrlPathID, Guid PageUrlPathGUID, string PageUrlPathCulture, int PageUrlPathNodeID, string PageUrlPathUrlPath, string PageUrlPathUrlPathHash, int PageUrlPathSiteID, DateTime PageUrlPathLastModified) - : ICmsPageUrlPath, ISourceModel + ); +}; +public partial record CmsPageUrlPathK13(int PageUrlPathID, Guid PageUrlPathGUID, string PageUrlPathCulture, int PageUrlPathNodeID, string PageUrlPathUrlPath, string PageUrlPathUrlPathHash, int PageUrlPathSiteID, DateTime PageUrlPathLastModified) : ICmsPageUrlPath, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "PageUrlPathID"; public static string TableName => "CMS_PageUrlPath"; public static string GuidColumnName => "PageUrlPathGUID"; - static CmsPageUrlPathK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageUrlPathID"), reader.Unbox("PageUrlPathGUID"), reader.Unbox("PageUrlPathCulture"), reader.Unbox("PageUrlPathNodeID"), reader.Unbox("PageUrlPathUrlPath"), - reader.Unbox("PageUrlPathUrlPathHash"), reader.Unbox("PageUrlPathSiteID"), reader.Unbox("PageUrlPathLastModified") - ); - + reader.Unbox("PageUrlPathID"), reader.Unbox("PageUrlPathGUID"), reader.Unbox("PageUrlPathCulture"), reader.Unbox("PageUrlPathNodeID"), reader.Unbox("PageUrlPathUrlPath"), reader.Unbox("PageUrlPathUrlPathHash"), reader.Unbox("PageUrlPathSiteID"), reader.Unbox("PageUrlPathLastModified") + ); public static CmsPageUrlPathK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("PageUrlPathID"), reader.Unbox("PageUrlPathGUID"), reader.Unbox("PageUrlPathCulture"), reader.Unbox("PageUrlPathNodeID"), reader.Unbox("PageUrlPathUrlPath"), - reader.Unbox("PageUrlPathUrlPathHash"), reader.Unbox("PageUrlPathSiteID"), reader.Unbox("PageUrlPathLastModified") - ); -} + reader.Unbox("PageUrlPathID"), reader.Unbox("PageUrlPathGUID"), reader.Unbox("PageUrlPathCulture"), reader.Unbox("PageUrlPathNodeID"), reader.Unbox("PageUrlPathUrlPath"), reader.Unbox("PageUrlPathUrlPathHash"), reader.Unbox("PageUrlPathSiteID"), reader.Unbox("PageUrlPathLastModified") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsRelationship.cs b/KVA/Migration.Toolkit.Source/Model/CmsRelationship.cs index 0ac7b851..e19f6c91 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsRelationship.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsRelationship.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsRelationship : ISourceModel +public partial interface ICmsRelationship : ISourceModel { int RelationshipID { get; } int LeftNodeID { get; } @@ -23,7 +21,6 @@ public interface ICmsRelationship : ISourceModel { Major: 13 } => CmsRelationshipK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsRelationshipK11.IsAvailable(version), @@ -31,10 +28,8 @@ public interface ICmsRelationship : ISourceModel { Major: 13 } => CmsRelationshipK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Relationship"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsRelationship ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsRelationshipK11.FromReader(reader, version), @@ -43,57 +38,43 @@ public interface ICmsRelationship : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsRelationshipK11(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel +public partial record CmsRelationshipK11(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RelationshipID"; public static string TableName => "CMS_Relationship"; public static string GuidColumnName => ""; - static CmsRelationshipK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); - + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); public static CmsRelationshipK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); -} - -public record CmsRelationshipK12(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); +}; +public partial record CmsRelationshipK12(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RelationshipID"; public static string TableName => "CMS_Relationship"; public static string GuidColumnName => ""; - static CmsRelationshipK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); - + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); public static CmsRelationshipK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); -} - -public record CmsRelationshipK13(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); +}; +public partial record CmsRelationshipK13(int RelationshipID, int LeftNodeID, int RightNodeID, int RelationshipNameID, string? RelationshipCustomData, int? RelationshipOrder, bool? RelationshipIsAdHoc) : ICmsRelationship, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RelationshipID"; public static string TableName => "CMS_Relationship"; public static string GuidColumnName => ""; - static CmsRelationshipK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); - + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); public static CmsRelationshipK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), - reader.Unbox("RelationshipIsAdHoc") - ); -} + reader.Unbox("RelationshipID"), reader.Unbox("LeftNodeID"), reader.Unbox("RightNodeID"), reader.Unbox("RelationshipNameID"), reader.Unbox("RelationshipCustomData"), reader.Unbox("RelationshipOrder"), reader.Unbox("RelationshipIsAdHoc") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsResource.cs b/KVA/Migration.Toolkit.Source/Model/CmsResource.cs index baa2c3ad..497cd596 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsResource.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsResource.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsResource : ISourceModel +public partial interface ICmsResource : ISourceModel { int ResourceID { get; } string ResourceDisplayName { get; } @@ -30,7 +28,6 @@ public interface ICmsResource : ISourceModel { Major: 13 } => CmsResourceK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsResourceK11.IsAvailable(version), @@ -38,10 +35,8 @@ public interface ICmsResource : ISourceModel { Major: 13 } => CmsResourceK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Resource"; static string ISourceModel.GuidColumnName => "ResourceGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsResource ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsResourceK11.FromReader(reader, version), @@ -50,105 +45,43 @@ public interface ICmsResource : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsResourceK11( - int ResourceID, - string ResourceDisplayName, - string ResourceName, - string? ResourceDescription, - bool? ShowInDevelopment, - string? ResourceURL, - Guid ResourceGUID, - DateTime ResourceLastModified, - bool? ResourceIsInDevelopment, - bool? ResourceHasFiles, - string? ResourceVersion, - string? ResourceAuthor, - string? ResourceInstallationState, - string? ResourceInstalledVersion) : ICmsResource, ISourceModel +public partial record CmsResourceK11(int ResourceID, string ResourceDisplayName, string ResourceName, string? ResourceDescription, bool? ShowInDevelopment, string? ResourceURL, Guid ResourceGUID, DateTime ResourceLastModified, bool? ResourceIsInDevelopment, bool? ResourceHasFiles, string? ResourceVersion, string? ResourceAuthor, string? ResourceInstallationState, string? ResourceInstalledVersion) : ICmsResource, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ResourceID"; public static string TableName => "CMS_Resource"; public static string GuidColumnName => "ResourceGUID"; - static CmsResourceK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); - + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); public static CmsResourceK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); -} - -public record CmsResourceK12( - int ResourceID, - string ResourceDisplayName, - string ResourceName, - string? ResourceDescription, - bool? ShowInDevelopment, - string? ResourceURL, - Guid ResourceGUID, - DateTime ResourceLastModified, - bool? ResourceIsInDevelopment, - bool? ResourceHasFiles, - string? ResourceVersion, - string? ResourceAuthor, - string? ResourceInstallationState, - string? ResourceInstalledVersion) : ICmsResource, ISourceModel + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); +}; +public partial record CmsResourceK12(int ResourceID, string ResourceDisplayName, string ResourceName, string? ResourceDescription, bool? ShowInDevelopment, string? ResourceURL, Guid ResourceGUID, DateTime ResourceLastModified, bool? ResourceIsInDevelopment, bool? ResourceHasFiles, string? ResourceVersion, string? ResourceAuthor, string? ResourceInstallationState, string? ResourceInstalledVersion) : ICmsResource, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ResourceID"; public static string TableName => "CMS_Resource"; public static string GuidColumnName => "ResourceGUID"; - static CmsResourceK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); - + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); public static CmsResourceK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); -} - -public record CmsResourceK13( - int ResourceID, - string ResourceDisplayName, - string ResourceName, - string? ResourceDescription, - bool? ShowInDevelopment, - string? ResourceURL, - Guid ResourceGUID, - DateTime ResourceLastModified, - bool? ResourceIsInDevelopment, - bool? ResourceHasFiles, - string? ResourceVersion, - string? ResourceAuthor, - string? ResourceInstallationState, - string? ResourceInstalledVersion) : ICmsResource, ISourceModel + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); +}; +public partial record CmsResourceK13(int ResourceID, string ResourceDisplayName, string ResourceName, string? ResourceDescription, bool? ShowInDevelopment, string? ResourceURL, Guid ResourceGUID, DateTime ResourceLastModified, bool? ResourceIsInDevelopment, bool? ResourceHasFiles, string? ResourceVersion, string? ResourceAuthor, string? ResourceInstallationState, string? ResourceInstalledVersion) : ICmsResource, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ResourceID"; public static string TableName => "CMS_Resource"; public static string GuidColumnName => "ResourceGUID"; - static CmsResourceK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); - + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); public static CmsResourceK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), - reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), - reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") - ); -} + reader.Unbox("ResourceID"), reader.Unbox("ResourceDisplayName"), reader.Unbox("ResourceName"), reader.Unbox("ResourceDescription"), reader.Unbox("ShowInDevelopment"), reader.Unbox("ResourceURL"), reader.Unbox("ResourceGUID"), reader.Unbox("ResourceLastModified"), reader.Unbox("ResourceIsInDevelopment"), reader.Unbox("ResourceHasFiles"), reader.Unbox("ResourceVersion"), reader.Unbox("ResourceAuthor"), reader.Unbox("ResourceInstallationState"), reader.Unbox("ResourceInstalledVersion") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsRole.cs b/KVA/Migration.Toolkit.Source/Model/CmsRole.cs index c29ed36a..35a75ec7 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsRole.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsRole.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsRole : ISourceModel +public partial interface ICmsRole : ISourceModel { int RoleID { get; } string RoleDisplayName { get; } @@ -24,7 +22,6 @@ public interface ICmsRole : ISourceModel { Major: 13 } => CmsRoleK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsRoleK11.IsAvailable(version), @@ -32,10 +29,8 @@ public interface ICmsRole : ISourceModel { Major: 13 } => CmsRoleK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Role"; static string ISourceModel.GuidColumnName => "RoleGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsRole ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsRoleK11.FromReader(reader, version), @@ -44,59 +39,43 @@ public interface ICmsRole : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsRoleK11(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, int? RoleGroupID, bool? RoleIsGroupAdministrator, bool? RoleIsDomain) - : ICmsRole, ISourceModel +public partial record CmsRoleK11(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, int? RoleGroupID, bool? RoleIsGroupAdministrator, bool? RoleIsDomain) : ICmsRole, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RoleID"; public static string TableName => "CMS_Role"; public static string GuidColumnName => "RoleGUID"; - static CmsRoleK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") - ); - + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") + ); public static CmsRoleK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") - ); -} - -public record CmsRoleK12(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, int? RoleGroupID, bool? RoleIsGroupAdministrator, bool? RoleIsDomain) - : ICmsRole, ISourceModel + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") + ); +}; +public partial record CmsRoleK12(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, int? RoleGroupID, bool? RoleIsGroupAdministrator, bool? RoleIsDomain) : ICmsRole, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RoleID"; public static string TableName => "CMS_Role"; public static string GuidColumnName => "RoleGUID"; - static CmsRoleK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") - ); - + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") + ); public static CmsRoleK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") - ); -} - -public record CmsRoleK13(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, bool? RoleIsDomain) : ICmsRole, ISourceModel + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleGroupID"), reader.Unbox("RoleIsGroupAdministrator"), reader.Unbox("RoleIsDomain") + ); +}; +public partial record CmsRoleK13(int RoleID, string RoleDisplayName, string RoleName, string? RoleDescription, int? SiteID, Guid RoleGUID, DateTime RoleLastModified, bool? RoleIsDomain) : ICmsRole, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "RoleID"; public static string TableName => "CMS_Role"; public static string GuidColumnName => "RoleGUID"; - static CmsRoleK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleIsDomain") - ); - + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleIsDomain") + ); public static CmsRoleK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), - reader.Unbox("RoleLastModified"), reader.Unbox("RoleIsDomain") - ); -} + reader.Unbox("RoleID"), reader.Unbox("RoleDisplayName"), reader.Unbox("RoleName"), reader.Unbox("RoleDescription"), reader.Unbox("SiteID"), reader.Unbox("RoleGUID"), reader.Unbox("RoleLastModified"), reader.Unbox("RoleIsDomain") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsSettingsKey.cs b/KVA/Migration.Toolkit.Source/Model/CmsSettingsKey.cs index b4d6a3c0..6f43ac89 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsSettingsKey.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsSettingsKey.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsSettingsKey : ISourceModel +public partial interface ICmsSettingsKey : ISourceModel { int KeyID { get; } string KeyName { get; } @@ -35,7 +33,6 @@ public interface ICmsSettingsKey : ISourceModel { Major: 13 } => CmsSettingsKeyK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsSettingsKeyK11.IsAvailable(version), @@ -43,10 +40,8 @@ public interface ICmsSettingsKey : ISourceModel { Major: 13 } => CmsSettingsKeyK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_SettingsKey"; static string ISourceModel.GuidColumnName => "KeyGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsSettingsKey ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsSettingsKeyK11.FromReader(reader, version), @@ -55,126 +50,43 @@ public interface ICmsSettingsKey : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsSettingsKeyK11( - int KeyID, - string KeyName, - string KeyDisplayName, - string? KeyDescription, - string? KeyValue, - string KeyType, - int? KeyCategoryID, - int? SiteID, - Guid KeyGUID, - DateTime KeyLastModified, - int? KeyOrder, - string? KeyDefaultValue, - string? KeyValidation, - string? KeyEditingControlPath, - bool? KeyIsGlobal, - bool? KeyIsCustom, - bool? KeyIsHidden, - string? KeyFormControlSettings, - string? KeyExplanationText) : ICmsSettingsKey, ISourceModel +public partial record CmsSettingsKeyK11(int KeyID, string KeyName, string KeyDisplayName, string? KeyDescription, string? KeyValue, string KeyType, int? KeyCategoryID, int? SiteID, Guid KeyGUID, DateTime KeyLastModified, int? KeyOrder, string? KeyDefaultValue, string? KeyValidation, string? KeyEditingControlPath, bool? KeyIsGlobal, bool? KeyIsCustom, bool? KeyIsHidden, string? KeyFormControlSettings, string? KeyExplanationText) : ICmsSettingsKey, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "KeyID"; public static string TableName => "CMS_SettingsKey"; public static string GuidColumnName => "KeyGUID"; - static CmsSettingsKeyK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); - + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); public static CmsSettingsKeyK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); -} - -public record CmsSettingsKeyK12( - int KeyID, - string KeyName, - string KeyDisplayName, - string? KeyDescription, - string? KeyValue, - string KeyType, - int? KeyCategoryID, - int? SiteID, - Guid KeyGUID, - DateTime KeyLastModified, - int? KeyOrder, - string? KeyDefaultValue, - string? KeyValidation, - string? KeyEditingControlPath, - bool? KeyIsGlobal, - bool? KeyIsCustom, - bool? KeyIsHidden, - string? KeyFormControlSettings, - string? KeyExplanationText) : ICmsSettingsKey, ISourceModel + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); +}; +public partial record CmsSettingsKeyK12(int KeyID, string KeyName, string KeyDisplayName, string? KeyDescription, string? KeyValue, string KeyType, int? KeyCategoryID, int? SiteID, Guid KeyGUID, DateTime KeyLastModified, int? KeyOrder, string? KeyDefaultValue, string? KeyValidation, string? KeyEditingControlPath, bool? KeyIsGlobal, bool? KeyIsCustom, bool? KeyIsHidden, string? KeyFormControlSettings, string? KeyExplanationText) : ICmsSettingsKey, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "KeyID"; public static string TableName => "CMS_SettingsKey"; public static string GuidColumnName => "KeyGUID"; - static CmsSettingsKeyK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); - + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); public static CmsSettingsKeyK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); -} - -public record CmsSettingsKeyK13( - int KeyID, - string KeyName, - string KeyDisplayName, - string? KeyDescription, - string? KeyValue, - string KeyType, - int? KeyCategoryID, - int? SiteID, - Guid KeyGUID, - DateTime KeyLastModified, - int? KeyOrder, - string? KeyDefaultValue, - string? KeyValidation, - string? KeyEditingControlPath, - bool? KeyIsGlobal, - bool? KeyIsCustom, - bool? KeyIsHidden, - string? KeyFormControlSettings, - string? KeyExplanationText) : ICmsSettingsKey, ISourceModel + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); +}; +public partial record CmsSettingsKeyK13(int KeyID, string KeyName, string KeyDisplayName, string? KeyDescription, string? KeyValue, string KeyType, int? KeyCategoryID, int? SiteID, Guid KeyGUID, DateTime KeyLastModified, int? KeyOrder, string? KeyDefaultValue, string? KeyValidation, string? KeyEditingControlPath, bool? KeyIsGlobal, bool? KeyIsCustom, bool? KeyIsHidden, string? KeyFormControlSettings, string? KeyExplanationText) : ICmsSettingsKey, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "KeyID"; public static string TableName => "CMS_SettingsKey"; public static string GuidColumnName => "KeyGUID"; - static CmsSettingsKeyK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); - + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); public static CmsSettingsKeyK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), - reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), - reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), - reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") - ); -} + reader.Unbox("KeyID"), reader.Unbox("KeyName"), reader.Unbox("KeyDisplayName"), reader.Unbox("KeyDescription"), reader.Unbox("KeyValue"), reader.Unbox("KeyType"), reader.Unbox("KeyCategoryID"), reader.Unbox("SiteID"), reader.Unbox("KeyGUID"), reader.Unbox("KeyLastModified"), reader.Unbox("KeyOrder"), reader.Unbox("KeyDefaultValue"), reader.Unbox("KeyValidation"), reader.Unbox("KeyEditingControlPath"), reader.Unbox("KeyIsGlobal"), reader.Unbox("KeyIsCustom"), reader.Unbox("KeyIsHidden"), reader.Unbox("KeyFormControlSettings"), reader.Unbox("KeyExplanationText") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsSite.cs b/KVA/Migration.Toolkit.Source/Model/CmsSite.cs index 3ca2b2d6..1e0c2316 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsSite.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsSite.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsSite : ISourceModel +public partial interface ICmsSite : ISourceModel { int SiteID { get; } string SiteName { get; } @@ -25,7 +23,6 @@ public interface ICmsSite : ISourceModel { Major: 13 } => CmsSiteK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsSiteK11.IsAvailable(version), @@ -33,10 +30,8 @@ public interface ICmsSite : ISourceModel { Major: 13 } => CmsSiteK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Site"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsSite ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsSiteK11.FromReader(reader, version), @@ -45,94 +40,43 @@ public interface ICmsSite : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsSiteK11( - int SiteID, - string SiteName, - string SiteDisplayName, - string? SiteDescription, - string SiteStatus, - string SiteDomainName, - int? SiteDefaultStylesheetID, - string? SiteDefaultVisitorCulture, - int? SiteDefaultEditorStylesheet, - Guid SiteGUID, - DateTime SiteLastModified, - bool? SiteIsOffline, - string? SiteOfflineRedirectURL, - string? SiteOfflineMessage, - string? SitePresentationURL, - bool? SiteIsContentOnly) : ICmsSite, ISourceModel +public partial record CmsSiteK11(int SiteID, string SiteName, string SiteDisplayName, string? SiteDescription, string SiteStatus, string SiteDomainName, int? SiteDefaultStylesheetID, string? SiteDefaultVisitorCulture, int? SiteDefaultEditorStylesheet, Guid SiteGUID, DateTime SiteLastModified, bool? SiteIsOffline, string? SiteOfflineRedirectURL, string? SiteOfflineMessage, string? SitePresentationURL, bool? SiteIsContentOnly) : ICmsSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "SiteID"; public static string TableName => "CMS_Site"; public static string GuidColumnName => ""; - static CmsSiteK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), - reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") - ); - + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") + ); public static CmsSiteK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), - reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") - ); -} - -public record CmsSiteK12( - int SiteID, - string SiteName, - string SiteDisplayName, - string? SiteDescription, - string SiteStatus, - string SiteDomainName, - int? SiteDefaultStylesheetID, - string? SiteDefaultVisitorCulture, - int? SiteDefaultEditorStylesheet, - Guid SiteGUID, - DateTime SiteLastModified, - bool? SiteIsOffline, - string? SiteOfflineRedirectURL, - string? SiteOfflineMessage, - string? SitePresentationURL, - bool? SiteIsContentOnly) : ICmsSite, ISourceModel + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") + ); +}; +public partial record CmsSiteK12(int SiteID, string SiteName, string SiteDisplayName, string? SiteDescription, string SiteStatus, string SiteDomainName, int? SiteDefaultStylesheetID, string? SiteDefaultVisitorCulture, int? SiteDefaultEditorStylesheet, Guid SiteGUID, DateTime SiteLastModified, bool? SiteIsOffline, string? SiteOfflineRedirectURL, string? SiteOfflineMessage, string? SitePresentationURL, bool? SiteIsContentOnly) : ICmsSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "SiteID"; public static string TableName => "CMS_Site"; public static string GuidColumnName => ""; - static CmsSiteK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), - reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") - ); - + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") + ); public static CmsSiteK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), - reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") - ); -} - -public record CmsSiteK13(int SiteID, string SiteName, string SiteDisplayName, string? SiteDescription, string SiteStatus, string SiteDomainName, string? SiteDefaultVisitorCulture, Guid SiteGUID, DateTime SiteLastModified, string SitePresentationURL) - : ICmsSite, ISourceModel + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultStylesheetID"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteDefaultEditorStylesheet"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SiteIsOffline"), reader.Unbox("SiteOfflineRedirectURL"), reader.Unbox("SiteOfflineMessage"), reader.Unbox("SitePresentationURL"), reader.Unbox("SiteIsContentOnly") + ); +}; +public partial record CmsSiteK13(int SiteID, string SiteName, string SiteDisplayName, string? SiteDescription, string SiteStatus, string SiteDomainName, string? SiteDefaultVisitorCulture, Guid SiteGUID, DateTime SiteLastModified, string SitePresentationURL) : ICmsSite, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "SiteID"; public static string TableName => "CMS_Site"; public static string GuidColumnName => ""; - static CmsSiteK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SitePresentationURL") - ); - + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SitePresentationURL") + ); public static CmsSiteK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), - reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SitePresentationURL") - ); -} + reader.Unbox("SiteID"), reader.Unbox("SiteName"), reader.Unbox("SiteDisplayName"), reader.Unbox("SiteDescription"), reader.Unbox("SiteStatus"), reader.Unbox("SiteDomainName"), reader.Unbox("SiteDefaultVisitorCulture"), reader.Unbox("SiteGUID"), reader.Unbox("SiteLastModified"), reader.Unbox("SitePresentationURL") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsSiteCulture.cs b/KVA/Migration.Toolkit.Source/Model/CmsSiteCulture.cs index 799b8495..ae95a31f 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsSiteCulture.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsSiteCulture.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsSiteCulture : ISourceModel +public partial interface ICmsSiteCulture : ISourceModel { int SiteID { get; } int CultureID { get; } @@ -18,7 +16,6 @@ public interface ICmsSiteCulture : ISourceModel { Major: 13 } => CmsSiteCultureK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsSiteCultureK11.IsAvailable(version), @@ -26,10 +23,8 @@ public interface ICmsSiteCulture : ISourceModel { Major: 13 } => CmsSiteCultureK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_SiteCulture"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsSiteCulture ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsSiteCultureK11.FromReader(reader, version), @@ -38,51 +33,43 @@ public interface ICmsSiteCulture : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsSiteCultureK11(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel +public partial record CmsSiteCultureK11(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_SiteCulture"; public static string GuidColumnName => ""; - static CmsSiteCultureK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); - + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); public static CmsSiteCultureK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); -} - -public record CmsSiteCultureK12(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); +}; +public partial record CmsSiteCultureK12(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_SiteCulture"; public static string GuidColumnName => ""; - static CmsSiteCultureK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); - + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); public static CmsSiteCultureK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); -} - -public record CmsSiteCultureK13(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); +}; +public partial record CmsSiteCultureK13(int SiteID, int CultureID) : ICmsSiteCulture, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "CultureID"; public static string TableName => "CMS_SiteCulture"; public static string GuidColumnName => ""; - static CmsSiteCultureK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); - + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); public static CmsSiteCultureK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("SiteID"), reader.Unbox("CultureID") - ); -} + reader.Unbox("SiteID"), reader.Unbox("CultureID") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsState.cs b/KVA/Migration.Toolkit.Source/Model/CmsState.cs index e1a5032a..fc7bf1d7 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsState.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsState.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsState : ISourceModel +public partial interface ICmsState : ISourceModel { int StateID { get; } string StateDisplayName { get; } @@ -23,7 +21,6 @@ public interface ICmsState : ISourceModel { Major: 13 } => CmsStateK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsStateK11.IsAvailable(version), @@ -31,10 +28,8 @@ public interface ICmsState : ISourceModel { Major: 13 } => CmsStateK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_State"; static string ISourceModel.GuidColumnName => "StateGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsState ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsStateK11.FromReader(reader, version), @@ -43,57 +38,43 @@ public interface ICmsState : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsStateK11(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel +public partial record CmsStateK11(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "StateID"; public static string TableName => "CMS_State"; public static string GuidColumnName => "StateGUID"; - static CmsStateK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); - + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); public static CmsStateK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); -} - -public record CmsStateK12(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); +}; +public partial record CmsStateK12(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "StateID"; public static string TableName => "CMS_State"; public static string GuidColumnName => "StateGUID"; - static CmsStateK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); - + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); public static CmsStateK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); -} - -public record CmsStateK13(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); +}; +public partial record CmsStateK13(int StateID, string StateDisplayName, string StateName, string? StateCode, int CountryID, Guid StateGUID, DateTime StateLastModified) : ICmsState, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "StateID"; public static string TableName => "CMS_State"; public static string GuidColumnName => "StateGUID"; - static CmsStateK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); - + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); public static CmsStateK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), - reader.Unbox("StateLastModified") - ); -} + reader.Unbox("StateID"), reader.Unbox("StateDisplayName"), reader.Unbox("StateName"), reader.Unbox("StateCode"), reader.Unbox("CountryID"), reader.Unbox("StateGUID"), reader.Unbox("StateLastModified") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsTree.cs b/KVA/Migration.Toolkit.Source/Model/CmsTree.cs index 8ba31ccc..92e10eb0 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsTree.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsTree.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsTree : ISourceModel +public partial interface ICmsTree : ISourceModel { int NodeID { get; } string NodeAliasPath { get; } @@ -37,7 +35,6 @@ public interface ICmsTree : ISourceModel { Major: 13 } => CmsTreeK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsTreeK11.IsAvailable(version), @@ -45,10 +42,8 @@ public interface ICmsTree : ISourceModel { Major: 13 } => CmsTreeK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_Tree"; static string ISourceModel.GuidColumnName => "NodeGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsTree ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsTreeK11.FromReader(reader, version), @@ -57,166 +52,43 @@ public interface ICmsTree : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsTreeK11( - int NodeID, - string NodeAliasPath, - string NodeName, - string NodeAlias, - int NodeClassID, - int? NodeParentID, - int NodeLevel, - int? NodeACLID, - int NodeSiteID, - Guid NodeGUID, - int? NodeOrder, - bool? IsSecuredNode, - int? NodeCacheMinutes, - int? NodeSKUID, - string? NodeDocType, - string? NodeHeadTags, - string? NodeBodyElementAttributes, - string? NodeInheritPageLevels, - int? RequiresSSL, - int? NodeLinkedNodeID, - int? NodeOwner, - string? NodeCustomData, - int? NodeGroupID, - int? NodeLinkedNodeSiteID, - int? NodeTemplateID, - bool? NodeTemplateForAllCultures, - bool? NodeInheritPageTemplate, - bool? NodeAllowCacheInFileSystem, - bool? NodeHasChildren, - bool? NodeHasLinks, - int? NodeOriginalNodeID, - bool NodeIsContentOnly, - bool NodeIsACLOwner, - string? NodeBodyScripts) : ICmsTree, ISourceModel +public partial record CmsTreeK11(int NodeID, string NodeAliasPath, string NodeName, string NodeAlias, int NodeClassID, int? NodeParentID, int NodeLevel, int? NodeACLID, int NodeSiteID, Guid NodeGUID, int? NodeOrder, bool? IsSecuredNode, int? NodeCacheMinutes, int? NodeSKUID, string? NodeDocType, string? NodeHeadTags, string? NodeBodyElementAttributes, string? NodeInheritPageLevels, int? RequiresSSL, int? NodeLinkedNodeID, int? NodeOwner, string? NodeCustomData, int? NodeGroupID, int? NodeLinkedNodeSiteID, int? NodeTemplateID, bool? NodeTemplateForAllCultures, bool? NodeInheritPageTemplate, bool? NodeAllowCacheInFileSystem, bool? NodeHasChildren, bool? NodeHasLinks, int? NodeOriginalNodeID, bool NodeIsContentOnly, bool NodeIsACLOwner, string? NodeBodyScripts) : ICmsTree, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "NodeID"; public static string TableName => "CMS_Tree"; public static string GuidColumnName => "NodeGUID"; - static CmsTreeK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), - reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), - reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), - reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), - reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") - ); - + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") + ); public static CmsTreeK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), - reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), - reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), - reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), - reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") - ); -} - -public record CmsTreeK12( - int NodeID, - string NodeAliasPath, - string NodeName, - string NodeAlias, - int NodeClassID, - int? NodeParentID, - int NodeLevel, - int? NodeACLID, - int NodeSiteID, - Guid NodeGUID, - int? NodeOrder, - bool? IsSecuredNode, - int? NodeCacheMinutes, - int? NodeSKUID, - string? NodeDocType, - string? NodeHeadTags, - string? NodeBodyElementAttributes, - string? NodeInheritPageLevels, - int? RequiresSSL, - int? NodeLinkedNodeID, - int? NodeOwner, - string? NodeCustomData, - int? NodeGroupID, - int? NodeLinkedNodeSiteID, - int? NodeTemplateID, - bool? NodeTemplateForAllCultures, - bool? NodeInheritPageTemplate, - bool? NodeAllowCacheInFileSystem, - bool? NodeHasChildren, - bool? NodeHasLinks, - int? NodeOriginalNodeID, - bool NodeIsContentOnly, - bool NodeIsACLOwner, - string? NodeBodyScripts) : ICmsTree, ISourceModel + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") + ); +}; +public partial record CmsTreeK12(int NodeID, string NodeAliasPath, string NodeName, string NodeAlias, int NodeClassID, int? NodeParentID, int NodeLevel, int? NodeACLID, int NodeSiteID, Guid NodeGUID, int? NodeOrder, bool? IsSecuredNode, int? NodeCacheMinutes, int? NodeSKUID, string? NodeDocType, string? NodeHeadTags, string? NodeBodyElementAttributes, string? NodeInheritPageLevels, int? RequiresSSL, int? NodeLinkedNodeID, int? NodeOwner, string? NodeCustomData, int? NodeGroupID, int? NodeLinkedNodeSiteID, int? NodeTemplateID, bool? NodeTemplateForAllCultures, bool? NodeInheritPageTemplate, bool? NodeAllowCacheInFileSystem, bool? NodeHasChildren, bool? NodeHasLinks, int? NodeOriginalNodeID, bool NodeIsContentOnly, bool NodeIsACLOwner, string? NodeBodyScripts) : ICmsTree, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "NodeID"; public static string TableName => "CMS_Tree"; public static string GuidColumnName => "NodeGUID"; - static CmsTreeK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), - reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), - reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), - reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), - reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") - ); - + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") + ); public static CmsTreeK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), - reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), - reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), - reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), - reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") - ); -} - -public record CmsTreeK13( - int NodeID, - string NodeAliasPath, - string NodeName, - string NodeAlias, - int NodeClassID, - int? NodeParentID, - int NodeLevel, - int? NodeACLID, - int NodeSiteID, - Guid NodeGUID, - int? NodeOrder, - bool? IsSecuredNode, - int? NodeSKUID, - int? NodeLinkedNodeID, - int? NodeOwner, - string? NodeCustomData, - int? NodeLinkedNodeSiteID, - bool? NodeHasChildren, - bool? NodeHasLinks, - int? NodeOriginalNodeID, - bool NodeIsACLOwner) : ICmsTree, ISourceModel + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeCacheMinutes"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeDocType"), reader.Unbox("NodeHeadTags"), reader.Unbox("NodeBodyElementAttributes"), reader.Unbox("NodeInheritPageLevels"), reader.Unbox("RequiresSSL"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeGroupID"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeTemplateID"), reader.Unbox("NodeTemplateForAllCultures"), reader.Unbox("NodeInheritPageTemplate"), reader.Unbox("NodeAllowCacheInFileSystem"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsContentOnly"), reader.Unbox("NodeIsACLOwner"), reader.Unbox("NodeBodyScripts") + ); +}; +public partial record CmsTreeK13(int NodeID, string NodeAliasPath, string NodeName, string NodeAlias, int NodeClassID, int? NodeParentID, int NodeLevel, int? NodeACLID, int NodeSiteID, Guid NodeGUID, int? NodeOrder, bool? IsSecuredNode, int? NodeSKUID, int? NodeLinkedNodeID, int? NodeOwner, string? NodeCustomData, int? NodeLinkedNodeSiteID, bool? NodeHasChildren, bool? NodeHasLinks, int? NodeOriginalNodeID, bool NodeIsACLOwner) : ICmsTree, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "NodeID"; public static string TableName => "CMS_Tree"; public static string GuidColumnName => "NodeGUID"; - static CmsTreeK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeLinkedNodeID"), - reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), - reader.Unbox("NodeIsACLOwner") - ); - + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsACLOwner") + ); public static CmsTreeK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), - reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeLinkedNodeID"), - reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), - reader.Unbox("NodeIsACLOwner") - ); -} + reader.Unbox("NodeID"), reader.Unbox("NodeAliasPath"), reader.Unbox("NodeName"), reader.Unbox("NodeAlias"), reader.Unbox("NodeClassID"), reader.Unbox("NodeParentID"), reader.Unbox("NodeLevel"), reader.Unbox("NodeACLID"), reader.Unbox("NodeSiteID"), reader.Unbox("NodeGUID"), reader.Unbox("NodeOrder"), reader.Unbox("IsSecuredNode"), reader.Unbox("NodeSKUID"), reader.Unbox("NodeLinkedNodeID"), reader.Unbox("NodeOwner"), reader.Unbox("NodeCustomData"), reader.Unbox("NodeLinkedNodeSiteID"), reader.Unbox("NodeHasChildren"), reader.Unbox("NodeHasLinks"), reader.Unbox("NodeOriginalNodeID"), reader.Unbox("NodeIsACLOwner") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsUser.cs b/KVA/Migration.Toolkit.Source/Model/CmsUser.cs index 6607cb70..1a7e7678 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsUser.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsUser.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsUser : ISourceModel +public partial interface ICmsUser : ISourceModel { int UserID { get; } string UserName { get; } @@ -43,7 +41,6 @@ public interface ICmsUser : ISourceModel { Major: 13 } => CmsUserK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsUserK11.IsAvailable(version), @@ -51,10 +48,8 @@ public interface ICmsUser : ISourceModel { Major: 13 } => CmsUserK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_User"; static string ISourceModel.GuidColumnName => "UserGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsUser ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsUserK11.FromReader(reader, version), @@ -63,162 +58,42 @@ public interface ICmsUser : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsUserK11( - int UserID, - string UserName, - string? FirstName, - string? MiddleName, - string? LastName, - string? FullName, - string? Email, - string UserPassword, - string? PreferredCultureCode, - string? PreferredUICultureCode, - bool UserEnabled, - bool? UserIsExternal, - string? UserPasswordFormat, - DateTime? UserCreated, - DateTime? LastLogon, - string? UserStartingAliasPath, - Guid UserGUID, - DateTime UserLastModified, - string? UserLastLogonInfo, - bool? UserIsHidden, - string? UserVisibility, - bool? UserIsDomain, - bool? UserHasAllowedCultures, - bool? UserMFRequired, - int UserPrivilegeLevel, - string? UserSecurityStamp, - byte[]? UserMFSecret, - long? UserMFTimestep) : ICmsUser, ISourceModel +public partial record CmsUserK11(int UserID, string UserName, string? FirstName, string? MiddleName, string? LastName, string? FullName, string? Email, string UserPassword, string? PreferredCultureCode, string? PreferredUICultureCode, bool UserEnabled, bool? UserIsExternal, string? UserPasswordFormat, DateTime? UserCreated, DateTime? LastLogon, string? UserStartingAliasPath, Guid UserGUID, DateTime UserLastModified, string? UserLastLogonInfo, bool? UserIsHidden, string? UserVisibility, bool? UserIsDomain, bool? UserHasAllowedCultures, bool? UserMFRequired, int UserPrivilegeLevel, string? UserSecurityStamp, byte[]? UserMFSecret, long? UserMFTimestep, string? CUSTOM_1) : ICmsUser, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserID"; public static string TableName => "CMS_User"; public static string GuidColumnName => "UserGUID"; - static CmsUserK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), - reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), - reader.Unbox("UserMFTimestep") - ); - + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep"), reader.Unbox("CUSTOM_1") + ); public static CmsUserK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), - reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), - reader.Unbox("UserMFTimestep") - ); -} - -public record CmsUserK12( - int UserID, - string UserName, - string? FirstName, - string? MiddleName, - string? LastName, - string? FullName, - string? Email, - string UserPassword, - string? PreferredCultureCode, - string? PreferredUICultureCode, - bool UserEnabled, - bool? UserIsExternal, - string? UserPasswordFormat, - DateTime? UserCreated, - DateTime? LastLogon, - string? UserStartingAliasPath, - Guid UserGUID, - DateTime UserLastModified, - string? UserLastLogonInfo, - bool? UserIsHidden, - string? UserVisibility, - bool? UserIsDomain, - bool? UserHasAllowedCultures, - bool? UserMFRequired, - int UserPrivilegeLevel, - string? UserSecurityStamp, - byte[]? UserMFSecret, - long? UserMFTimestep) : ICmsUser, ISourceModel + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep"), reader.Unbox("CUSTOM_1") + ); +}; +public partial record CmsUserK12(int UserID, string UserName, string? FirstName, string? MiddleName, string? LastName, string? FullName, string? Email, string UserPassword, string? PreferredCultureCode, string? PreferredUICultureCode, bool UserEnabled, bool? UserIsExternal, string? UserPasswordFormat, DateTime? UserCreated, DateTime? LastLogon, string? UserStartingAliasPath, Guid UserGUID, DateTime UserLastModified, string? UserLastLogonInfo, bool? UserIsHidden, string? UserVisibility, bool? UserIsDomain, bool? UserHasAllowedCultures, bool? UserMFRequired, int UserPrivilegeLevel, string? UserSecurityStamp, byte[]? UserMFSecret, long? UserMFTimestep) : ICmsUser, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserID"; public static string TableName => "CMS_User"; public static string GuidColumnName => "UserGUID"; - static CmsUserK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), - reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), - reader.Unbox("UserMFTimestep") - ); - + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep") + ); public static CmsUserK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), - reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), - reader.Unbox("UserMFTimestep") - ); -} - -public record CmsUserK13( - int UserID, - string UserName, - string? FirstName, - string? MiddleName, - string? LastName, - string? FullName, - string? Email, - string UserPassword, - string? PreferredCultureCode, - string? PreferredUICultureCode, - bool UserEnabled, - bool? UserIsExternal, - string? UserPasswordFormat, - DateTime? UserCreated, - DateTime? LastLogon, - string? UserStartingAliasPath, - Guid UserGUID, - DateTime UserLastModified, - string? UserLastLogonInfo, - bool? UserIsHidden, - bool? UserIsDomain, - bool? UserHasAllowedCultures, - bool? UserMFRequired, - int UserPrivilegeLevel, - string? UserSecurityStamp, - byte[]? UserMFSecret, - long? UserMFTimestep) : ICmsUser, ISourceModel + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserVisibility"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep") + ); +}; +public partial record CmsUserK13(int UserID, string UserName, string? FirstName, string? MiddleName, string? LastName, string? FullName, string? Email, string UserPassword, string? PreferredCultureCode, string? PreferredUICultureCode, bool UserEnabled, bool? UserIsExternal, string? UserPasswordFormat, DateTime? UserCreated, DateTime? LastLogon, string? UserStartingAliasPath, Guid UserGUID, DateTime UserLastModified, string? UserLastLogonInfo, bool? UserIsHidden, bool? UserIsDomain, bool? UserHasAllowedCultures, bool? UserMFRequired, int UserPrivilegeLevel, string? UserSecurityStamp, byte[]? UserMFSecret, long? UserMFTimestep) : ICmsUser, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserID"; public static string TableName => "CMS_User"; public static string GuidColumnName => "UserGUID"; - static CmsUserK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), - reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep") - ); - + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep")); public static CmsUserK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), - reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), - reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), - reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), - reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep") - ); -} + reader.Unbox("UserID"), reader.Unbox("UserName"), reader.Unbox("FirstName"), reader.Unbox("MiddleName"), reader.Unbox("LastName"), reader.Unbox("FullName"), reader.Unbox("Email"), reader.Unbox("UserPassword"), reader.Unbox("PreferredCultureCode"), reader.Unbox("PreferredUICultureCode"), reader.Unbox("UserEnabled"), reader.Unbox("UserIsExternal"), reader.Unbox("UserPasswordFormat"), reader.Unbox("UserCreated"), reader.Unbox("LastLogon"), reader.Unbox("UserStartingAliasPath"), reader.Unbox("UserGUID"), reader.Unbox("UserLastModified"), reader.Unbox("UserLastLogonInfo"), reader.Unbox("UserIsHidden"), reader.Unbox("UserIsDomain"), reader.Unbox("UserHasAllowedCultures"), reader.Unbox("UserMFRequired"), reader.Unbox("UserPrivilegeLevel"), reader.Unbox("UserSecurityStamp"), reader.Unbox("UserMFSecret"), reader.Unbox("UserMFTimestep") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsUserSetting.cs b/KVA/Migration.Toolkit.Source/Model/CmsUserSetting.cs index 60e08c5b..e9505747 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsUserSetting.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsUserSetting.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsUserSetting : ISourceModel +public partial interface ICmsUserSetting : ISourceModel { int UserSettingsID { get; } string? UserNickName { get; } @@ -48,7 +46,6 @@ public interface ICmsUserSetting : ISourceModel { Major: 13 } => CmsUserSettingK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsUserSettingK11.IsAvailable(version), @@ -56,10 +53,8 @@ public interface ICmsUserSetting : ISourceModel { Major: 13 } => CmsUserSettingK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_UserSettings"; static string ISourceModel.GuidColumnName => "UserSettingsUserGUID"; //assumtion, class Guid column doesn't change between versions - static ICmsUserSetting ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsUserSettingK11.FromReader(reader, version), @@ -68,221 +63,43 @@ public interface ICmsUserSetting : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsUserSettingK11( - int UserSettingsID, - string? UserNickName, - string? UserPicture, - string? UserSignature, - string? UserURLReferrer, - string? UserCampaign, - string? UserMessagingNotificationEmail, - string? UserCustomData, - string? UserRegistrationInfo, - string? UserPreferences, - DateTime? UserActivationDate, - int? UserActivatedByUserID, - int? UserTimeZoneID, - int? UserAvatarID, - int? UserBadgeID, - int? UserActivityPoints, - int? UserForumPosts, - int? UserBlogComments, - int? UserGender, - DateTime? UserDateOfBirth, - int? UserMessageBoardPosts, - Guid UserSettingsUserGUID, - int UserSettingsUserID, - string? WindowsLiveID, - int? UserBlogPosts, - bool? UserWaitingForApproval, - string? UserDialogsConfiguration, - string? UserDescription, - string? UserUsedWebParts, - string? UserUsedWidgets, - string? UserFacebookID, - Guid? UserAuthenticationGUID, - string? UserSkype, - string? UserIM, - string? UserPhone, - string? UserPosition, - string? UserLinkedInID, - bool? UserLogActivities, - string? UserPasswordRequestHash, - int? UserInvalidLogOnAttempts, - string? UserInvalidLogOnAttemptsHash, - string? UserAvatarType, - int? UserAccountLockReason, - DateTime? UserPasswordLastChanged, - bool? UserShowIntroductionTile, - string? UserDashboardApplications, - string? UserDismissedSmartTips) : ICmsUserSetting, ISourceModel +public partial record CmsUserSettingK11(int UserSettingsID, string? UserNickName, string? UserPicture, string? UserSignature, string? UserURLReferrer, string? UserCampaign, string? UserMessagingNotificationEmail, string? UserCustomData, string? UserRegistrationInfo, string? UserPreferences, DateTime? UserActivationDate, int? UserActivatedByUserID, int? UserTimeZoneID, int? UserAvatarID, int? UserBadgeID, int? UserActivityPoints, int? UserForumPosts, int? UserBlogComments, int? UserGender, DateTime? UserDateOfBirth, int? UserMessageBoardPosts, Guid UserSettingsUserGUID, int UserSettingsUserID, string? WindowsLiveID, int? UserBlogPosts, bool? UserWaitingForApproval, string? UserDialogsConfiguration, string? UserDescription, string? UserUsedWebParts, string? UserUsedWidgets, string? UserFacebookID, Guid? UserAuthenticationGUID, string? UserSkype, string? UserIM, string? UserPhone, string? UserPosition, string? UserLinkedInID, bool? UserLogActivities, string? UserPasswordRequestHash, int? UserInvalidLogOnAttempts, string? UserInvalidLogOnAttemptsHash, string? UserAvatarType, int? UserAccountLockReason, DateTime? UserPasswordLastChanged, bool? UserShowIntroductionTile, string? UserDashboardApplications, string? UserDismissedSmartTips, string? CUSTOM_2) : ICmsUserSetting, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserSettingsID"; public static string TableName => "CMS_UserSettings"; public static string GuidColumnName => "UserSettingsUserGUID"; - static CmsUserSettingK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), - reader.Unbox("UserMessagingNotificationEmail"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), - reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), - reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), - reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), - reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), - reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), - reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), - reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") - ); - + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserMessagingNotificationEmail"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("CUSTOM_2") + ); public static CmsUserSettingK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), - reader.Unbox("UserMessagingNotificationEmail"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), - reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), - reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), - reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), - reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), - reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), - reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), - reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") - ); -} - -public record CmsUserSettingK12( - int UserSettingsID, - string? UserNickName, - string? UserPicture, - string? UserSignature, - string? UserURLReferrer, - string? UserCampaign, - string? UserCustomData, - string? UserRegistrationInfo, - string? UserPreferences, - DateTime? UserActivationDate, - int? UserActivatedByUserID, - int? UserTimeZoneID, - int? UserAvatarID, - int? UserBadgeID, - int? UserActivityPoints, - int? UserForumPosts, - int? UserBlogComments, - int? UserGender, - DateTime? UserDateOfBirth, - int? UserMessageBoardPosts, - Guid UserSettingsUserGUID, - int UserSettingsUserID, - string? WindowsLiveID, - int? UserBlogPosts, - bool? UserWaitingForApproval, - string? UserDialogsConfiguration, - string? UserDescription, - string? UserUsedWebParts, - string? UserUsedWidgets, - string? UserFacebookID, - Guid? UserAuthenticationGUID, - string? UserSkype, - string? UserIM, - string? UserPhone, - string? UserPosition, - string? UserLinkedInID, - bool? UserLogActivities, - string? UserPasswordRequestHash, - int? UserInvalidLogOnAttempts, - string? UserInvalidLogOnAttemptsHash, - string? UserAvatarType, - int? UserAccountLockReason, - DateTime? UserPasswordLastChanged, - bool? UserShowIntroductionTile, - string? UserDashboardApplications, - string? UserDismissedSmartTips) : ICmsUserSetting, ISourceModel + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserMessagingNotificationEmail"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("CUSTOM_2") + ); +}; +public partial record CmsUserSettingK12(int UserSettingsID, string? UserNickName, string? UserPicture, string? UserSignature, string? UserURLReferrer, string? UserCampaign, string? UserCustomData, string? UserRegistrationInfo, string? UserPreferences, DateTime? UserActivationDate, int? UserActivatedByUserID, int? UserTimeZoneID, int? UserAvatarID, int? UserBadgeID, int? UserActivityPoints, int? UserForumPosts, int? UserBlogComments, int? UserGender, DateTime? UserDateOfBirth, int? UserMessageBoardPosts, Guid UserSettingsUserGUID, int UserSettingsUserID, string? WindowsLiveID, int? UserBlogPosts, bool? UserWaitingForApproval, string? UserDialogsConfiguration, string? UserDescription, string? UserUsedWebParts, string? UserUsedWidgets, string? UserFacebookID, Guid? UserAuthenticationGUID, string? UserSkype, string? UserIM, string? UserPhone, string? UserPosition, string? UserLinkedInID, bool? UserLogActivities, string? UserPasswordRequestHash, int? UserInvalidLogOnAttempts, string? UserInvalidLogOnAttemptsHash, string? UserAvatarType, int? UserAccountLockReason, DateTime? UserPasswordLastChanged, bool? UserShowIntroductionTile, string? UserDashboardApplications, string? UserDismissedSmartTips) : ICmsUserSetting, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserSettingsID"; public static string TableName => "CMS_UserSettings"; public static string GuidColumnName => "UserSettingsUserGUID"; - static CmsUserSettingK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), - reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), - reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), - reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), - reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), - reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), - reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), - reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), - reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") - ); - + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") + ); public static CmsUserSettingK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), - reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), - reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), - reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), - reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), - reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), - reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), - reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), - reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") - ); -} - -public record CmsUserSettingK13( - int UserSettingsID, - string? UserNickName, - string? UserSignature, - string? UserURLReferrer, - string? UserCampaign, - string? UserCustomData, - string? UserRegistrationInfo, - DateTime? UserActivationDate, - int? UserActivatedByUserID, - int? UserTimeZoneID, - int? UserAvatarID, - int? UserGender, - DateTime? UserDateOfBirth, - Guid UserSettingsUserGUID, - int UserSettingsUserID, - bool? UserWaitingForApproval, - string? UserDialogsConfiguration, - string? UserDescription, - Guid? UserAuthenticationGUID, - string? UserSkype, - string? UserIM, - string? UserPhone, - string? UserPosition, - bool? UserLogActivities, - string? UserPasswordRequestHash, - int? UserInvalidLogOnAttempts, - string? UserInvalidLogOnAttemptsHash, - int? UserAccountLockReason, - DateTime? UserPasswordLastChanged, - bool? UserShowIntroductionTile, - string? UserDashboardApplications, - string? UserDismissedSmartTips, - string? SuperSettingsCustomizedKey) : ICmsUserSetting, ISourceModel + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserPicture"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserPreferences"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserBadgeID"), reader.Unbox("UserActivityPoints"), reader.Unbox("UserForumPosts"), reader.Unbox("UserBlogComments"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserMessageBoardPosts"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("WindowsLiveID"), reader.Unbox("UserBlogPosts"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserUsedWebParts"), reader.Unbox("UserUsedWidgets"), reader.Unbox("UserFacebookID"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLinkedInID"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAvatarType"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips") + ); +}; +public partial record CmsUserSettingK13(int UserSettingsID, string? UserNickName, string? UserSignature, string? UserURLReferrer, string? UserCampaign, string? UserCustomData, string? UserRegistrationInfo, DateTime? UserActivationDate, int? UserActivatedByUserID, int? UserTimeZoneID, int? UserAvatarID, int? UserGender, DateTime? UserDateOfBirth, Guid UserSettingsUserGUID, int UserSettingsUserID, bool? UserWaitingForApproval, string? UserDialogsConfiguration, string? UserDescription, Guid? UserAuthenticationGUID, string? UserSkype, string? UserIM, string? UserPhone, string? UserPosition, bool? UserLogActivities, string? UserPasswordRequestHash, int? UserInvalidLogOnAttempts, string? UserInvalidLogOnAttemptsHash, int? UserAccountLockReason, DateTime? UserPasswordLastChanged, bool? UserShowIntroductionTile, string? UserDashboardApplications, string? UserDismissedSmartTips, string? SuperSettingsCustomizedKey) : ICmsUserSetting, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "UserSettingsID"; public static string TableName => "CMS_UserSettings"; public static string GuidColumnName => "UserSettingsUserGUID"; - static CmsUserSettingK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), - reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), - reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("UserWaitingForApproval"), - reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), - reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), - reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), - reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("SuperSettingsCustomizedKey") - ); - + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("SuperSettingsCustomizedKey") + ); public static CmsUserSettingK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), - reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), - reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("UserWaitingForApproval"), - reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), - reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), - reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), - reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("SuperSettingsCustomizedKey") - ); -} + reader.Unbox("UserSettingsID"), reader.Unbox("UserNickName"), reader.Unbox("UserSignature"), reader.Unbox("UserURLReferrer"), reader.Unbox("UserCampaign"), reader.Unbox("UserCustomData"), reader.Unbox("UserRegistrationInfo"), reader.Unbox("UserActivationDate"), reader.Unbox("UserActivatedByUserID"), reader.Unbox("UserTimeZoneID"), reader.Unbox("UserAvatarID"), reader.Unbox("UserGender"), reader.Unbox("UserDateOfBirth"), reader.Unbox("UserSettingsUserGUID"), reader.Unbox("UserSettingsUserID"), reader.Unbox("UserWaitingForApproval"), reader.Unbox("UserDialogsConfiguration"), reader.Unbox("UserDescription"), reader.Unbox("UserAuthenticationGUID"), reader.Unbox("UserSkype"), reader.Unbox("UserIM"), reader.Unbox("UserPhone"), reader.Unbox("UserPosition"), reader.Unbox("UserLogActivities"), reader.Unbox("UserPasswordRequestHash"), reader.Unbox("UserInvalidLogOnAttempts"), reader.Unbox("UserInvalidLogOnAttemptsHash"), reader.Unbox("UserAccountLockReason"), reader.Unbox("UserPasswordLastChanged"), reader.Unbox("UserShowIntroductionTile"), reader.Unbox("UserDashboardApplications"), reader.Unbox("UserDismissedSmartTips"), reader.Unbox("SuperSettingsCustomizedKey") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/CmsVersionHistory.cs b/KVA/Migration.Toolkit.Source/Model/CmsVersionHistory.cs index 276f381f..b348bda1 100644 --- a/KVA/Migration.Toolkit.Source/Model/CmsVersionHistory.cs +++ b/KVA/Migration.Toolkit.Source/Model/CmsVersionHistory.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface ICmsVersionHistory : ISourceModel +public partial interface ICmsVersionHistory : ISourceModel { int VersionHistoryID { get; } int NodeSiteID { get; } @@ -36,7 +34,6 @@ public interface ICmsVersionHistory : ISourceModel { Major: 13 } => CmsVersionHistoryK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => CmsVersionHistoryK11.IsAvailable(version), @@ -44,10 +41,8 @@ public interface ICmsVersionHistory : ISourceModel { Major: 13 } => CmsVersionHistoryK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "CMS_VersionHistory"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static ICmsVersionHistory ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => CmsVersionHistoryK11.FromReader(reader, version), @@ -56,139 +51,43 @@ public interface ICmsVersionHistory : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record CmsVersionHistoryK11( - int VersionHistoryID, - int NodeSiteID, - int? DocumentID, - string DocumentNamePath, - string NodeXML, - int? ModifiedByUserID, - DateTime ModifiedWhen, - string? VersionNumber, - string? VersionComment, - bool ToBePublished, - DateTime? PublishFrom, - DateTime? PublishTo, - DateTime? WasPublishedFrom, - DateTime? WasPublishedTo, - string? VersionDocumentName, - string? VersionDocumentType, - int? VersionClassID, - string? VersionMenuRedirectUrl, - int? VersionWorkflowID, - int? VersionWorkflowStepID, - string? VersionNodeAliasPath, - int? VersionDeletedByUserID, - DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel +public partial record CmsVersionHistoryK11(int VersionHistoryID, int NodeSiteID, int? DocumentID, string DocumentNamePath, string NodeXML, int? ModifiedByUserID, DateTime ModifiedWhen, string? VersionNumber, string? VersionComment, bool ToBePublished, DateTime? PublishFrom, DateTime? PublishTo, DateTime? WasPublishedFrom, DateTime? WasPublishedTo, string? VersionDocumentName, string? VersionDocumentType, int? VersionClassID, string? VersionMenuRedirectUrl, int? VersionWorkflowID, int? VersionWorkflowStepID, string? VersionNodeAliasPath, int? VersionDeletedByUserID, DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "VersionHistoryID"; public static string TableName => "CMS_VersionHistory"; public static string GuidColumnName => ""; - static CmsVersionHistoryK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), - reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), - reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), - reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), - reader.Unbox("VersionDeletedWhen") - ); - + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); public static CmsVersionHistoryK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), - reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), - reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), - reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), - reader.Unbox("VersionDeletedWhen") - ); -} - -public record CmsVersionHistoryK12( - int VersionHistoryID, - int NodeSiteID, - int? DocumentID, - string DocumentNamePath, - string NodeXML, - int? ModifiedByUserID, - DateTime ModifiedWhen, - string? VersionNumber, - string? VersionComment, - bool ToBePublished, - DateTime? PublishFrom, - DateTime? PublishTo, - DateTime? WasPublishedFrom, - DateTime? WasPublishedTo, - string? VersionDocumentName, - string? VersionDocumentType, - int? VersionClassID, - string? VersionMenuRedirectUrl, - int? VersionWorkflowID, - int? VersionWorkflowStepID, - string? VersionNodeAliasPath, - int? VersionDeletedByUserID, - DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); +}; +public partial record CmsVersionHistoryK12(int VersionHistoryID, int NodeSiteID, int? DocumentID, string DocumentNamePath, string NodeXML, int? ModifiedByUserID, DateTime ModifiedWhen, string? VersionNumber, string? VersionComment, bool ToBePublished, DateTime? PublishFrom, DateTime? PublishTo, DateTime? WasPublishedFrom, DateTime? WasPublishedTo, string? VersionDocumentName, string? VersionDocumentType, int? VersionClassID, string? VersionMenuRedirectUrl, int? VersionWorkflowID, int? VersionWorkflowStepID, string? VersionNodeAliasPath, int? VersionDeletedByUserID, DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "VersionHistoryID"; public static string TableName => "CMS_VersionHistory"; public static string GuidColumnName => ""; - static CmsVersionHistoryK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), - reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), - reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), - reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), - reader.Unbox("VersionDeletedWhen") - ); - + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); public static CmsVersionHistoryK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), - reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), - reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), - reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), - reader.Unbox("VersionDeletedWhen") - ); -} - -public record CmsVersionHistoryK13( - int VersionHistoryID, - int NodeSiteID, - int? DocumentID, - string NodeXML, - int? ModifiedByUserID, - DateTime ModifiedWhen, - string? VersionNumber, - string? VersionComment, - bool ToBePublished, - DateTime? PublishFrom, - DateTime? PublishTo, - DateTime? WasPublishedFrom, - DateTime? WasPublishedTo, - string? VersionDocumentName, - int? VersionClassID, - int? VersionWorkflowID, - int? VersionWorkflowStepID, - string? VersionNodeAliasPath, - int? VersionDeletedByUserID, - DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("DocumentNamePath"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionDocumentType"), reader.Unbox("VersionClassID"), reader.Unbox("VersionMenuRedirectUrl"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); +}; +public partial record CmsVersionHistoryK13(int VersionHistoryID, int NodeSiteID, int? DocumentID, string NodeXML, int? ModifiedByUserID, DateTime ModifiedWhen, string? VersionNumber, string? VersionComment, bool ToBePublished, DateTime? PublishFrom, DateTime? PublishTo, DateTime? WasPublishedFrom, DateTime? WasPublishedTo, string? VersionDocumentName, int? VersionClassID, int? VersionWorkflowID, int? VersionWorkflowStepID, string? VersionNodeAliasPath, int? VersionDeletedByUserID, DateTime? VersionDeletedWhen) : ICmsVersionHistory, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "VersionHistoryID"; public static string TableName => "CMS_VersionHistory"; public static string GuidColumnName => ""; - static CmsVersionHistoryK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), - reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), - reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionClassID"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), - reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") - ); - + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionClassID"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); public static CmsVersionHistoryK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), - reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), - reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionClassID"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), - reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") - ); -} + reader.Unbox("VersionHistoryID"), reader.Unbox("NodeSiteID"), reader.Unbox("DocumentID"), reader.Unbox("NodeXML"), reader.Unbox("ModifiedByUserID"), reader.Unbox("ModifiedWhen"), reader.Unbox("VersionNumber"), reader.Unbox("VersionComment"), reader.Unbox("ToBePublished"), reader.Unbox("PublishFrom"), reader.Unbox("PublishTo"), reader.Unbox("WasPublishedFrom"), reader.Unbox("WasPublishedTo"), reader.Unbox("VersionDocumentName"), reader.Unbox("VersionClassID"), reader.Unbox("VersionWorkflowID"), reader.Unbox("VersionWorkflowStepID"), reader.Unbox("VersionNodeAliasPath"), reader.Unbox("VersionDeletedByUserID"), reader.Unbox("VersionDeletedWhen") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/MediaFile.cs b/KVA/Migration.Toolkit.Source/Model/MediaFile.cs index 4073e999..25732d1e 100644 --- a/KVA/Migration.Toolkit.Source/Model/MediaFile.cs +++ b/KVA/Migration.Toolkit.Source/Model/MediaFile.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface IMediaFile : ISourceModel +public partial interface IMediaFile : ISourceModel { int FileID { get; } string FileName { get; } @@ -34,7 +32,6 @@ public interface IMediaFile : ISourceModel { Major: 13 } => MediaFileK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => MediaFileK11.IsAvailable(version), @@ -42,10 +39,8 @@ public interface IMediaFile : ISourceModel { Major: 13 } => MediaFileK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "Media_File"; static string ISourceModel.GuidColumnName => "FileGUID"; //assumtion, class Guid column doesn't change between versions - static IMediaFile ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => MediaFileK11.FromReader(reader, version), @@ -54,123 +49,43 @@ public interface IMediaFile : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record MediaFileK11( - int FileID, - string FileName, - string FileTitle, - string FileDescription, - string FileExtension, - string FileMimeType, - string FilePath, - long FileSize, - int? FileImageWidth, - int? FileImageHeight, - Guid FileGUID, - int FileLibraryID, - int FileSiteID, - int? FileCreatedByUserID, - DateTime FileCreatedWhen, - int? FileModifiedByUserID, - DateTime FileModifiedWhen, - string? FileCustomData) : IMediaFile, ISourceModel +public partial record MediaFileK11(int FileID, string FileName, string FileTitle, string FileDescription, string FileExtension, string FileMimeType, string FilePath, long FileSize, int? FileImageWidth, int? FileImageHeight, Guid FileGUID, int FileLibraryID, int FileSiteID, int? FileCreatedByUserID, DateTime FileCreatedWhen, int? FileModifiedByUserID, DateTime FileModifiedWhen, string? FileCustomData) : IMediaFile, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FileID"; public static string TableName => "Media_File"; public static string GuidColumnName => "FileGUID"; - static MediaFileK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); - + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); public static MediaFileK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); -} - -public record MediaFileK12( - int FileID, - string FileName, - string FileTitle, - string FileDescription, - string FileExtension, - string FileMimeType, - string FilePath, - long FileSize, - int? FileImageWidth, - int? FileImageHeight, - Guid FileGUID, - int FileLibraryID, - int FileSiteID, - int? FileCreatedByUserID, - DateTime FileCreatedWhen, - int? FileModifiedByUserID, - DateTime FileModifiedWhen, - string? FileCustomData) : IMediaFile, ISourceModel + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); +}; +public partial record MediaFileK12(int FileID, string FileName, string FileTitle, string FileDescription, string FileExtension, string FileMimeType, string FilePath, long FileSize, int? FileImageWidth, int? FileImageHeight, Guid FileGUID, int FileLibraryID, int FileSiteID, int? FileCreatedByUserID, DateTime FileCreatedWhen, int? FileModifiedByUserID, DateTime FileModifiedWhen, string? FileCustomData) : IMediaFile, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FileID"; public static string TableName => "Media_File"; public static string GuidColumnName => "FileGUID"; - static MediaFileK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); - + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); public static MediaFileK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); -} - -public record MediaFileK13( - int FileID, - string FileName, - string FileTitle, - string FileDescription, - string FileExtension, - string FileMimeType, - string FilePath, - long FileSize, - int? FileImageWidth, - int? FileImageHeight, - Guid FileGUID, - int FileLibraryID, - int FileSiteID, - int? FileCreatedByUserID, - DateTime FileCreatedWhen, - int? FileModifiedByUserID, - DateTime FileModifiedWhen, - string? FileCustomData) : IMediaFile, ISourceModel + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); +}; +public partial record MediaFileK13(int FileID, string FileName, string FileTitle, string FileDescription, string FileExtension, string FileMimeType, string FilePath, long FileSize, int? FileImageWidth, int? FileImageHeight, Guid FileGUID, int FileLibraryID, int FileSiteID, int? FileCreatedByUserID, DateTime FileCreatedWhen, int? FileModifiedByUserID, DateTime FileModifiedWhen, string? FileCustomData) : IMediaFile, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "FileID"; public static string TableName => "Media_File"; public static string GuidColumnName => "FileGUID"; - static MediaFileK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); - + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); public static MediaFileK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), - reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), - reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), - reader.Unbox("FileCustomData") - ); -} + reader.Unbox("FileID"), reader.Unbox("FileName"), reader.Unbox("FileTitle"), reader.Unbox("FileDescription"), reader.Unbox("FileExtension"), reader.Unbox("FileMimeType"), reader.Unbox("FilePath"), reader.Unbox("FileSize"), reader.Unbox("FileImageWidth"), reader.Unbox("FileImageHeight"), reader.Unbox("FileGUID"), reader.Unbox("FileLibraryID"), reader.Unbox("FileSiteID"), reader.Unbox("FileCreatedByUserID"), reader.Unbox("FileCreatedWhen"), reader.Unbox("FileModifiedByUserID"), reader.Unbox("FileModifiedWhen"), reader.Unbox("FileCustomData") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/MediaLibrary.cs b/KVA/Migration.Toolkit.Source/Model/MediaLibrary.cs index 826dddb5..61665711 100644 --- a/KVA/Migration.Toolkit.Source/Model/MediaLibrary.cs +++ b/KVA/Migration.Toolkit.Source/Model/MediaLibrary.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface IMediaLibrary : ISourceModel +public partial interface IMediaLibrary : ISourceModel { int LibraryID { get; } string LibraryName { get; } @@ -27,7 +25,6 @@ public interface IMediaLibrary : ISourceModel { Major: 13 } => MediaLibraryK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => MediaLibraryK11.IsAvailable(version), @@ -35,10 +32,8 @@ public interface IMediaLibrary : ISourceModel { Major: 13 } => MediaLibraryK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "Media_Library"; static string ISourceModel.GuidColumnName => "LibraryGUID"; //assumtion, class Guid column doesn't change between versions - static IMediaLibrary ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => MediaLibraryK11.FromReader(reader, version), @@ -47,95 +42,43 @@ public interface IMediaLibrary : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record MediaLibraryK11( - int LibraryID, - string LibraryName, - string LibraryDisplayName, - string? LibraryDescription, - string LibraryFolder, - int? LibraryAccess, - int? LibraryGroupID, - int LibrarySiteID, - Guid? LibraryGUID, - DateTime? LibraryLastModified, - string? LibraryTeaserPath, - Guid? LibraryTeaserGUID) : IMediaLibrary, ISourceModel +public partial record MediaLibraryK11(int LibraryID, string LibraryName, string LibraryDisplayName, string? LibraryDescription, string LibraryFolder, int? LibraryAccess, int? LibraryGroupID, int LibrarySiteID, Guid? LibraryGUID, DateTime? LibraryLastModified, string? LibraryTeaserPath, Guid? LibraryTeaserGUID) : IMediaLibrary, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "LibraryID"; public static string TableName => "Media_Library"; public static string GuidColumnName => "LibraryTeaserGUID"; - static MediaLibraryK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") - ); - + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") + ); public static MediaLibraryK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") - ); -} - -public record MediaLibraryK12( - int LibraryID, - string LibraryName, - string LibraryDisplayName, - string? LibraryDescription, - string LibraryFolder, - int? LibraryAccess, - int? LibraryGroupID, - int LibrarySiteID, - Guid? LibraryGUID, - DateTime? LibraryLastModified, - string? LibraryTeaserPath, - Guid? LibraryTeaserGUID) : IMediaLibrary, ISourceModel + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") + ); +}; +public partial record MediaLibraryK12(int LibraryID, string LibraryName, string LibraryDisplayName, string? LibraryDescription, string LibraryFolder, int? LibraryAccess, int? LibraryGroupID, int LibrarySiteID, Guid? LibraryGUID, DateTime? LibraryLastModified, string? LibraryTeaserPath, Guid? LibraryTeaserGUID) : IMediaLibrary, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "LibraryID"; public static string TableName => "Media_Library"; public static string GuidColumnName => "LibraryTeaserGUID"; - static MediaLibraryK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") - ); - + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") + ); public static MediaLibraryK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") - ); -} - -public record MediaLibraryK13( - int LibraryID, - string LibraryName, - string LibraryDisplayName, - string? LibraryDescription, - string LibraryFolder, - int? LibraryAccess, - int LibrarySiteID, - Guid? LibraryGUID, - DateTime? LibraryLastModified, - string? LibraryTeaserPath, - Guid? LibraryTeaserGUID, - bool? LibraryUseDirectPathForContent) : IMediaLibrary, ISourceModel + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibraryGroupID"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID") + ); +}; +public partial record MediaLibraryK13(int LibraryID, string LibraryName, string LibraryDisplayName, string? LibraryDescription, string LibraryFolder, int? LibraryAccess, int LibrarySiteID, Guid? LibraryGUID, DateTime? LibraryLastModified, string? LibraryTeaserPath, Guid? LibraryTeaserGUID, bool? LibraryUseDirectPathForContent) : IMediaLibrary, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "LibraryID"; public static string TableName => "Media_Library"; public static string GuidColumnName => "LibraryTeaserGUID"; - static MediaLibraryK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID"), - reader.Unbox("LibraryUseDirectPathForContent") - ); - + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID"), reader.Unbox("LibraryUseDirectPathForContent") + ); public static MediaLibraryK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), - reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID"), - reader.Unbox("LibraryUseDirectPathForContent") - ); -} + reader.Unbox("LibraryID"), reader.Unbox("LibraryName"), reader.Unbox("LibraryDisplayName"), reader.Unbox("LibraryDescription"), reader.Unbox("LibraryFolder"), reader.Unbox("LibraryAccess"), reader.Unbox("LibrarySiteID"), reader.Unbox("LibraryGUID"), reader.Unbox("LibraryLastModified"), reader.Unbox("LibraryTeaserPath"), reader.Unbox("LibraryTeaserGUID"), reader.Unbox("LibraryUseDirectPathForContent") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/OmActivity.cs b/KVA/Migration.Toolkit.Source/Model/OmActivity.cs index e7d4b3a6..d6191618 100644 --- a/KVA/Migration.Toolkit.Source/Model/OmActivity.cs +++ b/KVA/Migration.Toolkit.Source/Model/OmActivity.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface IOmActivity : ISourceModel +public partial interface IOmActivity : ISourceModel { int ActivityID { get; } int ActivityContactID { get; } @@ -35,7 +33,6 @@ public interface IOmActivity : ISourceModel { Major: 13 } => OmActivityK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => OmActivityK11.IsAvailable(version), @@ -43,10 +40,8 @@ public interface IOmActivity : ISourceModel { Major: 13 } => OmActivityK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "OM_Activity"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static IOmActivity ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => OmActivityK11.FromReader(reader, version), @@ -55,128 +50,43 @@ public interface IOmActivity : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record OmActivityK11( - int ActivityID, - int ActivityContactID, - DateTime? ActivityCreated, - string ActivityType, - int? ActivityItemID, - int? ActivityItemDetailID, - string? ActivityValue, - string? ActivityURL, - string? ActivityTitle, - int ActivitySiteID, - string? ActivityComment, - string? ActivityCampaign, - string? ActivityURLReferrer, - string? ActivityCulture, - int? ActivityNodeID, - string? ActivityUTMSource, - string? ActivityABVariantName, - string? ActivityMVTCombinationName, - long ActivityURLHash, - string? ActivityUTMContent) : IOmActivity, ISourceModel +public partial record OmActivityK11(int ActivityID, int ActivityContactID, DateTime? ActivityCreated, string ActivityType, int? ActivityItemID, int? ActivityItemDetailID, string? ActivityValue, string? ActivityURL, string? ActivityTitle, int ActivitySiteID, string? ActivityComment, string? ActivityCampaign, string? ActivityURLReferrer, string? ActivityCulture, int? ActivityNodeID, string? ActivityUTMSource, string? ActivityABVariantName, string? ActivityMVTCombinationName, long ActivityURLHash, string? ActivityUTMContent) : IOmActivity, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ActivityID"; public static string TableName => "OM_Activity"; public static string GuidColumnName => ""; - static OmActivityK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); - + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); public static OmActivityK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); -} - -public record OmActivityK12( - int ActivityID, - int ActivityContactID, - DateTime? ActivityCreated, - string ActivityType, - int? ActivityItemID, - int? ActivityItemDetailID, - string? ActivityValue, - string? ActivityURL, - string? ActivityTitle, - int ActivitySiteID, - string? ActivityComment, - string? ActivityCampaign, - string? ActivityURLReferrer, - string? ActivityCulture, - int? ActivityNodeID, - string? ActivityUTMSource, - string? ActivityABVariantName, - string? ActivityMVTCombinationName, - long ActivityURLHash, - string? ActivityUTMContent) : IOmActivity, ISourceModel + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); +}; +public partial record OmActivityK12(int ActivityID, int ActivityContactID, DateTime? ActivityCreated, string ActivityType, int? ActivityItemID, int? ActivityItemDetailID, string? ActivityValue, string? ActivityURL, string? ActivityTitle, int ActivitySiteID, string? ActivityComment, string? ActivityCampaign, string? ActivityURLReferrer, string? ActivityCulture, int? ActivityNodeID, string? ActivityUTMSource, string? ActivityABVariantName, string? ActivityMVTCombinationName, long ActivityURLHash, string? ActivityUTMContent) : IOmActivity, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ActivityID"; public static string TableName => "OM_Activity"; public static string GuidColumnName => ""; - static OmActivityK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); - + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); public static OmActivityK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); -} - -public record OmActivityK13( - int ActivityID, - int ActivityContactID, - DateTime? ActivityCreated, - string ActivityType, - int? ActivityItemID, - int? ActivityItemDetailID, - string? ActivityValue, - string? ActivityURL, - string? ActivityTitle, - int ActivitySiteID, - string? ActivityComment, - string? ActivityCampaign, - string? ActivityURLReferrer, - string? ActivityCulture, - int? ActivityNodeID, - string? ActivityUTMSource, - string? ActivityABVariantName, - long ActivityURLHash, - string? ActivityUTMContent) : IOmActivity, ISourceModel + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityMVTCombinationName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); +}; +public partial record OmActivityK13(int ActivityID, int ActivityContactID, DateTime? ActivityCreated, string ActivityType, int? ActivityItemID, int? ActivityItemDetailID, string? ActivityValue, string? ActivityURL, string? ActivityTitle, int ActivitySiteID, string? ActivityComment, string? ActivityCampaign, string? ActivityURLReferrer, string? ActivityCulture, int? ActivityNodeID, string? ActivityUTMSource, string? ActivityABVariantName, long ActivityURLHash, string? ActivityUTMContent) : IOmActivity, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ActivityID"; public static string TableName => "OM_Activity"; public static string GuidColumnName => ""; - static OmActivityK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); - + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); public static OmActivityK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), - reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), - reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), - reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") - ); -} + reader.Unbox("ActivityID"), reader.Unbox("ActivityContactID"), reader.Unbox("ActivityCreated"), reader.Unbox("ActivityType"), reader.Unbox("ActivityItemID"), reader.Unbox("ActivityItemDetailID"), reader.Unbox("ActivityValue"), reader.Unbox("ActivityURL"), reader.Unbox("ActivityTitle"), reader.Unbox("ActivitySiteID"), reader.Unbox("ActivityComment"), reader.Unbox("ActivityCampaign"), reader.Unbox("ActivityURLReferrer"), reader.Unbox("ActivityCulture"), reader.Unbox("ActivityNodeID"), reader.Unbox("ActivityUTMSource"), reader.Unbox("ActivityABVariantName"), reader.Unbox("ActivityURLHash"), reader.Unbox("ActivityUTMContent") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/OmContact.cs b/KVA/Migration.Toolkit.Source/Model/OmContact.cs index 675a3c9d..d0729534 100644 --- a/KVA/Migration.Toolkit.Source/Model/OmContact.cs +++ b/KVA/Migration.Toolkit.Source/Model/OmContact.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface IOmContact : ISourceModel +public partial interface IOmContact : ISourceModel { int ContactID { get; } string? ContactFirstName { get; } @@ -47,7 +45,6 @@ public interface IOmContact : ISourceModel { Major: 13 } => OmContactK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => OmContactK11.IsAvailable(version), @@ -55,10 +52,8 @@ public interface IOmContact : ISourceModel { Major: 13 } => OmContactK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "OM_Contact"; static string ISourceModel.GuidColumnName => "ContactGUID"; //assumtion, class Guid column doesn't change between versions - static IOmContact ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => OmContactK11.FromReader(reader, version), @@ -67,229 +62,43 @@ public interface IOmContact : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record OmContactK11( - int ContactID, - string? ContactFirstName, - string? ContactMiddleName, - string? ContactLastName, - string? ContactJobTitle, - string? ContactAddress1, - string? ContactCity, - string? ContactZIP, - int? ContactStateID, - int? ContactCountryID, - string? ContactMobilePhone, - string? ContactBusinessPhone, - string? ContactEmail, - DateTime? ContactBirthday, - int? ContactGender, - int? ContactStatusID, - string? ContactNotes, - int? ContactOwnerUserID, - bool? ContactMonitored, - Guid ContactGUID, - DateTime ContactLastModified, - DateTime ContactCreated, - int? ContactBounces, - string? ContactCampaign, - string? ContactSalesForceLeadID, - bool? ContactSalesForceLeadReplicationDisabled, - DateTime? ContactSalesForceLeadReplicationDateTime, - DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, - string? ContactCompanyName, - bool? ContactSalesForceLeadReplicationRequired, - int? ContactPersonaID) : IOmContact, ISourceModel +public partial record OmContactK11(int ContactID, string? ContactFirstName, string? ContactMiddleName, string? ContactLastName, string? ContactJobTitle, string? ContactAddress1, string? ContactCity, string? ContactZIP, int? ContactStateID, int? ContactCountryID, string? ContactMobilePhone, string? ContactBusinessPhone, string? ContactEmail, DateTime? ContactBirthday, int? ContactGender, int? ContactStatusID, string? ContactNotes, int? ContactOwnerUserID, bool? ContactMonitored, Guid ContactGUID, DateTime ContactLastModified, DateTime ContactCreated, int? ContactBounces, string? ContactCampaign, string? ContactSalesForceLeadID, bool? ContactSalesForceLeadReplicationDisabled, DateTime? ContactSalesForceLeadReplicationDateTime, DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, string? ContactCompanyName, bool? ContactSalesForceLeadReplicationRequired, int? ContactPersonaID) : IOmContact, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactID"; public static string TableName => "OM_Contact"; public static string GuidColumnName => "ContactGUID"; - static OmContactK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") - ); - + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") + ); public static OmContactK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") - ); -} - -public record OmContactK12( - int ContactID, - string? ContactFirstName, - string? ContactMiddleName, - string? ContactLastName, - string? ContactJobTitle, - string? ContactAddress1, - string? ContactCity, - string? ContactZIP, - int? ContactStateID, - int? ContactCountryID, - string? ContactMobilePhone, - string? ContactBusinessPhone, - string? ContactEmail, - DateTime? ContactBirthday, - int? ContactGender, - int? ContactStatusID, - string? ContactNotes, - int? ContactOwnerUserID, - bool? ContactMonitored, - Guid ContactGUID, - DateTime ContactLastModified, - DateTime ContactCreated, - int? ContactBounces, - string? ContactCampaign, - string? ContactSalesForceLeadID, - bool? ContactSalesForceLeadReplicationDisabled, - DateTime? ContactSalesForceLeadReplicationDateTime, - DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, - string? ContactCompanyName, - bool? ContactSalesForceLeadReplicationRequired, - int? ContactPersonaID, - string? FirstUserAgent, - string? FirstIPAddress, - string? FirstRequestUrl, - string? KenticoUrlReferrer, - string? KenticoContactRegionName, - string? KenticoContactRegionCode, - string? KenticoContactPostalCode, - string? KenticoContactCampaignSource, - string? KenticoContactCampaignContent, - bool? NeedRecalculation, - int? ProfileScore, - int? EngagementScore, - int? TotalScore, - int? Zone, - Guid? DynamicsLeadGuid, - Guid? DynamicsContactGuid, - string? DynamicsAccountType, - string? DynamicsAccountStatus, - bool? LegitimateInterest, - string? DynamicsActivePartnerships, - DateTime? DynamicsDateOfSync, - bool? PairedWithDynamicsCrm, - DateTime? FirstPairDate, - int? PairedBy, - bool? IsArchived, - DateTime? ArchivationDate, - bool? HasFreeEmail, - int? SameDomainContacts, - string? AreYouLookingForCMS, - string? Role, - string? KenticoContactBusinessType, - string? MarketingAutomationVariant, - string? KontentIntercomUserID, - string? KontentGoogleAnalyticsUserID, - string? KontentAmplitudeUserID) : IOmContact, ISourceModel + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") + ); +}; +public partial record OmContactK12(int ContactID, string? ContactFirstName, string? ContactMiddleName, string? ContactLastName, string? ContactJobTitle, string? ContactAddress1, string? ContactCity, string? ContactZIP, int? ContactStateID, int? ContactCountryID, string? ContactMobilePhone, string? ContactBusinessPhone, string? ContactEmail, DateTime? ContactBirthday, int? ContactGender, int? ContactStatusID, string? ContactNotes, int? ContactOwnerUserID, bool? ContactMonitored, Guid ContactGUID, DateTime ContactLastModified, DateTime ContactCreated, int? ContactBounces, string? ContactCampaign, string? ContactSalesForceLeadID, bool? ContactSalesForceLeadReplicationDisabled, DateTime? ContactSalesForceLeadReplicationDateTime, DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, string? ContactCompanyName, bool? ContactSalesForceLeadReplicationRequired, int? ContactPersonaID, string? FirstUserAgent, string? FirstIPAddress, string? FirstRequestUrl, string? KenticoUrlReferrer, string? KenticoContactRegionName, string? KenticoContactRegionCode, string? KenticoContactPostalCode, string? KenticoContactCampaignSource, string? KenticoContactCampaignContent, bool? NeedRecalculation, int? ProfileScore, int? EngagementScore, int? TotalScore, int? Zone, Guid? DynamicsLeadGuid, Guid? DynamicsContactGuid, string? DynamicsAccountType, string? DynamicsAccountStatus, bool? LegitimateInterest, string? DynamicsActivePartnerships, DateTime? DynamicsDateOfSync, bool? PairedWithDynamicsCrm, DateTime? FirstPairDate, int? PairedBy, bool? IsArchived, DateTime? ArchivationDate, bool? HasFreeEmail, int? SameDomainContacts, string? AreYouLookingForCMS, string? Role, string? KenticoContactBusinessType, string? MarketingAutomationVariant, string? KontentIntercomUserID, string? KontentGoogleAnalyticsUserID, string? KontentAmplitudeUserID) : IOmContact, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactID"; public static string TableName => "OM_Contact"; public static string GuidColumnName => "ContactGUID"; - static OmContactK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID"), reader.Unbox("FirstUserAgent"), reader.Unbox("FirstIPAddress"), reader.Unbox("FirstRequestUrl"), - reader.Unbox("KenticoUrlReferrer"), reader.Unbox("KenticoContactRegionName"), reader.Unbox("KenticoContactRegionCode"), reader.Unbox("KenticoContactPostalCode"), - reader.Unbox("KenticoContactCampaignSource"), reader.Unbox("KenticoContactCampaignContent"), reader.Unbox("NeedRecalculation"), reader.Unbox("ProfileScore"), reader.Unbox("EngagementScore"), - reader.Unbox("TotalScore"), reader.Unbox("Zone"), reader.Unbox("DynamicsLeadGuid"), reader.Unbox("DynamicsContactGuid"), reader.Unbox("DynamicsAccountType"), reader.Unbox("DynamicsAccountStatus"), - reader.Unbox("LegitimateInterest"), reader.Unbox("DynamicsActivePartnerships"), reader.Unbox("DynamicsDateOfSync"), reader.Unbox("PairedWithDynamicsCrm"), reader.Unbox("FirstPairDate"), - reader.Unbox("PairedBy"), reader.Unbox("IsArchived"), reader.Unbox("ArchivationDate"), reader.Unbox("HasFreeEmail"), reader.Unbox("SameDomainContacts"), reader.Unbox("AreYouLookingForCMS"), - reader.Unbox("Role"), reader.Unbox("KenticoContactBusinessType"), reader.Unbox("MarketingAutomationVariant"), reader.Unbox("KontentIntercomUserID"), reader.Unbox("KontentGoogleAnalyticsUserID"), - reader.Unbox("KontentAmplitudeUserID") - ); - + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID"), reader.Unbox("FirstUserAgent"), reader.Unbox("FirstIPAddress"), reader.Unbox("FirstRequestUrl"), reader.Unbox("KenticoUrlReferrer"), reader.Unbox("KenticoContactRegionName"), reader.Unbox("KenticoContactRegionCode"), reader.Unbox("KenticoContactPostalCode"), reader.Unbox("KenticoContactCampaignSource"), reader.Unbox("KenticoContactCampaignContent"), reader.Unbox("NeedRecalculation"), reader.Unbox("ProfileScore"), reader.Unbox("EngagementScore"), reader.Unbox("TotalScore"), reader.Unbox("Zone"), reader.Unbox("DynamicsLeadGuid"), reader.Unbox("DynamicsContactGuid"), reader.Unbox("DynamicsAccountType"), reader.Unbox("DynamicsAccountStatus"), reader.Unbox("LegitimateInterest"), reader.Unbox("DynamicsActivePartnerships"), reader.Unbox("DynamicsDateOfSync"), reader.Unbox("PairedWithDynamicsCrm"), reader.Unbox("FirstPairDate"), reader.Unbox("PairedBy"), reader.Unbox("IsArchived"), reader.Unbox("ArchivationDate"), reader.Unbox("HasFreeEmail"), reader.Unbox("SameDomainContacts"), reader.Unbox("AreYouLookingForCMS"), reader.Unbox("Role"), reader.Unbox("KenticoContactBusinessType"), reader.Unbox("MarketingAutomationVariant"), reader.Unbox("KontentIntercomUserID"), reader.Unbox("KontentGoogleAnalyticsUserID"), reader.Unbox("KontentAmplitudeUserID") + ); public static OmContactK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID"), reader.Unbox("FirstUserAgent"), reader.Unbox("FirstIPAddress"), reader.Unbox("FirstRequestUrl"), - reader.Unbox("KenticoUrlReferrer"), reader.Unbox("KenticoContactRegionName"), reader.Unbox("KenticoContactRegionCode"), reader.Unbox("KenticoContactPostalCode"), - reader.Unbox("KenticoContactCampaignSource"), reader.Unbox("KenticoContactCampaignContent"), reader.Unbox("NeedRecalculation"), reader.Unbox("ProfileScore"), reader.Unbox("EngagementScore"), - reader.Unbox("TotalScore"), reader.Unbox("Zone"), reader.Unbox("DynamicsLeadGuid"), reader.Unbox("DynamicsContactGuid"), reader.Unbox("DynamicsAccountType"), reader.Unbox("DynamicsAccountStatus"), - reader.Unbox("LegitimateInterest"), reader.Unbox("DynamicsActivePartnerships"), reader.Unbox("DynamicsDateOfSync"), reader.Unbox("PairedWithDynamicsCrm"), reader.Unbox("FirstPairDate"), - reader.Unbox("PairedBy"), reader.Unbox("IsArchived"), reader.Unbox("ArchivationDate"), reader.Unbox("HasFreeEmail"), reader.Unbox("SameDomainContacts"), reader.Unbox("AreYouLookingForCMS"), - reader.Unbox("Role"), reader.Unbox("KenticoContactBusinessType"), reader.Unbox("MarketingAutomationVariant"), reader.Unbox("KontentIntercomUserID"), reader.Unbox("KontentGoogleAnalyticsUserID"), - reader.Unbox("KontentAmplitudeUserID") - ); -} - -public record OmContactK13( - int ContactID, - string? ContactFirstName, - string? ContactMiddleName, - string? ContactLastName, - string? ContactJobTitle, - string? ContactAddress1, - string? ContactCity, - string? ContactZIP, - int? ContactStateID, - int? ContactCountryID, - string? ContactMobilePhone, - string? ContactBusinessPhone, - string? ContactEmail, - DateTime? ContactBirthday, - int? ContactGender, - int? ContactStatusID, - string? ContactNotes, - int? ContactOwnerUserID, - bool? ContactMonitored, - Guid ContactGUID, - DateTime ContactLastModified, - DateTime ContactCreated, - int? ContactBounces, - string? ContactCampaign, - string? ContactSalesForceLeadID, - bool? ContactSalesForceLeadReplicationDisabled, - DateTime? ContactSalesForceLeadReplicationDateTime, - DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, - string? ContactCompanyName, - bool? ContactSalesForceLeadReplicationRequired, - int? ContactPersonaID) : IOmContact, ISourceModel + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID"), reader.Unbox("FirstUserAgent"), reader.Unbox("FirstIPAddress"), reader.Unbox("FirstRequestUrl"), reader.Unbox("KenticoUrlReferrer"), reader.Unbox("KenticoContactRegionName"), reader.Unbox("KenticoContactRegionCode"), reader.Unbox("KenticoContactPostalCode"), reader.Unbox("KenticoContactCampaignSource"), reader.Unbox("KenticoContactCampaignContent"), reader.Unbox("NeedRecalculation"), reader.Unbox("ProfileScore"), reader.Unbox("EngagementScore"), reader.Unbox("TotalScore"), reader.Unbox("Zone"), reader.Unbox("DynamicsLeadGuid"), reader.Unbox("DynamicsContactGuid"), reader.Unbox("DynamicsAccountType"), reader.Unbox("DynamicsAccountStatus"), reader.Unbox("LegitimateInterest"), reader.Unbox("DynamicsActivePartnerships"), reader.Unbox("DynamicsDateOfSync"), reader.Unbox("PairedWithDynamicsCrm"), reader.Unbox("FirstPairDate"), reader.Unbox("PairedBy"), reader.Unbox("IsArchived"), reader.Unbox("ArchivationDate"), reader.Unbox("HasFreeEmail"), reader.Unbox("SameDomainContacts"), reader.Unbox("AreYouLookingForCMS"), reader.Unbox("Role"), reader.Unbox("KenticoContactBusinessType"), reader.Unbox("MarketingAutomationVariant"), reader.Unbox("KontentIntercomUserID"), reader.Unbox("KontentGoogleAnalyticsUserID"), reader.Unbox("KontentAmplitudeUserID") + ); +}; +public partial record OmContactK13(int ContactID, string? ContactFirstName, string? ContactMiddleName, string? ContactLastName, string? ContactJobTitle, string? ContactAddress1, string? ContactCity, string? ContactZIP, int? ContactStateID, int? ContactCountryID, string? ContactMobilePhone, string? ContactBusinessPhone, string? ContactEmail, DateTime? ContactBirthday, int? ContactGender, int? ContactStatusID, string? ContactNotes, int? ContactOwnerUserID, bool? ContactMonitored, Guid ContactGUID, DateTime ContactLastModified, DateTime ContactCreated, int? ContactBounces, string? ContactCampaign, string? ContactSalesForceLeadID, bool? ContactSalesForceLeadReplicationDisabled, DateTime? ContactSalesForceLeadReplicationDateTime, DateTime? ContactSalesForceLeadReplicationSuspensionDateTime, string? ContactCompanyName, bool? ContactSalesForceLeadReplicationRequired, int? ContactPersonaID) : IOmContact, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactID"; public static string TableName => "OM_Contact"; public static string GuidColumnName => "ContactGUID"; - static OmContactK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") - ); - + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") + ); public static OmContactK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), - reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), - reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), - reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), - reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), - reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), - reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") - ); -} + reader.Unbox("ContactID"), reader.Unbox("ContactFirstName"), reader.Unbox("ContactMiddleName"), reader.Unbox("ContactLastName"), reader.Unbox("ContactJobTitle"), reader.Unbox("ContactAddress1"), reader.Unbox("ContactCity"), reader.Unbox("ContactZIP"), reader.Unbox("ContactStateID"), reader.Unbox("ContactCountryID"), reader.Unbox("ContactMobilePhone"), reader.Unbox("ContactBusinessPhone"), reader.Unbox("ContactEmail"), reader.Unbox("ContactBirthday"), reader.Unbox("ContactGender"), reader.Unbox("ContactStatusID"), reader.Unbox("ContactNotes"), reader.Unbox("ContactOwnerUserID"), reader.Unbox("ContactMonitored"), reader.Unbox("ContactGUID"), reader.Unbox("ContactLastModified"), reader.Unbox("ContactCreated"), reader.Unbox("ContactBounces"), reader.Unbox("ContactCampaign"), reader.Unbox("ContactSalesForceLeadID"), reader.Unbox("ContactSalesForceLeadReplicationDisabled"), reader.Unbox("ContactSalesForceLeadReplicationDateTime"), reader.Unbox("ContactSalesForceLeadReplicationSuspensionDateTime"), reader.Unbox("ContactCompanyName"), reader.Unbox("ContactSalesForceLeadReplicationRequired"), reader.Unbox("ContactPersonaID") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/Model/OmContactStatus.cs b/KVA/Migration.Toolkit.Source/Model/OmContactStatus.cs index 9070ffb9..a9286d44 100644 --- a/KVA/Migration.Toolkit.Source/Model/OmContactStatus.cs +++ b/KVA/Migration.Toolkit.Source/Model/OmContactStatus.cs @@ -1,12 +1,10 @@ // ReSharper disable InconsistentNaming using System.Data; - using Migration.Toolkit.Common; namespace Migration.Toolkit.Source.Model; - -public interface IOmContactStatus : ISourceModel +public partial interface IOmContactStatus : ISourceModel { int ContactStatusID { get; } string ContactStatusName { get; } @@ -20,7 +18,6 @@ public interface IOmContactStatus : ISourceModel { Major: 13 } => OmContactStatusK13.GetPrimaryKeyName(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static bool ISourceModel.IsAvailable(SemanticVersion version) => version switch { { Major: 11 } => OmContactStatusK11.IsAvailable(version), @@ -28,10 +25,8 @@ public interface IOmContactStatus : ISourceModel { Major: 13 } => OmContactStatusK13.IsAvailable(version), _ => throw new InvalidCastException($"Invalid version {version}") }; - static string ISourceModel.TableName => "OM_ContactStatus"; static string ISourceModel.GuidColumnName => ""; //assumtion, class Guid column doesn't change between versions - static IOmContactStatus ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => version switch { { Major: 11 } => OmContactStatusK11.FromReader(reader, version), @@ -40,51 +35,43 @@ public interface IOmContactStatus : ISourceModel _ => throw new InvalidCastException($"Invalid version {version}") }; } - -public record OmContactStatusK11(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel +public partial record OmContactStatusK11(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactStatusID"; public static string TableName => "OM_ContactStatus"; public static string GuidColumnName => ""; - static OmContactStatusK11 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); - + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); public static OmContactStatusK11 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); -} - -public record OmContactStatusK12(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); +}; +public partial record OmContactStatusK12(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactStatusID"; public static string TableName => "OM_ContactStatus"; public static string GuidColumnName => ""; - static OmContactStatusK12 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); - + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); public static OmContactStatusK12 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); -} - -public record OmContactStatusK13(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); +}; +public partial record OmContactStatusK13(int ContactStatusID, string ContactStatusName, string ContactStatusDisplayName, string? ContactStatusDescription) : IOmContactStatus, ISourceModel { public static bool IsAvailable(SemanticVersion version) => true; public static string GetPrimaryKeyName(SemanticVersion version) => "ContactStatusID"; public static string TableName => "OM_ContactStatus"; public static string GuidColumnName => ""; - static OmContactStatusK13 ISourceModel.FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); - + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); public static OmContactStatusK13 FromReader(IDataReader reader, SemanticVersion version) => new( - reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") - ); -} + reader.Unbox("ContactStatusID"), reader.Unbox("ContactStatusName"), reader.Unbox("ContactStatusDisplayName"), reader.Unbox("ContactStatusDescription") + ); +}; + diff --git a/KVA/Migration.Toolkit.Source/ModelExtensions/ICmsAttachment.cs b/KVA/Migration.Toolkit.Source/ModelExtensions/ICmsAttachment.cs new file mode 100644 index 00000000..d21b8194 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/ModelExtensions/ICmsAttachment.cs @@ -0,0 +1,20 @@ +using System.Collections.Frozen; +using Migration.Toolkit.Common; + +namespace Migration.Toolkit.Source.Model; + +public partial interface ICmsAttachment : ISourceGuidEntity +{ + (Guid EntityGuid, int? SiteId) ISourceGuidEntity.GetIdentity() => (AttachmentGUID, AttachmentSiteID); + + static FrozenDictionary ISourceGuidEntity.Load(ModelFacade modelFacade) => + modelFacade + .Select("SELECT AttachmentGUID, AttachmentSiteID FROM CMS_Attachment", (reader, _) => new { AttachmentGUID = reader.Unbox("AttachmentGUID"), AttachmentSiteID = reader.Unbox("AttachmentSiteID") }) + .ToLookup(x => x.AttachmentGUID) + .ToFrozenDictionary( + x => x.Key, + x => x.Select(z => z.AttachmentSiteID).ToArray() + ); + + static Guid ISourceGuidEntity.NewGuidNs => new("78ACF349-948E-4DB8-BD3C-F91D1D072122"); +} diff --git a/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaFile.cs b/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaFile.cs new file mode 100644 index 00000000..9e538302 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaFile.cs @@ -0,0 +1,20 @@ +using System.Collections.Frozen; +using Migration.Toolkit.Common; + +namespace Migration.Toolkit.Source.Model; + +public partial interface IMediaFile : ISourceGuidEntity +{ + (Guid EntityGuid, int? SiteId) ISourceGuidEntity.GetIdentity() => (FileGUID, FileSiteID); + + static FrozenDictionary ISourceGuidEntity.Load(ModelFacade modelFacade) => + modelFacade + .Select("SELECT FileGUID, FileSiteID FROM Media_File", (reader, _) => new { FileGUID = reader.Unbox("FileGUID"), FileSiteID = reader.Unbox("FileSiteID") }) + .ToLookup(x => x.FileGUID) + .ToFrozenDictionary( + x => x.Key, + x => x.Select(z => z.FileSiteID).ToArray() + ); + + static Guid ISourceGuidEntity.NewGuidNs => new("A897335A-2FC0-4B9D-87BC-3BA95BD5B309"); +} diff --git a/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaLibrary.cs b/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaLibrary.cs new file mode 100644 index 00000000..c2daba07 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/ModelExtensions/IMediaLibrary.cs @@ -0,0 +1,21 @@ +using System.Collections.Frozen; +using Migration.Toolkit.Common; +using Migration.Toolkit.Common.Helpers; + +namespace Migration.Toolkit.Source.Model; + +public partial interface IMediaLibrary : ISourceGuidEntity +{ + (Guid EntityGuid, int? SiteId) ISourceGuidEntity.GetIdentity() => (LibraryGUID ?? GuidHelper.CreateGuidFromLibraryAndSiteID(LibraryName, LibrarySiteID), LibrarySiteID); + + static FrozenDictionary ISourceGuidEntity.Load(ModelFacade modelFacade) => + modelFacade + .Select("SELECT LibraryGUID, LibrarySiteID, LibraryName FROM Media_Library", (reader, _) => new { LibraryGUID = reader.Unbox("LibraryGUID"), LibrarySiteID = reader.Unbox("LibrarySiteID"), LibraryName = reader.Unbox("LibraryName") }) + .ToLookup(x => x.LibraryGUID ?? GuidHelper.CreateGuidFromLibraryAndSiteID(x.LibraryName, x.LibrarySiteID)) + .ToFrozenDictionary( + x => x.Key, + x => x.Select(z => z.LibrarySiteID).ToArray() + ); + + static Guid ISourceGuidEntity.NewGuidNs => new("15EC1A66-2322-4931-BE8C-C22AA117CF8F"); +} diff --git a/KVA/Migration.Toolkit.Source/ModelFacade.cs b/KVA/Migration.Toolkit.Source/ModelFacade.cs index 4cccfa49..4412ee37 100644 --- a/KVA/Migration.Toolkit.Source/ModelFacade.cs +++ b/KVA/Migration.Toolkit.Source/ModelFacade.cs @@ -108,8 +108,12 @@ public IEnumerable Select(string query, Func + /// Translates legacy media file to new preferred storage - content item + /// + /// Media file to convert + /// Media library that owns media file + /// CmsSite that owns media file in source instance + /// preferably only default language + /// + /// occurs when media path cannot be determined + Task FromMediaFile(IMediaFile mediaFile, IMediaLibrary mediaLibrary, ICmsSite site, string[] contentLanguageNames); + + Task FromAttachment(ICmsAttachment attachment, ICmsSite site, ICmsTree? referencedNode, string[] contentLanguageNames); + + /// + /// translates identity of media file to newly created content item (and content item asset) + /// + /// + /// + /// + (Guid ownerContentItemGuid, Guid assetGuid) GetRef(IMediaFile mediaFile, string? contentLanguageName = null); + + /// + /// translates identity of attachment to newly created content item (and content item asset) + /// + /// + /// + /// + (Guid ownerContentItemGuid, Guid assetGuid) GetRef(ICmsAttachment attachment, string? contentLanguageName = null); + + Task PreparePrerequisites(); +} + +public class AssetFacade( + EntityIdentityFacade entityIdentityFacade, + ToolkitConfiguration toolkitConfiguration, + ModelFacade modelFacade, + IImporter importer, + ILogger logger, + IProtocol protocol + ) : IAssetFacade +{ + public string DefaultContentLanguage + { + get + { + if (defaultContentLanguage == null) + { + var contentLanguageRetriever = Service.Resolve(); + defaultContentLanguage = contentLanguageRetriever.GetDefaultContentLanguage().GetAwaiter().GetResult(); + } + return defaultContentLanguage.ContentLanguageName; + } + } + + /// + public async Task FromMediaFile(IMediaFile mediaFile, IMediaLibrary mediaLibrary, ICmsSite site, string[] contentLanguageNames) + { + Debug.Assert(mediaFile.FileLibraryID == mediaLibrary.LibraryID, "mediaFile.FileLibraryID == mediaLibrary.LibraryID"); + Debug.Assert(mediaLibrary.LibrarySiteID == site.SiteID, "mediaLibrary.LibrarySiteID == site.SiteID"); + + string? mediaLibraryAbsolutePath = GetMediaLibraryAbsolutePath(toolkitConfiguration, site, mediaLibrary, modelFacade); + if (string.IsNullOrWhiteSpace(mediaLibraryAbsolutePath)) + { + throw new InvalidOperationException($"Invalid media file path generated for {mediaFile} and {mediaLibrary} on {site}"); + } + + string mediaFilePath = Path.Combine(mediaLibraryAbsolutePath, mediaFile.FilePath); + + int? createdByUserId = AdminUserHelper.MapTargetAdminUser( + mediaFile.FileCreatedByUserID, + CMSActionContext.CurrentUser.UserID, + () => protocol.Append(HandbookReferences + .MissingRequiredDependency(nameof(mediaFile.FileCreatedByUserID), mediaFile.FileCreatedByUserID) + .NeedsManualAction() + ) + ); + var createdByUser = createdByUserId.HasValue ? modelFacade.SelectById(createdByUserId) : null; + + var (_, translatedMediaGuid) = entityIdentityFacade.Translate(mediaFile); + + List languageData = []; + languageData.AddRange(contentLanguageNames.Select(contentLanguageName => new ContentItemLanguageData + { + LanguageName = contentLanguageName, + DisplayName = $"{mediaFile.FileName}", + UserGuid = createdByUser?.UserGUID, + VersionStatus = VersionStatus.Published, + ContentItemData = new Dictionary + { + ["Asset"] = new AssetFileSource + { + ContentItemGuid = translatedMediaGuid, + Identifier = GuidHelper.CreateAssetGuid(translatedMediaGuid, contentLanguageName), + Name = Path.Combine(mediaFile.FileName, mediaFile.FileExtension), + Extension = mediaFile.FileExtension, + Size = null, + LastModified = null, + FilePath = mediaFilePath + } + } + })); + + string mediaFolder = Path.Combine(mediaLibrary.LibraryFolder, Path.GetDirectoryName(mediaFile.FilePath)!); + + var folder = GetAssetFolder(site); + + var contentItem = new ContentItemSimplifiedModel + { + CustomProperties = [], + ContentItemGUID = translatedMediaGuid, + ContentItemContentFolderGUID = (await EnsureFolderStructure(mediaFolder, folder))?.ContentFolderGUID ?? folder.ContentFolderGUID, + IsSecured = null, + ContentTypeName = LegacyMediaFileContentType.ClassName, + Name = $"{mediaFile.FileName}_{translatedMediaGuid}", + IsReusable = true, + LanguageData = languageData, + }; + + // TODO tomas.krch: 2024-09-02 append url to protocol + // urlProtocol.AppendMediaFileUrlIfNeeded(); + + return contentItem; + } + + public async Task FromAttachment(ICmsAttachment attachment, ICmsSite site, ICmsTree? referencedNode, string[] contentLanguageNames) + { + Debug.Assert(attachment.AttachmentSiteID == site.SiteID || attachment.AttachmentSiteID == 0, "attachment.AttachmentSiteID == site.SiteID || attachment.AttachmentSiteID == 0"); + + var (_, translatedAttachmentGuid) = entityIdentityFacade.Translate(attachment); + + List languageData = []; + languageData.AddRange(contentLanguageNames.Select(contentLanguageName => new ContentItemLanguageData + { + LanguageName = contentLanguageName, + DisplayName = $"{attachment.AttachmentName}", + UserGuid = null, + VersionStatus = VersionStatus.Published, + ContentItemData = new Dictionary + { + ["Asset"] = new AssetDataSource + { + ContentItemGuid = translatedAttachmentGuid, + Identifier = GuidHelper.CreateAssetGuid(translatedAttachmentGuid, contentLanguageName), + Name = Path.Combine(attachment.AttachmentName, attachment.AttachmentExtension), + Extension = attachment.AttachmentExtension, + Size = null, + LastModified = attachment.AttachmentLastModified, + Data = attachment.AttachmentBinary, + } + } + })); + + string mediaFolder = "__Attachments"; + if (referencedNode != null && string.IsNullOrWhiteSpace(referencedNode.NodeAliasPath)) + { + mediaFolder += referencedNode.NodeAliasPath.StartsWith("/") ? referencedNode.NodeAliasPath : $"/{referencedNode.NodeAliasPath}"; + } + + var folder = GetAssetFolder(site); + + var contentItem = new ContentItemSimplifiedModel + { + ContentItemGUID = translatedAttachmentGuid, + ContentItemContentFolderGUID = (await EnsureFolderStructure(mediaFolder, folder))?.ContentFolderGUID ?? folder.ContentFolderGUID, + IsSecured = null, + ContentTypeName = LegacyMediaFileContentType.ClassName, + Name = $"{attachment.AttachmentGUID}_{translatedAttachmentGuid}", + IsReusable = true, + LanguageData = languageData, + }; + + // TODO tomas.krch: 2024-09-02 append url to protocol + // urlProtocol.AppendMediaFileUrlIfNeeded(); + + return contentItem; + } + + private readonly Dictionary contentFolderModels = []; + private ContentLanguageInfo? defaultContentLanguage; + + private async Task EnsureFolderStructure(string folderPath, ContentFolderModel rootFolder) + { + ArgumentException.ThrowIfNullOrWhiteSpace(folderPath); + + string rootKey = $"root|{rootFolder.ContentFolderGUID}"; + if (!contentFolderModels.TryGetValue(rootKey, out _)) + { + switch (await importer.ImportAsync(rootFolder)) + { + case { Success: true }: + { + contentFolderModels[rootKey] = rootFolder; + break; + } + case { Success: false, Exception: { } exception }: + { + logger.LogError("Failed to import asset migration folder: {Error} {Prerequisite}", exception.ToString(), rootFolder.PrintMe()); + break; + } + case { Success: false, ModelValidationResults: { } validation }: + { + foreach (var validationResult in validation) + { + logger.LogError("Failed to import asset migration folder {Members}: {Error} - {Prerequisite}", string.Join(",", validationResult.MemberNames), validationResult.ErrorMessage, rootFolder.PrintMe()); + } + + break; + } + default: + { + throw new InvalidOperationException($"Asset migration cannot continue, cannot prepare prerequisite - unknown result"); + } + } + contentFolderModels[rootKey] = rootFolder; + } + + string[] pathSplit = folderPath.Split(Path.DirectorySeparatorChar); + ContentFolderModel? lastFolder = null; + for (int i = 0; i < pathSplit.Length; i++) + { + string current = pathSplit[i]; + string currentPath = string.Join("/", rootFolder.ContentFolderTreePath!, string.Join("/", pathSplit[..(i + 1)])); + var folderGuid = GuidHelper.CreateFolderGuid($"{rootFolder.ContentFolderGUID}|{currentPath}"); + string folderKey = $"{currentPath}"; + if (!contentFolderModels.TryGetValue(folderKey, out lastFolder)) + { + lastFolder = new ContentFolderModel + { + ContentFolderGUID = folderGuid, + ContentFolderName = $"{folderGuid}", + ContentFolderDisplayName = current, + ContentFolderTreePath = currentPath, + ContentFolderParentFolderGUID = lastFolder?.ContentFolderGUID ?? rootFolder.ContentFolderGUID + }; + switch (await importer.ImportAsync(lastFolder)) + { + case { Success: true }: + { + contentFolderModels[folderKey] = lastFolder; + break; + } + case { Success: false, Exception: { } exception }: + { + logger.LogError("Failed to import asset migration folder: {Error} {Prerequisite}", exception.ToString(), lastFolder.PrintMe()); + break; + } + case { Success: false, ModelValidationResults: { } validation }: + { + foreach (var validationResult in validation) + { + logger.LogError("Failed to import asset migration folder {Members}: {Error} - {Prerequisite}", string.Join(",", validationResult.MemberNames), validationResult.ErrorMessage, lastFolder.PrintMe()); + } + + break; + } + default: + { + throw new InvalidOperationException($"Asset migration cannot continue, cannot prepare prerequisite - unknown result"); + } + } + } + } + + return lastFolder; + } + + /// + public (Guid ownerContentItemGuid, Guid assetGuid) GetRef(IMediaFile mediaFile, string? contentLanguageName = null) + { + var (_, translatedMediaGuid) = entityIdentityFacade.Translate(mediaFile); + return (translatedMediaGuid, GuidHelper.CreateAssetGuid(translatedMediaGuid, contentLanguageName ?? DefaultContentLanguage)); + } + + /// + public (Guid ownerContentItemGuid, Guid assetGuid) GetRef(ICmsAttachment attachment, string? contentLanguageName = null) + { + var (_, translatedAttachmentGuid) = entityIdentityFacade.Translate(attachment); + return (translatedAttachmentGuid, GuidHelper.CreateAssetGuid(translatedAttachmentGuid, contentLanguageName ?? DefaultContentLanguage)); + } + + #region Asset facade DB prerequisites + + public async Task PreparePrerequisites() + { + foreach (var umtModel in prerequisites) + { + AssertSuccess(await importer.ImportAsync(umtModel), umtModel); + } + } + + private void AssertSuccess(IImportResult importResult, IUmtModel model) + { + switch (importResult) + { + case { Success: true }: + { + logger.LogInformation("Asset migration prerequisite created {Prerequisite}", model.PrintMe()); + break; + } + case { Success: false, Exception: { } exception }: + { + logger.LogError("Failed to import asset migration prerequisite: {Error} {Prerequisite}", exception.ToString(), model.PrintMe()); + throw new InvalidOperationException($"Asset migration cannot continue, cannot prepare prerequisite"); + } + case { Success: false, ModelValidationResults: { } validation }: + { + foreach (var validationResult in validation) + { + logger.LogError("Failed to import asset migration prerequisite {Members}: {Error} - {Prerequisite}", string.Join(",", validationResult.MemberNames), validationResult.ErrorMessage, model.PrintMe()); + } + throw new InvalidOperationException($"Asset migration cannot continue, cannot prepare prerequisite"); + } + default: + { + throw new InvalidOperationException($"Asset migration cannot continue, cannot prepare prerequisite - unknown result"); + } + } + } + + internal static readonly DataClassModel LegacyMediaFileContentType = new() + { + ClassName = "Legacy.MediaFile", + ClassType = ClassType.CONTENT_TYPE, + ClassContentTypeType = ClassContentTypeType.REUSABLE, + ClassGUID = new Guid("BB17604C-C134-4FAA-A401-2727CAD93707"), + ClassDisplayName = "Legacy media file", + ClassTableName = "Legacy_MediaFile", + ClassLastModified = new DateTime(2024, 1, 1), + ClassHasUnmanagedDbSchema = false, + ClassWebPageHasUrl = false, + Fields = + [ + new() + { + Column = "Asset", + ColumnType = "contentitemasset", + AllowEmpty = true, + Visible = true, + Enabled = true, + Guid = new Guid("DFC3D011-8F63-43F6-9ED8-4B444333A1D0"), + Properties = new FormFieldProperties { FieldCaption = "Asset", }, + Settings = new FormFieldSettings { CustomProperties = new Dictionary { { "AllowedExtensions", "_INHERITED_" } }, ControlName = "Kentico.Administration.ContentItemAssetUploader" } + } + ] + }; + + internal static readonly DataClassModel LegacyAttachmentContentType = new() + { + ClassName = "Legacy.Attachment", + ClassType = ClassType.CONTENT_TYPE, + ClassContentTypeType = ClassContentTypeType.REUSABLE, + ClassGUID = new Guid("4E214DF1-EDD5-4441-A0B7-53849526B1D3"), + ClassDisplayName = "Legacy attachment", + ClassTableName = "Legacy_Attachment", + ClassLastModified = new DateTime(2024, 1, 1), + ClassHasUnmanagedDbSchema = false, + ClassWebPageHasUrl = false, + Fields = + [ + new() + { + Column = "Asset", + ColumnType = "contentitemasset", + AllowEmpty = true, + Visible = true, + Enabled = true, + Guid = new Guid("50C2BC4C-A8FF-46BA-95C2-0E74752D147F"), + Properties = new FormFieldProperties { FieldCaption = "Asset", }, + Settings = new FormFieldSettings { CustomProperties = new Dictionary { { "AllowedExtensions", "_INHERITED_" } }, ControlName = "Kentico.Administration.ContentItemAssetUploader" } + } + ] + }; + + internal static ContentFolderModel GetAssetFolder(ICmsSite site) + { + var folderGuid = GuidHelper.CreateFolderGuid($"{site.SiteName}|{site.SiteGUID}"); + return new ContentFolderModel + { + ContentFolderGUID = folderGuid, + ContentFolderName = $"{folderGuid}", + ContentFolderDisplayName = $"{site.SiteDisplayName} assets", + ContentFolderTreePath = $"/{site.SiteName}-assets", + ContentFolderParentFolderGUID = null // root + }; + } + + private static readonly IUmtModel[] prerequisites = [ + LegacyMediaFileContentType, + LegacyAttachmentContentType + ]; + + + #endregion + + private const string DirMedia = "media"; + public static string? GetMediaLibraryAbsolutePath(ToolkitConfiguration toolkitConfiguration, ICmsSite ksSite, IMediaLibrary ksMediaLibrary, ModelFacade modelFacade) + { + string? sourceMediaLibraryPath = null; + if (!toolkitConfiguration.MigrateOnlyMediaFileInfo.GetValueOrDefault(true) && + !string.IsNullOrWhiteSpace(toolkitConfiguration.KxCmsDirPath)) + { + string? cmsMediaLibrariesFolder = KenticoHelper.GetSettingsKey(modelFacade, ksSite.SiteID, "CMSMediaLibrariesFolder"); + if (cmsMediaLibrariesFolder != null) + { + if (Path.IsPathRooted(cmsMediaLibrariesFolder)) + { + sourceMediaLibraryPath = Path.Combine(cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + } + else + { + if (cmsMediaLibrariesFolder.StartsWith("~/")) + { + string cleared = $"{cmsMediaLibrariesFolder[2..]}".Replace("/", "\\"); + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cleared, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + } + else + { + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + } + } + } + else + { + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, ksSite.SiteName, DirMedia, ksMediaLibrary.LibraryFolder); + } + } + + return sourceMediaLibraryPath; + } +} diff --git a/KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToContentItem.cs b/KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToContentItem.cs new file mode 100644 index 00000000..d50bd8d5 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToContentItem.cs @@ -0,0 +1,167 @@ +using System.Diagnostics; +using CMS.ContentEngine.Internal; +using CMS.Core; +using Kentico.Xperience.UMT.Services; +using Microsoft.Data.SqlClient; +using Microsoft.Extensions.Logging; +using Migration.Toolkit.Common.MigrationProtocol; +using Migration.Toolkit.Source.Auxiliary; +using Migration.Toolkit.Source.Model; + +namespace Migration.Toolkit.Source.Services; + +public class AttachmentMigratorToContentItem( + ILogger logger, + IProtocol protocol, + ModelFacade modelFacade, + EntityIdentityFacade entityIdentityFacade, + IAssetFacade assetFacade, + IImporter importer +) : IAttachmentMigrator +{ + public async Task TryMigrateAttachmentByPath(string documentPath, string additionalPath) + { + if (string.IsNullOrWhiteSpace(documentPath)) + { + return new MigrateAttachmentResultContentItem(false, false, null); + } + + documentPath = $"/{documentPath.Trim('/')}"; + + var attachments = + modelFacade.SelectWhere( + """ + EXISTS ( + SELECT T.NodeAliasPath + FROM CMS_Document [D] JOIN + CMS_Tree [T] ON D.DocumentNodeID = T.NodeID + WHERE D.DocumentID = AttachmentDocumentID AND T.NodeAliasPath = @nodeAliasPath + ) + """, new SqlParameter("nodeAliasPath", documentPath)).ToList() + ; + + Debug.Assert(attachments.Count == 1, "attachments.Count == 1"); + var attachment = attachments.FirstOrDefault(); + + return attachment != null + ? await MigrateAttachment(attachment, additionalPath) + : new MigrateAttachmentResultContentItem(false, false, null); + } + + public async IAsyncEnumerable MigrateGroupedAttachments(int documentId, Guid attachmentGroupGuid, string fieldName) + { + var groupedAttachment = modelFacade.SelectWhere( + """ + AttachmentGroupGuid = @attachmentGroupGuid AND + AttachmentDocumentId = @attachmentDocumentId + """, + new SqlParameter("attachmentGroupGuid", attachmentGroupGuid), + new SqlParameter("attachmentDocumentId", documentId) + ); + + foreach (var cmsAttachment in groupedAttachment) + { + yield return await MigrateAttachment(cmsAttachment, $"__{fieldName}"); + } + } + + public async Task MigrateAttachment(Guid ksAttachmentGuid, string additionalPath, int siteId) + { + var attachments = modelFacade + .SelectWhere("AttachmentGuid = @attachmentGuid AND AttachmentSiteID = @siteId", + new SqlParameter("attachmentGuid", ksAttachmentGuid), + new SqlParameter("siteId", siteId) + ) + .ToList(); + + switch (attachments) + { + case { Count: 0 }: + { + logger.LogWarning("Attachment '{AttachmentGuid}' not found! => skipping", ksAttachmentGuid); + protocol.Append(HandbookReferences.TemporaryAttachmentMigrationIsNotSupported.WithData(new { AttachmentGuid = ksAttachmentGuid })); + return new MigrateAttachmentResultContentItem(false, true, null); + } + case [var attachment]: + { + return await MigrateAttachment(attachment, additionalPath); + } + default: + { + logger.LogWarning("Attachment '{AttachmentGuid}' found multiple times! => skipping", ksAttachmentGuid); + protocol.Append(HandbookReferences.NonUniqueEntityGuid.WithData(new { AttachmentGuid = ksAttachmentGuid, AttachmentIds = attachments.Select(a => a.AttachmentID) })); + return new MigrateAttachmentResultContentItem(false, true, null); + } + } + } + + private bool assetFacadeInitialized; + public async Task MigrateAttachment(ICmsAttachment ksAttachment, string? additionalMediaPath = null) + { + if (!assetFacadeInitialized) + { + await assetFacade.PreparePrerequisites(); + assetFacadeInitialized = true; + } + + protocol.FetchedSource(ksAttachment); + + if (ksAttachment.AttachmentFormGUID != null) + { + logger.LogWarning("Attachment '{AttachmentGuid}' is temporary => skipping", ksAttachment.AttachmentGUID); + protocol.Append(HandbookReferences.TemporaryAttachmentMigrationIsNotSupported.WithData(new { ksAttachment.AttachmentID, ksAttachment.AttachmentGUID, ksAttachment.AttachmentName, ksAttachment.AttachmentSiteID })); + return new MigrateAttachmentResultContentItem(false, true, null); + } + + var ksAttachmentDocument = ksAttachment.AttachmentDocumentID is { } attachmentDocumentId + ? modelFacade.SelectById(attachmentDocumentId) + : null; + + var ksNode = ksAttachmentDocument?.DocumentNodeID is { } documentNodeId + ? modelFacade.SelectById(documentNodeId) + : null; + + var site = modelFacade.SelectById(ksAttachment.AttachmentSiteID) ?? throw new InvalidOperationException("Site not exists!"); + + (bool isFixed, var newAttachmentGuid) = entityIdentityFacade.Translate(ksAttachment); + if (isFixed) + { + logger.LogWarning("Attachment {Attachment} link will be broken, new guid {Guid} was required", new { ksAttachment.AttachmentSiteID, ksAttachment.AttachmentID, ksAttachment.AttachmentGUID }, newAttachmentGuid); + } + + if (ksAttachment.AttachmentBinary is null) + { + logger.LogError("Binary data is null, cannot migrate attachment: {Attachment}", ksAttachment); + throw new InvalidOperationException("Attachment data is null!"); + } + + var contentLanguageRetriever = Service.Resolve(); + var defaultContentLanguage = await contentLanguageRetriever.GetDefaultContentLanguage(); + + var asset = await assetFacade.FromAttachment(ksAttachment, site, ksNode, [ksAttachmentDocument?.DocumentCulture ?? defaultContentLanguage.ContentLanguageName]); + switch (await importer.ImportAsync(asset)) + { + case { Success: true }: + { + logger.LogInformation("Media file '{File}' imported", ksAttachment.AttachmentGUID); + return new MigrateAttachmentResultContentItem(true, true, asset.ContentItemGUID); + } + case { Success: false, Exception: { } exception }: + { + logger.LogError("Media file '{File}' not migrated: {Error}", ksAttachment.AttachmentGUID, exception); + return new MigrateAttachmentResultContentItem(false, true, null); + } + case { Success: false, ModelValidationResults: { } validation }: + { + foreach (var validationResult in validation) + { + logger.LogError("Media file '{File}' not migrated: {Members}: {Error}", ksAttachment.AttachmentGUID, string.Join(",", validationResult.MemberNames), validationResult.ErrorMessage); + } + + return new MigrateAttachmentResultContentItem(false, true, null); + } + default: + return new MigrateAttachmentResultContentItem(false, false, null); + } + } +} diff --git a/KVA/Migration.Toolkit.Source/Services/AttachmentMigrator.cs b/KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToMediaLibrary.cs similarity index 78% rename from KVA/Migration.Toolkit.Source/Services/AttachmentMigrator.cs rename to KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToMediaLibrary.cs index 2143382a..960acbbd 100644 --- a/KVA/Migration.Toolkit.Source/Services/AttachmentMigrator.cs +++ b/KVA/Migration.Toolkit.Source/Services/AttachmentMigratorToMediaLibrary.cs @@ -1,34 +1,33 @@ using System.Collections.Concurrent; using System.Diagnostics; using System.Text.RegularExpressions; - using CMS.Base; using CMS.Helpers; using CMS.MediaLibrary; - using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; - using Migration.Toolkit.Common; using Migration.Toolkit.Common.Abstractions; using Migration.Toolkit.Common.MigrationProtocol; using Migration.Toolkit.KXP.Api; using Migration.Toolkit.KXP.Api.Auxiliary; using Migration.Toolkit.KXP.Context; +using Migration.Toolkit.Source.Auxiliary; using Migration.Toolkit.Source.Mappers; using Migration.Toolkit.Source.Model; namespace Migration.Toolkit.Source.Services; -public class AttachmentMigrator( - ILogger logger, +public class AttachmentMigratorToMediaLibrary( + ILogger logger, KxpMediaFileFacade mediaFileFacade, IDbContextFactory kxpContextFactory, IEntityMapper attachmentMapper, IProtocol protocol, - ModelFacade modelFacade -) + ModelFacade modelFacade, + EntityIdentityFacade entityIdentityFacade +) : IAttachmentMigrator { private static readonly Regex sanitizationRegex = RegexHelper.GetRegex("[^-_a-z0-9]", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); @@ -39,11 +38,11 @@ ModelFacade modelFacade private readonly ConcurrentDictionary<(string libraryName, int siteId), int> mediaLibraryIdCache = new(); - public MigrateAttachmentResult TryMigrateAttachmentByPath(string documentPath, string additionalPath) + public async Task TryMigrateAttachmentByPath(string documentPath, string additionalPath) { if (string.IsNullOrWhiteSpace(documentPath)) { - return new MigrateAttachmentResult(false, false); + return new MigrateAttachmentResultMediaFile(false, false); } documentPath = $"/{documentPath.Trim('/')}"; @@ -64,11 +63,11 @@ FROM CMS_Document [D] JOIN var attachment = attachments.FirstOrDefault(); return attachment != null - ? MigrateAttachment(attachment, additionalPath) - : new MigrateAttachmentResult(false, false); + ? await MigrateAttachment(attachment, additionalPath) + : new MigrateAttachmentResultMediaFile(false, false); } - public IEnumerable MigrateGroupedAttachments(int documentId, Guid attachmentGroupGuid, string fieldName) + public async IAsyncEnumerable MigrateGroupedAttachments(int documentId, Guid attachmentGroupGuid, string fieldName) { var groupedAttachment = modelFacade.SelectWhere( """ @@ -81,14 +80,17 @@ public IEnumerable MigrateGroupedAttachments(int docume foreach (var cmsAttachment in groupedAttachment) { - yield return MigrateAttachment(cmsAttachment, $"__{fieldName}"); + yield return await MigrateAttachment(cmsAttachment, $"__{fieldName}"); } } - public MigrateAttachmentResult MigrateAttachment(Guid ksAttachmentGuid, string additionalPath) + public async Task MigrateAttachment(Guid ksAttachmentGuid, string additionalPath, int siteId) { var attachments = modelFacade - .SelectWhere("AttachmentGuid = @attachmentGuid", new SqlParameter("attachmentGuid", ksAttachmentGuid)) + .SelectWhere("AttachmentGuid = @attachmentGuid AND AttachmentSiteID = @siteId", + new SqlParameter("attachmentGuid", ksAttachmentGuid), + new SqlParameter("siteId", siteId) + ) .ToList(); switch (attachments) @@ -97,22 +99,22 @@ public MigrateAttachmentResult MigrateAttachment(Guid ksAttachmentGuid, string a { logger.LogWarning("Attachment '{AttachmentGuid}' not found! => skipping", ksAttachmentGuid); protocol.Append(HandbookReferences.TemporaryAttachmentMigrationIsNotSupported.WithData(new { AttachmentGuid = ksAttachmentGuid })); - return new MigrateAttachmentResult(false, true); + return new MigrateAttachmentResultMediaFile(false, true); } case [var attachment]: { - return MigrateAttachment(attachment, additionalPath); + return await MigrateAttachment(attachment, additionalPath); } default: { logger.LogWarning("Attachment '{AttachmentGuid}' found multiple times! => skipping", ksAttachmentGuid); protocol.Append(HandbookReferences.NonUniqueEntityGuid.WithData(new { AttachmentGuid = ksAttachmentGuid, AttachmentIds = attachments.Select(a => a.AttachmentID) })); - return new MigrateAttachmentResult(false, true); + return new MigrateAttachmentResultMediaFile(false, true); } } } - public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, string? additionalMediaPath = null) + public async Task MigrateAttachment(ICmsAttachment ksAttachment, string? additionalMediaPath = null) { protocol.FetchedSource(ksAttachment); @@ -120,7 +122,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st { logger.LogWarning("Attachment '{AttachmentGuid}' is temporary => skipping", ksAttachment.AttachmentGUID); protocol.Append(HandbookReferences.TemporaryAttachmentMigrationIsNotSupported.WithData(new { ksAttachment.AttachmentID, ksAttachment.AttachmentGUID, ksAttachment.AttachmentName, ksAttachment.AttachmentSiteID })); - return new MigrateAttachmentResult(false, true); + return new MigrateAttachmentResultMediaFile(false, true); } var ksAttachmentDocument = ksAttachment.AttachmentDocumentID is { } attachmentDocumentId @@ -134,7 +136,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st var site = modelFacade.SelectById(ksAttachment.AttachmentSiteID) ?? throw new InvalidOperationException("Site not exists!"); if (!TryEnsureTargetLibraryExists(ksAttachment.AttachmentSiteID, site.SiteName, out int targetMediaLibraryId)) { - return new MigrateAttachmentResult(false, false); + return new MigrateAttachmentResultMediaFile(false, false); } var uploadedFile = CreateUploadFileFromAttachment(ksAttachment); @@ -145,10 +147,15 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st .WithIdentityPrint(ksAttachment) .WithMessage("Failed to create dummy upload file containing data") ); - return new MigrateAttachmentResult(false, true); + return new MigrateAttachmentResultMediaFile(false, true); } - var mediaFile = mediaFileFacade.GetMediaFile(ksAttachment.AttachmentGUID); + (bool isFixed, var newAttachmentGuid) = entityIdentityFacade.Translate(ksAttachment); + if (isFixed) + { + logger.LogWarning("Attachment {Attachment} link will be broken, new guid {Guid} was required", new { ksAttachment.AttachmentSiteID, ksAttachment.AttachmentID, ksAttachment.AttachmentGUID }, newAttachmentGuid); + } + var mediaFile = mediaFileFacade.GetMediaFile(newAttachmentGuid); protocol.FetchedTarget(mediaFile); @@ -164,7 +171,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st librarySubFolder = Path.Combine(librarySubFolder, additionalMediaPath); } - var mapped = attachmentMapper.Map(new CmsAttachmentMapperSource(ksAttachment, targetMediaLibraryId, uploadedFile, librarySubFolder, ksNode), mediaFile); + var mapped = attachmentMapper.Map(new CmsAttachmentMapperSource(ksAttachment, newAttachmentGuid, targetMediaLibraryId, uploadedFile, librarySubFolder, ksNode), mediaFile); protocol.MappedTarget(mapped); if (mapped is (var mediaFileInfo, var newInstance) { Success: true }) @@ -183,7 +190,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st protocol.Success(ksAttachmentDocument, mediaFileInfo, mapped); logger.LogEntitySetAction(newInstance, mediaFileInfo); - return new MigrateAttachmentResult(true, true, mediaFileInfo, MediaLibraryInfoProvider.ProviderObject.Get(targetMediaLibraryId)); + return new MigrateAttachmentResultMediaFile(true, true, mediaFileInfo, MediaLibraryInfoProvider.ProviderObject.Get(targetMediaLibraryId)); } catch (Exception exception) { @@ -196,7 +203,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st } } - return new MigrateAttachmentResult(false, true); + return new MigrateAttachmentResultMediaFile(false, true); } private IUploadedFile? CreateUploadFileFromAttachment(ICmsAttachment attachment) @@ -207,6 +214,7 @@ public MigrateAttachmentResult MigrateAttachment(ICmsAttachment ksAttachment, st return DummyUploadedFile.FromStream(ms, attachment.AttachmentMimeType, attachment.AttachmentSize, attachment.AttachmentName); } + logger.LogWarning("Attachment binary is null! {Attachment}", new { attachment.AttachmentName, attachment.AttachmentSiteID, attachment.AttachmentID }); return null; } @@ -252,11 +260,5 @@ private static int MediaLibraryFactory((string libraryName, int siteId) arg, Med .CreateMediaLibrary(siteId, libraryDirectory, "Created by Xperience Migration.Toolkit", context.TargetLibraryCodeName, context.TargetLibraryDisplayName).LibraryID; } - public record MigrateAttachmentResult( - bool Success, - bool CanContinue, - MediaFileInfo? MediaFileInfo = null, - MediaLibraryInfo? MediaLibraryInfo = null); - private record MediaLibraryFactoryContext(KxpMediaFileFacade MediaFileFacade, string TargetLibraryCodeName, string TargetLibraryDisplayName, KxpContext DbContext); } diff --git a/KVA/Migration.Toolkit.Source/Services/IAttachmentMigrator.cs b/KVA/Migration.Toolkit.Source/Services/IAttachmentMigrator.cs new file mode 100644 index 00000000..a75d1a0e --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/IAttachmentMigrator.cs @@ -0,0 +1,32 @@ +using CMS.MediaLibrary; +using Migration.Toolkit.Source.Model; + +namespace Migration.Toolkit.Source.Services; + +public interface IAttachmentMigrator +{ + Task TryMigrateAttachmentByPath(string documentPath, string additionalPath); + IAsyncEnumerable MigrateGroupedAttachments(int documentId, Guid attachmentGroupGuid, string fieldName); + Task MigrateAttachment(Guid ksAttachmentGuid, string additionalPath, int siteId); + Task MigrateAttachment(ICmsAttachment ksAttachment, string? additionalMediaPath = null); +} + +public interface IMigrateAttachmentResult +{ + bool Success { get; init; } + bool CanContinue { get; init; } + void Deconstruct(out bool success, out bool canContinue) + { + success = Success; + canContinue = CanContinue; + } +} + +public record MigrateAttachmentResultMediaFile( + bool Success, + bool CanContinue, + MediaFileInfo? MediaFileInfo = null, + MediaLibraryInfo? MediaLibraryInfo = null +) : IMigrateAttachmentResult; + +public record MigrateAttachmentResultContentItem(bool Success, bool CanContinue, Guid? ContentItemGuid) : IMigrateAttachmentResult; diff --git a/KVA/Migration.Toolkit.Source/Services/IMediaFileMigrator.cs b/KVA/Migration.Toolkit.Source/Services/IMediaFileMigrator.cs new file mode 100644 index 00000000..0e7a9237 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/IMediaFileMigrator.cs @@ -0,0 +1,9 @@ +using Migration.Toolkit.Common; +using Migration.Toolkit.Common.Abstractions; + +namespace Migration.Toolkit.Source.Services; + +public interface IMediaFileMigrator +{ + Task Handle(MigrateMediaLibrariesCommand request, CancellationToken cancellationToken); +} diff --git a/KVA/Migration.Toolkit.Source/Services/MediaFileMigrator.cs b/KVA/Migration.Toolkit.Source/Services/MediaFileMigrator.cs new file mode 100644 index 00000000..ae06bdf9 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/MediaFileMigrator.cs @@ -0,0 +1,310 @@ +using System.Collections.Immutable; +using CMS.Base; +using CMS.MediaLibrary; +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Migration.Toolkit.Common; +using Migration.Toolkit.Common.Abstractions; +using Migration.Toolkit.Common.MigrationProtocol; +using Migration.Toolkit.KXP.Api; +using Migration.Toolkit.KXP.Api.Auxiliary; +using Migration.Toolkit.KXP.Context; +using Migration.Toolkit.KXP.Models; +using Migration.Toolkit.Source.Auxiliary; +using Migration.Toolkit.Source.Contexts; +using Migration.Toolkit.Source.Handlers; +using Migration.Toolkit.Source.Helpers; +using Migration.Toolkit.Source.Mappers; +using Migration.Toolkit.Source.Model; + +namespace Migration.Toolkit.Source.Services; + +public class MediaFileMigrator( + ILogger logger, + IDbContextFactory kxpContextFactory, + ModelFacade modelFacade, + KxpMediaFileFacade mediaFileFacade, + IEntityMapper mediaFileInfoMapper, + IEntityMapper mediaLibraryInfoMapper, + ToolkitConfiguration toolkitConfiguration, + PrimaryKeyMappingContext primaryKeyMappingContext, + EntityIdentityFacade entityIdentityFacade, + IProtocol protocol + ) : IMediaFileMigrator, IDisposable +{ + private const string DirMedia = "media"; + + private KxpContext kxpContext = kxpContextFactory.CreateDbContext(); + + public void Dispose() => kxpContext.Dispose(); + + public async Task Handle(MigrateMediaLibrariesCommand request, CancellationToken cancellationToken) + { + //var skippedMediaLibraries = new HashSet(); + // var unsuitableMediaLibraries = + // modelFacade.Select(""" + // SELECT LibraryName, LibraryGUID FROM Media_Library [ML] + // WHERE EXISTS( + // SELECT 1 + // FROM Media_Library [MLI] + // WHERE MLI.LibraryName = ML.LibraryName + // GROUP BY LibraryName + // HAVING COUNT(*) > 1 + // ) + // """, + // (reader, _) => new + // { + // LibraryName = reader.Unbox("LibraryName"), + // LibraryGuid = reader.Unbox("LibraryGUID") + // }); + // + // var groupedMls = unsuitableMediaLibraries + // .GroupBy(x => x.LibraryName) + // .Select(x => new { LibraryGuids = x.Select(y => y.LibraryGuid).ToArray(), LibraryName = x.Key }); + // + // foreach (var mlg in groupedMls) + // { + // logger.LogError( + // "Media libraries with LibraryGuid ({LibraryGuids}) have same LibraryName '{LibraryName}', due to removal of sites and media library globalization it is required to set unique LibraryName and LibraryFolder", + // string.Join(",", mlg.LibraryGuids), mlg.LibraryName); + // + // foreach (var libraryGuid in mlg.LibraryGuids) + // { + // if (libraryGuid is { } lg) + // { + // // skippedMediaLibraries.Add(lg); + // + // protocol.Append(HandbookReferences.NotCurrentlySupportedSkip() + // .WithMessage($"Media library '{mlg.LibraryName}' with LibraryGuid '{libraryGuid}' doesn't satisfy unique LibraryName and LibraryFolder condition for migration") + // .WithData(new { LibraryGuid = libraryGuid, mlg.LibraryName }) + // ); + // } + // } + // } + + var ksMediaLibraries = modelFacade.SelectAll(" ORDER BY LibraryID"); + + var nonUniqueLibraryNames = modelFacade.Select(""" + SELECT LibraryName FROM Media_Library GROUP BY LibraryName HAVING COUNT(*) > 1 + """, (reader, version) => reader.Unbox("LibraryName")) + .ToImmutableHashSet(StringComparer.InvariantCultureIgnoreCase); + + var migratedMediaLibraries = new List<(IMediaLibrary sourceLibrary, ICmsSite sourceSite, MediaLibraryInfo targetLibrary)>(); + foreach (var ksMediaLibrary in ksMediaLibraries) + { + (bool isFixed, var libraryGuid) = entityIdentityFacade.Translate(ksMediaLibrary); + if (isFixed) + { + logger.LogWarning("MediaLibrary {Library} has non-unique guid, new guid {Guid} was required", new { ksMediaLibrary.LibraryGUID, ksMediaLibrary.LibraryName, ksMediaLibrary.LibrarySiteID }, libraryGuid); + } + + protocol.FetchedSource(ksMediaLibrary); + + var mediaLibraryInfo = mediaFileFacade.GetMediaLibraryInfo(libraryGuid); + + protocol.FetchedTarget(mediaLibraryInfo); + + if (modelFacade.SelectById(ksMediaLibrary.LibrarySiteID) is not { } ksSite) + { + protocol.Append(HandbookReferences + .InvalidSourceData() + .WithId(nameof(MediaLibrary.LibraryId), ksMediaLibrary.LibraryID) + .WithMessage("Media library has missing site assigned") + ); + logger.LogError("Missing site, SiteID=={SiteId}", ksMediaLibrary.LibrarySiteID); + continue; + } + + string safeLibraryName = nonUniqueLibraryNames.Contains(ksMediaLibrary.LibraryName) + ? $"{ksSite.SiteName}_{ksMediaLibrary.LibraryName}" + : ksMediaLibrary.LibraryName; + + var mapped = mediaLibraryInfoMapper.Map(new MediaLibraryInfoMapperSource(ksMediaLibrary, ksSite, libraryGuid, safeLibraryName), mediaLibraryInfo); + protocol.MappedTarget(mapped); + + if (mapped is { Success: true } result) + { + (var mfi, bool newInstance) = result; + ArgumentNullException.ThrowIfNull(mfi, nameof(mfi)); + + try + { + mediaFileFacade.SetMediaLibrary(mfi); + + protocol.Success(ksMediaLibrary, mfi, mapped); + logger.LogEntitySetAction(newInstance, mfi); + } + catch (Exception ex) + { + await kxpContext.DisposeAsync(); // reset context errors + kxpContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); + + protocol.Append(HandbookReferences + .ErrorCreatingTargetInstance(ex) + .NeedsManualAction() + .WithIdentityPrint(mfi) + ); + logger.LogEntitySetError(ex, newInstance, mfi); + continue; + } + + primaryKeyMappingContext.SetMapping( + r => r.LibraryId, + ksMediaLibrary.LibraryID, + mfi.LibraryID + ); + + migratedMediaLibraries.Add((ksMediaLibrary, ksSite, mfi)); + } + } + + await RequireMigratedMediaFiles(migratedMediaLibraries, cancellationToken); + + return new GenericCommandResult(); + } + + private LoadMediaFileResult LoadMediaFileBinary(string? sourceMediaLibraryPath, string relativeFilePath, string contentType) + { + if (sourceMediaLibraryPath == null) + { + return new LoadMediaFileResult(false, null, ""); + } + + string filePath = Path.Combine(sourceMediaLibraryPath, relativeFilePath); + if (File.Exists(filePath)) + { + byte[] data = File.ReadAllBytes(filePath); + var dummyFile = DummyUploadedFile.FromByteArray(data, contentType, data.LongLength, Path.GetFileName(filePath)); + return new LoadMediaFileResult(true, dummyFile, filePath); + } + + return new LoadMediaFileResult(false, null, filePath); + } + + private async Task RequireMigratedMediaFiles(List<(IMediaLibrary sourceLibrary, ICmsSite sourceSite, MediaLibraryInfo targetLibrary)> migratedMediaLibraries, CancellationToken cancellationToken) + { + var kxoDbContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); + try + { + foreach (var (ksMediaLibrary, ksSite, targetMediaLibrary) in migratedMediaLibraries) + { + string? sourceMediaLibraryPath = null; + bool loadMediaFileData = false; + if (!toolkitConfiguration.MigrateOnlyMediaFileInfo.GetValueOrDefault(true) && + !string.IsNullOrWhiteSpace(toolkitConfiguration.KxCmsDirPath)) + { + string? cmsMediaLibrariesFolder = KenticoHelper.GetSettingsKey(modelFacade, ksSite.SiteID, "CMSMediaLibrariesFolder"); + if (cmsMediaLibrariesFolder != null) + { + if (Path.IsPathRooted(cmsMediaLibrariesFolder)) + { + sourceMediaLibraryPath = Path.Combine(cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + loadMediaFileData = true; + } + else + { + if (cmsMediaLibrariesFolder.StartsWith("~/")) + { + string cleared = $"{cmsMediaLibrariesFolder[2..]}".Replace("/", "\\"); + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cleared, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + loadMediaFileData = true; + } + else + { + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, cmsMediaLibrariesFolder, ksSite.SiteName, ksMediaLibrary.LibraryFolder); + loadMediaFileData = true; + } + } + } + else + { + sourceMediaLibraryPath = Path.Combine(toolkitConfiguration.KxCmsDirPath, ksSite.SiteName, DirMedia, ksMediaLibrary.LibraryFolder); + loadMediaFileData = true; + } + } + + var ksMediaFiles = modelFacade.SelectWhere("FileLibraryID = @FileLibraryId", new SqlParameter("FileLibraryId", ksMediaLibrary.LibraryID)); + + foreach (var ksMediaFile in ksMediaFiles) + { + protocol.FetchedSource(ksMediaFile); + + bool found = false; + IUploadedFile? uploadedFile = null; + string? fullMediaPath = ""; + if (loadMediaFileData) + { + (found, uploadedFile, fullMediaPath) = LoadMediaFileBinary(sourceMediaLibraryPath, ksMediaFile.FilePath, ksMediaFile.FileMimeType); + if (!found) + { + // report missing file (currently reported in mapper) + } + } + + string? librarySubfolder = Path.GetDirectoryName(ksMediaFile.FilePath); + + (bool isFixed, var safeMediaFileGuid) = entityIdentityFacade.Translate(ksMediaFile); + if (isFixed) + { + logger.LogWarning("MediaFile {File} has non-unique guid, new guid {Guid} was required", new { ksMediaFile.FileGUID, ksMediaFile.FileName, ksMediaFile.FileSiteID }, safeMediaFileGuid); + } + + var kxoMediaFile = mediaFileFacade.GetMediaFile(safeMediaFileGuid); + + protocol.FetchedTarget(kxoMediaFile); + + var source = new MediaFileInfoMapperSource(fullMediaPath, ksMediaFile, targetMediaLibrary.LibraryID, found ? uploadedFile : null, + librarySubfolder, toolkitConfiguration.MigrateOnlyMediaFileInfo.GetValueOrDefault(false), safeMediaFileGuid); + var mapped = mediaFileInfoMapper.Map(source, kxoMediaFile); + protocol.MappedTarget(mapped); + + if (mapped is { Success: true } result) + { + (var mf, bool newInstance) = result; + ArgumentNullException.ThrowIfNull(mf, nameof(mf)); + + try + { + if (newInstance) + { + mediaFileFacade.EnsureMediaFilePathExistsInLibrary(mf, targetMediaLibrary.LibraryID); + } + + mediaFileFacade.SetMediaFile(mf, newInstance); + await kxpContext.SaveChangesAsync(cancellationToken); + + protocol.Success(ksMediaFile, mf, mapped); + logger.LogEntitySetAction(newInstance, mf); + } + catch (Exception ex) + { + await kxoDbContext.DisposeAsync(); // reset context errors + kxoDbContext = await kxpContextFactory.CreateDbContextAsync(cancellationToken); + + protocol.Append(HandbookReferences + .ErrorCreatingTargetInstance(ex) + .NeedsManualAction() + .WithIdentityPrint(mf) + ); + logger.LogEntitySetError(ex, newInstance, mf); + continue; + } + + primaryKeyMappingContext.SetMapping( + r => r.FileId, + ksMediaFile.FileID, + mf.FileID + ); + } + } + } + } + finally + { + await kxoDbContext.DisposeAsync(); + } + } + + private record LoadMediaFileResult(bool Found, IUploadedFile? File, string? SearchedPath); +} diff --git a/KVA/Migration.Toolkit.Source/Services/MediaFileMigratorToContentItem.cs b/KVA/Migration.Toolkit.Source/Services/MediaFileMigratorToContentItem.cs new file mode 100644 index 00000000..f661d132 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/MediaFileMigratorToContentItem.cs @@ -0,0 +1,77 @@ +using System.Collections.Concurrent; +using CMS.ContentEngine.Internal; +using CMS.Core; +using Kentico.Xperience.UMT.Services; +using Microsoft.Extensions.Logging; +using Migration.Toolkit.Common; +using Migration.Toolkit.Common.Abstractions; +using Migration.Toolkit.Source.Handlers; +using Migration.Toolkit.Source.Model; + +namespace Migration.Toolkit.Source.Services; + +public class MediaFileMigratorToContentItem( + ILogger logger, + ModelFacade modelFacade, + IAssetFacade assetFacade, + IImporter importer + ) : IMediaFileMigrator +{ + public async Task Handle(MigrateMediaLibrariesCommand request, CancellationToken cancellationToken) + { + await MigrateToAssets(); + return new GenericCommandResult(); + } + + private async Task MigrateToAssets() + { + var ksMediaFiles = modelFacade.SelectAll(" ORDER BY FileLibraryID"); + var ksMediaLibraries = new ConcurrentDictionary(); + var ksSites = new ConcurrentDictionary(); + var contentLanguageRetriever = Service.Resolve(); + var defaultContentLanguage = await contentLanguageRetriever.GetDefaultContentLanguage(); + + await assetFacade.PreparePrerequisites(); + + foreach (var ksMediaFile in ksMediaFiles) + { + if (ksSites.GetOrAdd(ksMediaFile.FileSiteID, siteId => modelFacade.SelectById(siteId)) is not { } ksSite) + { + logger.LogError("Media file '{File}' site not found", ksMediaFile); + continue; + } + if (ksMediaLibraries.GetOrAdd(ksMediaFile.FileLibraryID, libraryId => modelFacade.SelectById(libraryId)) is not { } ksMediaLibrary) + { + logger.LogError("Media file '{File}' library not found", ksMediaFile); + continue; + } + + var umtContentItem = await assetFacade.FromMediaFile(ksMediaFile, ksMediaLibrary, ksSite, [defaultContentLanguage.ContentLanguageName]); + + switch (await importer.ImportAsync(umtContentItem)) + { + case { Success: true }: + { + logger.LogInformation("Media file '{File}' imported", ksMediaFile.FileGUID); + break; + } + case { Success: false, Exception: { } exception }: + { + logger.LogError("Media file '{File}' not migrated: {Error}", ksMediaFile.FileGUID, exception); + break; + } + case { Success: false, ModelValidationResults: { } validation }: + { + foreach (var validationResult in validation) + { + logger.LogError("Media file '{File}' not migrated: {Members}: {Error}", ksMediaFile.FileGUID, string.Join(",", validationResult.MemberNames), validationResult.ErrorMessage); + } + + break; + } + default: + throw new ArgumentOutOfRangeException(); + } + } + } +} diff --git a/KVA/Migration.Toolkit.Source/Services/Model/MediaFilesSelectorItem.cs b/KVA/Migration.Toolkit.Source/Services/Model/MediaFilesSelectorItem.cs new file mode 100644 index 00000000..79e4dda3 --- /dev/null +++ b/KVA/Migration.Toolkit.Source/Services/Model/MediaFilesSelectorItem.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; + +namespace Migration.Toolkit.Source.Services.Model; + +// +// Summary: +// Represents item for media files selector. +public class MediaFilesSelectorItem +{ + // + // Summary: + // Media file GUID. + [JsonProperty("fileGuid")] + public Guid FileGuid { get; set; } +} diff --git a/KVA/Migration.Toolkit.Source/Services/PrimaryKeyLocatorService.cs b/KVA/Migration.Toolkit.Source/Services/PrimaryKeyLocatorService.cs index 99102890..91b0079f 100644 --- a/KVA/Migration.Toolkit.Source/Services/PrimaryKeyLocatorService.cs +++ b/KVA/Migration.Toolkit.Source/Services/PrimaryKeyLocatorService.cs @@ -1,5 +1,4 @@ using System.Linq.Expressions; - using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; diff --git a/Migration.Toolkit.CLI/Program.cs b/Migration.Toolkit.CLI/Program.cs index 5898a86f..8bb02253 100644 --- a/Migration.Toolkit.CLI/Program.cs +++ b/Migration.Toolkit.CLI/Program.cs @@ -21,6 +21,7 @@ using Migration.Toolkit.KX13; using Migration.Toolkit.KXP; using Migration.Toolkit.KXP.Api; +using Migration.Toolkit.KXP.Api.Services.CmsClass; using Migration.Toolkit.KXP.Context; using Migration.Toolkit.Source; @@ -37,6 +38,8 @@ .Build() ; +Directory.SetCurrentDirectory(config.GetValue("Settings:XbKDirPath") ?? throw new InvalidOperationException("Settings:XbKDirPath must be set to valid directory path")); + var validationErrors = ConfigurationValidator.GetValidationErrors(config); bool anyValidationErrors = false; foreach ((var validationMessageType, string message, string? recommendedFix) in validationErrors) @@ -91,6 +94,8 @@ var kxpApiSettings = settingsSection.GetSection(ConfigurationNames.XbKApiSettings); settings.SetXbKConnectionStringIfNotEmpty(kxpApiSettings["ConnectionStrings:CMSConnectionString"]); +FieldMappingInstance.PrepareFieldMigrations(settings); + var services = new ServiceCollection(); services @@ -107,7 +112,7 @@ }); -services.UseKsToolkitCore(); +services.UseKsToolkitCore(settings.MigrateMediaToMediaLibrary); await using var conn = new SqlConnection(settings.KxConnectionString); try { diff --git a/Migration.Toolkit.CLI/appsettings.json b/Migration.Toolkit.CLI/appsettings.json index d9da159d..7fb9cf9a 100644 --- a/Migration.Toolkit.CLI/appsettings.json +++ b/Migration.Toolkit.CLI/appsettings.json @@ -16,15 +16,17 @@ } }, "Settings": { + "MigrationProtocolPath": "C:\\Logs\\protocol.txt", "KxConnectionString": "[TODO]", "KxCmsDirPath": "[TODO]", "XbKDirPath": "[TODO]", - "MigrateOnlyMediaFileInfo": false, + "MigrateOnlyMediaFileInfo": true, "XbKApiSettings": { "ConnectionStrings": { "CMSConnectionString": "[TODO]" } }, + "MigrateMediaToMediaLibrary": false, "CreateReusableFieldSchemaForClasses": "", "OptInFeatures": { "QuerySourceInstanceApi": { diff --git a/Migration.Toolkit.Common/CommonDiExtensions.cs b/Migration.Toolkit.Common/CommonDiExtensions.cs index 0e5676eb..1ad522a3 100644 --- a/Migration.Toolkit.Common/CommonDiExtensions.cs +++ b/Migration.Toolkit.Common/CommonDiExtensions.cs @@ -11,6 +11,7 @@ public static IServiceCollection UseToolkitCommon(this IServiceCollection servic services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); return services; } } diff --git a/Migration.Toolkit.Common/ConfigurationNames.cs b/Migration.Toolkit.Common/ConfigurationNames.cs index 05b360ee..4acc5221 100644 --- a/Migration.Toolkit.Common/ConfigurationNames.cs +++ b/Migration.Toolkit.Common/ConfigurationNames.cs @@ -15,8 +15,10 @@ public class ConfigurationNames public const string MigrationProtocolPath = "MigrationProtocolPath"; public const string Enabled = "Enabled"; public const string Connections = "Connections"; + public const string UrlProtocol = "UrlProtocol"; public const string MemberIncludeUserSystemFields = "MemberIncludeUserSystemFields"; + public const string MigrateMediaToMediaLibrary = "MigrateMediaToMediaLibrary"; public const string ExcludeCodeNames = "ExcludeCodeNames"; public const string ExplicitPrimaryKeyMapping = "ExplicitPrimaryKeyMapping"; diff --git a/Migration.Toolkit.Common/Helpers/GuidHelper.cs b/Migration.Toolkit.Common/Helpers/GuidHelper.cs index 8dd83da8..5aa2ac58 100644 --- a/Migration.Toolkit.Common/Helpers/GuidHelper.cs +++ b/Migration.Toolkit.Common/Helpers/GuidHelper.cs @@ -8,6 +8,8 @@ public static class GuidHelper public static readonly Guid GuidNsNode = new("8691FEE4-FFFF-4642-8605-1B20B9D05360"); public static readonly Guid GuidNsTaxonomy = new("7F23EF23-F9AE-4DB8-914B-96964E6E78E6"); public static readonly Guid GuidNsDocumentNameField = new("8935FCE5-1BDC-4677-A4CA-6DFD32F65A0F"); + public static readonly Guid GuidNsAsset = new("9CC6DE90-8993-42D8-B4C1-1429B2F780A2"); + public static readonly Guid GuidNsFolder = new("E21255AC-70F3-4A95-881A-E4AD908AF27C"); public static Guid CreateWebPageUrlPathGuid(string hash) => GuidV5.NewNameBased(GuidNsWebPageUrlPathInfo, hash); public static Guid CreateReusableSchemaGuid(string name) => GuidV5.NewNameBased(GuidNsReusableSchema, name); @@ -15,4 +17,10 @@ public static class GuidHelper public static Guid CreateNodeGuid(string name) => GuidV5.NewNameBased(GuidNsNode, name); public static Guid CreateTaxonomyGuid(string name) => GuidV5.NewNameBased(GuidNsTaxonomy, name); public static Guid CreateDocumentNameFieldGuid(string name) => GuidV5.NewNameBased(GuidNsDocumentNameField, name); + public static Guid CreateAssetGuid(Guid newMediaFileGuid, string contentLanguageCode) => GuidV5.NewNameBased(GuidNsAsset, $"{newMediaFileGuid}|{contentLanguageCode}"); + public static Guid CreateFolderGuid(string path) => GuidV5.NewNameBased(GuidNsDocumentNameField, path); + + + public static readonly Guid GuidNsLibraryFallback = new("8935FCE5-1BDC-4677-A4CA-6DFD32F65A0F"); + public static Guid CreateGuidFromLibraryAndSiteID(string libraryName, int siteId) => GuidV5.NewNameBased(GuidNsLibraryFallback, $"{libraryName}|{siteId}"); } diff --git a/Migration.Toolkit.Common/Migration.Toolkit.Common.csproj b/Migration.Toolkit.Common/Migration.Toolkit.Common.csproj index 35cd2c15..ee48a656 100644 --- a/Migration.Toolkit.Common/Migration.Toolkit.Common.csproj +++ b/Migration.Toolkit.Common/Migration.Toolkit.Common.csproj @@ -16,7 +16,7 @@ - + diff --git a/Migration.Toolkit.Common/Services/BulkCopy/BulkDataCopyService.cs b/Migration.Toolkit.Common/Services/BulkCopy/BulkDataCopyService.cs index 98055e6e..12bb6a72 100644 --- a/Migration.Toolkit.Common/Services/BulkCopy/BulkDataCopyService.cs +++ b/Migration.Toolkit.Common/Services/BulkCopy/BulkDataCopyService.cs @@ -226,7 +226,6 @@ public IEnumerable GetSqlTableColumns(string tableName, string? conne { logger.LogTrace("[{Table}].{ColumnName} SKIPPED", tableName, columnName); } - // TODO tk: 2022-05-31 IS_NULLABLE, DATA_TYPE, ... check column compatibility } } } diff --git a/Migration.Toolkit.Common/ToolkitConfiguration.cs b/Migration.Toolkit.Common/ToolkitConfiguration.cs index e251b5db..40f1159f 100644 --- a/Migration.Toolkit.Common/ToolkitConfiguration.cs +++ b/Migration.Toolkit.Common/ToolkitConfiguration.cs @@ -40,6 +40,9 @@ public class ToolkitConfiguration [ConfigurationKeyName(ConfigurationNames.MemberIncludeUserSystemFields)] public string? MemberIncludeUserSystemFields { get; set; } + [ConfigurationKeyName(ConfigurationNames.MigrateMediaToMediaLibrary)] + public bool MigrateMediaToMediaLibrary { get; set; } + [ConfigurationKeyName(ConfigurationNames.CreateReusableFieldSchemaForClasses)] public string? CreateReusableFieldSchemaForClasses { get; set; } @@ -97,4 +100,7 @@ public void SetXbKConnectionStringIfNotEmpty(string? connectionString) public string? XbKDirPath { get; set; } = null; #endregion + + [ConfigurationKeyName(ConfigurationNames.UrlProtocol)] + public string? UrlProtocol { get; set; } } diff --git a/Migration.Toolkit.Common/UrlProtocol.cs b/Migration.Toolkit.Common/UrlProtocol.cs new file mode 100644 index 00000000..1b616456 --- /dev/null +++ b/Migration.Toolkit.Common/UrlProtocol.cs @@ -0,0 +1,84 @@ +namespace Migration.Toolkit.Common; + +public class UrlProtocol : IDisposable, IAsyncDisposable +{ + private readonly bool migrationToAssets; + private readonly StreamWriter streamWriter; + + public UrlProtocol(ToolkitConfiguration toolkitConfiguration) + { + string? dirName = Path.GetDirectoryName(toolkitConfiguration.UrlProtocol); + string? fileName = Path.GetFileNameWithoutExtension(toolkitConfiguration.UrlProtocol); + string? extension = Path.GetExtension(toolkitConfiguration.UrlProtocol); + if (!Directory.Exists(dirName)) + { + throw new InvalidOperationException($"Directory {dirName} does not exist"); + } + + streamWriter = new StreamWriter(Path.Combine(dirName, $"{fileName}_{DateTime.UtcNow:yyyyMMdd_hhmm}{extension}")); + migrationToAssets = !toolkitConfiguration.MigrateMediaToMediaLibrary; + } + + #region Media file urls + + // https://docs.kentico.com/13/developing-websites/retrieving-content/displaying-content-from-media-libraries#getting-media-file-urls + + public record MediaFileUrlInfo(string MediaLibraryFolder, Guid MediaGuid, string FileName, int SiteId, Guid NewMediaGuid, string NewLibraryFolder); + + public void AppendMediaFileUrlIfNeeded(MediaFileUrlInfo info) + { + (string? mediaLibraryFolder, var mediaGuid, string fileName, int siteId, var newMediaGuid, string? newLibraryFolder) = info; + + if (migrationToAssets) + { + + } + else + { + // Relative path: ~/getmedia/0140bccc-9d47-41ea-94a9-ca5d35b2964c/sample_image.jpg + if (mediaGuid != newMediaGuid) + { + FormatAndWriteUriRow($"~/getmedia/{mediaGuid}/{fileName}", $"~/getmedia/{newMediaGuid}/{fileName}", "mediafile", siteId); + } + + // Direct path: ~/MediaLibraryFolder/sample_image.jpg + if (mediaLibraryFolder != newLibraryFolder) + { + FormatAndWriteUriRow($"~/{mediaLibraryFolder}/{fileName}", $"~/{newLibraryFolder}/{fileName}", "mediafile", siteId); + } + } + } + + #endregion + + #region Attachment file urls + + // https://docs.kentico.com/13/developing-websites/retrieving-content/displaying-page-attachments#getting-page-attachment-urls + + public record AttachmentUrlInfo(Guid AttachmentGuid, string AttachmentFileName, int SiteId, Guid NewMediaGuid, string NewLibraryFolder); + + public void AppendAttachmentUrlIfNeeded(AttachmentUrlInfo info) + { + (var attachmentGuid, string? attachmentFileName, int siteId, var newMediaGuid, _) = info; + if (migrationToAssets) + { + + } + else + { + // Relative path: ~/getattachment/0140bccc-9d47-41ea-94a9-ca5d35b2964c/sample_image.jpg + FormatAndWriteUriRow($"~/getattachment/{attachmentGuid}/{attachmentFileName}", $"~/getmedia/{newMediaGuid}/{attachmentFileName}", "attachment", siteId); + + // AbsoluteUrl: + } + } + + #endregion + + + private void FormatAndWriteUriRow(string oldUrl, string newUrl, string kind, int siteId) => streamWriter.WriteLine($"{kind}|{oldUrl}|{newUrl}|{siteId}"); + + public void Dispose() => streamWriter.Dispose(); + + public async ValueTask DisposeAsync() => await streamWriter.DisposeAsync(); +} diff --git a/Migration.Toolkit.Core.K11/Mappers/MemberInfoMapper.cs b/Migration.Toolkit.Core.K11/Mappers/MemberInfoMapper.cs index 7c5c1a95..5088982b 100644 --- a/Migration.Toolkit.Core.K11/Mappers/MemberInfoMapper.cs +++ b/Migration.Toolkit.Core.K11/Mappers/MemberInfoMapper.cs @@ -57,9 +57,6 @@ protected override MemberInfo MapInternal(MemberInfoMapperSource source, MemberI // target.UserName = source.UserName; target.MemberName = user.UserName; - // target.FirstName = source.FirstName; // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.LastName = source.LastName; // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.Email = source.Email; target.MemberEmail = user.Email; @@ -72,20 +69,16 @@ protected override MemberInfo MapInternal(MemberInfoMapperSource source, MemberI target.SetValue("UserCreated", user.UserCreated); target.MemberCreated = user.UserCreated.GetValueOrDefault(); - // target.SetValue("LastLogon", source.LastLogon); // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.UserGUID = source.UserGuid; target.MemberGuid = user.UserGuid; - // target.UserLastModified = source.UserLastModified; // TODO tomas.krch: 2023-04-11 configurable autocreate - target.MemberSecurityStamp = user.UserSecurityStamp; // TODO tomas.krch: 2023-04-11 still relevant? + target.MemberSecurityStamp = user.UserSecurityStamp; // OBSOLETE: target.UserAdministrationAccess = source.UserPrivilegeLevel == 3; // OBSOLETE: target.UserIsPendingRegistration = false; // OBSOLETE: target.UserPasswordLastChanged = null; // OBSOLETE: target.UserRegistrationLinkExpiration = DateTime.Now.AddDays(365); - // TODO tomas.krch: 2023-04-11 migrate customized fields var customized = kxpClassFacade.GetCustomizedFieldInfosAll(MemberInfo.TYPEINFO.ObjectClassName); foreach (var customizedFieldInfo in customized) { diff --git a/Migration.Toolkit.Core.KX12/Handlers/MigrateContactManagementCommandHandler.cs b/Migration.Toolkit.Core.KX12/Handlers/MigrateContactManagementCommandHandler.cs index 0a7a2904..ab71c6e3 100644 --- a/Migration.Toolkit.Core.KX12/Handlers/MigrateContactManagementCommandHandler.cs +++ b/Migration.Toolkit.Core.KX12/Handlers/MigrateContactManagementCommandHandler.cs @@ -245,7 +245,7 @@ private ValueInterceptorResult ContactValueInterceptor(int ordinal, string colum #region "Migrate contact activities" - private CommandResult? MigrateContactActivities() //(List migratedSiteIds) + private CommandResult? MigrateContactActivities() { var requiredColumnsForContactMigration = new Dictionary { @@ -287,8 +287,8 @@ private ValueInterceptorResult ContactValueInterceptor(int ordinal, string colum // _primaryKeyMappingContext.PreloadDependencies(u => u.ContactId); var bulkCopyRequest = new BulkCopyRequestExtended("OM_Activity", - s => true, // s => s != "ActivityID", - reader => true, // migratedSiteIds.Contains(reader.GetInt32(reader.GetOrdinal("ActivitySiteID"))), // TODO tk: 2022-07-07 move condition to source query + s => true, + reader => true, 50000, requiredColumnsForContactMigration, ActivityValueInterceptor, diff --git a/Migration.Toolkit.Core.KX12/Migration.Toolkit.Core.KX12.csproj b/Migration.Toolkit.Core.KX12/Migration.Toolkit.Core.KX12.csproj index 12570c59..14dd9573 100644 --- a/Migration.Toolkit.Core.KX12/Migration.Toolkit.Core.KX12.csproj +++ b/Migration.Toolkit.Core.KX12/Migration.Toolkit.Core.KX12.csproj @@ -12,8 +12,4 @@ - - - - diff --git a/Migration.Toolkit.Core.KX13/Handlers/MigrateContactManagementCommandHandler.cs b/Migration.Toolkit.Core.KX13/Handlers/MigrateContactManagementCommandHandler.cs index 44834225..52e6ea3a 100644 --- a/Migration.Toolkit.Core.KX13/Handlers/MigrateContactManagementCommandHandler.cs +++ b/Migration.Toolkit.Core.KX13/Handlers/MigrateContactManagementCommandHandler.cs @@ -282,8 +282,8 @@ private ValueInterceptorResult ContactValueInterceptor(int ordinal, string colum } var bulkCopyRequest = new BulkCopyRequestExtended("OM_Activity", - s => true, // s => s != "ActivityID", - reader => true, // migratedSiteIds.Contains(reader.GetInt32(reader.GetOrdinal("ActivitySiteID"))), // TODO tk: 2022-07-07 move condition to source query + s => true, + reader => true, 50000, requiredColumnsForContactMigration, ActivityValueInterceptor, diff --git a/Migration.Toolkit.Core.KX13/Mappers/MemberInfoMapper.cs b/Migration.Toolkit.Core.KX13/Mappers/MemberInfoMapper.cs index fd0875e4..b59e9cec 100644 --- a/Migration.Toolkit.Core.KX13/Mappers/MemberInfoMapper.cs +++ b/Migration.Toolkit.Core.KX13/Mappers/MemberInfoMapper.cs @@ -56,9 +56,6 @@ protected override MemberInfo MapInternal(MemberInfoMapperSource source, MemberI // target.UserName = source.UserName; target.MemberName = user.UserName; - // target.FirstName = source.FirstName; // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.LastName = source.LastName; // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.Email = source.Email; target.MemberEmail = user.Email; @@ -71,20 +68,16 @@ protected override MemberInfo MapInternal(MemberInfoMapperSource source, MemberI target.SetValue("UserCreated", user.UserCreated); target.MemberCreated = user.UserCreated.GetValueOrDefault(); - // target.SetValue("LastLogon", source.LastLogon); // TODO tomas.krch: 2023-04-11 configurable autocreate - // target.UserGUID = source.UserGuid; target.MemberGuid = user.UserGuid; - // target.UserLastModified = source.UserLastModified; // TODO tomas.krch: 2023-04-11 configurable autocreate - target.MemberSecurityStamp = user.UserSecurityStamp; // TODO tomas.krch: 2023-04-11 still relevant? + target.MemberSecurityStamp = user.UserSecurityStamp; // OBSOLETE: target.UserAdministrationAccess = source.UserPrivilegeLevel == 3; // OBSOLETE: target.UserIsPendingRegistration = false; // OBSOLETE: target.UserPasswordLastChanged = null; // OBSOLETE: target.UserRegistrationLinkExpiration = DateTime.Now.AddDays(365); - // TODO tomas.krch: 2023-04-11 migrate customized fields var customized = kxpClassFacade.GetCustomizedFieldInfosAll(MemberInfo.TYPEINFO.ObjectClassName); foreach (var customizedFieldInfo in customized) { diff --git a/Migration.Toolkit.Core.KX13/Mappers/UserInfoMapper.cs b/Migration.Toolkit.Core.KX13/Mappers/UserInfoMapper.cs index 581852bd..1c503515 100644 --- a/Migration.Toolkit.Core.KX13/Mappers/UserInfoMapper.cs +++ b/Migration.Toolkit.Core.KX13/Mappers/UserInfoMapper.cs @@ -47,13 +47,8 @@ protected override UserInfo MapInternal(KX13M.CmsUser source, UserInfo target, b target.UserLastModified = source.UserLastModified; target.UserSecurityStamp = source.UserSecurityStamp; - // TODO tk: 2022-05-18 deduced - check target.UserAdministrationAccess = source.UserPrivilegeLevel == 3; - // TODO tk: 2022-05-18 deduce info target.UserIsPendingRegistration = false; - // TODO tk: 2022-05-18 deduce info - // target.UserPasswordLastChanged = null; - // TODO tk: 2022-05-18 deduce info target.UserRegistrationLinkExpiration = DateTime.Now.AddDays(365); var customizedFields = kxpClassFacade.GetCustomizedFieldInfos(UserInfo.TYPEINFO.ObjectClassName).ToList(); diff --git a/Migration.Toolkit.Core.KX13/Migration.Toolkit.Core.KX13.csproj b/Migration.Toolkit.Core.KX13/Migration.Toolkit.Core.KX13.csproj index dbe49596..af9b0455 100644 --- a/Migration.Toolkit.Core.KX13/Migration.Toolkit.Core.KX13.csproj +++ b/Migration.Toolkit.Core.KX13/Migration.Toolkit.Core.KX13.csproj @@ -12,7 +12,7 @@ - + diff --git a/Migration.Toolkit.KXP.Api/Migration.Toolkit.KXP.Api.csproj b/Migration.Toolkit.KXP.Api/Migration.Toolkit.KXP.Api.csproj index 4be7b8ce..d5ce7236 100644 --- a/Migration.Toolkit.KXP.Api/Migration.Toolkit.KXP.Api.csproj +++ b/Migration.Toolkit.KXP.Api/Migration.Toolkit.KXP.Api.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/Migration.Toolkit.KXP.Api/Services/CmsClass/FormDefinitionPatcher.cs b/Migration.Toolkit.KXP.Api/Services/CmsClass/FormDefinitionPatcher.cs index 078a5087..aeb6e738 100644 --- a/Migration.Toolkit.KXP.Api/Services/CmsClass/FormDefinitionPatcher.cs +++ b/Migration.Toolkit.KXP.Api/Services/CmsClass/FormDefinitionPatcher.cs @@ -227,7 +227,6 @@ private void PatchField(XElement field) visibleAttr?.SetValue(false); break; case TfcDirective.CopySourceControl: - // TODO tk: 2022-10-06 support only for custom controls logger.LogDebug("Field {FieldDescriptor} ControlName: Tca:{TcaDirective} => {ControlName}", fieldDescriptor, targetFormComponent, controlName); controlNameElem?.SetValue(controlName); PerformActionsOnField(field, fieldDescriptor, actions); @@ -404,10 +403,10 @@ private void PerformActionsOnField(XElement field, string fieldDescriptor, strin .EnsureElement(FieldElemSettings, settings => { settings.EnsureElement(SettingsMaximumpages, maxAssets => maxAssets.Value = SettingsMaximumpagesFallback); - settings.EnsureElement(SettingsRootpath, maxAssets => maxAssets.Value = SettingsRootpathFallback); // TODO tk: 2022-08-31 describe why? + settings.EnsureElement(SettingsRootpath, maxAssets => maxAssets.Value = SettingsRootpathFallback); }); - field.SetAttributeValue(FieldAttrSize, FieldAttrSizeZero); // TODO tk: 2022-08-31 describe why? + field.SetAttributeValue(FieldAttrSize, FieldAttrSizeZero); var settings = field.EnsureElement(FieldElemSettings); settings.EnsureElement("TreePath", element => element.Value = settings.Element("RootPath")?.Value ?? ""); diff --git a/Migration.Toolkit.KXP.Api/Services/CmsClass/FormFieldMappingModel.cs b/Migration.Toolkit.KXP.Api/Services/CmsClass/FormFieldMappingModel.cs index f8b1fea2..90139650 100644 --- a/Migration.Toolkit.KXP.Api/Services/CmsClass/FormFieldMappingModel.cs +++ b/Migration.Toolkit.KXP.Api/Services/CmsClass/FormFieldMappingModel.cs @@ -1,11 +1,9 @@ using System.Text.RegularExpressions; - using CMS.DataEngine; using CMS.OnlineForms; - +using Migration.Toolkit.Common; using Migration.Toolkit.Common.Enumerations; using Migration.Toolkit.KXP.Api.Auxiliary; - using FcLongText = Migration.Toolkit.Common.Enumerations.Kx13FormControls.UserControlForLongText; using FcText = Migration.Toolkit.Common.Enumerations.Kx13FormControls.UserControlForText; @@ -53,41 +51,61 @@ public static class SfcDirective public static class FieldMappingInstance { - public static FieldMigration[] BuiltInFieldMigrations => - [ - new FieldMigration(KsFieldDataType.ALL, FieldDataType.ALL, SfcDirective.CatchAnyNonMatching, null, [TfcDirective.Clear]), - new FieldMigration(KsFieldDataType.Unknown, FieldDataType.Unknown, SfcDirective.CatchAnyNonMatching, null, [TfcDirective.Clear]), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.TextBoxControl, FormComponents.AdminTextInputComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.DropDownListControl, FormComponents.AdminDropDownComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.IconSelector, FormComponents.AdminIconSelectorComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.Password, FormComponents.AdminPasswordComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.RadioButtonsControl, FormComponents.AdminRadioGroupComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.TextAreaControl, FormComponents.AdminTextAreaComponent), - new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent), - new FieldMigration(KsFieldDataType.LongText, FieldDataType.RichTextHTML, FcLongText.HtmlAreaControl, FormComponents.AdminRichTextEditorComponent, [TcaDirective.ConvertToRichText]), - new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.TextBoxControl, FormComponents.AdminTextInputComponent), - new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.DropDownListControl, FormComponents.AdminDropDownComponent), - new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.TextAreaControl, FormComponents.AdminTextAreaComponent), - new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextAreaComponent), - new FieldMigration(KsFieldDataType.Integer, FieldDataType.Integer, SfcDirective.CatchAnyNonMatching, FormComponents.AdminNumberInputComponent), - new FieldMigration(KsFieldDataType.LongInteger, FieldDataType.LongInteger, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear, [TfcDirective.Clear]), //FormComponents.AdminNumberInputComponent), - new FieldMigration(KsFieldDataType.Double, FieldDataType.Double, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear, [TfcDirective.Clear]), // FormComponents.AdminNumberInputComponent), - new FieldMigration(KsFieldDataType.Decimal, FieldDataType.Decimal, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDecimalNumberInputComponent), - new FieldMigration(KsFieldDataType.DateTime, FieldDataType.DateTime, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDateTimeInputComponent), - new FieldMigration(KsFieldDataType.Date, FieldDataType.Date, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDateInputComponent), - new FieldMigration(KsFieldDataType.TimeSpan, FieldDataType.TimeSpan, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent), - new FieldMigration(KsFieldDataType.Boolean, FieldDataType.Boolean, SfcDirective.CatchAnyNonMatching, FormComponents.AdminCheckBoxComponent), - new FieldMigration(KsFieldDataType.DocAttachments, FieldDataType.Assets, SfcDirective.CatchAnyNonMatching, FormComponents.AdminAssetSelectorComponent, [TcaDirective.ConvertToAsset]), - new FieldMigration(KsFieldDataType.File, FieldDataType.Assets, SfcDirective.CatchAnyNonMatching, FormComponents.AdminAssetSelectorComponent, [TcaDirective.ConvertToAsset]), - new FieldMigration(KsFieldDataType.Guid, FieldDataType.LongText, "RelatedDocuments", FormComponents.Kentico_Xperience_Admin_Websites_WebPageSelectorComponent, [TcaDirective.ConvertToPages]), - new FieldMigration(KsFieldDataType.Guid, FieldDataType.Guid, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear), - new FieldMigration(KsFieldDataType.Binary, FieldDataType.Binary, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear), - new FieldMigration(KsFieldDataType.Xml, FieldDataType.Xml, SfcDirective.CatchAnyNonMatching, FormComponents.AdminNumberWithLabelComponent), - new FieldMigration(KsFieldDataType.DocRelationships, FieldDataType.WebPages, SfcDirective.CatchAnyNonMatching, FormComponents.Kentico_Xperience_Admin_Websites_WebPageSelectorComponent, [TcaDirective.ConvertToPages]), + public static void PrepareFieldMigrations(ToolkitConfiguration configuration) + { + var m = new List(); + m.AddRange([ + new FieldMigration(KsFieldDataType.ALL, FieldDataType.ALL, SfcDirective.CatchAnyNonMatching, null, [TfcDirective.Clear]), + new FieldMigration(KsFieldDataType.Unknown, FieldDataType.Unknown, SfcDirective.CatchAnyNonMatching, null, [TfcDirective.Clear]), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.TextBoxControl, FormComponents.AdminTextInputComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.DropDownListControl, FormComponents.AdminDropDownComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.IconSelector, FormComponents.AdminIconSelectorComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.Password, FormComponents.AdminPasswordComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.RadioButtonsControl, FormComponents.AdminRadioGroupComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, FcText.TextAreaControl, FormComponents.AdminTextAreaComponent), + new FieldMigration(KsFieldDataType.Text, FieldDataType.Text, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent), + new FieldMigration(KsFieldDataType.LongText, FieldDataType.RichTextHTML, FcLongText.HtmlAreaControl, FormComponents.AdminRichTextEditorComponent, [TcaDirective.ConvertToRichText]), + new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.TextBoxControl, FormComponents.AdminTextInputComponent), + new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.DropDownListControl, FormComponents.AdminDropDownComponent), + new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, FcLongText.TextAreaControl, FormComponents.AdminTextAreaComponent), + new FieldMigration(KsFieldDataType.LongText, FieldDataType.LongText, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextAreaComponent), + new FieldMigration(KsFieldDataType.Integer, FieldDataType.Integer, SfcDirective.CatchAnyNonMatching, FormComponents.AdminNumberInputComponent), + new FieldMigration(KsFieldDataType.LongInteger, FieldDataType.LongInteger, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear, [TfcDirective.Clear]), //FormComponents.AdminNumberInputComponent), + new FieldMigration(KsFieldDataType.Double, FieldDataType.Double, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear, [TfcDirective.Clear]), // FormComponents.AdminNumberInputComponent), + new FieldMigration(KsFieldDataType.Decimal, FieldDataType.Decimal, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDecimalNumberInputComponent), + new FieldMigration(KsFieldDataType.DateTime, FieldDataType.DateTime, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDateTimeInputComponent), + new FieldMigration(KsFieldDataType.Date, FieldDataType.Date, SfcDirective.CatchAnyNonMatching, FormComponents.AdminDateInputComponent), + new FieldMigration(KsFieldDataType.TimeSpan, FieldDataType.TimeSpan, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent), + new FieldMigration(KsFieldDataType.Boolean, FieldDataType.Boolean, SfcDirective.CatchAnyNonMatching, FormComponents.AdminCheckBoxComponent), + new FieldMigration(KsFieldDataType.Guid, FieldDataType.LongText, "RelatedDocuments", FormComponents.Kentico_Xperience_Admin_Websites_WebPageSelectorComponent, [TcaDirective.ConvertToPages]), + new FieldMigration(KsFieldDataType.Guid, FieldDataType.Guid, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear), + new FieldMigration(KsFieldDataType.Binary, FieldDataType.Binary, SfcDirective.CatchAnyNonMatching, TfcDirective.Clear), + new FieldMigration(KsFieldDataType.Xml, FieldDataType.Xml, SfcDirective.CatchAnyNonMatching, FormComponents.AdminNumberWithLabelComponent), + new FieldMigration(KsFieldDataType.DocRelationships, FieldDataType.WebPages, SfcDirective.CatchAnyNonMatching, FormComponents.Kentico_Xperience_Admin_Websites_WebPageSelectorComponent, [TcaDirective.ConvertToPages]), + + new FieldMigration(KsFieldDataType.TimeSpan, FieldDataType.TimeSpan, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent, [TcaDirective.ConvertToPages]), + new FieldMigration(KsFieldDataType.BizFormFile, BizFormUploadFile.DATATYPE_FORMFILE, SfcDirective.CatchAnyNonMatching, FormComponents.MvcFileUploaderComponent, []) + ]); + + if (configuration.MigrateMediaToMediaLibrary) + { + m.AddRange([ + new FieldMigration(KsFieldDataType.DocAttachments, FieldDataType.Assets, SfcDirective.CatchAnyNonMatching, FormComponents.AdminAssetSelectorComponent, [TcaDirective.ConvertToAsset]), + new FieldMigration(KsFieldDataType.File, FieldDataType.Assets, SfcDirective.CatchAnyNonMatching, FormComponents.AdminAssetSelectorComponent, [TcaDirective.ConvertToAsset]), + ]); + } + else + { + m.AddRange([ + new FieldMigration(KsFieldDataType.DocAttachments, FieldDataType.ContentItemReference, SfcDirective.CatchAnyNonMatching, FormComponents.AdminContentItemSelectorComponent, [TcaDirective.ConvertToAsset]), + new FieldMigration(KsFieldDataType.File, FieldDataType.ContentItemReference, SfcDirective.CatchAnyNonMatching, FormComponents.AdminContentItemSelectorComponent, [TcaDirective.ConvertToAsset]), + ]); + } + + BuiltInFieldMigrations = [.. m]; + } - new FieldMigration(KsFieldDataType.TimeSpan, FieldDataType.TimeSpan, SfcDirective.CatchAnyNonMatching, FormComponents.AdminTextInputComponent, [TcaDirective.ConvertToPages]), - new FieldMigration(KsFieldDataType.BizFormFile, BizFormUploadFile.DATATYPE_FORMFILE, SfcDirective.CatchAnyNonMatching, FormComponents.MvcFileUploaderComponent, []) - ]; + public static FieldMigration[] BuiltInFieldMigrations { get; private set; } = null!; public static DataTypeMigrationModel BuiltInModel => new( BuiltInFieldMigrations, diff --git a/Migration.Toolkit.KXP.Extensions/Migration.Toolkit.KXP.Extensions.csproj b/Migration.Toolkit.KXP.Extensions/Migration.Toolkit.KXP.Extensions.csproj index 63b062d8..beea6162 100644 --- a/Migration.Toolkit.KXP.Extensions/Migration.Toolkit.KXP.Extensions.csproj +++ b/Migration.Toolkit.KXP.Extensions/Migration.Toolkit.KXP.Extensions.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Migration.Toolkit.Tests/Migration.Toolkit.Tests.csproj b/Migration.Toolkit.Tests/Migration.Toolkit.Tests.csproj index 87085552..d0d41fc9 100644 --- a/Migration.Toolkit.Tests/Migration.Toolkit.Tests.csproj +++ b/Migration.Toolkit.Tests/Migration.Toolkit.Tests.csproj @@ -5,7 +5,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive