public ConfigurationContext()
 {
     _azureTable = MefBase.Resolve<IAzureTableUtility>();
     _azureTable.ConnectionString = ConfigurationsSelector.GetLocalConnectionString("StorageAccount");
     _azureTable.TableName = "Configuration";
     _azureTable.CreateTable();
 }
        internal static IAzureTableUtility Create(string connectionString, string tableName)
        {
            IAzureTableUtility azureTable = MefBase.Container.GetExportedValue <IAzureTableUtility>();

            azureTable.ConnectionString = connectionString;
            azureTable.TableName        = tableName;
            azureTable.CreateTable();
            return(azureTable);
        }
Ejemplo n.º 3
0
        public void test_delete()
        {
            var redundantTable = new RedundantTableStorage <Customer>("UseDevelopmentStorage=true", "Customer", true, serviceBus, "RedundancyQueue", "UseDevelopmentStorage=true");
            var customer       = new Customer();

            redundantTable.Insert(customer);
            redundantTable.Delete(customer.PartitionKey, customer.RowKey);
            IAzureTableUtility customerArchiver = MefBase.Container.GetExportedValue <IAzureTableUtility>();

            customerArchiver.ConnectionString = "UseDevelopmentStorage=True";
            customerArchiver.TableName        = "TransactionLog";
            Assert.IsTrue(customerArchiver.FindByPartitionKey <TableEntity>("Customer").Count() == 2);
        }
Ejemplo n.º 4
0
        public void Clean()
        {
            IAzureTableUtility customerArchiver = MefBase.Container.GetExportedValue <IAzureTableUtility>();

            customerArchiver.ConnectionString = "UseDevelopmentStorage=True";
            customerArchiver.TableName        = "TransactionLog";
            customerArchiver.DeleteTable();

            IAzureTableUtility customer = MefBase.Container.GetExportedValue <IAzureTableUtility>();

            customer.ConnectionString = "UseDevelopmentStorage=True";
            customer.TableName        = "Customer";
            customer.DeleteTable();
        }
        public static Action Create(this TransactionLog transactionLogMessage, string connectionString)
        {
            IAzureTableUtility azureTableUtility = ContextFactory.Create(connectionString, transactionLogMessage.TableName);

            JObject jsonMessage = JsonConvert.DeserializeObject <JObject>(transactionLogMessage.Object);

            DynamicTableEntity temp = new DynamicTableEntity();

            foreach (KeyValuePair <string, JToken> keyValuePair in jsonMessage)
            {
                if (keyValuePair.Key.Equals("Timestamp") || keyValuePair.Key.Equals("ETag"))
                {
                    continue;
                }

                if (keyValuePair.Key.Equals("PartitionKey"))
                {
                    temp.PartitionKey = keyValuePair.Value.ToString();
                }
                else if (keyValuePair.Key.Equals("RowKey"))
                {
                    temp.RowKey = keyValuePair.Value.ToString();
                }
                else
                {
                    temp.Properties.Add(keyValuePair.Key, EntityProperty.CreateEntityPropertyFromObject(keyValuePair.Value));
                }
            }

            string actionType = transactionLogMessage.Action;

            if (actionType.Equals("UPSERT", StringComparison.OrdinalIgnoreCase) || actionType.Equals("INSERT", StringComparison.OrdinalIgnoreCase))
            {
                return(() => azureTableUtility.Upset <DynamicTableEntity>(temp));
            }
            if (actionType.Equals("DELETE", StringComparison.OrdinalIgnoreCase))
            {
                return(() => azureTableUtility.DeleteEntity(temp.PartitionKey, temp.RowKey));
            }

            return(default(Action));
        }
Ejemplo n.º 6
0
        public void test_insert()
        {
            var redundantTable = new RedundantTableStorage <Customer>("UseDevelopmentStorage=true", "Customer", true, serviceBus, "RedundancyQueue", "UseDevelopmentStorage=true");

            for (int i = 0; i < 10; i++)
            {
                redundantTable.Upsert(new Customer
                {
                    Email     = i.ToString(),
                    FirstName = i.ToString(),
                    LastName  = i.ToString()
                });
            }

            Assert.IsTrue(redundantTable.FindByPartitionKey($"{DateTime.Now:yyyy-MM-DD}").Count() == 10);
            IAzureTableUtility customerArchiver = MefBase.Container.GetExportedValue <IAzureTableUtility>();

            customerArchiver.ConnectionString = "UseDevelopmentStorage=True";
            customerArchiver.TableName        = "TransactionLog";
            Assert.IsTrue(customerArchiver.FindByPartitionKey <TableEntity>("Customer").Count() == 10);
        }