Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves some build warnings in the ImportExport project. #4211

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
452 changes: 237 additions & 215 deletions DNN Platform/Modules/DnnExportImport/Components/Common/CompressionUtil.cs

Large diffs are not rendered by default.

123 changes: 65 additions & 58 deletions DNN Platform/Modules/DnnExportImport/Components/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,68 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

// ReSharper disable InconsistentNaming
namespace Dnn.ExportImport.Components.Common
{
using System;

public class Constants
{
/// <summary>
/// This is the currently supported schema version support as of this release.
/// In future releases thi must be updated to be compatible wiht th e.
/// </summary>
public const string CurrentSchemaVersion = "1.0.2";

// these are set by the API caller
public const string Category_Users = "USERS";
public const string Category_Vocabularies = "VOCABULARIES";
public const string Category_Roles = "ROLES";
public const string Category_ProfileProps = "PROFILE_PROPERTIES";
public const string Category_Content = "CONTENT";
public const string Category_Templates = "TEMPLATES";
public const string Category_Assets = "ASSETS";
public const string Category_Packages = "PACKAGES";
public const string Category_Themes = "THEMES";
public const string Category_Workflows = "WORKFLOW";

internal const string ExportFolder = @"\App_Data\ExportImport\";
internal const string ExportManifestName = "export.json"; // export manifest file name
internal const string ExportDbName = "export.dnndb"; // export database file name
internal const string ExportZipDbName = "export_db.zip"; // export compressed database file name
internal const string ExportZipFiles = "export_files.zip"; // Compressed assets file name
internal const string ExportZipTemplates = "export_templates.zip"; // Compressed templates file name
internal const string ExportZipPackages = "export_packages.zip"; // Compressed extension packages
internal const string ExportZipThemes = "export_themes.zip"; // Compressed site used themes

internal const string LogTypeSiteExport = "SITE_EXPORT";
internal const string LogTypeSiteImport = "SITE_IMPORT";

internal const string JobRunDateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff";
internal const string LastJobStartTimeKey = "EXPORT_LastJobStartTime";
internal const string MaxSecondsToRunJobKey = "MaxSecondsToRunJob";
internal const string PortalSettingExportKey = "PortalSettingExportList";
internal const string TemplatesExtension = "template";
internal const int DefaultPageSize = 1000;

internal const int LogColumnLength = 255;

internal const string SharedResources = "/DesktopModules/SiteExportImport/App_LocalResources/ExportImport.resx";

// these are added internally by the engine
internal const string Category_Portal = "PORTAL";
internal const string Category_Pages = "PAGES";
internal const string Category_UsersData = "USERS_DATA";

internal static DateTime MinDbTime = new DateTime(1980, 1, 1, 0, 0, 0, DateTimeKind.Utc);
internal static DateTime MaxDbTime = new DateTime(3000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
internal static int MaxZipFilesMemory = 104857600; // 100 MB
}
}
// ReSharper disable InconsistentNaming
namespace Dnn.ExportImport.Components.Common
{
using System;

/// <summary>
/// Lists constants used across the library.
/// </summary>
public class Constants
{
/// <summary>
/// This is the currently supported schema version support as of this release.
/// In future releases this must be updated to be compatible with the schema version.
/// </summary>
public const string CurrentSchemaVersion = "1.0.2";

// these are set by the API caller
#pragma warning disable SA1310 // Field names should not contain underscore, bypassing this warning in case something unexpected consumes these.
#pragma warning disable SA1600 // Elements should be documented, these names carry their meaning enough to not need documenting.
public const string Category_Users = "USERS";
public const string Category_Vocabularies = "VOCABULARIES";
public const string Category_Roles = "ROLES";
public const string Category_ProfileProps = "PROFILE_PROPERTIES";
public const string Category_Content = "CONTENT";
public const string Category_Templates = "TEMPLATES";
public const string Category_Assets = "ASSETS";
public const string Category_Packages = "PACKAGES";
public const string Category_Themes = "THEMES";
public const string Category_Workflows = "WORKFLOW";

internal const string ExportFolder = @"\App_Data\ExportImport\";
internal const string ExportManifestName = "export.json"; // export manifest file name
internal const string ExportDbName = "export.dnndb"; // export database file name
internal const string ExportZipDbName = "export_db.zip"; // export compressed database file name
internal const string ExportZipFiles = "export_files.zip"; // Compressed assets file name
internal const string ExportZipTemplates = "export_templates.zip"; // Compressed templates file name
internal const string ExportZipPackages = "export_packages.zip"; // Compressed extension packages
internal const string ExportZipThemes = "export_themes.zip"; // Compressed site used themes

internal const string LogTypeSiteExport = "SITE_EXPORT";
internal const string LogTypeSiteImport = "SITE_IMPORT";

internal const string JobRunDateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff";
internal const string LastJobStartTimeKey = "EXPORT_LastJobStartTime";
internal const string MaxSecondsToRunJobKey = "MaxSecondsToRunJob";
internal const string PortalSettingExportKey = "PortalSettingExportList";
internal const string TemplatesExtension = "template";
internal const int DefaultPageSize = 1000;

internal const int LogColumnLength = 255;

internal const string SharedResources = "/DesktopModules/SiteExportImport/App_LocalResources/ExportImport.resx";

// these are added internally by the engine
internal const string Category_Portal = "PORTAL";
internal const string Category_Pages = "PAGES";
internal const string Category_UsersData = "USERS_DATA";

internal static readonly DateTime MinDbTime = new DateTime(1980, 1, 1, 0, 0, 0, DateTimeKind.Utc);
internal static readonly DateTime MaxDbTime = new DateTime(3000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
internal static readonly int MaxZipFilesMemory = 104857600; // 100 MB
#pragma warning restore SA1310 // Field names should not contain underscore
#pragma warning restore SA1600 // Elements should be documented
}
}
157 changes: 107 additions & 50 deletions DNN Platform/Modules/DnnExportImport/Components/Common/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,110 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace Dnn.ExportImport.Components.Common
{
public enum JobType
{
Export = 0, // never change these numbers
Import,
}

public enum JobStatus
{
Submitted = 0, // never change these numbers
InProgress,
Successful,
Failed,
Cancelled,
}

/// <summary>
/// Mode for export job.
/// </summary>
public enum ExportMode
{
Full = 0,
Differential = 1,
}

/// <summary>
/// Specifies what to do when there is a collision during the import process.
/// </summary>
public enum CollisionResolution
{
/// <summary>
/// Ignore the imported item and continue.
/// </summary>
Ignore,

/// <summary>
/// Overwrites the existing item upon importing.
/// </summary>
Overwrite,
}

public enum ReportLevel
{
Verbose,
Info,
Warn,
Error,
}
}
namespace Dnn.ExportImport.Components.Common
{
/// <summary>
/// Defines the possible job types.
/// </summary>
public enum JobType
{
/// <summary>
/// An export job.
/// </summary>
Export = 0, // never change these numbers

/// <summary>
/// An import job.
/// </summary>
Import,
}

/// <summary>
/// Defines the possible job statuses.
/// </summary>
public enum JobStatus
{
/// <summary>
/// The job was submitted but not yet started.
/// </summary>
Submitted = 0, // never change these numbers

/// <summary>
/// The job is currently in progress.
/// </summary>
InProgress,

/// <summary>
/// The job completed successfully.
/// </summary>
Successful,

/// <summary>
/// The job completed but failed.
/// </summary>
Failed,

/// <summary>
/// The job was cancelled.
/// </summary>
Cancelled,
}

/// <summary>
/// Mode for export job.
/// </summary>
public enum ExportMode
{
/// <summary>
/// Exports the full content.
/// </summary>
Full = 0,

/// <summary>
/// Exports the difference only.
/// </summary>
Differential = 1,
}

/// <summary>
/// Specifies what to do when there is a collision during the import process.
/// </summary>
public enum CollisionResolution
{
/// <summary>
/// Ignore the imported item and continue.
/// </summary>
Ignore,

/// <summary>
/// Overwrites the existing item upon importing.
/// </summary>
Overwrite,
}

/// <summary>
/// Defines the possible report (log) levels.
/// </summary>
public enum ReportLevel
{
/// <summary>
/// Reports everything.
/// </summary>
Verbose,

/// <summary>
/// Reports information, warnings and errors.
/// </summary>
Info,

/// <summary>
/// Reports warnings and errors.
/// </summary>
Warn,

/// <summary>
/// Reports errors only.
/// </summary>
Error,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,46 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace Dnn.ExportImport.Components.Common
{
using System.Collections.Generic;
using System.Linq;
namespace Dnn.ExportImport.Components.Common
{
using System.Collections.Generic;
using System.Linq;

using Dnn.ExportImport.Components.Dto;
using Dnn.ExportImport.Components.Dto;

public class SummaryList : List<SummaryItem>
{
public new void Add(SummaryItem item)
{
if (this.Any(x => x.Category == item.Category))
{
this.First(x => x.Category == item.Category).TotalItems += item.TotalItems;
this.First(x => x.Category == item.Category).ProcessedItems += item.ProcessedItems;
}
else
{
base.Add(item);
}
}

public new void AddRange(IEnumerable<SummaryItem> items)
{
var summaryItems = items as IList<SummaryItem> ?? items.ToList();
foreach (var summaryItem in summaryItems.OrderBy(x => x.Order))
{
this.Add(summaryItem);
}
}
}
}
/// <summary>
/// Represents a collection of <see cref="SummaryItem"/>.
/// </summary>
public class SummaryList : List<SummaryItem>
{
/// <summary>
/// Adds an item to the list.
/// </summary>
/// <param name="item"><see cref="SummaryItem"/>.</param>
public new void Add(SummaryItem item)
{
if (this.Any(x => x.Category == item.Category))
{
this.First(x => x.Category == item.Category).TotalItems += item.TotalItems;
this.First(x => x.Category == item.Category).ProcessedItems += item.ProcessedItems;
}
else
{
base.Add(item);
}
}

/// <summary>
/// Adds multiple items to the collection.
/// </summary>
/// <param name="items">The items to add.</param>
public new void AddRange(IEnumerable<SummaryItem> items)
{
var summaryItems = items as IList<SummaryItem> ?? items.ToList();
foreach (var summaryItem in summaryItems.OrderBy(x => x.Order))
{
this.Add(summaryItem);
}
}
}
}
Loading