Ejemplo n.º 1
0
        private async void GetUserEvent()
        {
            var user = await FireBaseController.GetUser(ContentManager.sessionUserProfile.Name);

            if (user != null)
            {
            }
        }
Ejemplo n.º 2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         FirebaseDB.init();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 3
0
        private async void SetItemList()
        {
            var metaItemInfo = (await LocalStorageController.GetMetaUserInfo());

            isUserLocal = metaItemInfo == null ? ContentManager.isLocal : metaItemInfo.IsLocal;
            if (isUserLocal)
            {
                itemList = await LocalStorageController.GetTableListAsync <Item>();
            }
            // Check if user is connected before retrieving data from online
            else if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
            {
                itemList = (await FireBaseController.GetItems()).ToList().ConvertAll(o => o.Object);
            }
        }
Ejemplo n.º 4
0
        public override Result DoWork()
        {
            if (ContentManager.sessionUserProfile == null)
            {
                return(Result.InvokeRetry());
            }

            SetItemList();
            int expItemCount1 = 0;
            int expItemCount3 = 0;
            int expItemCount7 = 0;

            foreach (var item in itemList)
            {
                item.SetDaysUntilExpiration();
                if (item.daysUntilExp < 1 && !item.oneDayWarning && ContentManager.sessionUserProfile.enableOneDayWarning)
                {
                    expItemCount1++;
                    item.oneDayWarning = true;
                }
                else if (item.daysUntilExp < 3 && !item.threeDaysWarning && ContentManager.sessionUserProfile.enableThreeDayWarning)
                {
                    expItemCount3++;
                    item.threeDaysWarning = true;
                }
                else if (item.daysUntilExp < 7 && !item.weekWarning && ContentManager.sessionUserProfile.enableOneWeekWarning)
                {
                    expItemCount7++;
                    item.weekWarning = true;
                }

                if (isUserLocal)
                {
                    LocalStorageController.UpdateItem(item);
                }
                else if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
                {
                    FireBaseController.SaveItem(item);
                }
            }
            sender.ScheduleNotification(ContentManager.exp_notification_title, expItemCount1 + " of your items expire in one day!");
            sender.ScheduleNotification(ContentManager.exp_notification_title, expItemCount3 + " of your items expire in three days!");
            sender.ScheduleNotification(ContentManager.exp_notification_title, expItemCount7 + " of your items expire in one week!");
            Console.WriteLine("item item weeeee " + itemList.Count);
            return(Result.InvokeSuccess());
        }
Ejemplo n.º 5
0
        private async Task LoginAsync()
        {
            var loginResult = await client.LoginAsync();

            if (!loginResult.IsError)
            {
                var name  = loginResult.User.FindFirst(c => c.Type == "name")?.Value;
                var email = loginResult.User.FindFirst(c => c.Type == "email")?.Value;
                var image = loginResult.User.FindFirst(c => c.Type == "picture")?.Value;

                userProfile = new UserProfile()
                {
                    Email     = email,
                    Name      = name,
                    IconImage = ContentManager.ProfileIcons[0]
                };


                if (!await FireBaseController.HasUser(email))
                {
                    ContentManager.isUserNew          = true;
                    ContentManager.sessionUserProfile = userProfile;
                }
                else
                {
                    ContentManager.sessionUserProfile = await FireBaseController.GetUser(email);

                    Console.WriteLine("Local Storage 85 user icon " + ContentManager.sessionUserProfile.IconImage + " user name " + ContentManager.sessionUserProfile.Name);
                }

                //  var serializedLoginResponse = JsonConvert.SerializeObject(userProfile);
                AppDelegate.ToPageControllerAction.Invoke();
            }
            else
            {
                Console.WriteLine("Failure");
            }
        }
Ejemplo n.º 6
0
        public override async void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler)
        {
            base.PerformFetch(application, completionHandler);
            Console.WriteLine("APP DELEGATE 114 Perfor Fetch Called  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            var metaItemInfo = (await LocalStorageController.GetMetaUserInfo());
            var itemList     = new List <Item>();
            var isUserLocal  = metaItemInfo == null ? ContentManager.isLocal : metaItemInfo.IsLocal;

            if (isUserLocal)
            {
                itemList = await LocalStorageController.GetTableListAsync <Item>();
            }
            // Check if user is connected before retrieving data from online
            else if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
            {
                itemList = (await FireBaseController.GetItems()).ToList().ConvertAll(o => o.Object);
            }

            int expItemCount1 = 0;
            int expItemCount3 = 0;
            int expItemCount7 = 0;

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                foreach (var item in itemList)
                {
                    item.SetDaysUntilExpiration();
                    if (item.daysUntilExp < 1 && !item.oneDayWarning && ContentManager.sessionUserProfile.enableOneDayWarning)
                    {
                        expItemCount1++;
                        item.oneDayWarning = true;
                    }
                    else if (item.daysUntilExp < 3 && !item.threeDaysWarning && ContentManager.sessionUserProfile.enableThreeDayWarning)
                    {
                        expItemCount3++;
                        item.threeDaysWarning = true;
                    }
                    else if (item.daysUntilExp < 7 && !item.weekWarning && ContentManager.sessionUserProfile.enableOneWeekWarning)
                    {
                        expItemCount7++;
                        item.weekWarning = true;
                    }

                    if (isUserLocal)
                    {
                        LocalStorageController.UpdateItem(item);
                    }
                    else if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
                    {
                        FireBaseController.SaveItem(item);
                    }
                }
                NotifyUser(expItemCount1 + " of your items expire in one day!");
                NotifyUser(expItemCount3 + " of your items expire in three days!");
                NotifyUser(expItemCount7 + " of your items expire in one week!");
            }
            else
            {
                foreach (var item in itemList)
                {
                    item.SetDaysUntilExpiration();
                    if (item.daysUntilExp < 1 && !item.oneDayWarning && ContentManager.sessionUserProfile.enableOneDayWarning)
                    {
                        expItemCount1++;
                        item.oneDayWarning = true;
                    }
                    else if (item.daysUntilExp < 3 && !item.threeDaysWarning && ContentManager.sessionUserProfile.enableThreeDayWarning)
                    {
                        expItemCount3++;
                        item.threeDaysWarning = true;
                    }
                    else if (item.daysUntilExp < 7 && !item.weekWarning && ContentManager.sessionUserProfile.enableOneWeekWarning)
                    {
                        expItemCount7++;
                        item.weekWarning = true;
                    }

                    if (isUserLocal)
                    {
                        LocalStorageController.UpdateItem(item);
                    }
                    else if (Xamarin.Essentials.Connectivity.NetworkAccess == Xamarin.Essentials.NetworkAccess.Internet)
                    {
                        FireBaseController.SaveItem(item);
                    }
                }
                NotifyUserOld(expItemCount1 + " of your items expire in one day!");
                NotifyUserOld(expItemCount3 + " of your items expire in three days!");
                NotifyUserOld(expItemCount7 + " of your items expire in one week!");
            }
            completionHandler(UIBackgroundFetchResult.NewData);
        }