//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(); }
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(); }
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); }
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(); }
/// <summary> /// The main loop for the log table service thread. /// </summary> protected void Run(Object stateInfo) { // Initialise the Azure table service creating the table if it does not exist. var storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(FiftyOne.Foundation.Mobile.Constants.AZURE_STORAGE_NAME)); var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); var tableName = Regex.Replace(LogFile, "[^A-Za-z]+", String.Empty); storageAccount.CreateCloudTableClient().CreateTableIfNotExist(tableName); while (IsQueueEmpty() == false) { try { while (IsQueueEmpty() == false) { lock (_syncQueue) { string message = _queue.Peek(); if (message != null) { var entity = new LogMessageEntity(message); serviceContext.AddObject(tableName, entity); _queue.Dequeue(); } } } // Commit the new log entries to the database. serviceContext.SaveChanges(); } catch { // End the thread and wait until another message comes // arrives to resume writing. _running = false; return; } // Sleep for 50ms incase any new messages come in. Thread.Sleep(50); } _running = false; }
private void PushEventToStore(TableServiceContext context, Guid eventSourceId, IEnumerable<SourcedEvent> events) { var formatter = new BinaryFormatter(); var blobClient = _account.CreateCloudBlobClient(); foreach (var eventToPush in events) { using (var buffer = new MemoryStream()) { var eventEntity = SourcedEventEntity.FromEventSource(eventToPush); var rootContainer = blobClient.GetContainerReference("events"); rootContainer.CreateIfNotExist(); var permissions = new BlobContainerPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; rootContainer.SetPermissions(permissions); var blob = rootContainer.GetBlobReference(eventEntity.RowKey); formatter.Serialize(buffer, eventToPush); buffer.Seek(0, SeekOrigin.Begin); blob.UploadFromStream(buffer); context.AddObject(EVENTS_TABLE_NAME, eventEntity); } } }
private EventSourceEntity InsertNewEventSource(TableServiceContext context, IEventSource source) { var sourceEntity = EventSourceEntity.CreateFromEventSource(source); context.AddObject(PROVIDERS_TABLE_NAME, sourceEntity); return sourceEntity; }
public void Insert(object key, InternalId internalId, TableServiceContext serviceContext) { serviceContext.AddObject(ForwardIndexName, new IndexEntity {PartitionKey = KeyAsString(key), RowKey = internalId.ToString(), OriginalValue = key.ToString()}); serviceContext.AddObject(ReverseIndexName, new IndexEntity { PartitionKey = internalId.ToString(), RowKey = KeyAsString(key), OriginalValue = key.ToString() }); }
public void AddDoctorHospitalConnectionDetails(DoctorHospitalConnectionDetails DocHospData) { #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); DoctorHospitalConnectionDetails x = new DoctorHospitalConnectionDetails(); x.DoctorIDLinkRowKey = DocHospData.DoctorIDLinkRowKey; x.HospitalIDLinkRowKey = DocHospData.HospitalIDLinkRowKey; x.DoctorHospitalPhoneNumber = DocHospData.DoctorHospitalPhoneNumber; tableContext.AddObject("DoctorDetails", x); tableContext.SaveChanges(); }
//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(); }
//ADD BASIC DETAILS public void AddPatientData(BasicDetails PatientData) { #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); BasicDetails x = new BasicDetails(); x.Name = PatientData.Name; x.SSN = PatientData.SSN; x.DOB = PatientData.DOB; x.LegalStatus = PatientData.LegalStatus; x.MedicalInsurance = PatientData.MedicalInsurance; x.Gender = PatientData.Gender; x.Address = PatientData.Address; x.Nationality = PatientData.Nationality; x.NextOfKin = PatientData.NextOfKin; x.PhoneNumber = PatientData.PhoneNumber; x.Longitude = PatientData.Longitude; x.Latitude = PatientData.Latitude; tableContext.AddObject("PatientDetails", x); tableContext.SaveChanges(); }
public void AddHospitalBasicDetails(HospitalBasicDetails HospitalData) { #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); HospitalBasicDetails x = new HospitalBasicDetails(); 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.AddObject("DoctorDetails", x); tableContext.SaveChanges(); }
//ADD GENERAL HISTORY public void AddGeneralHistoryData(GeneralHistory GenHistData) { #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); GeneralHistory x = new GeneralHistory(); 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.SaveChanges(); }
private void MovePageRecursively(Models.Site site, string pageFullName, string newParent, TableServiceContext serviceContext) { var oldPage = Get(new Page(site, pageFullName)); var entity = PageEntityHelper.ToPageEntity(oldPage); if (!string.IsNullOrEmpty(newParent)) { var newPage = new Page(new Page(site, newParent), oldPage.Name); entity.FullName = newPage.FullName; entity.ParentPage = newPage.Parent.FullName; } else { entity.FullName = oldPage.Name; entity.ParentPage = ""; } foreach (var item in ChildPages(oldPage)) { MovePageRecursively(site, item.FullName, entity.FullName, serviceContext); } serviceContext.AddObject(PageTable, entity); var oldEntity = PageEntityHelper.ToPageEntity(oldPage); serviceContext.AttachTo(PageTable, oldEntity, "*"); serviceContext.DeleteObject(oldEntity); }
private void LocalizeWithChildPages(TableServiceContext serviceContext, Page page, Site targetSite) { var entity = CloudTableHelper.GetTableServiceContext().CreateQuery<PageEntity>(PageTable) .Where(it => it.PartitionKey == targetSite.FullName && it.RowKey == page.FullName) .FirstOrDefault(); if (entity == null) { page = Get(page); entity = PageEntityHelper.ToPageEntity(page); entity.SiteName = targetSite.FullName; serviceContext.AddObject(PageTable, entity); foreach (var item in ChildPages(page)) { LocalizeWithChildPages(serviceContext, item, targetSite); } } }