public static IPersonalInfoEnrichmentService BuildService(ILogger logger) { var settings = new TableStorageSettings() { ConnectionString = InfrastructureConfiguration.TableStorageConnString }; var initializer = new AzureTableStorageInitializer(settings); var storedPersonalInfoRepo = new AzureTableStorageRepository <StoredPersonalInfo>(initializer, logger); var personLocalStorage = new PersonLocalStorage(storedPersonalInfoRepo); var contextMappingRepo = new AzureTableStorageRepository <ContextMapping>(initializer, logger); var contextMappingLocalStorage = new ContextMappingLocalStorage(contextMappingRepo); var authenticationSettings = new AuthenticationSettings(InfrastructureConfiguration.AuthProviderUri, InfrastructureConfiguration.AuthProviderClient, InfrastructureConfiguration.AuthProviderSecret); var authenticationProvider = new AuthenticationProvider(authenticationSettings); var personalInfoExternalServiceFactory = new PersonalInfoExternalServiceFactory(contextMappingLocalStorage, authenticationProvider, logger); return(new PersonalInfoEnrichmentService(personLocalStorage, personalInfoExternalServiceFactory, logger)); }
public AzureTableStorageRepository <T> GetInstance(ILogger log) { var initializer = new AzureTableStorageInitializer(_configuration); var azureStorageRepository = new AzureTableStorageRepository <T>(initializer, log); return(azureStorageRepository); }
public void OnInitializationWhenValidSettingsProvidedAnInstanceIsReturned() { var sut = new AzureTableStorageRepository <ContextMapping>(initializer, logger); Assert.IsNotNull(sut); Assert.IsInstanceOfType(sut, typeof(AzureTableStorageRepository <ContextMapping>)); }
public AzureTableRepositorySpecSetup() { var config = new ConfigurationBuilder().AddJsonFile(@"appsettings.json").Build(); var settings = new NetCoreAppSettings(config); Repository = AzureTableStorageRepository.FromSettings(settings); AzureStorageAccountBase.InitializeAllTests(); }
public static void InitializeAllTests(TestContext context) { InitializeAllTests(); var config = new ConfigurationBuilder().AddJsonFile(@"appsettings.json").Build(); var settings = new NetCoreAppSettings(config); repository = AzureTableStorageRepository.FromSettings(settings); AzureStorageAccountBase.InitializeAllTests(context); }
public static async Task CleanUpPersonFromLocalStorage(string context, string id) { var initializer = InitializeTableStorage(); var repo = new AzureTableStorageRepository <StoredPersonalInfo>(initializer, new Mock <ILogger>().Object); var person = await repo.RetrieveRecord(context, id); if (person != null) { await repo.DeleteRecord(person); } }
public static async Task CleanUpContextMapping(string context) { var initializer = InitializeTableStorage(); var repo = new AzureTableStorageRepository <ContextMapping>(initializer, new Mock <ILogger>().Object); var mapping = await repo.RetrieveRecord("PersonInfo", context); if (mapping != null) { await repo.DeleteRecord(mapping); } }
/// <summary> /// Initializes a new instance of the <see cref="UnstructuredStorageInstanceStore" /> class. /// </summary> /// <param name="unstructuredStorageRepository">The unstructured storage repository.</param> /// <param name="ownerInstanceId">The owner instance id.</param> /// <param name="submitStateMessage">The submit State Message.</param> internal UnstructuredStorageInstanceStore( AzureTableStorageRepository <InstanceData> unstructuredStorageRepository, Guid ownerInstanceId, Action <Guid> submitStateMessage) { lock (LocalLock) { this.unstructuredStorageRepository = unstructuredStorageRepository; this.ownerInstanceId = ownerInstanceId; this.submitStateMessage = submitStateMessage; } }
/// <summary> /// Initializes a new instance of the <see cref="UnstructuredStorageInstanceStore" /> class. /// </summary> /// <param name="unstructuredStorageRepository">The unstructured storage repository.</param> /// <param name="ownerInstanceId">The owner instance id.</param> /// <param name="submitStateMessage">The submit State Message.</param> internal UnstructuredStorageInstanceStore( AzureTableStorageRepository<InstanceData> unstructuredStorageRepository, Guid ownerInstanceId, Action<Guid> submitStateMessage) { lock (LocalLock) { this.unstructuredStorageRepository = unstructuredStorageRepository; this.ownerInstanceId = ownerInstanceId; this.submitStateMessage = submitStateMessage; } }
public static async Task EnsureContextMappingIsCreated(string context, string url) { var initializer = InitializeTableStorage(); var repo = new AzureTableStorageRepository <ContextMapping>(initializer, new Mock <ILogger>().Object); var mapping = await repo.RetrieveRecord("PersonInfo", context); if (mapping != null) { await repo.DeleteRecord(mapping); } await repo.InsertRecordToTable(new ContextMapping() { PartitionKey = "PersonInfo", RowKey = context, URL = url }); }
public static async Task EnsurePersonIsInLocalStorage(string context, string id, string initials, string lastNameAtBirth, string lastNameAtBirthPrefix, DateTime birthdate) { var initializer = InitializeTableStorage(); var repo = new AzureTableStorageRepository <StoredPersonalInfo>(initializer, new Mock <ILogger>().Object); var person = await repo.RetrieveRecord(context, id); if (person != null) { await repo.DeleteRecord(person); } await repo.InsertRecordToTable(new StoredPersonalInfo() { PartitionKey = context, RowKey = id, initials = initials, lastNameAtBirth = lastNameAtBirth, lastNameAtBirthPrefix = lastNameAtBirthPrefix, birthdate = birthdate.ToString("dd/MM/yyyy", CultureInfo.CreateSpecificCulture("nl")) }); }
public async Task RepositoryIsAbleToConnectAndManagePersonalInfo() { var initializer = AzureTableStorageHelper.InitializeTableStorage(); var repo = new AzureTableStorageRepository <StoredPersonalInfo>(initializer, new Mock <ILogger>().Object); var partitionKey = "AzureTableStorageClientIntegrationTests"; var rowKey = "R234568"; // Clean up var sut = await repo.RetrieveRecord(partitionKey, rowKey); if (sut != null) { await repo.DeleteRecord(sut); } // Insert await repo.InsertRecordToTable(new StoredPersonalInfo() { PartitionKey = partitionKey, RowKey = rowKey, initials = "AP", lastNameAtBirthPrefix = "Aylen Perez", lastNameAtBirth = "", birthdate = "28/09/1976" }); sut = await repo.RetrieveRecord(partitionKey, rowKey); Assert.IsNotNull(sut); Assert.IsInstanceOfType(sut, typeof(StoredPersonalInfo)); // Delete await repo.DeleteRecord(sut); sut = await repo.RetrieveRecord(partitionKey, rowKey); Assert.IsNull(sut); }
public async Task RepositoryIsAbleToConnectAndManageContextMappings() { var initializer = AzureTableStorageHelper.InitializeTableStorage(); var repo = new AzureTableStorageRepository <ContextMapping>(initializer, new Mock <ILogger>().Object); var partitionKey = "PersonInfo"; var rowKey = "AzureTableStorageClientIntegrationTests"; // Clean up var sut = await repo.RetrieveRecord(partitionKey, rowKey); if (sut != null) { await repo.DeleteRecord(sut); } // Insert await repo.InsertRecordToTable(new ContextMapping() { PartitionKey = partitionKey, RowKey = rowKey, URL = "http://localhost:9002/youforcereseolver" }); sut = await repo.RetrieveRecord(partitionKey, rowKey); Assert.IsNotNull(sut); Assert.IsInstanceOfType(sut, typeof(ContextMapping)); Assert.IsFalse(string.IsNullOrEmpty(sut.URL)); // Delete await repo.DeleteRecord(sut); sut = await repo.RetrieveRecord(partitionKey, rowKey); Assert.IsNull(sut); }
public CreateButtonActionHandler(AzureTableStorageRepository repository) { _repository = repository; }
/// <summary> /// Setups the workflow environment. /// </summary> /// <param name="workflowApplication">The workflow application.</param> /// <param name="workflowId">The workflow identifier.</param> private void SetupWorkflowEnvironment(WorkflowApplication workflowApplication, Guid workflowId) { //// Setup workflow execution environment. //// 1. Make the workflow synchronous workflowApplication.SynchronizationContext = new SynchronousSynchronizationContext(); //// 2. Initialize instance store with instance identifier. this.repository = new AzureTableStorageRepository <InstanceData>( "instanceStore", CloudConfigurationManager.GetSetting("WorkflowStorage")); this.repository.CreateStorageObjectAndSetExecutionContext(); var instanceStore = new UnstructuredStorageInstanceStore( this.repository, workflowId, this.AddBookmarkMessage); //// 3. Assign this instance store to WFA workflowApplication.InstanceStore = instanceStore; //// 4. Handle persistable idle to remove application from memory. //// Also, at this point we need to add message to host queue to add message signaling that bookmark has been added. workflowApplication.PersistableIdle = persistableIdleEventArgument => { //// Check whether the application is unloading because of bookmarks. if (persistableIdleEventArgument.Bookmarks.Any()) { Trace.Write( Routines.FormatStringInvariantCulture( "Application Instance {0} is going to save state for bookmark {1}", persistableIdleEventArgument.InstanceId, persistableIdleEventArgument.Bookmarks.Last().BookmarkName)); } return(PersistableIdleAction.Unload); }; //// 5. Log when a WF completes. workflowApplication.Completed = applicationCompletedEventArgument => { Trace.Write( Routines.FormatStringInvariantCulture( "Workflow instance {0} has completed with state {1}", applicationCompletedEventArgument.InstanceId, applicationCompletedEventArgument.CompletionState)); }; //// 6. Log when WF is unloaded from memory. workflowApplication.Unloaded = applicationUnloadedEventArgs => { Trace.Write( Routines.FormatStringInvariantCulture( "Workflow instance {0} has been unloaded from memory", applicationUnloadedEventArgs.InstanceId)); this.resetEvent.Set(); }; //// 7. If workflow throws an unhandled exception, don't consume the message so that it can be retried. workflowApplication.OnUnhandledException = args => { Trace.Write("Workflow encountered an unhandled exception", args.UnhandledException.ToString()); this.resetEvent.Set(); return(UnhandledExceptionAction.Abort); }; }
/// <summary> /// Setups the workflow environment. /// </summary> /// <param name="workflowApplication">The workflow application.</param> /// <param name="workflowId">The workflow identifier.</param> private void SetupWorkflowEnvironment(WorkflowApplication workflowApplication, Guid workflowId) { //// Setup workflow execution environment. //// 1. Make the workflow synchronous workflowApplication.SynchronizationContext = new SynchronousSynchronizationContext(); //// 2. Initialize instance store with instance identifier. this.repository = new AzureTableStorageRepository<InstanceData>( "instanceStore", CloudConfigurationManager.GetSetting("WorkflowStorage")); this.repository.CreateStorageObjectAndSetExecutionContext(); var instanceStore = new UnstructuredStorageInstanceStore( this.repository, workflowId, this.AddBookmarkMessage); //// 3. Assign this instance store to WFA workflowApplication.InstanceStore = instanceStore; //// 4. Handle persistable idle to remove application from memory. //// Also, at this point we need to add message to host queue to add message signaling that bookmark has been added. workflowApplication.PersistableIdle = persistableIdleEventArgument => { //// Check whether the application is unloading because of bookmarks. if (persistableIdleEventArgument.Bookmarks.Any()) { Trace.Write( Routines.FormatStringInvariantCulture( "Application Instance {0} is going to save state for bookmark {1}", persistableIdleEventArgument.InstanceId, persistableIdleEventArgument.Bookmarks.Last().BookmarkName)); } return PersistableIdleAction.Unload; }; //// 5. Log when a WF completes. workflowApplication.Completed = applicationCompletedEventArgument => { Trace.Write( Routines.FormatStringInvariantCulture( "Workflow instance {0} has completed with state {1}", applicationCompletedEventArgument.InstanceId, applicationCompletedEventArgument.CompletionState)); }; //// 6. Log when WF is unloaded from memory. workflowApplication.Unloaded = applicationUnloadedEventArgs => { Trace.Write( Routines.FormatStringInvariantCulture( "Workflow instance {0} has been unloaded from memory", applicationUnloadedEventArgs.InstanceId)); this.resetEvent.Set(); }; //// 7. If workflow throws an unhandled exception, don't consume the message so that it can be retried. workflowApplication.OnUnhandledException = args => { Trace.Write("Workflow encountered an unhandled exception", args.UnhandledException.ToString()); this.resetEvent.Set(); return UnhandledExceptionAction.Abort; }; }
public void OnInitializationWhenNullSettingsProvidedArgumentNullExceptionIsThrown() { var sut = new AzureTableStorageRepository <ContextMapping>(null, logger); }