private void RunCreatePackage() { Log.Information("User action: Create package"); _testSession.ArchiveMetadata = new ArchiveMetadata { Id = $"UUID:{_testSession.Archive.Uuid}", ArchiveDescription = ArchiveMetadataMapper.MapToArchiveDescription(_metaDataArchiveDescription), AgreementNumber = ArchiveMetadataMapper.MapToAgreementNumber(_metaDataArchiveDescription), ArchiveCreators = ArchiveMetadataMapper.MapToArchiveCreators(_metaDataArchiveCreators.Where(c => !c.IsDeleted)), Transferer = ArchiveMetadataMapper.MapToTransferer(_metaDataTransferer), Producer = ArchiveMetadataMapper.MapToProducer(_metaDataProducer), Owners = ArchiveMetadataMapper.MapToArchiveOwners(_metaDataOwners.Where(o => !o.IsDeleted)), Recipient = ArchiveMetadataMapper.MapToRecipient(_metaDataRecipient), System = ArchiveMetadataMapper.MapToSystem(_metaDataSystem), ArchiveSystem = ArchiveMetadataMapper.MapToArchiveSystem(_metaDataArchiveSystem), Comments = ArchiveMetadataMapper.MapToComments(_metaDataComments), StartDate = ArchiveMetadataMapper.MapToStartDate(_metaDataNoarkSection), EndDate = ArchiveMetadataMapper.MapToEndDate(_metaDataNoarkSection), }; _isRunningCreatePackage = true; CreatePackageCommand.RaiseCanExecuteChanged(); PackageType packageType = SelectedPackageTypeSip ? PackageType.SubmissionInformationPackage : PackageType.ArchivalInformationPackage; // todo must be async string informationPackageFileName = _testSession.Archive.GetInformationPackageFileName().FullName; try { _arkadeApi.CreatePackage(_testSession, packageType); StatusMessageText = "IP og metadata lagret i "; StatusMessagePath = informationPackageFileName; Log.Debug("Package created in " + informationPackageFileName); _isRunningCreatePackage = false; //CreatePackageCommand.RaiseCanExecuteChanged(); } catch { StatusMessageText = Resources.MetaDataUI.PackageCreationErrorStatusMessage; StatusMessagePath = informationPackageFileName; Log.Debug(string.Format(Resources.MetaDataUI.PackageCreationErrorLogMessage, informationPackageFileName)); _isRunningCreatePackage = false; } }
private void CreatePackageRunEngine(string outputDirectory) { try { string packageFilePath = _arkadeApi.CreatePackage(_testSession, outputDirectory); string packageOutputContainer = new FileInfo(packageFilePath).DirectoryName; string argument = "/select, \"" + packageOutputContainer + "\""; System.Diagnostics.Process.Start("explorer.exe", argument); StatusMessageText = "IP og metadata lagret i "; StatusMessagePath = packageOutputContainer; Log.Debug("Package created in " + packageOutputContainer); } catch (Exception exception) { if (exception is IOException) { StatusMessageText = Resources.MetaDataGUI.PackageCreationErrorStatusMessage; Log.Debug(Resources.MetaDataGUI.PackageCreationErrorLogMessage); } if (exception is InsufficientDiskSpaceException) { StatusMessageText = MetaDataGUI.UnsufficientDiskSpaceStatusMessage; Log.Debug(MetaDataGUI.UnsufficientDiskSpaceLogMessage); } string fileName = new DetailedExceptionMessage(exception).WriteToFile(); if (!string.IsNullOrEmpty(fileName)) { StatusMessagePath = string.Format(Resources.GUI.DetailedErrorMessageInfo, fileName); } _isRunningCreatePackage = false; } ProgressBarVisibility = Visibility.Hidden; }
private void RunCreatePackage() { Log.Information("User action: Create package"); string suggestedOutputDirectory = new FileInfo(_archiveFileName).DirectoryName; var selectOutputDirectoryDialog = new CommonOpenFileDialog { Title = Resources.MetaDataUI.SelectOutputDirectoryMessage, IsFolderPicker = true, InitialDirectory = suggestedOutputDirectory, DefaultFileName = suggestedOutputDirectory, }; string outputDirectory; if (selectOutputDirectoryDialog.ShowDialog() == CommonFileDialogResult.Ok) { outputDirectory = selectOutputDirectoryDialog.FileName; } else { return; } Log.Information("User action: Choose package destination {informationPackageDestination}", outputDirectory); _testSession.ArchiveMetadata = new ArchiveMetadata { Id = $"UUID:{_testSession.Archive.Uuid}", ArchiveDescription = ArchiveMetadataMapper.MapToArchiveDescription(_metaDataArchiveDescription), AgreementNumber = ArchiveMetadataMapper.MapToAgreementNumber(_metaDataArchiveDescription), ArchiveCreators = ArchiveMetadataMapper.MapToArchiveCreators(_metaDataArchiveCreators.Where(c => !c.IsDeleted)), Transferer = ArchiveMetadataMapper.MapToTransferer(_metaDataTransferer), Producer = ArchiveMetadataMapper.MapToProducer(_metaDataProducer), Owners = ArchiveMetadataMapper.MapToArchiveOwners(_metaDataOwners.Where(o => !o.IsDeleted)), Recipient = ArchiveMetadataMapper.MapToRecipient(_metaDataRecipient), System = ArchiveMetadataMapper.MapToSystem(_metaDataSystem), ArchiveSystem = ArchiveMetadataMapper.MapToArchiveSystem(_metaDataArchiveSystem), Comments = ArchiveMetadataMapper.MapToComments(_metaDataComments), StartDate = ArchiveMetadataMapper.MapToStartDate(_metaDataNoarkSection), EndDate = ArchiveMetadataMapper.MapToEndDate(_metaDataNoarkSection), ExtractionDate = ArchiveMetadataMapper.MapToExtractionDate(_metaDataExtractionDate), }; _isRunningCreatePackage = true; CreatePackageCommand.RaiseCanExecuteChanged(); PackageType packageType = SelectedPackageTypeSip ? PackageType.SubmissionInformationPackage : PackageType.ArchivalInformationPackage; // todo must be async try { string packageFilePath = _arkadeApi.CreatePackage(_testSession, packageType, outputDirectory); string packageOutputContainer = new FileInfo(packageFilePath).DirectoryName; string argument = "/select, \"" + packageOutputContainer + "\""; System.Diagnostics.Process.Start("explorer.exe", argument); StatusMessageText = "IP og metadata lagret i "; StatusMessagePath = packageOutputContainer; Log.Debug("Package created in " + packageOutputContainer); _isRunningCreatePackage = false; //CreatePackageCommand.RaiseCanExecuteChanged(); } catch (IOException exception) { StatusMessageText = Resources.MetaDataUI.PackageCreationErrorStatusMessage; Log.Debug(Resources.MetaDataUI.PackageCreationErrorLogMessage); string fileName = new DetailedExceptionMessage(exception).WriteToFile(); if (!string.IsNullOrEmpty(fileName)) { StatusMessagePath = string.Format(Resources.UI.DetailedErrorMessageInfo, fileName); } _isRunningCreatePackage = false; } }