private async Task ExportMaps() { if (importedMaps != null) { try { await mMigrator.MigrateToCloudIA(importedMaps.ToList(), this.ApplicationContext.GetService <IntegrationAccountDetails>()); } catch (Exception ex) { StatusBarViewModel.ShowError("(Error) " + ExceptionHelper.GetExceptionMessage(ex)); } finally { foreach (var map in importedMaps) { ExportedItems.Where(item => item.ArtifactName == map.MigrationEntity.fullNameOfMapToUpload).First().ExportStatus = map.ExportStatus; ExportedItems.Where(item => item.ArtifactName == map.MigrationEntity.fullNameOfMapToUpload).First().ExportStatusText = map.ExportStatusText; countArtifactsMigrated++; UpdateProgress(); } } foreach (var item in importedMaps) { if (item.ExportStatus == MigrationStatus.Failed) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError("Error(s) were encountered. Please refer the Status Tool Tip / Log File for more details."); break; } } } }
public override void Initialize(IApplicationContext applicationContext) { base.Initialize(applicationContext); statusBarViewModel = this.ApplicationContext.GetService <StatusBarViewModel>(); var cachedintegrationAccountDetails = this.ApplicationContext.GetService <IntegrationAccountDetails>(); var cachedintegrationServiceDetails = this.ApplicationContext.GetService <IntegrationServiceDetails>(); AzureLoginButtonClickCommand = new RelayCommand(o => AzureLoginButtonClick("AzureLoginButton")); if (cachedintegrationAccountDetails != null) { UserSubscriptions = this.ApplicationContext.GetProperty("Subscriptions") as ObservableCollection <Subscription.RootObject>; UserResourceGroups = this.ApplicationContext.GetProperty("ResourceGroups") as ObservableCollection <ResourceGroup.RootObject>; UserIntegrationAccounts = this.ApplicationContext.GetProperty("IntegrationAccounts") as ObservableCollection <IntegrationAccount.RootObject>; UserKeyVaults = this.ApplicationContext.GetProperty("KeyVaults") as ObservableCollection <KeyVault.RootObject>; SelectedSubscription = UserSubscriptions.Where(x => x.SubscriptionId == cachedintegrationAccountDetails.SubscriptionId).First(); SelectedResourceGroup = UserResourceGroups.Where(x => x.Name == cachedintegrationAccountDetails.ResourceGroupName).First(); SelectedIntegrationAccount = UserIntegrationAccounts.Where(x => x.Name == cachedintegrationAccountDetails.IntegrationAccountName).First(); if (!string.IsNullOrEmpty(cachedintegrationAccountDetails.KeyVaultName)) { SelectedKeyVault = UserKeyVaults.Where(x => x.Name == cachedintegrationAccountDetails.KeyVaultName).First(); } IsLoginButttonEnabled = false; SubscriptionVisible = true; } else { UserSubscriptions = new ObservableCollection <Subscription.RootObject>(); UserResourceGroups = new ObservableCollection <ResourceGroup.RootObject>(); UserIntegrationAccounts = new ObservableCollection <IntegrationAccount.RootObject>(); UserKeyVaults = new ObservableCollection <KeyVault.RootObject>(); IsLoginButttonEnabled = true; SubscriptionVisible = false; ResourceGroupVisible = false; IntegrationAccountVisible = false; KeyVaultVisible = false; } if (cachedintegrationServiceDetails != null) { this.integrationServiceDetails = cachedintegrationServiceDetails; } else { this.integrationServiceDetails = new IntegrationServiceDetails(); this.ApplicationContext.AddService(this.integrationServiceDetails); } }
private async Task ExportPartners() { try { if (importedPartners != null) { foreach (var partner in importedPartners) { try { await pMigrator.ExportToIA(partner, this.ApplicationContext.GetService <IntegrationAccountDetails>()); } catch (Exception ex) { partner.ExportStatus = MigrationStatus.Failed; partner.ExportStatusText = ex.Message; TraceProvider.WriteLine(string.Format("An exception occured:{0}", ex.Message)); } finally { ExportedItems.Where(item => item.ArtifactName == partner.MigrationEntity.Name).First().ExportStatus = partner.ExportStatus; ExportedItems.Where(item => item.ArtifactName == partner.MigrationEntity.Name).First().ExportStatusText = partner.ExportStatusText; countArtifactsMigrated++; UpdateProgress(); } } foreach (var item in importedPartners) { if (item.ExportStatus == MigrationStatus.Failed) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError("Error(s) were encountered. Please refer the Status Tool Tip / Log File for more details."); break; } } } } catch (Exception ex) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError("Error was encountered. Reason: " + ex.Message); TraceProvider.WriteLine("Error was encountered. Reason: " + ex.InnerException.StackTrace); } }
public override void Initialize(IApplicationContext applicationContext) { base.Initialize(applicationContext); pMigrator = new PartnerMigrator(this.ApplicationContext); aMigrator = new AgreementMigrator(this.ApplicationContext); sMigrator = new SchemaMigrator(this.ApplicationContext); mMigrator = new MapMigrator(this.ApplicationContext); c1Migrator = new CerificateMigrator <PartnerMigrationItemViewModel>(this.ApplicationContext); c2Migrator = new CerificateMigrator <Certificate>(this.ApplicationContext); ExportedItems = new ObservableCollection <ExportedArtifact>(); selectedSchemas = this.ApplicationContext.GetProperty(AppConstants.SelectedSchemasContextPropertyName) as IEnumerable <SchemaMigrationItemViewModel>; importedSchemas = selectedSchemas.Where(item => item.ImportStatus == MigrationStatus.Succeeded); selectedMaps = this.ApplicationContext.GetProperty(AppConstants.SelectedMapsContextPropertyName) as IEnumerable <MapMigrationItemViewModel>; importedMaps = selectedMaps.Where(item => item.ImportStatus == MigrationStatus.Succeeded); selectedPartners = this.ApplicationContext.GetProperty(AppConstants.SelectedPartnersContextPropertyName) as IEnumerable <PartnerMigrationItemViewModel>; if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner") { importedPartners = selectedPartners.Where(item => item.ImportStatus == MigrationStatus.Succeeded); } if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner") { importedPartnersWithCertificates = selectedPartners.Where(item => item.CertificationRequired == true && item.CertificateImportStatus == MigrationStatus.Succeeded); } selectedAgreements = this.ApplicationContext.GetProperty(AppConstants.SelectedAgreementsContextPropertyName) as IEnumerable <AgreementMigrationItemViewModel>; if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner") { importedAgreements = selectedAgreements.Where(item => item.ImportStatus == MigrationStatus.Succeeded); } otherCerts = this.ApplicationContext.GetProperty("OtherCertificates") as List <Certificate>; ExportSchemasFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportSchemas")); ExportMapsFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportMaps")); ExportCertificatesFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportCertificates")); ExportPartnersFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportPartners")); ExportAgreementsFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportAgreements")); bool consolidateAgreements = Convert.ToBoolean(this.ApplicationContext.GetProperty(AppConstants.ConsolidationEnabled)); bool generateMetadataContext = Convert.ToBoolean(this.ApplicationContext.GetProperty(AppConstants.ContextGenerationEnabled)); if (ExportSchemasFlag || ExportCertificatesFlag || ExportPartnersFlag || ExportAgreementsFlag || ExportMapsFlag) { if (ExportSchemasFlag) { foreach (var item in importedSchemas) { ExportedItems.Add(new ExportedArtifact { ArtifactName = item.MigrationEntity.fullNameOfSchemaToUpload, ArtifactType = ArtifactTypes.Schema, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } } if (ExportMapsFlag) { foreach (var item in importedMaps) { ExportedItems.Add(new ExportedArtifact { ArtifactName = item.MigrationEntity.fullNameOfMapToUpload, ArtifactType = ArtifactTypes.Map, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } } if (ExportCertificatesFlag) { foreach (var item in importedPartnersWithCertificates) { ExportedItems.Add(new ExportedArtifact { ArtifactName = item.MigrationEntity.CertificateName, ArtifactType = ArtifactTypes.Certificate, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } if (otherCerts != null) { otherExtractedCerts = otherCerts.Where(item => item.ImportStatus == MigrationStatus.Succeeded); foreach (var item in otherExtractedCerts) { ExportedItems.Add(new ExportedArtifact { ArtifactName = item.certificateName, ArtifactType = ArtifactTypes.Certificate, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } } } if (ExportPartnersFlag) { foreach (var item in importedPartners) { ExportedItems.Add(new ExportedArtifact { ArtifactName = item.MigrationEntity.Name, ArtifactType = ArtifactTypes.Partner, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } } if (ExportAgreementsFlag) { if (consolidateAgreements) { AuthenticationResult authresult = this.ApplicationContext.GetProperty("IntegrationAccountAuthorization") as AuthenticationResult; List <X12AgreementJson.Rootobject> x12AgreementsInIA = AgreementMigrator.GetAllX12AgreementsInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult).Result; this.ApplicationContext.SetProperty("X12AgreementsInIntegrationAccount", x12AgreementsInIA); List <EDIFACTAgreementJson.Rootobject> edifactAgreementsInIA = AgreementMigrator.GetAllEdifactAgreementsInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult).Result; this.ApplicationContext.SetProperty("EdifactAgreementsInIntegrationAccount", edifactAgreementsInIA); } foreach (var item in importedAgreements) { if (consolidateAgreements) { TraceProvider.WriteLine(string.Format("Checking {0} for Agreement consolidation..", item.Name)); AgreementMigrator agmtMigrator = new AgreementMigrator(this.ApplicationContext); try { agmtMigrator.CheckIfAgreementHasToBeConsolidated(item); } catch (Exception ex) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError(string.Format("Error was encountered during the check for consolidating agreement {0} with IA agreements. Reason: {1}. The agreement will be migrated as such", item.Name, ExceptionHelper.GetExceptionMessage(ex))); TraceProvider.WriteLine(string.Format("Error was encountered during the check for consolidating agreement {0} with IA agreements. Reason: {1}. The agreement will be migrated as such", item.Name, ExceptionHelper.GetExceptionMessage(ex))); TraceProvider.WriteLine(); } } ExportedItems.Add(new ExportedArtifact { ArtifactName = item.Name, ArtifactType = ArtifactTypes.Agreement, ExportStatus = MigrationStatus.NotStarted, ExportStatusText = null }); } } countArtifactsMigrated = 0; countTotalArtifactsToMigrate = ExportedItems.Count(); TotalArtifacts = countTotalArtifactsToMigrate; ProgressVisible = false; UpdateProgress(); ExportArtifacts(); } else { var lastNavigation = this.ApplicationContext.LastNavigation; if (lastNavigation == NavigateAction.Next) { this.ApplicationContext.GetService <WizardNavigationViewModel>().MoveToNextStep(); } else if (lastNavigation == NavigateAction.Previous) { this.ApplicationContext.GetService <WizardNavigationViewModel>().MoveToPreviousStep(); } } }
private async Task ExportAgreements() { try { AuthenticationResult authresult = this.ApplicationContext.GetProperty("IntegrationAccountAuthorization") as AuthenticationResult; Dictionary <string, string> schemasInIA = await AgreementMigrator.GetAllSchemasInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult); Dictionary <KeyValuePair <string, string>, string> partnerIdentitiesInIA = await AgreementMigrator.GetAllPartnerIdentitiesInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult); this.ApplicationContext.SetProperty("SchemasInIntegrationAccount", schemasInIA); this.ApplicationContext.SetProperty("PartnerIdentitiesInIntegrationAccount", partnerIdentitiesInIA); } catch (Exception ex) { MessageBox.Show("Following error occured : " + ExceptionHelper.GetExceptionMessage(ex)); TraceProvider.WriteLine("Following error occured : " + ExceptionHelper.GetExceptionMessage(ex)); } try { if (importedAgreements != null) { foreach (var agreement in importedAgreements) { try { await aMigrator.ExportToIA(agreement, this.ApplicationContext.GetService <IntegrationAccountDetails>()); } catch (Exception ex) { agreement.ExportStatus = MigrationStatus.Failed; agreement.ExportStatusText = ex.Message; TraceProvider.WriteLine(string.Format("An exception occured:{0}", ex.Message)); TraceProvider.WriteLine(); } finally { ExportedItems.Where(item => item.ArtifactName == agreement.Name).First().ExportStatus = agreement.ExportStatus; ExportedItems.Where(item => item.ArtifactName == agreement.Name).First().ExportStatusText = agreement.ExportStatusText; countArtifactsMigrated++; UpdateProgress(); } } foreach (var item in importedAgreements) { if (item.ExportStatus == MigrationStatus.Failed) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError("Error(s) were encountered. Please refer the Status Tool Tip / Log File for more details."); break; } } } } catch (Exception ex) { StatusBarViewModel.StatusInfoType = StatusInfoType.Error; StatusBarViewModel.ShowError("Error was encountered. Reason: " + ex.Message); TraceProvider.WriteLine("Error was encountered. Reason: " + ex.InnerException.StackTrace); } }