예제 #1
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif

            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            //client = new CloudQueueClient(account.BlobEndpoint.ToString(), account.Credentials);
            qclient = account.CreateCloudQueueClient();
            q = qclient.GetQueueReference("icd9mapplotrequests");
            rows = new List<ICD9MapPlotResultEntry>();
            bclient = account.CreateCloudBlobClient();
            container = bclient.GetContainerReference("results");
            container.CreateIfNotExist();
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("ICD9MapPlotResult");
            client.CreateTableIfNotExist("DoctorDetails");
            client.CreateTableIfNotExist("PatientDetails");
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
        public static void Initialize()
        {
            CloudStorageAccount account = CloudConfiguration.GetStorageAccount(AzureConnectionStrings.DataConnection);

            // Tables
            var cloudTableClient = new CloudTableClient(account.TableEndpoint.ToString(), account.Credentials);
            cloudTableClient.CreateTableIfNotExist<ExpenseExpenseItemEntity>(AzureStorageNames.ExpenseTable);
            cloudTableClient.CreateTableIfNotExist<ExpenseExportEntity>(AzureStorageNames.ExpenseExportTable);

            // Blobs
            CloudBlobClient client = account.CreateCloudBlobClient();
            client.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(5));
            var container = client.GetContainerReference(AzureStorageNames.ReceiptContainerName);
            container.CreateIfNotExist();
            container = client.GetContainerReference(AzureStorageNames.ExpenseExportContainerName);
            container.CreateIfNotExist();

            // Queues
            CloudQueueClient queueClient = account.CreateCloudQueueClient();
            queueClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(5));
            CloudQueue queueReference = queueClient.GetQueueReference(AzureStorageNames.ApprovedExpenseMessage);
            queueReference.CreateIfNotExist();
            queueReference = queueClient.GetQueueReference(AzureStorageNames.PoisonApprovedExpenseMessage);
            queueReference.CreateIfNotExist();
            queueReference = queueClient.GetQueueReference(AzureStorageNames.NewReceiptMessage);
            queueReference.CreateIfNotExist();
            queueReference = queueClient.GetQueueReference(AzureStorageNames.PoisonNewReceiptMessage);
            queueReference.CreateIfNotExist();
        }
 public PlayerRepository(Microsoft.WindowsAzure.StorageClient.CloudTableClient client)
 {
     _client = client;
     _client.CreateTableIfNotExist(_table_name);
     _client.CreateTableIfNotExist(_facebook_player_table_name);
     _client.CreateTableIfNotExist(_player_password_table_name);
 }
예제 #4
0
파일: Context.cs 프로젝트: SamirHafez/Bantu
 static Context()
 {
     CloudStorageAccount.SetConfigurationSettingPublisher((configname, configsettingsPublisher) =>
     {
         var connectionString = RoleEnvironment.GetConfigurationSettingValue(configname);
         configsettingsPublisher(connectionString);
     });
     account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
     CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint.AbsoluteUri, account.Credentials);
     tableClient.CreateTableIfNotExist(PLAYER);
     tableClient.CreateTableIfNotExist(GAME);
     //tableClient.DeleteTableIfExist(PLAYER);
     //tableClient.DeleteTableIfExist(GAME);
 }
예제 #5
0
        internal static bool InitializeStorage()
        {
            try
            {
                // 仅为测试目的,如果我们不在计算仿真程序中运行该服务,我们始终使用 dev 存储.
                if (RoleEnvironment.IsAvailable)
                {
                    CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
                    {
                        configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
                    });
                    StorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                }
                else
                {
                    StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
                }

                CloudBlobClient blobClient = new CloudBlobClient(StorageAccount.BlobEndpoint, StorageAccount.Credentials);
                CloudBlobContainer container = blobClient.GetContainerReference("videostories");
                container.CreateIfNotExist();
                CloudQueueClient queueClient = new CloudQueueClient(StorageAccount.QueueEndpoint, StorageAccount.Credentials);
                CloudQueue queue = queueClient.GetQueueReference("videostories");
                queue.CreateIfNotExist();
                CloudTableClient tableClient = new CloudTableClient(StorageAccount.TableEndpoint.AbsoluteUri, StorageAccount.Credentials);
                tableClient.CreateTableIfNotExist("Stories");
                return true;
            }
            catch (Exception ex)
            {
                Trace.Write("错误初始化存储: " + ex.Message, "Error");
                return false;
            }
        }
예제 #6
0
        //ADD AILMENT DETAILS
        public void AddAilmentDetails(AilmentDetails AilData)
        {
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("PatientDetails");
            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            AilmentDetails x = new AilmentDetails();
            x.AttendingPhysician = AilData.AttendingPhysician;
            x.Diagnosis = AilData.Diagnosis;
            x.DiagnosisID = AilData.DiagnosisID;
            x.GeneralPhysician = AilData.GeneralPhysician;
            x.Hospital = AilData.Hospital;
            x.Lab_Pathology = AilData.Lab_Pathology;
            x.Lab_Physical = AilData.Lab_Physical;
            x.Lab_Radiology = AilData.Lab_Physical;
            x.Medication = AilData.Medication;
            x.PatientIDLinkRowKey = AilData.PatientIDLinkRowKey;
            x.ProgressNotes = AilData.ProgressNotes;
            x.Symptoms = AilData.Symptoms;
            x.TimeIn = AilData.TimeIn;
            x.TimeOut = AilData.TimeOut;
            x.Treatment = AilData.Treatment;
            x.AilmentDetailRowKey = AilData.AilmentDetailRowKey;

            tableContext.AddObject("PatientDetails", x);
            tableContext.SaveChanges();
        }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
 }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
 }
예제 #9
0
        private static void Initialize()
        {
            if (_isStorageInitialized)
                return;

            lock(_initializeLock)
            {
                if (_isStorageInitialized)
                    return;

                CloudStorageAccount.SetConfigurationSettingPublisher((setting, setter) =>
                {
                    setter(RoleEnvironment.GetConfigurationSettingValue(setting));
                });

                var cloudStorageAccount = CloudStorageAccount.FromConfigurationSetting(StorageConstants.StorageConnectionsString);
                _cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();

                CloudQueue membershipsPumpQueue = _cloudQueueClient.GetQueueReference(StorageConstants.MembershipsPumpQueue);
                membershipsPumpQueue.CreateIfNotExist();

                CloudQueue testMembershipPumpQueue = _cloudQueueClient.GetQueueReference(StorageConstants.TestMembershipPumpQueue);
                testMembershipPumpQueue.CreateIfNotExist();

                CloudQueue testMembershipDeleterQueue = _cloudQueueClient.GetQueueReference(StorageConstants.TestMembershipDeleterQueue);
                testMembershipDeleterQueue.CreateIfNotExist();

                _cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
                _cloudTableClient.CreateTableIfNotExist(StorageConstants.TestTable);

                _isStorageInitialized = true;
            }
        }
 public FriendshipRepository()
 {
     storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
 public PersistPrimeSum()
 {
     tableClient = storageAccount.CreateCloudTableClient();
     tableClient.CreateTableIfNotExist(TheTableName);
     tableServiceContext = tableClient.GetDataServiceContext();
     tableServiceContext.IgnoreResourceNotFoundException = true;
 }
 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
예제 #13
0
 public UserTextNotificationRepository()
     : base()
 {
     tableClient = new CloudTableClient(StorageBase.TableBaseUri, StorageBase.Credentials);
     notificationContext = new UserTextNotificationContext(StorageBase.TableBaseUri, StorageBase.Credentials);
     notificationContext2 = new UserTextNotificationContext(StorageBase.TableBaseUri, StorageBase.Credentials);
     tableClient.CreateTableIfNotExist(EntitySetName);
 }
 public AzureStorageClient()
 {
     CloudStorageAccount account = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
     mTableClient = account.CreateCloudTableClient();
     mTableClient.CreateTableIfNotExist(TranslationTable);
     mContext = mTableClient.GetDataServiceContext();
     mContext.IgnoreResourceNotFoundException = true;
 }
        public CustomerRepoDapper()
        {
            connStr = ConfigurationManager.ConnectionStrings["DMTPrimary"].ConnectionString;

            storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
            client = storage.CreateCloudTableClient();
            client.CreateTableIfNotExist(TableName);
            context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
        }
        //The default constructor initializes the storage account by reading its settings from
        //the configuration and then uses CreateTableIfNotExist method in the CloudTableClient
        //class to create the table used by the application.
        public MessageBoardDataSource()
        {
            string connectionString = RoleEnvironment.GetConfigurationSettingValue(connectionStringName);

            storageAccount = CloudStorageAccount.Parse(connectionString);
            tableClient = new CloudTableClient(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
            tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
            tableClient.CreateTableIfNotExist(messageTableName);
        }
예제 #17
0
        public SingleDeliveryQueueClient(CloudStorageAccount account, string queueName)
        {
            var queueClient = account.CreateCloudQueueClient();
            queue = queueClient.GetQueueReference(queueName);
            queue.CreateIfNotExist();

            tableClient = account.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(TableName);
        }
        public CloudPopulator(string connectionString, IMetricRecorder recorder)
        {
            //create table if needed

            var account = CloudStorageAccount.Parse(connectionString);
            _client = account.CreateCloudTableClient();
            _client.CreateTableIfNotExist(TableName);

            _recorder = recorder;
        }
        public ChallengeStatusVoteRepository()
        {
            storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
            client = storage.CreateCloudTableClient();

            client.CreateTableIfNotExist(TableName);

            context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
            context.MergeOption = MergeOption.NoTracking;
        }
예제 #20
0
        public LogDataContext(string logType, CloudStorageAccount storageAccount)
            : base(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials)
        {
            _storageAccount = storageAccount;
            var tableStorage = new CloudTableClient(_storageAccount.TableEndpoint.AbsoluteUri, _storageAccount.Credentials);

            _tableName = logType.ToLower() + "log";

            try
            {
                tableStorage.CreateTableIfNotExist(_tableName + "byactivity" + EnvironmentSettings.Environment.Current);
                tableStorage.CreateTableIfNotExist(_tableName + "bytime" + EnvironmentSettings.Environment.Current);
                tableStorage.CreateTableIfNotExist(_tableName + "byuser" + EnvironmentSettings.Environment.Current);
                tableStorage.CreateTableIfNotExist(_tableName + "byip" + EnvironmentSettings.Environment.Current);
            }
            catch (Exception e)
            {
            }
        }
        public ActivityRepository()
        {
            storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
            client = storage.CreateCloudTableClient();

            client.CreateTableIfNotExist(TableName);

            context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
            context.IgnoreResourceNotFoundException = true;
        }
        public ChallengeStatusRepository()
        {
            storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
            client = storage.CreateCloudTableClient();

            client.CreateTableIfNotExist(TableName);

            //context = client.GetDataServiceContext();
            context = new TableServiceContextV2(client.BaseUri.ToString(), client.Credentials);
            context.IgnoreResourceNotFoundException = true;
        }
        public TableStorageSiteUrlRepository()
        {
            _storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting(_connectionStringName)
                );

            _tableClient = new CloudTableClient(_storageAccount.TableEndpoint.AbsoluteUri, _storageAccount.Credentials);
            _tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
            _tableClient.CreateTableIfNotExist(_tableName);
            _tableContext = _tableClient.GetDataServiceContext();
        }
예제 #24
0
 public StorageWrapper()
 {
     _storageAccount = CloudStorageAccount.Parse(
         RoleEnvironment.GetConfigurationSettingValue(_connectionStringName)
         );
     _tableClient = new CloudTableClient(_storageAccount.TableEndpoint.AbsoluteUri,
         _storageAccount.Credentials);
     _tableClient.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
     _tableClient.CreateTableIfNotExist(_tableName);
     _tableContext = _tableClient.GetDataServiceContext();
 }
        public NotificationRepository()
        {
            // Retrieve storage account from connection-string
            storageAccount = CloudStorageAccount.Parse(Properties.Settings.Default.DataStorageConnectionString);

            // Create the table client
            tableClient = storageAccount.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(tableName);

            // Get the data service context
            context = tableClient.GetDataServiceContext();
        }
        public RoleInfoDataSource()
        {
            this.storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
            //this.storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
            //CloudTableClient.CreateTablesFromModel(typeof(RoleInfoDataContext), storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);

            CloudTableClient client = new CloudTableClient(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
            client.CreateTableIfNotExist(entitySetName);

            this.context = new RoleInfoDataContext(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials);
            this.context.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1));
        }
        public NotificationRepository()
        {
            // Retrieve storage account from connection-string
            storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting(Constants.DataStorageConnectionStringKey));

            // Create the table client
            tableClient = storageAccount.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(tableName);

            // Get the data service context
            context = tableClient.GetDataServiceContext();
        }
예제 #28
0
        private DatabaseManager()
        {
            // Retrieve the storage account from the connection string
            storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));

            // Create the table client
            tableClient = storageAccount.CreateCloudTableClient();

            // Create the table if it doesn't exist
            tableClient.CreateTableIfNotExist(tableName);

            // Get the data service context
            serviceContext = tableClient.GetDataServiceContext();
        }
        public AzureMessageLogWriter(CloudStorageAccount account, string tableName)
        {
            if (account == null) throw new ArgumentNullException("account");
            if (tableName == null) throw new ArgumentNullException("tableName");
            if (string.IsNullOrWhiteSpace(tableName)) throw new ArgumentException("tableName");

            this.account = account;
            this.tableName = tableName;
            this.tableClient = account.CreateCloudTableClient();
            this.tableClient.RetryPolicy = RetryPolicies.NoRetry();

            var retryStrategy = new ExponentialBackoff(10, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(1));
            this.retryPolicy = new RetryPolicy<StorageTransientErrorDetectionStrategy>(retryStrategy);

            this.retryPolicy.ExecuteAction(() => tableClient.CreateTableIfNotExist(tableName));
        }
        private static void CreateUserPrivilegeTable(CloudTableClient cloudTableClient)
        {
            cloudTableClient.CreateTableIfNotExist(PrivilegesTableServiceContext.UserPrivilegeTableName);

            // Execute conditionally for development storage only.
            if (cloudTableClient.BaseUri.IsLoopback)
            {
                TableServiceContext context = cloudTableClient.GetDataServiceContext();
                var entity = new UserPrivilege { UserId = "UserId", Privilege = "Privilege" };

                context.AddObject(PrivilegesTableServiceContext.UserPrivilegeTableName, entity);
                context.SaveChangesWithRetries();
                context.DeleteObject(entity);
                context.SaveChangesWithRetries();
            }
        }