Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // on set notre layout
            SetContentView(Resource.Layout.Accueil);

            alarmListView = FindViewById <ListView>(Resource.Id.listView);
            refreshButton = FindViewById <Button>(Resource.Id.refreshButton);

            refreshButton.Click += new EventHandler(async(sender, e) =>
            {
                User u = UserItemManager.GetUser("0");

                alarmsInverted = await AlarmServerManager.getAlarms(u.Profil);
                alarms         = AlarmItemManager.GetAlarms();

                alarmListAdapter      = new AlarmItemListAdapter(this, alarms);
                alarmListView.Adapter = alarmListAdapter;
            });

            /*
             * alarm = new AlarmItem();
             * alarm.IDAlarm = 1;
             * alarm.Status = true;
             * alarm.Chambre = "Chambre 1";
             * alarm.NomPersonnelAidant = "Amadou";
             * alarm.NomOccupant = "Diaby";
             * alarm.DtDebut = "23:05";
             * AlarmItemManager.AddAlarm(alarm);
             */
        }
        public App()
        {
            InitializeComponent();

            UserManager = new UserItemManager(new RestService());
            MainPage    = new NavigationPage(new MainPage());
        }
Example #3
0
        private async Task AddNewAsync()
        {
            if (SelectedDropdownType == null)
            {
                return;
            }

            await UserItemManager.CreateNewUserItemAndAddItToUserAsync(
                CurrentUserService.CurrentUser, SelectedDropdownType.ItemObject);
        }
Example #4
0
 private async void DeleteAllDone()
 {
     try
     {
         BusyOverlayService.SetBusyState(BusyEnum.Busy);
         await UserItemManager.DeleteAllDoneAsync(CurrentUserService.CurrentUser);
     }
     finally
     {
         BusyOverlayService.SetBusyState(BusyEnum.NotBusy);
     }
 }
Example #5
0
        public async Task <bool> AcountExist()
        {
            UserItemManager userManager = DBConnection.MainConnection.UserItem;
            await userManager.ClearTable();

            var isLogged = await userManager.GetItemsAsync(true, false);

            if (isLogged.Count == 1)
            {
                return(await Task.FromResult(true));
            }
            else
            {
                return(await Task.FromResult(false));
            }
        }
Example #6
0
        private DBConnection()
        {
            Client = new MobileServiceClient(Constants.ApplicationURL);

            const string offlineDbPath = @"localstore.db";
            var          store         = new MobileServiceSQLiteStore(offlineDbPath);

            store.DefineTable <WorkoutItem>();
            store.DefineTable <UserItem>();
            store.DefineTable <MapPointItem>();
            //Initializes the SyncContext using the default IMobileServiceSyncHandler.This class executes the async calls to synchronize the database
            Client.SyncContext.InitializeAsync(store, new MobileServiceSyncHandler());

            WorkoutItem = new WorkoutItemManager(Client);
            MapPoint    = new MapPointManager(Client);
            UserItem    = new UserItemManager(Client);
            UserLogin   = DependencyService.Get <ILoginSupplier>();
        }
        protected override async Task OnParametersSetAsync()
        {
            await base.OnParametersSetAsync();

            var authState = await AuthenticationStateTask;

            IsAuthenticated = authState.User.Identity.IsAuthenticated;

            if (!IsAuthenticated || CurrentUserService.CurrentUser.IsUserItemsPropertyLoaded)
            {
                return;
            }
            try
            {
                BusyOverlayService.SetBusyState(BusyEnum.Busy);
                await UserItemManager.RetrieveAllUserItemsOfUserAndSetToUserAsync(CurrentUserService.CurrentUser);
            }
            finally
            {
                BusyOverlayService.SetBusyState(BusyEnum.NotBusy);
            }
        }
Example #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Intent.Extras != null)
            {
                foreach (var key in Intent.Extras.KeySet())
                {
                    if (key != null)
                    {
                        var value = Intent.Extras.GetString(key);
                        Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
                    }
                }
            }
            if (UserItemManager.IsDB())
            {
                User u = UserItemManager.GetUser("a");
                if (u.IsLogged == 1)
                {
                    StartActivity(typeof(Accueil));
                }
            }
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            connexionButton = FindViewById <Button>(Resource.Id.connexionButton);
            username        = FindViewById <EditText>(Resource.Id.idEditText);
            pwd             = FindViewById <EditText>(Resource.Id.pswdEditText);

            // button clicks
            connexionButton.Click += async(sender, e) => {
                if (UserItemManager.IsDB())
                {
                    var resp = await _apiLogin.LoginAsync(username.Text, pwd.Text);

                    if (resp == 200)
                    {
                        UserItemManager.ChangeStatus(username.Text, 1);
                        StartActivity(typeof(Accueil));
                    }
                }
                else
                {
                    var resp = await _apiLogin.FirstLoginAsync(username.Text, pwd.Text);

                    if (resp == 200)
                    {
                        /*var token = FirebaseInstanceId.Instance.Token;
                         * NotificationHub hub = new NotificationHub(EAndroid.Resources.Constants.NotificationHubName,
                         *                                        EAndroid.Resources.Constants.ListenConnectionString,
                         *                                        Android.App.Application.Context);
                         *
                         * hub.Register(token, "3");*/

                        StartActivity(typeof(Accueil));
                    }
                }
            };
        }
Example #9
0
 private async void OnChildItemTitleChanged(ChildItem childItem, ChangeEventArgs eventArgs)
 {
     childItem.Title = eventArgs.Value.ToString();
     await UserItemManager.UpdateAsync(childItem);
 }
Example #10
0
 private async Task AddNewchildToParentAsync()
 {
     await UserItemManager.CreateNewChildItemAndAddItParentItemAsync(ParentItem);
 }
Example #11
0
 private void HandleDebounceTimerElapsed(object sender, ElapsedEventArgs e)
 {
     Console.WriteLine("Timer Elapsed");
     UserItemManager.UpdateAsync(Item);
 }
        public async void OnRegistration(object sender, EventArgs e)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                return;
            }

            await Navigation.PushModalAsync(new LoadingScreenPage());

            UserItemManager userManager = DBConnection.MainConnection.UserItem;
            UserItem        newUser     = new UserItem();

            if (unitsSwitch.IsToggled == false)
            {
                Constants.AppUnitsType = "KM";
            }
            else
            {
                Constants.AppUnitsType = "MI";
            }

            newUser.Birth = birthdayText.Date;

            if (!string.IsNullOrEmpty(weightText.Text))
            {
                newUser.Weight = Convert.ToDouble(weightText.Text);
            }

            if (!string.IsNullOrEmpty(heightText.Text))
            {
                newUser.Height = Convert.ToDouble(heightText.Text);
            }

            if (genderSwitch.IsToggled == true)
            {
                newUser.Gender = "F";
            }

            try
            {
                await userManager.SaveItemAsync(newUser, true);
            }
            catch (Exception ex) {
                await DBConnection.MainConnection.LogoutUser();

                await Navigation.PopModalAsync();

                OnBackButtonPressed();
                var message = string.Format("{0}", ex.Message);
                options             = Constants.NotificationStyle.Options(Constants.NotificationStyle.Which.Error);
                options.Description = message;
                await notificator.Notify(options);

                return;
            }

            await DBConnection.MainConnection.ConfirmUser();

            await Navigation.PopModalAsync();

            StartMainFunction();
        }
Example #13
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            // Get our object for position
            var alarm = alarms[position];

            // TODO: use this code to populate the row, and remove the above view
            Android.Views.View view = convertView; // re-use an existing view, if one is available
            if (view == null)                      // otherwise create a new one
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.CustomRowView, null);
            }

            listeButton = view.FindViewById <Button>(Resource.Id.PriseEnChargeButton);
            String etat;

            if (alarm.Status == false)
            {
                etat = "Non pris en charge";
            }
            else
            {
                listeButton.Enabled = false;
                listeButton.SetBackgroundColor(Color.Gray);
                etat = "Pris en charge par " + alarm.NomPersonnelAidant;
            }
            view.FindViewById <TextView>(Resource.Id.DateTime).Text         = alarm.DtDebut;
            view.FindViewById <TextView>(Resource.Id.AlarmDescription).Text = "Alarme : Appel de la chambre " + alarm.Chambre +
                                                                              " (" + alarm.NomOccupant + ")" + "\n Type:" + alarm.Display;
            view.FindViewById <TextView>(Resource.Id.Status).Text           = "Etat : " + etat;
            view.FindViewById <Button>(Resource.Id.PriseEnChargeButton).Tag = position;

            listeButton.Click += async(sender, e) => {
                var user    = UserItemManager.GetUser("0");
                var Cstatus = await AlarmServerManager.changeStatusAsync(alarms[Convert.ToInt32(((Button)sender).Tag)].IDAlarm, user.IdSS);

                if (Cstatus)
                {
                    Button clickedButton = (Button)sender;
                    alarm = alarms[Convert.ToInt32(clickedButton.Tag)];
                    alarm.NomPersonnelAidant    = user.Lastname;
                    alarm.PrenomPersonnelAidant = user.Firstname;
                    //int r = 0;
                    //r = AlarmItemManager.AddAlarm(alarm);
                    alarms                = AlarmItemManager.GetAlarms();
                    alarmListView         = context.FindViewById <ListView>(Resource.Id.listView);
                    alarmListAdapter      = new AlarmItemListAdapter(context, alarms);
                    alarmListView.Adapter = alarmListAdapter;
                }
                else
                {
                    User u = UserItemManager.GetUser("0");
                    AlarmItemManager.DeleteAlarms();
                    var alarmsInverted = await AlarmServerManager.getAlarms(u.Profil);

                    alarms                = AlarmItemManager.GetAlarms();
                    alarmListView         = context.FindViewById <ListView>(Resource.Id.listView);
                    alarmListAdapter      = new AlarmItemListAdapter(context, alarms);
                    alarmListView.Adapter = alarmListAdapter;
                }
            }
            ;
            return(view);
        }
Example #14
0
        public void PrendreEnCharge(object sender, EventArgs e)
        {
            int    r             = 0;
            Button clickedButton = (Button)sender;

            r                     = AlarmItemManager.ChangeStatus(alarms[Convert.ToInt32(clickedButton.Tag)].IDAlarm, UserItemManager.GetUser("0").IdSS);
            alarms                = AlarmItemManager.GetAlarms();
            alarmListView         = context.FindViewById <ListView>(Resource.Id.listView);
            alarmListAdapter      = new AlarmItemListAdapter(context, alarms);
            alarmListView.Adapter = alarmListAdapter;

            /*
             * var request = (HttpWebRequest)WebRequest.Create("http://192.168.1.69:88/ptrans/ptrans.php");
             * var postData = "newSupport=hello";
             * postData += "&idAlarm=23";
             * postData += "&numRoom=65";
             * postData += "&occupantName=Marie";
             * postData += "&services=1";
             * postData += "&aidantName=default";
             *
             * var data = Encoding.ASCII.GetBytes(postData);
             * request.Method = "POST";
             * request.ContentType = "application/x-www-form-urlencoded";
             * request.ContentLength = data.Length;
             *
             * using (var stream = request.GetRequestStream())
             * {
             *  stream.Write(data, 0, data.Length);
             * }
             *
             * var response = (HttpWebResponse)request.GetResponse();
             * var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
             * Console.WriteLine(responseString);*/
        }