private async void update() { int numOfMembers = Participants.Count(); for (int i = 0; i < numOfMembers; i++) { BandEntry latest = await AzureDbService.getLatestBandEntryForUser(participants[i].user.UserId); var member = participants[i]; // check if not null and latest date > members date if (latest != null && (DateTime.Compare(member.BandEntry.TimeStamp, latest.TimeStamp) < 0)) { member.BandEntry = latest; Participants[i] = new Participant(member.RowNumber, member.user, member.BandEntry, member.dehydrateTicks, member.BandEntryHistory, member.notified); if (latest.IsDehydrated && noticed == false) { await DisplayAlert("Dehydration Alert", member.user.userName + " is dehydrated!!", "Ok"); noticed = true; numOfAlerts_summary++; } } } }
private bool UseMemberInfo() { if (counter < CurrentParticipant.BandEntryHistory.Count) { currentEntry = CurrentParticipant.BandEntryHistory[counter]; counter++; DehydrationLevel.Add(new ChartDataPoint(currentEntry.TimeStamp, currentEntry.FluidLoss)); } return(true); }
public async Task <int> addBandEntry(BandEntry bandEntry) { try { await mobileService.GetTable <BandEntry>().InsertAsync(bandEntry); } catch (Exception e) { return(-1); } return(1); }
public int writeToDB(BandEntry entry) { //String connectionString = "Server=tcp:hydrapp-tau.database.windows.net,1433;Initial Catalog=Hydrapp;Persist Security Info=False;User ID={hydrapp2016};Password={tau2016BsNw};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; //SqlConnection connection = new SqlConnection(connectionString); //connection.Open(); //SqlConnection conn = new SqlConnection(); //conn.ConnectionString = connectionString; return(1); }
private bool AddData() { if (counter < historicData.Count) { currentEntry = historicData.ElementAt(counter); counter++; } else { setLatestData(); } DehydrationLevel.Add(new ChartDataPoint(currentEntry.TimeStamp, currentEntry.FluidLoss)); return(true); }
private void updateVal() { // TODO REMOVE int numofusers = Participants.Count(); for (int i = 0; i < numofusers; i++) { Participant p = Participants[i]; BandEntry latest = GenerateBandEntry(p.BandEntry); var member = participants[i]; member.BandEntry = latest; Participants[i] = new Participant(member.RowNumber, member.user, member.BandEntry, member.dehydrateTicks, member.BandEntryHistory, member.notified); } }
private bool UpdateDataInDb() { try { double fluidLoss = double.Parse(readFluidLoss); bool dehydration = fluidLoss >= 0.01; // change to 3 BandEntry newEntry = new BandEntry(DateTime.UtcNow, App.ActivityId, App.GroupId, App.User.UserId, BandId, int.Parse(readGSR), double.Parse(readSkinTemp), int.Parse(readAmbientLight), int.Parse(readHR), getUV(readUV), int.Parse(readCalories), 0, fluidLoss, dehydration); sendToCloud(newEntry); } catch (Exception e) { // ignored } return(true); }
/// <summary> /// ************************************************ /// ************************************************ /// ************************************************ /// ************************************************ /// FUNCTIONS FOR DEBUG /// ************************************************ /// ************************************************ /// ************************************************ /// ************************************************ /// </summary> /// private void GenerateaddNewMembers() { // TODO REMOVE if (participants.Count() != 3) { User user = new User("Ben", "123", "nan", 70, 1.80); BandEntry latest = GenerateBandEntry(null); participants.Add(new Participant(RowCount(), user, latest, 1000, false)); user = new User("Noam", "123", "nan", 70, 1.80); latest = GenerateBandEntry(null); participants.Add(new Participant(RowCount(), user, latest, 2000, false)); user = new User("Shimon", "123", "nan", 70, 1.80); latest = GenerateBandEntry(null); participants.Add(new Participant(RowCount(), user, latest, 3000, false)); } NumOfParticipants = participants.Count(); }
private async void addNewMembers() { List <User> membersToAdd = await AzureDbService.getNewMembers(currentMembersList, App.GroupId); foreach (var user in membersToAdd) { BandEntry latest = await AzureDbService.getLatestBandEntryForUser(user.UserId); long dehydrateTicks = await AzureDbService.getDehydrateAVGForUser(user.UserId, App.ActivityLvl); if (latest != null) { participants.Add(new Participant(RowCount(), user, latest, dehydrateTicks, false)); currentMembersList.Add(user.UserId); } } App.Users = currentMembersList; NumOfParticipants = participants.Count(); }
public BandEntry GenerateBandEntry(BandEntry current) { // TODO REMOVE bool isDe = false; Random random = new Random(); int hearRate = random.Next(70, 200); double skinTemp = random.NextDouble() * (37 - 28) + 28; double hear = random.NextDouble() * (100 - 50) + 50; double fluidloss; if (current == null) { fluidloss = 0; } else { fluidloss = current.FluidLoss + (random.NextDouble() * (0.8)); } if (fluidloss >= 3) { isDe = true; } return(new BandEntry(DateTime.Now, App.ActivityId, 32, 3, 3, 3, skinTemp, 0, hearRate, 0, 0, 0, fluidloss, isDe)); }
private async void setLatestData() { currentEntry = await AzureDbservice.getLatestBandEntryForUser(CurrentUser.UserId); }
private async void sendToCloud(BandEntry newEntry) { await AzureDbservice.addBandEntry(newEntry); }