private void RunCreatePackage() { Log.Information("User action: Create package"); string suggestedOutputDirectory = new FileInfo(_archiveFileName).DirectoryName; var selectOutputDirectoryDialog = new CommonOpenFileDialog { Title = Resources.MetaDataGUI.SelectOutputDirectoryMessage, IsFolderPicker = true, InitialDirectory = suggestedOutputDirectory, DefaultFileName = suggestedOutputDirectory, }; string outputDirectory; if (selectOutputDirectoryDialog.ShowDialog() == CommonFileDialogResult.Ok) { outputDirectory = selectOutputDirectoryDialog.FileName; } else { return; } ProgressBarVisibility = Visibility.Visible; Log.Information("User action: Choose package destination {informationPackageDestination}", outputDirectory); _testSession.ArchiveMetadata = new ArchiveMetadata { Id = $"UUID:{_testSession.Archive.Uuid}", Label = ArchiveMetadataMapper.MapToLabel(_metaDataNoarkSection, StandardLabelIsSelected), 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)), Creator = ArchiveMetadataMapper.MapToCreator(_metaDataCreator), Recipient = ArchiveMetadataMapper.MapToRecipient(_metaDataRecipient), System = ArchiveMetadataMapper.MapToSystem(_metaDataSystem), ArchiveSystem = ArchiveMetadataMapper.MapToArchiveSystem(_metaDataArchiveSystem), StartDate = ArchiveMetadataMapper.MapToStartDate(_metaDataNoarkSection), EndDate = ArchiveMetadataMapper.MapToEndDate(_metaDataNoarkSection), ExtractionDate = ArchiveMetadataMapper.MapToExtractionDate(_metaDataExtractionDate), PackageType = ArchiveMetadataMapper.MapToPackageType(SelectedPackageTypeSip) }; _isRunningCreatePackage = true; CreatePackageCommand.RaiseCanExecuteChanged(); Task.Factory.StartNew(() => CreatePackageRunEngine(outputDirectory)).ContinueWith(t => OnCompletedCreatePackage()); }
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 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; } }