public AzureTablesRepositorySpecificTests() { var connString = AzureTablesHelper.GetConnectionString(); tableClientFactory = new TableClientFactory(connString); sut = new AzureTablesSagaRepository(tableClientFactory, new JsonNetSerialiser(), new DumbSagaFactory()); }
/// <summary> /// Retrieve all messages logged matching the filter param dictionary given as (Column Name, Coumn Value). Pass in optional start and end time params. /// </summary> /// <param name="queryDictionary">Dictionary of (Column Name, Coumn Value) to run query for</param> /// <param name="dateFrom">dateFrom</param> /// <param name="dateTo">dateFrom</param> /// <returns>All messages logged by the given caller, between optional start and end time params.</returns> public static IEnumerable <DynamicTableEntity> RetrieveLogMessagesFromTableStorage( Dictionary <string, string> queryDictionary, DateTime?dateFrom = null, DateTime?dateTo = null) { try { var filter = AzureTablesHelper.CreateTableStorageQueryFilter <DynamicTableEntity>(queryDictionary); if (dateFrom != null) { if (dateTo == null) { dateTo = DateTime.UtcNow; } filter = AzureTablesHelper.AppendOptionalTimeBasedFilters( dateFrom.Value.AddSeconds(-1), dateTo.Value.AddSeconds(1), filter); } var entities = ExecuteAzureTableStorageQuery(filter); return(entities); } catch (Exception) { // ignored } return(null); }
/// <summary> /// Execute an Azure Table Query Filter filter against the Azure Storage account and Table name specified in the settings file of the calling executable /// </summary> /// <param name="filter">Azure Table Query Filter</param> /// <returns>Entities matching the query in the target table</returns> private static List <DynamicTableEntity> ExecuteAzureTableStorageQuery(string filter) { var tableQuery = new TableQuery <DynamicTableEntity>().Where(filter); var table = AzureTablesHelper.GetAzureTablesTableObject( CloudConfigurationManager.GetSetting(telemetryStorageConnectionStringSettingName), AzureTableStorageTableName); TableContinuationToken token = null; var entities = new List <DynamicTableEntity>(); do { var queryResult = table.ExecuteQuerySegmented(tableQuery, token); entities.AddRange(queryResult.Results); token = queryResult.ContinuationToken; }while (token != null); return(entities); }
/// <summary> /// Store the given LogMessage object an Azure Table Storage table called "SystemLogs" in the Azure Storage account pointed to by the "AzureStorageConnectionString" /// </summary> /// <param name="logMessage">Message object to log</param> public static void LogMessageToTableStorage(LogMessage logMessage) { try { // Convert message to Azure Table Entity var logAzureTableEntity = new LogAzureTableEntity(logMessage); var connectionString = CloudConfigurationManager.GetSetting(telemetryStorageConnectionStringSettingName); var table = AzureTablesHelper.GetAzureTablesTableObject(connectionString, AzureTableStorageTableName); table.CreateIfNotExists(); // Create the TableOperation object that inserts the entity. var insertOperation = TableOperation.Insert(logAzureTableEntity); // Execute the insert operation. table.Execute(insertOperation); } catch (Exception e) { // ignored } }
public AzureTablesSagaRepositoryTests() { var connectionString = AzureTablesHelper.GetConnectionString(); this.Sut = new AzureTablesSagaRepository(new TableClientFactory(connectionString), new JsonNetSerialiser(), new DumbSagaFactory()); }