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

Implement migration.json support when importing #141

Merged
merged 5 commits into from
Nov 5, 2020
Merged
Changes from 3 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
29 changes: 29 additions & 0 deletions CDP4JsonFileDal/JsonFileDal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public class JsonFileDal : Dal
/// </summary>
private const string EngineeringModelZipLocation = "EngineeringModels";

/// <summary>
/// The application-dependent(extensions) files zip location.
adrianchivu marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
private const string ExtensionsZipLocation = "Extensions";

/// <summary>
/// The iteration zip location.
/// </summary>
Expand Down Expand Up @@ -243,6 +248,8 @@ public override Task<IEnumerable<Thing>> Write(IEnumerable<OperationContainer> o
this.WriteModelReferenceDataLibraryToZipFile(modelReferenceDataLibraries, zipFile, path);

this.WriteIterationsToZipFile(iterations, zipFile, path);

this.WriteExtraFilesToZipFile(files, zipFile, path);
adrianchivu marked this conversation as resolved.
Show resolved Hide resolved
}

Logger.Info("Successfully exported the open session {1} to {0}.", path, this.Session.Credentials.Uri);
Expand Down Expand Up @@ -806,6 +813,28 @@ private void WriteIterationsToZipFile(IEnumerable<CDP4Common.EngineeringModelDat
}
}

/// <summary>
/// Writes the application dependend files inside specific folder to the <see cref="ZipFile"/>
/// </summary>
/// <param name="extraFilesPath">The files list that will be written</param>
/// <param name="zipFile">The target <see cref="ZipFile"/></param>
/// <param name="filePath">The file of the target <see cref="ZipFile"/></param>
adrianchivu marked this conversation as resolved.
Show resolved Hide resolved
private void WriteExtraFilesToZipFile(IEnumerable<string> extraFilesPath, ZipFile zipFile, string filePath)
adrianchivu marked this conversation as resolved.
Show resolved Hide resolved
{
if (extraFilesPath is null)
{
return;
}

foreach (var extraFile in extraFilesPath)
{
var zipEntry = zipFile.AddFile(extraFile, ExtensionsZipLocation);
zipEntry.Comment = $"The {extraFile} file";
adrianchivu marked this conversation as resolved.
Show resolved Hide resolved
}

zipFile.Save(filePath);
}

/// <summary>
/// Reads SiteDirectory data from the archive
/// </summary>
Expand Down