Пример #1
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();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine(@"Run Fiddler now, make sure it is capturing requests,
            and set automatic breakpoints in it:
            [Rules]->[Automatic Breakpoints]->[After Responses] or Alt+F11 in Fiddler window

            Then press Enter...");
            Console.ReadLine();

            //using storage emulator credentials as we need any valid name/key pair to force outgoing request to Azure Storage servers.
            var cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==");

            var context = new TableServiceContext(cloudStorageAccount.TableEndpoint.AbsoluteUri, cloudStorageAccount.Credentials)
            {
                RetryPolicy = RetryPolicies.Retry(10, TimeSpan.FromSeconds(1)), //just to show that it's not used
            };

            var dataServiceQuery = context.CreateQuery<TableServiceEntity>("TableServiceEntity");

            //var cloudTableQuery = dataServiceQuery.AsTableServiceQuery(); //note that this code doesn't transfer RetryPolicy to CloudTableQuery, so using explicit declaration:
            var cloudTableQuery = new CloudTableQuery<TableServiceEntity>(dataServiceQuery, context.RetryPolicy);

            Console.WriteLine(@"Paused request to devstoreaccount1.table.core.windows.net should appear in Fiddler now.
            Please wait 2 minutes to get exception described");

            foreach (var tableServiceEntity in cloudTableQuery)
            {
                //Notice that Fiddler registered only one attempt to get the resource, so RetryPolicy is not used here
            }
        }
Пример #3
0
 public ErrorMapContext()
 {
     StorageAccount = CloudStorageAccount.FromConfigurationSetting(ConfigurationName);
     CloudTableClient TableClient = StorageAccount.CreateCloudTableClient();
     TableClient.CreateTableIfNotExist(TableName);
     servCtx = TableClient.GetDataServiceContext();
 }
 public FriendshipRepository()
 {
     storage = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
Пример #5
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 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();
 }
Пример #8
0
        private void CreateAvailableEndpoints(dynamic data)
        {
            if (string.IsNullOrEmpty(data.alias))
                return;

            string alias = data.alias;
            string description = data.description;
            string disclaimer = data.disclaimer;

            var esa = new AvailableEndpoint
            {
                PartitionKey = alias,
                RowKey = "",
                alias = alias,
                description = description,
                disclaimer = disclaimer,
                storageaccountname = data.storagename,
                storageaccountkey = data.storagekey
            };

            CloudStorageAccount ta = CloudStorageAccount.Parse(string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", data.storagename, data.storagekey));
            var ctx = new TableServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);
            var tableClient = ta.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(ENDPOINTS_TABLENAME);
            ctx.AddObject(ENDPOINTS_TABLENAME, esa);
            ctx.SaveChanges();
        }
        /// <summary>
        /// Returns all entities from given table
        /// </summary>
        /// <param name="serviceContext"></param>
        /// <param name="entitySetName"></param>
        /// <returns></returns>
        public CloudTableQuery<Object> GetEntities(TableServiceContext serviceContext, string entitySetName)
        {
            CloudTableQuery<Object> partitionQuery =
            (from e in serviceContext.CreateQuery<Object>(entitySetName)
             select e).AsTableServiceQuery<Object>();

            return partitionQuery;
        }
 public AzureStorageClient()
 {
     CloudStorageAccount account = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
     mTableClient = account.CreateCloudTableClient();
     mTableClient.CreateTableIfNotExist(TranslationTable);
     mContext = mTableClient.GetDataServiceContext();
     mContext.IgnoreResourceNotFoundException = true;
 }
Пример #11
0
        protected override IQueryable<Entity> CreateBenchmarkQuery(TableServiceContext context)
        {
            var r = new Random();
            var value = String.Format("{0:D4}", r.Next(10000));

            return from e in context.CreateQuery<Entity>("Entities")
                   where e.PartitionKey == "0" && e.RowKey == value
                   select e;
        }
Пример #12
0
 public IEnumerable<InternalId> Execute(TableServiceContext serviceContext)
 {
     return
         queries
             .OrderBy(_ => _.EstimatedQueryCost(serviceContext))
             .Aggregate(
                 Enumerable.Empty<InternalId>(),
                 (matching, query) => matching.Union(query.Execute(serviceContext)).Materialize()
             );
 }
Пример #13
0
 public IEnumerable<InternalId> ExecuteInsideIntersect(TableServiceContext serviceContext, IEnumerable<InternalId> joinConstraint)
 {
     return
         queries
             .OrderBy(_ => _.EstimatedQueryCost(serviceContext))
             .Aggregate(
                 joinConstraint.Materialize(),
                 (matching, query) => matching.Intersect(query.ExecuteInsideIntersect(serviceContext, matching))
             );
 }
Пример #14
0
 public IEnumerable<InternalId> Execute(TableServiceContext serviceContext)
 {
     return
         (from fi in managedIndex.ForwardIndex(serviceContext)
          where fi.PartitionKey.CompareTo(managedIndex.KeyAsString(Key)) >= 0
          select fi)
             .AsEnumerable()
             .TakeWhile(fi => fi.PartitionKey.StartsWith(Key))
             .Select(fi => managedIndex.ConvertToInternalId(fi.RowKey));
 }
Пример #15
0
        public UserSettings(string accountName, string accountKey, string settingsTableName)
        {
            this.settingsTableName = settingsTableName;
            this.partitionTableName = settingsTableName + "UserDirectory";
            var account = new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accountKey), true);
            var tableClient = account.CreateCloudTableClient();

            tableClient.CreateTableIfNotExist(settingsTableName);
            tableClient.CreateTableIfNotExist(partitionTableName);
            settingsTableContext = tableClient.GetDataServiceContext();
        }
        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();
        }
Пример #17
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();
        }
Пример #19
0
        public IEnumerable<InternalId> Execute(TableServiceContext serviceContext)
        {
            var queriesByCost = queries.OrderBy(_ => _.EstimatedQueryCost(serviceContext));

            return
                queriesByCost
                    .Skip(1)
                    .Aggregate(
                        queriesByCost.First().Execute(serviceContext).Materialize(),
                        (matching, query) => matching.Intersect(query.ExecuteInsideIntersect(serviceContext, matching)).Materialize()
                    );
        }
        public AzureTableTraceListener(string applicationName, string tableConnectionString, string tableName = "TraceLogs")
        {
            if (string.IsNullOrEmpty(applicationName))
                throw new ArgumentNullException("applicationName",
                    "You must define an ApplicationName to log trace messages");

            ApplicationName = applicationName;
            _tableName = tableName;
            var storageAccount = CloudStorageAccount.Parse(tableConnectionString);
            var tableClient = storageAccount.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(tableName);
            _table = tableClient.GetDataServiceContext();
        }
        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();
        }
        public AzureStorageOld(string account, string key, string table, bool nagling = true)
        {
            this._account = this.GetStorageAccount(account, key);

            EnableNagling(nagling);
            this._client = _account.CreateCloudTableClient();

            this._table = table;

            this.CreateTable(table);

            this._context = _client.GetDataServiceContext();
        }
Пример #23
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();
        }
        protected void DelAllBut_Click(object sender, EventArgs e)
        {
            #if AZURE
            var storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees"));
            var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials);
            storageAccount.CreateCloudTableClient().CreateTableIfNotExist("log");

            foreach (var row in serviceContext.CreateQuery<LogMessageEntity>("log"))
            {
                serviceContext.DeleteObject(row);
            }
            serviceContext.SaveChanges();

            Page.Response.Redirect(Page.Request.Url.ToString(), true);
            #endif
        }
        protected void Load_Data()
        {
            #if AZURE
            //Access the storage account
            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees"));
            //Create the service context to access the table
            var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials);

            //Getting the table entries
            foreach (var row in serviceContext.CreateQuery<LogMessageEntity>("log"))    //"log" - the name of the table you wish to see
            {
                OutBox.Text += row.Message;
            }
            #else
            OutBox.Text = "This page will only work when compiled for use with Windows Azure";
            #endif
        }
        public void CanCreateTable()
        {
            var tableName = "ReviewEntity";

            var tableServiceContext = new TableServiceContext(_account.TableEndpoint.ToString(), _account.Credentials);

            _account.CreateCloudTableClient().DeleteTableIfExist(tableName);
            _account.CreateCloudTableClient().CreateTableIfNotExist(tableName);

            tableServiceContext.AddObject(tableName, new ReviewEntity() { Title = "blah", PublicationDate = DateTime.Now });
            tableServiceContext.AddObject(tableName, new ReviewEntity() { Title = "test", PublicationDate = DateTime.Now.AddDays(-7) });
            tableServiceContext.SaveChanges();

            var results = from c in tableServiceContext.CreateQuery<ReviewEntity>(tableName) select c;

            var query = results.AsTableServiceQuery<ReviewEntity>();
            var queryResults = query.Execute();
            queryResults.Count().ShouldEqual(2);
        }
Пример #27
0
        public IEnumerable<InternalId> Execute(TableServiceContext serviceContext)
        {
            var query = managedIndex.ReverseIndex(serviceContext);

            Func<InternalId, InternalId> nextInternalId =
                cid =>
                    {
                        var next =
                            (from ri in query
                             where ri.PartitionKey.CompareTo(cid.Value.ToString()) > 0
                             select ri)
                                .FirstOrDefault();
                        return next != null ? managedIndex.ConvertToInternalId(next.PartitionKey) : null;
                    };

            var currentInternalId = new InternalId(Guid.Empty);
            while ((currentInternalId = nextInternalId(currentInternalId)) != null)
                yield return currentInternalId;
        }
Пример #28
0
        internal RequestHistory()
        {
            // Get the timeout used to remove devices.
            _redirectTimeout = Manager.Redirect.Timeout;

            // Get the table name.
            _tableName = Regex.Replace(Manager.Redirect.DevicesFile, "[^A-Za-z]+", String.Empty);

            // Determine if the functionality should be enabled.
            _enabled = String.IsNullOrEmpty(_tableName) == false;

            if (_enabled)
            {
                // Initialise the Azure table service creating the table if it does not exist.
                _storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(Mobile.Constants.AZURE_STORAGE_NAME));
                _serviceContext = new TableServiceContext(_storageAccount.TableEndpoint.ToString(), _storageAccount.Credentials);
                _serviceContext.IgnoreResourceNotFoundException = false;
                _storageAccount.CreateCloudTableClient().CreateTableIfNotExist(_tableName);
            }
        }
Пример #29
0
        private static void AddData(TableServiceContext tableContext, string p)
        {
            CustomerEntity customerEntity1 = new CustomerEntity("Jusel", "Jaroslaw");
            customerEntity1.Email = "*****@*****.**";
            customerEntity1.PhoneNumber = "+370xxxxx1";

            tableContext.AddObject("sampleTable", customerEntity1);

            CustomerEntity customerEntity2 = new CustomerEntity("Ungurys", "Andrius");
            customerEntity2.Email = "*****@*****.**";
            customerEntity2.PhoneNumber = "+370xxxxx2";

            tableContext.AddObject("sampleTable", customerEntity2);

            CustomerEntity customerEntity3 = new CustomerEntity("Čiukšys", "Vytautas");
            customerEntity3.Email = "*****@*****.**";
            customerEntity3.PhoneNumber = "+370xxxxx3";

            tableContext.AddObject("sampleTable", customerEntity3);

            CustomerEntity customerEntity4 = new CustomerEntity("Norvaišaitė", "Modesta");
            customerEntity4.Email = "*****@*****.**";
            customerEntity4.PhoneNumber = "+370xxxxx4";

            tableContext.AddObject("sampleTable", customerEntity4);

            CustomerEntity customerEntity5 = new CustomerEntity("Vaicekauskas", "Vilius");
            customerEntity5.Email = "*****@*****.**";
            customerEntity5.PhoneNumber = "+370xxxxx5";

            tableContext.AddObject("sampleTable", customerEntity5);

            CustomerEntity customerEntity6 = new CustomerEntity("Stašys", "Laurynas");
            customerEntity6.Email = "*****@*****.**";
            customerEntity6.PhoneNumber = "+370xxxxx6";

            tableContext.AddObject("sampleTable", customerEntity6);

            //Finally, changes are saved
            tableContext.SaveChangesWithRetries();
        }
Пример #30
0
        //ADD DOCTOR DETAILS
        public void AddDoctorBasicDetails(DoctorBasicDetails DocData)
        {
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("DoctorDetails");
            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            DoctorBasicDetails x = new DoctorBasicDetails();

            x.DoctorID = DocData.DoctorID;
            x.Name = DocData.Name;
            x.Specialization = DocData.Specialization;
            x.PhoneNumber = DocData.PhoneNumber;
            x.Email = DocData.Email;
            x.PersonalClinicID = DocData.PersonalClinicID;

            tableContext.AddObject("DoctorDetails", x);
            tableContext.SaveChanges();
        }