예제 #1
0
        private async void ConnectToBand()
        {
            this.CurrentStatus = "Connecting...";
            try
            {
                int index = MainPageNew.bandSelectedIndex;
                band = BandList[index];

                this.BandId = await AzureDbservice.getBandIdForUserId(App.User.UserId, App.GroupId, band.Name);

                var result = await bandService.ConnectToBand(band, App.User);

                if (result)
                {
                    this.CurrentStatus           = "Connected to band : " + band.Name;
                    this.ConnectButtonEnabled    = false;
                    bandService.PropertyChanged += BandService_PropertyChanged;
                    bandService.UpdateFluidLoss();
                    // Band Readings
                    await bandService.StartReadingSkinTemp();

                    await bandService.StartReadingHeartRate();

                    await bandService.StartReadingGSR();

                    await bandService.StartReadingUV();

                    await bandService.StartReadingAmbientLight();

                    await bandService.StartReadingPedometer();

                    await bandService.StartReadingCalories();

                    //await bandService.StartReadingFluidLoss();

                    InserToDB();
                    return;
                }
                else
                {
                    throw new Exception("cannot connect");
                }
            }
            catch (Exception e)
            {
                this.CurrentStatus = "Failed to connect : " + band.Name;
            }
        }