private static void ReleaseItemExclusive(TableServiceContext svc, SessionRow session, object lockId) { if ((int)lockId != session.Lock) { // obviously that can happen, but let's see when at least in Debug mode Debug.Assert(false, "Error"); return; } session.ExpiresUtc = DateTime.UtcNow.AddMinutes(session.Timeout); session.Locked = false; svc.UpdateObject(session); svc.SaveChangesWithRetries(); }
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(); } } }
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 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(); } } }
//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(); } } }
//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(); } } }
//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 MembershipUser ProcessGetUserQuery(TableServiceContext svc, IQueryable<MembershipRow> query, bool updateLastActivityDate) { if (query == null) { throw new ArgumentNullException("query"); } // if no user is found, we return null MembershipUser res = null; // the GetUser query should return at most 1 result, we do a Take(2) to detect error conditions query = query.Take(2); IEnumerable<MembershipRow> queryResult = query.AsTableServiceQuery().Execute(); if (queryResult == null) { return null; } var l = new List<MembershipRow>(queryResult); if (l.Count == 0) { return null; } else if (l.Count > 1) { throw new ProviderException("Non-unique primary keys!"); } else { MembershipRow row = l.First(); if (updateLastActivityDate) { row.LastActivityDateUtc = DateTime.UtcNow; } res = new MembershipUser( this.Name, row.UserName, row.UserId, row.Email, row.PasswordQuestion, row.Comment, row.IsApproved, row.IsLockedOut, row.CreateDateUtc.ToLocalTime(), row.LastLoginDateUtc.ToLocalTime(), row.LastActivityDateUtc.ToLocalTime(), row.LastPasswordChangedDateUtc.ToLocalTime(), row.LastLockoutDateUtc.ToLocalTime()); if (updateLastActivityDate) { svc.UpdateObject(row); svc.SaveChangesWithRetries(); } } return res; }
private static void ReleaseItemExclusive(TableServiceContext svc, SessionRow session, object lockId) { if ((int) lockId != session.Lock) { return; } session.ExpiresUtc = DateTime.UtcNow.AddMinutes(session.Timeout); session.Locked = false; svc.UpdateObject(session); svc.SaveChangesWithRetries(); }
public void SaveFriendLikes() { // Persist friend likes to Table Storage var context = new TableServiceContext(tableClient.BaseUri.ToString(), tableClient.Credentials); // Using the Upsert pattern in the August 2011 API / November 2011 SDK (1.6) var n = 0; foreach (var k in FriendLikes.Keys) { context.AttachTo(FRIEND_LIKES_TABLE, FriendLikes[k]); context.UpdateObject(FriendLikes[k]); if (n++ % 100 == 0) { context.SaveChangesWithRetries(SaveChangesOptions.Batch|SaveChangesOptions.ReplaceOnUpdate); } } // Create the pre-calculated JSON Blob var blob = blobContainer.GetBlobReference(UserId); var likes = GetOrderedFriendLikes(); var json = JsonConvert.SerializeObject(likes); blob.UploadText("dataCallback(" + json + ")"); }