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 } }
/// <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; }
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; }
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); }
public HospitalPatientConnectionDetails SeeHospitalPatientConnectionDetails(string HospID) { if (HospID == null) return null; #if DEBUG account = CloudStorageAccount.DevelopmentStorageAccount; #else account = new CloudStorageAccount(accountAndKey, true); #endif if (HospID == null) return null; client = account.CreateCloudTableClient(); client.CreateTableIfNotExist("DoctorDetails"); tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials); IQueryable<HospitalPatientConnectionDetails> data = (from i in tableContext.CreateQuery<HospitalPatientConnectionDetails>("DoctorDetails") where i.PartitionKey == "HospitalPatientConnectionDetails" select i).AsQueryable<HospitalPatientConnectionDetails>(); //Label1.Text = ""; if (data.AsEnumerable<HospitalPatientConnectionDetails>().Any<HospitalPatientConnectionDetails>()) { HospitalPatientConnectionDetails z = new HospitalPatientConnectionDetails(); var y = (from HospitalPatientConnectionDetails i in data where i.HospitalIDLinkRowKey == HospID select i).FirstOrDefault<HospitalPatientConnectionDetails>() as HospitalPatientConnectionDetails; if (y != null) { z = y; } else { z = null; } return z; } else return null; }
public void UpdateHospitalPatientConnectionDetails(string HospID, HospitalPatientConnectionDetails HospPatientData) { if (HospID == null) return; #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); IQueryable<HospitalPatientConnectionDetails> data = (from i in tableContext.CreateQuery<HospitalPatientConnectionDetails>("DoctorDetails") where i.PartitionKey == "HospitalPatientConnectionDetails" select i).AsQueryable<HospitalPatientConnectionDetails>(); //Label1.Text = ""; if (data.AsEnumerable<HospitalPatientConnectionDetails>().Any<HospitalPatientConnectionDetails>()) { HospitalPatientConnectionDetails z = new HospitalPatientConnectionDetails(); var x = (from HospitalPatientConnectionDetails i in data where i.HospitalIDLinkRowKey == HospID select i).FirstOrDefault<HospitalPatientConnectionDetails>() as HospitalPatientConnectionDetails; if (x != null) { //x.HospitalIDLinkRowKey = HospPatientData.HospitalIDLinkRowKey; x.PatientIDLinkRowKey = HospPatientData.PatientIDLinkRowKey; tableContext.UpdateObject(x); tableContext.SaveChanges(); } } }
public void UpdateHospitalBasicDetails(string HospID, HospitalBasicDetails HospitalData) { if (HospID == null) return; #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); IQueryable<HospitalBasicDetails> data = (from i in tableContext.CreateQuery<HospitalBasicDetails>("DoctorDetails") where i.PartitionKey == "HospitalBasicDetails" select i).AsQueryable<HospitalBasicDetails>(); //Label1.Text = ""; if (data.AsEnumerable<HospitalBasicDetails>().Any<HospitalBasicDetails>()) { HospitalBasicDetails z = new HospitalBasicDetails(); var x = (from HospitalBasicDetails i in data where i.HospitalID == HospID select i).FirstOrDefault<HospitalBasicDetails>() as HospitalBasicDetails; if (x != null) { //x.HospitalID = HospitalData.HospitalID; x.HospitalName = HospitalData.HospitalName; x.Address = HospitalData.Address; x.Latitude = HospitalData.Latitude; x.Longitude = HospitalData.Longitude; x.Facilities = HospitalData.Facilities; x.Departments = HospitalData.Departments; x.Beds_Rooms = HospitalData.Beds_Rooms; x.Type = HospitalData.Type; tableContext.UpdateObject(x); tableContext.SaveChanges(); } } }
//UPDATE GENERAL HISTORY public void UpdateGeneralHistory(string SSN, GeneralHistory GenHistData) { if (SSN == null) return; #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); IQueryable<GeneralHistory> data = (from i in tableContext.CreateQuery<GeneralHistory>("PatientDetails") where i.PartitionKey == "GeneralHistory" select i).AsQueryable<GeneralHistory>(); //Label1.Text = ""; if (data.AsEnumerable<GeneralHistory>().Any<GeneralHistory>()) { var x = (from GeneralHistory i in data where i.PatientIDLinkRowKey == SSN select i).FirstOrDefault<GeneralHistory>() as GeneralHistory; if (x != null) { x.Allergies = GenHistData.Allergies; x.BloodPressure = GenHistData.BloodPressure; x.BloodType = GenHistData.BloodType; x.BMI = GenHistData.BMI; x.Conditions = GenHistData.Conditions; x.Height = GenHistData.Height; x.Weight = GenHistData.Weight; x.Others = GenHistData.Others; //x.PatientIDLinkRowKey = GenHistData.PatientIDLinkRowKey; //tableContext.AddObject("PatientDetails", x); tableContext.UpdateObject(x); tableContext.SaveChanges(); } } }
public void UpdateDoctorBasicDetails(string DocID, DoctorBasicDetails DocData) { if (DocID == null) return; #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); IQueryable<DoctorBasicDetails> data = (from i in tableContext.CreateQuery<DoctorBasicDetails>("DoctorDetails") where i.PartitionKey == "DoctorBasicDetails" select i).AsQueryable<DoctorBasicDetails>(); //Label1.Text = ""; if (data.AsEnumerable<DoctorBasicDetails>().Any<DoctorBasicDetails>()) { //DoctorBasicDetails z = new DoctorBasicDetails(); var x = (from DoctorBasicDetails i in data where i.DoctorID == DocID select i).FirstOrDefault<DoctorBasicDetails>() as DoctorBasicDetails; if (x != null) { //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.UpdateObject(x); tableContext.SaveChanges(); } } }
public static IEnumerable<Person> Get(TableServiceContext context) { return from e in context.CreateQuery<Person>("Entities") where e.PartitionKey == "0" select e; }
/// <summary>Gets the text to display in the root Schema Explorer node for a given connection info.</summary> /// <param name="cxInfo">The connection information.</param> /// <returns>The text to display in the root Schema Explorer node for a given connection info</returns> public override string GetConnectionDescription(IConnectionInfo connectionInfo) { var temp = new TableServiceContext("", null); temp.CreateQuery<object>("").AsTableServiceQuery().ToList(); return new StorageAccountProperties(connectionInfo).DisplayName; }
public DataServiceQuery<IndexEntity> ReverseIndex(TableServiceContext serviceContext) { if(indexCompiled.WaitOne(recompileTimeoutMs)) return serviceContext.CreateQuery<IndexEntity>(ReverseIndexName); throw new IndexNotReadyException(Name); }
//VIEW GENERAL HISTORY public GeneralHistory SeeGeneralHistoryData(string SSN) { if (SSN == null) return null; #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); IQueryable<GeneralHistory> data = (from i in tableContext.CreateQuery<GeneralHistory>("PatientDetails") where i.PartitionKey == "GeneralHistory" select i).AsQueryable<GeneralHistory>(); //Label1.Text = ""; if (data.AsEnumerable<GeneralHistory>().Any<GeneralHistory>()) { GeneralHistory z = new GeneralHistory(); var y = (from GeneralHistory i in data where i.PatientIDLinkRowKey == SSN select i).FirstOrDefault<GeneralHistory>() as GeneralHistory; if (y != null) { z = y; } else { z = null; } return z; } else return null; }
//VIEW ALL AILMENTS public List<AilmentDetails> SeeAilmentDetailsData(string SSN) { if (SSN == null) return null; #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); IQueryable<AilmentDetails> data = (from i in tableContext.CreateQuery<AilmentDetails>("PatientDetails") where i.PartitionKey == "AilmentDetails" && i.PatientIDLinkRowKey == SSN select i).AsQueryable<AilmentDetails>(); if (data != null) { return data.ToList(); } else return null; }
//UPDATE SPECIFIC AILMENT DETAILS public void UpdateSpecificAilmentsData(string SSN, string rowkey, AilmentDetails AilData) { if (SSN == null) return; #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); IQueryable<AilmentDetails> data = (from i in tableContext.CreateQuery<AilmentDetails>("PatientDetails") where i.PartitionKey == "AilmentDetails" select i).AsQueryable<AilmentDetails>(); //Label1.Text = ""; if (data.AsEnumerable<AilmentDetails>().Any<AilmentDetails>()) { var x = (from AilmentDetails i in data where i.PatientIDLinkRowKey == SSN && i.AilmentDetailRowKey == rowkey select i).FirstOrDefault<AilmentDetails>() as AilmentDetails; if (x != null) { //x.AilmentDetailRowKey = AilData.AilmentDetailRowKey; x.AttendingPhysician = AilData.AttendingPhysician; x.Diagnosis = AilData.Diagnosis; 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; //tableContext.AddObject("PatientDetails", x); tableContext.UpdateObject(x); tableContext.SaveChanges(); } } }
private void RemovePageWithChildPages(TableServiceContext serviceContext, PageEntity entity) { serviceContext.DeleteObject(entity); var children = serviceContext.CreateQuery<PageEntity>(PageTable) .Where(it => it.PartitionKey == entity.SiteName && it.ParentPage == entity.FullName) .ToArray(); foreach (var item in children) { RemovePageWithChildPages(serviceContext, item); } }
public DataServiceQuery<IndexEntity> ForwardIndex(TableServiceContext serviceContext) { //Give the background thread time to finish recompiling. if(indexCompiled.WaitOne(recompileTimeoutMs)) return serviceContext.CreateQuery<IndexEntity>(ForwardIndexName); throw new IndexNotReadyException(Name); }
//VIEW BASIC DETAILS public BasicDetails SeePatientData(string SSN) { if (SSN == null) return null; #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); IQueryable<BasicDetails> data = (from i in tableContext.CreateQuery<BasicDetails>("PatientDetails") where i.PartitionKey == "BasicDetails" select i).AsQueryable<BasicDetails>(); //Label1.Text = ""; if (data.AsEnumerable<BasicDetails>().Any<BasicDetails>()) { BasicDetails z = new BasicDetails(); var y = (from BasicDetails i in data where i.SSN == SSN select i).FirstOrDefault<BasicDetails>() as BasicDetails; if (y != null) { z = y; } else { z = null; } return z; } else return null; }
private Vanity GetVanityFromUri(TableServiceContext context, Uri uri) { var rowKey = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(uri.ToString().ToLower())); Trace.WriteLine(string.Format("Handling {0} ({1})", uri, rowKey)); Vanity result = null; try { result = context.CreateQuery<Vanity>(Vanity.TableName) .Where(v => v.PartitionKey == string.Empty && v.RowKey == rowKey) .FirstOrDefault(); } catch (System.Data.Services.Client.DataServiceQueryException ex) { Trace.WriteLine(string.Format("Url {0} Base64Ecoded {1} is invalid. {2}", uri.ToString(), rowKey, ex.Message)); } if (result != null) { Trace.WriteLine(string.Format("Uri: {0} Vanity.RowKey: {1} Vanity.Destation: {2} Vanity.Options: {3}", uri.ToString(), rowKey, result.Destination, result.Options)); } return result; }
//VIEW SPECIFIC AILMENT DETAILS public AilmentDetails SeeSpecificAilmentDetailsData(string SSN, string rowkey) { if (SSN == null) return null; #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); IQueryable<AilmentDetails> data = (from i in tableContext.CreateQuery<AilmentDetails>("PatientDetails") where i.PartitionKey == "AilmentDetails" && i.PatientIDLinkRowKey == SSN && i.AilmentDetailRowKey == rowkey select i).AsQueryable<AilmentDetails>(); if (data.AsEnumerable<AilmentDetails>().Any<AilmentDetails>()) { AilmentDetails z = new AilmentDetails(); var y = (from AilmentDetails i in data select i).FirstOrDefault<AilmentDetails>() as AilmentDetails; if (y != null) { z = y; } else { z = null; } return z; } else return null; }
private EventSourceEntity GetSourceFromStore(TableServiceContext context, Guid eventSourceId) { var query = from p in context.CreateQuery<EventSourceEntity>(PROVIDERS_TABLE_NAME) where p.RowKey == eventSourceId.ToString() select p; return query.FirstOrDefault(); }
//UPDATE BASIC DETAILS public void UpdateBasicDetails(string SSN, BasicDetails PatientData) { if (SSN == null) return; #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); IQueryable<BasicDetails> data = (from i in tableContext.CreateQuery<BasicDetails>("PatientDetails") where i.PartitionKey == "BasicDetails" select i).AsQueryable<BasicDetails>(); //Label1.Text = ""; if (data.AsEnumerable<BasicDetails>().Any<BasicDetails>()) { var y = (from BasicDetails i in data where i.SSN == SSN select i).FirstOrDefault<BasicDetails>() as BasicDetails; if (y != null) { y.Name = PatientData.Name; //y.SSN = PatientData.SSN; y.DOB = PatientData.DOB; y.LegalStatus = PatientData.LegalStatus; y.MedicalInsurance = PatientData.MedicalInsurance; y.Gender = PatientData.Gender; y.Address = PatientData.Address; y.Nationality = PatientData.Nationality; y.NextOfKin = PatientData.NextOfKin; y.PhoneNumber = PatientData.PhoneNumber; //tableContext.AddObject("PatientDetails", x); tableContext.UpdateObject(y); tableContext.SaveChanges(); } } }