Example #1
0
        public void Setup()
        {
            var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount);

            _repository   = new WebSiteRepository(factory);
            _webSiteTable = factory.GetTable <WebSiteRow>(typeof(WebSiteRow).Name);
            _bindingTable = factory.GetTable <BindingRow>(typeof(BindingRow).Name);
        }
        public static void EnsureDomainObjectsExist()
        {
            var factory = new AzureStorageFactory(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"));

            factory.GetTable<Contact>(FBwithWA.Domain.AzureConstants.ContactTableName).Initialize();
            factory.GetQueue<ContactQueueMessage>(AzureConstants.ContactQueueName).Initialize();
            factory.GetTable<ZipStore>(FBwithWA.Domain.AzureConstants.ZipStoreTableName).Initialize();
            factory.GetTable<Store>(FBwithWA.Domain.AzureConstants.StoreTableName).Initialize();
        }
Example #3
0
        protected override void FixtureSetup()
        {
            base.FixtureSetup();

            // RoleEnvironment
            AzureRoleEnvironment.DeploymentId          = () => "DEPLOYMENTID";
            AzureRoleEnvironment.CurrentRoleInstanceId = () => "ROLEINSTANCEID";

            // File Resource Paths
            var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", ""));

            _sitePath      = Path.Combine(basePath, "Sites");
            _tempPath      = Path.Combine(basePath, "Temp");
            _configPath    = Path.Combine(basePath, "Config");
            _resourcesPath = Path.Combine(basePath, "_resources");
            Directory.CreateDirectory(_sitePath);
            Directory.CreateDirectory(_tempPath);
            Directory.CreateDirectory(_configPath);

            // Website Repository
            var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount);

            _repo         = new WebSiteRepository(factory);
            _webSiteTable = factory.GetTable <WebSiteRow>(typeof(WebSiteRow).Name);
            _bindingTable = factory.GetTable <BindingRow>(typeof(BindingRow).Name);

            // Clean up IIS and table storage to prepare for test
            using (var serverManager = new ServerManager())
            {
                _excludedSites = new List <string>();
                using (var manager = new ServerManager())
                {
                    manager.Sites.Where(s => s.Name != AzureRoleEnvironment.RoleWebsiteName()).ToList().ForEach(s => _excludedSites.Add(s.Name));
                }
                CleanupWebsiteTest(serverManager);
            }

            // Sync Service
            _syncService = new SyncService(
                _repo,
                new SyncStatusRepository(factory),
                CloudStorageAccount.DevelopmentStorageAccount,
                _sitePath,
                _tempPath,
                new string[] { },
                _excludedSites,
                () => true,
                new IISManager(_sitePath, _tempPath, new SyncStatusRepository(factory), new ConsoleFactory(), LoggerLevel.Debug),
                new ConsoleFactory(),
                LoggerLevel.Debug
                );
        }
Example #4
0
 public UserStore(string userTableName, string userClaimTableName, string userRoleTableName, string userLoginTableName, string lookupTableName)
 {
     m_userTable      = AzureStorageFactory.GetTable(userTableName, true);
     m_userClaimTable = AzureStorageFactory.GetTable(userClaimTableName, true);
     m_userRoleTable  = AzureStorageFactory.GetTable(userRoleTableName, true);
     m_userLoginTable = AzureStorageFactory.GetTable(userLoginTableName, true);
     m_lookupTable    = AzureStorageFactory.GetTable(lookupTableName, true);
 }
 public void Setup()
 {
     var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount);
     _repository = new WebSiteRepository(factory);
     _webSiteTable = factory.GetTable<WebSiteRow>(typeof(WebSiteRow).Name);
     _bindingTable = factory.GetTable<BindingRow>(typeof(BindingRow).Name);
 }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is a simple program to copy the sample data to your Windows Azure storage account. This can take some time, depending on your network speed. Make sure you have changed the data connection string to point to your storage account.");

            // this could be easily re-written to use batching in the client storage api,
            // but I wanted to be consistent with how we access table storage through the sample.
            // And you will likely only run this once.

            AzureTable<Store> _Stores;
            AzureTable<ZipStore> _ZipCodes;
            AppSettingsReader myAppSettings = new AppSettingsReader();
            const int numberOfStores = 1000;
            const int numberOfZipCodes = 42192;

            var factory = new AzureStorageFactory(CloudStorageAccount.Parse((string)myAppSettings.GetValue("DataConnectionString", typeof(string))));

            _Stores = (AzureTable<Store>)factory.GetTable<Store>(FBwithWA.Domain.AzureConstants.StoreTableName);
            _Stores.Initialize();

            _ZipCodes = (AzureTable<ZipStore>)factory.GetTable<ZipStore>(FBwithWA.Domain.AzureConstants.ZipStoreTableName);
            _ZipCodes.Initialize();

            Console.WriteLine("Load stores..." + DateTime.Now.ToShortTimeString());
            using (CsvFileReader reader = new CsvFileReader(@"Store_List.csv"))
            {
                int count = 0;
                CsvRow row = new CsvRow();
                while (reader.ReadRow(row))
                {
                    //row headers: PartitionKey,RowKey,Name,City,State,Zip
                    Store aStore = new Store
                    {
                        PartitionKey = row[0],
                        RowKey = row[1],
                        Name = row[2],
                        City = row[3],
                        State = row[4],
                        Zip = row[5]
                    };
                    _Stores.AddOrUpdate(aStore);
                    Console.WriteLine(string.Format("Completed: {0} of {1} stores", count.ToString(), numberOfStores));
                    count++;
                }
            }
            Console.WriteLine("Load stores done. " + DateTime.Now.ToShortTimeString());

            // load zip array
            Console.WriteLine("Load zip code data..." + DateTime.Now.ToShortTimeString());

            using (CsvFileReader reader = new CsvFileReader(@"Zip_Map.csv"))
            {
                int count = 0;
                CsvRow row = new CsvRow();
                while (reader.ReadRow(row))
                {
                    ZipStore aZipCode = new ZipStore
                    {
                        // file format: PartitionKey,RowKey,zip,store1,store2,store3
                        PartitionKey = row[0],
                        RowKey = row[1],
                        store1 = row[3],
                        store2 = row[4],
                        store3 = row[5]
                    };
                    _ZipCodes.AddOrUpdate(aZipCode);
                    Console.WriteLine(string.Format("Completed: {0} of {1} zip codes", count.ToString(), numberOfZipCodes));
                    count++;
                }
            }
            Console.WriteLine("Load zip codes done. " + DateTime.Now.ToShortTimeString());
            Console.WriteLine("Prese enter to exit.");
            Console.ReadLine();
        }
 public ContactRepository()
 {
     var factory = new AzureStorageFactory(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"));
     _table = (AzureTable<Contact>) factory.GetTable<Contact>(FBwithWA.Domain.AzureConstants.ContactTableName);
 }
Example #8
0
 public StoreRepository()
 {
     var factory = new AzureStorageFactory();
     _zipStore = (AzureTable<ZipStore>)factory.GetTable<ZipStore>(FBwithWA.Domain.AzureConstants.ZipStoreTableName);
     _store = (AzureTable<Store>)factory.GetTable<Store>(FBwithWA.Domain.AzureConstants.StoreTableName);
 }
Example #9
0
 public RoleStore(string roleTableName)
 {
     m_roleTable = AzureStorageFactory.GetTable(roleTableName, true);
 }
        protected override void FixtureSetup()
        {
            base.FixtureSetup();

            // RoleEnvironment
            AzureRoleEnvironment.DeploymentId = () => "DEPLOYMENTID";
            AzureRoleEnvironment.CurrentRoleInstanceId = () => "ROLEINSTANCEID";

            // File Resource Paths
            var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", ""));
            _sitePath = Path.Combine(basePath, "Sites");
            _tempPath = Path.Combine(basePath, "Temp");
            _configPath = Path.Combine(basePath, "Config");
            _resourcesPath = Path.Combine(basePath, "_resources");
            Directory.CreateDirectory(_sitePath);
            Directory.CreateDirectory(_tempPath);
            Directory.CreateDirectory(_configPath);

            // Website Repository
            var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount);
            _repo = new WebSiteRepository(factory);
            _webSiteTable = factory.GetTable<WebSiteRow>(typeof(WebSiteRow).Name);
            _bindingTable = factory.GetTable<BindingRow>(typeof(BindingRow).Name);

            // Clean up IIS and table storage to prepare for test
            using (var serverManager = new ServerManager())
            {
                _excludedSites = new List<string>();
                using (var manager = new ServerManager())
                {
                    manager.Sites.Where(s => s.Name != AzureRoleEnvironment.RoleWebsiteName()).ToList().ForEach(s => _excludedSites.Add(s.Name));
                }
                CleanupWebsiteTest(serverManager);
            }

            // Sync Service
            _syncService = new SyncService(
                _repo,
                new SyncStatusRepository(factory),
                CloudStorageAccount.DevelopmentStorageAccount,
                _sitePath,
                _tempPath,
                new string[] { },
                _excludedSites,
                () => true,
                new IISManager(_sitePath, _tempPath, new SyncStatusRepository(factory), new ConsoleFactory(), LoggerLevel.Debug),
                new ConsoleFactory(),
                LoggerLevel.Debug
            );
        }