public async Task MigrateToCloudIA(List <SchemaMigrationItemViewModel> schemaItems, IntegrationAccountDetails iaDetails) { this.iaDetails = iaDetails; ActionOnSchemas action = new ActionOnSchemas(); var schemasToBeUploaded = thisApplicationContext.GetProperty("SchemasToUploadOrder") as List <SchemaDetails>; AuthenticationResult authresult = thisApplicationContext.GetProperty("IntegrationAccountAuthorization") as AuthenticationResult; bool overwriteExistingArtifacts = Convert.ToBoolean(thisApplicationContext.GetProperty("OverwriteEnabled")); List <SchemaDetails> schemaDetailsList = new List <SchemaDetails>(); foreach (var schemaItem in schemaItems) { schemaItem.MigrationEntity.schemaUploadToIAStatus = SchemaUploadToIAStatus.NotYetStarted; schemaItem.MigrationEntity.errorDetailsForMigration = ""; schemaDetailsList.Add(schemaItem.MigrationEntity); } await Task.Factory.StartNew(() => { try { action.UploadToIntegrationAccount(schemasToBeUploaded, ref schemaDetailsList, Resources.JsonSchemaFilesLocalPath, overwriteExistingArtifacts, iaDetails.SubscriptionId, iaDetails.ResourceGroupName, iaDetails.IntegrationAccountName, authresult); SetMigrationStatus(schemaDetailsList, schemaItems); } catch (Exception ex) { SetMigrationStatus(schemaDetailsList, schemaItems); TraceProvider.WriteLine(string.Format("Schemas Migration Failed. Reason:{0}", ExceptionHelper.GetExceptionMessage(ex))); TraceProvider.WriteLine(); throw new Exception(string.Format("Schemas Migration Failed. Reason:{0}", ExceptionHelper.GetExceptionMessage(ex))); } }); }
protected override Task <IEnumerable <SchemaDetails> > GetEntitiesAsync() { return(Task.Factory.StartNew <IEnumerable <SchemaDetails> >(() => { try { var appDetails = ApplicationContext.GetProperty("SelectedApps") as ObservableCollection <ApplicationDetails>; string parameter = ""; foreach (var item in appDetails) { if (item.isSelected) { parameter += "'" + item.nID + "',"; } } parameter = parameter.Remove(parameter.Length - 1); var schemas = this.ApplicationContext.GetProperty(AppConstants.AllSchemasContextPropertyName) as ObservableCollection <SchemaSelectionItemViewModel>; List <SchemaDetails> schemasList = new List <SchemaDetails>(); if (schemas != null && schemas.Count != 0) { foreach (var schemaItem in schemas) { schemasList.Add(schemaItem.MigrationEntity); } return schemasList; } else { ActionOnSchemas action = new ActionOnSchemas(); string connectionString = this.ApplicationContext.GetProperty("DatabaseConnectionString") as string; schemasList = action.GetListOfSchemas(connectionString, Resources.JsonSchemaFilesLocalPath, parameter); this.ApplicationContext.SetProperty(AppConstants.SchemaNamespaceVersionList, action.schemaNamespaceVersionDict); return schemasList; } } catch (Exception ex) { TraceProvider.WriteLine(string.Format(CultureInfo.InvariantCulture, "Not able to retrieve schemas. {0}", ExceptionHelper.GetExceptionMessage(ex))); var statusBarViewModel = this.ApplicationContext.GetService <StatusBarViewModel>(); statusBarViewModel.StatusInfoType = StatusInfoType.Error; statusBarViewModel.ShowError("Error. Failed to retrieve schemas from Biztalk Server. Reason: " + ExceptionHelper.GetExceptionMessage(ex)); return new List <SchemaDetails>(); } })); }
public async Task CreateSchemas(List <SchemaMigrationItemViewModel> schemaItems) { ActionOnSchemas action = new ActionOnSchemas(); List <SchemaDetails> schemaDetailsList = new List <SchemaDetails>(); List <SchemaDetails> response = new List <SchemaDetails>(); ObservableCollection <SchemaSelectionItemViewModel> originalCollection = this.thisApplicationContext.GetProperty(AppConstants.AllSchemasContextPropertyName) as ObservableCollection <SchemaSelectionItemViewModel>; List <SchemaSelectionItemViewModel> orignalList = originalCollection.ToList(); List <SchemaDetails> originalSchemaDetailsList = new List <SchemaDetails>(); foreach (var schemaItem in schemaItems) { schemaItem.MigrationEntity.isSchemaExtractedFromDb = false; schemaItem.MigrationEntity.errorDetailsForExtraction = ""; schemaDetailsList.Add(schemaItem.MigrationEntity); } foreach (var schemaItem in orignalList) { originalSchemaDetailsList.Add(schemaItem.MigrationEntity); } await Task.Factory.StartNew(() => { try { response = action.ExtractSchemasFromDlls(ref schemaDetailsList, Resources.JsonSchemaFilesLocalPath, originalSchemaDetailsList); thisApplicationContext.SetProperty("SchemasToUploadOrder", response); SetExtractionStatus(schemaDetailsList, schemaItems); } catch (Exception ex) { SetExtractionStatus(schemaDetailsList, schemaItems); TraceProvider.WriteLine(string.Format("Schemas Extraction Failed:{0}", ExceptionHelper.GetExceptionMessage(ex))); TraceProvider.WriteLine(); throw new Exception(string.Format("Schemas Extraction Failed. Reason:{0}", ExceptionHelper.GetExceptionMessage(ex))); } }); }