Skip to content

Commit

Permalink
DNN-25697 - Update processed item count in regardless the result of t…
Browse files Browse the repository at this point in the history
…he (#3492)

process import module package
- Stop the import process if the process is interuppted
  • Loading branch information
tingung authored and valadas committed Jan 17, 2020
1 parent fe7fc7a commit 6dac8c3
Showing 1 changed file with 45 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,44 @@ private ExportPackage GenerateExportPackage(string filePath)
return new ExportPackage { PackageFileName = fileName, PackageName = packageName, PackageType = packageType, Version = version };
}

private void ProcessImportModulePackage(ExportPackage exportPackage, String tempFolder, CollisionResolution collisionResolution)
{
try
{
var filePath = Path.Combine(tempFolder, exportPackage.PackageFileName);
if (!File.Exists(filePath))
{
return;
}

var packageType = exportPackage.PackageType;
var packageName = exportPackage.PackageName;
var version = exportPackage.Version;

var existPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger,
p => p.PackageType == packageType && p.Name == packageName);
if (existPackage != null &&
(existPackage.Version > version ||
(existPackage.Version == version &&
collisionResolution == CollisionResolution.Ignore)))
{
Result.AddLogEntry("Import Package ignores",
$"{packageName} has higher version {existPackage.Version} installed, ignore import it");
return;
}

InstallPackage(filePath);
Result.AddLogEntry("Import Package completed", $"{packageName} version: {version}");

}
catch (Exception ex)
{
Result.AddLogEntry("Import Package error",
$"{exportPackage.PackageName} : {exportPackage.Version} - {ex.Message}");
Logger.Error(ex);
}
}

private void ProcessImportModulePackages(ImportDto importDto)
{
var packageZipFile = $"{Globals.ApplicationMapPath}{Constants.ExportFolder}{_exportImportJob.Directory.TrimEnd('\\', '/')}\\{Constants.ExportZipPackages}";
Expand All @@ -173,42 +211,13 @@ private void ProcessImportModulePackages(ImportDto importDto)
{
foreach (var exportPackage in exportPackages)
{
try
{
var filePath = Path.Combine(tempFolder, exportPackage.PackageFileName);
if (!File.Exists(filePath))
{
continue;
}

var packageType = exportPackage.PackageType;
var packageName = exportPackage.PackageName;
var version = exportPackage.Version;

var existPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger,
p => p.PackageType == packageType && p.Name == packageName);
if (existPackage != null &&
(existPackage.Version > version ||
(existPackage.Version == version &&
importDto.CollisionResolution == CollisionResolution.Ignore)))
{
Result.AddLogEntry("Import Package ignores",
$"{packageName} has higher version {existPackage.Version} installed, ignore import it");
continue;
}

InstallPackage(filePath);
Result.AddLogEntry("Import Package completed", $"{packageName} version: {version}");
CheckPoint.ProcessedItems++;
CheckPoint.Progress = CheckPoint.ProcessedItems * 100.0 / exportPackages.Count;
CheckPointStageCallback(this); // just to update the counts without exit logic
}
catch (Exception ex)
{
Result.AddLogEntry("Import Package error",
$"{exportPackage.PackageName} : {exportPackage.Version} - {ex.Message}");
Logger.Error(ex);
}

ProcessImportModulePackage(exportPackage, tempFolder, importDto.CollisionResolution);

CheckPoint.ProcessedItems++;
CheckPoint.Progress = CheckPoint.ProcessedItems * 100.0 / exportPackages.Count;
if (CheckPointStageCallback(this)) break;

}
CheckPoint.Stage++;
CheckPoint.Completed = true;
Expand Down

0 comments on commit 6dac8c3

Please sign in to comment.