Esempio n. 1
0
        public override void OnReceive(Context context, Intent intent)
        {
            switch (intent.Action)
            {
            case "TAKE":
                try
                {
                    MedicationDatabase db = new MedicationDatabase();
                    db.addtracktaken("true");
                    Toast.MakeText(context, "DOSAGE TAKEN", ToastLength.Short).Show();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                }
                break;

            case "SKIP":
                try
                {
                    Toast.MakeText(context, "DOSAGE SKIPPED", ToastLength.Short).Show();
                    MedicationDatabase db = new MedicationDatabase();
                    db.addtrackmissed("true");
                    Toast.MakeText(context, "DOSAGE MISSED", ToastLength.Short).Show();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                }
                break;
            }
        }
Esempio n. 2
0
        public void MakeAlarm()
        {
            // Setting the Alarm time
            MedicationDatabase db = new MedicationDatabase();
            var alarm_list        = db.GetAlarmList();

            //Debug.WriteLine(" Time -- : "+ m.ToString());
            foreach (var list in alarm_list)
            {
                var hour = Int32.Parse(list.Substring(0, 2));
                var min  = Int32.Parse(list.Substring(3, 2));
                Debug.WriteLine("Hour : " + hour + "\n");
                Debug.WriteLine("Minute   " + min + "\n");
                try
                {
                    DependencyService.Get <ISetAlarm>().SetAlarm(hour, min, "Diabetics App", "Hello i remind you to take medicine");
                }
                catch (FormatException v)
                {
                    Debug.WriteLine("Format Exception : " + v);
                }
                catch (OverflowException c)
                {
                    Debug.WriteLine("Overflow Exception : " + c);
                }
                catch (NullReferenceException en) {
                    Debug.WriteLine("Overflow Exception : " + en);
                }
            }
        }
Esempio n. 3
0
        async void onSave(object sender, System.EventArgs e)
        {
            try
            {
                MedicationDatabase db          = new MedicationDatabase();
                string             insulintype = inulin_type_entry.Text;
                var    alarmtime    = time_pk.Time.ToString();
                string units        = measurements_pk.SelectedItem.ToString();
                string username     = "******";
                string unique_no    = "YTRU3747473b";
                string status       = "true";
                var    units_list   = db.GetUnitsList();
                var    alarm_list   = db.GetAlarmList();
                var    alarm_result = JsonConvert.SerializeObject(alarm_list);
                var    units_result = JsonConvert.SerializeObject(units_list);
                //await DisplayAlert("", "" + alarm_result, "Ok");
                //DependencyService.Get<ISetMyAlarm>().MakeAlarm();

                db.DeleteAlarm();
                db.AddReminder(username, alarm_result, units_result, insulintype, "2");

                Navigation.PopAsync();
            }
            catch (NullReferenceException f)
            {
                await DisplayAlert("Hey!", "Hey please select the measurements!!", "OK");
            }
        }
Esempio n. 4
0
        public void MyLooper()
        {
            try
            {
                alarmService = new SetAlarmImplementation();
                MedicationDatabase c = new MedicationDatabase();
                var alarm            = c.GetAlarmList();
                var username         = c.GetUserName();
                var hour             = 0;
                var minute           = 0;

                foreach (var list in alarm)
                {
                    hour   = Int32.Parse(list.Substring(0, 2));
                    minute = Int32.Parse(list.Substring(3, 2));

                    try
                    {
                        System.Diagnostics.Debug.WriteLine("Hour : " + hour + " Minutes : " + minute);
                        alarmService.SetAlarm(hour, minute, "Diabetics App", "Hello  " + username + " , I remind you to take your insulin at this stated time");
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("Error  " + e);
                    }
                }
            }
            catch (Exception f)
            {
            }
        }
        async void onLogOut(object sender, System.EventArgs e)
        {
            MedicationDatabase db = new MedicationDatabase();

            db.DeleteUsers();
            await Navigation.PushAsync(new SignUp());
        }
Esempio n. 6
0
        void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            var medic             = e.SelectedItem as Medication;
            MedicationDatabase db = new MedicationDatabase();

            db.DeleteTime(medic.ID);
            RefreshList();
        }
Esempio n. 7
0
        void OnDeleteTimeSet(object sender, System.EventArgs e)
        {
            MedicationDatabase db = new MedicationDatabase();

            db.DeleteAlarm();
            db.DeleteAllTime();
            RefreshList();
        }
Esempio n. 8
0
        public void RefreshList()
        {
            MedicationDatabase db = new MedicationDatabase();
            var medical_lis       = db.AllReminders();
            ObservableCollection <SetReminder> trends = new ObservableCollection <SetReminder>(medical_lis);

            reminder_lv.ItemsSource = trends;
            int i = trends.Count;

            i = (trends.Count * heightRowsList);
            reminder_lv.HeightRequest = i;
        }
Esempio n. 9
0
        public void RefreshList()
        {
            MedicationDatabase db = new MedicationDatabase();
            var medical_lis       = db.AllMedicationResults();
            ObservableCollection <Medication> trends = new ObservableCollection <Medication>(medical_lis);

            //ObservableCollection<> t = new ObservableCollection<>();
            set_time_lv.ItemsSource = trends;
            int i = trends.Count;

            i = (trends.Count * heightRowsList);
            set_time_lv.HeightRequest = i;
        }
        public FacebookPageRenderer()
        {
            // this is a ViewGroup - so should be able to load an AXML file and FindView<>
            var activity = this.Context as Activity;

            var auth = new OAuth2Authenticator(
                clientId: "134161603894277",                                                  // your OAuth2 client id
                scope: "",                                                                    // The scopes for the particular API you're accessing. The format for this will vary by API.
                authorizeUrl: new Uri("https://www.facebook.com/v2.10/dialog/oauth/"),        // the auth URL for the service
                redirectUrl: new Uri("https://www.facebook.com/connect/login_success.html")); // the redirect URL for the service

            auth.Completed += async(sender, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    try
                    {
                        var accesstoken = eventArgs.Account.Properties["access_token"].ToString();
                        var expiresIn   = Convert.ToDouble(eventArgs.Account.Properties["expires_in"]);
                        var expiryDate  = DateTime.Now + TimeSpan.FromSeconds(expiresIn);
                        var request     = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), null, eventArgs.Account);
                        var response    = await request.GetResponseAsync();

                        var obj  = JObject.Parse(response.GetResponseText());
                        var id   = obj["id"].ToString().Replace("\"", "");
                        var name = obj["name"].ToString().Replace("\"", "");

                        MedicationDatabase db = new MedicationDatabase();
                        db.addUser(name, "true");
                        // goes to the next form
                        await App.NavigateToProfile(name);
                    }
                    catch (ArgumentOutOfRangeException el)
                    {
                        Toast.MakeText(activity, "Something went wrong , try again please ", ToastLength.Long).Show();
                    }

                    catch (Exception e)
                    {
                        Toast.MakeText(activity, "Something went wrong , try again please ", ToastLength.Long).Show();
                    }
                }
                else
                {
                    // The user cancelled
                    await App.NavigateToProfile(string.Format("Sorry, you didn't login successfully, try again please"));
                }
            };

            activity.StartActivity(auth.GetUI(activity));
        }
Esempio n. 11
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MedicationDatabase db = new MedicationDatabase();
            var medical_lis       = db.AllMedicationResults();
            ObservableCollection <Medication> trends = new ObservableCollection <Medication>(medical_lis);

            set_time_lv.ItemsSource = trends;
            int i = trends.Count;

            i = (trends.Count * heightRowsList);
            set_time_lv.HeightRequest = i;
        }
Esempio n. 12
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MedicationDatabase db = new MedicationDatabase();
            var medical_lis       = db.AllReminders();
            ObservableCollection <SetReminder> trends = new ObservableCollection <SetReminder>(medical_lis);

            reminder_lv.ItemsSource = trends;
            int i = trends.Count;

            i = (trends.Count * heightRowsList);
            reminder_lv.HeightRequest = i;
        }
Esempio n. 13
0
 public async void StoreLocally()
 {
     try
     {
         string             insulintype = inulin_type_entry.Text;
         var                alarmtime   = time_pk.Time.ToString();
         string             units       = measurements_pk.SelectedItem.ToString();
         string             username    = "******";
         string             unique_no   = "YTRU3747473b";
         string             status      = "true";
         MedicationDatabase db          = new MedicationDatabase();
         if (insulintype != "")
         {
             if (insulintype != "")
             {
                 try
                 {
                     db.AddDetails("musa", alarmtime, units, insulintype, unique_no, status);
                 }
                 catch (NullReferenceException ev)
                 {
                     await DisplayAlert("Hey!", "Insert the insulin type please!!", "OK");
                 }
             }
             else
             {
                 await DisplayAlert("Hey!", "Make sure all fields are not empty or un selected ", "OK");
             }
         }
         else
         {
             await DisplayAlert("Hey!", "Insert the insulin type please!!", "OK");
         }
     }
     catch (NullReferenceException r)
     {
         await DisplayAlert("Hey!", "Make sure all fields are not empty or un selected ", "OK");
     }
 }