Ejemplo n.º 1
0
        protected async override void OnResume()
        {
            try
            {
                AppCrossConnectivity.Init(CrossConnectivity.Current);
                UserDialogs.Instance.ShowLoading("Reconnecting, please wait...");

                if (AppCrossConnectivity.Instance.IsConnected)
                {
                    var keyValueCacheUtility = Container.Resolve <IDependencyService>().Get <IKeyValueCacheUtility>();
                    UserName = keyValueCacheUtility.GetUserDefaultsKeyValue("Username");
                    Password = keyValueCacheUtility.GetUserDefaultsKeyValue("Password");

                    if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
                    {
                        await PostFeedSpokeStatic.LogonToHubFake(UserName, Password);
                    }

                    await ShowLocalNotifications();
                }

                Container.Resolve <IDependencyService>().Get <IHelperUtility>().ResetPackageVersionNo();
            }
            catch (Exception ex)
            {
                Container.GetContainer().Resolve <IDependencyService>().Get <ILogger>().Log(ex);
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Ejemplo n.º 2
0
        //chito. this code is just put to public here to be unit tested
        public async Task OnResumePublic()
        {
            try
            {
                UserDialogs.Instance.ShowLoading("Reconnecting, please wait...");

                if (AppCrossConnectivity.Instance.IsConnected)
                {
                    var keyValueCacheUtility = Container.Resolve <IDependencyService>().Get <IKeyValueCacheUtility>();
                    UserName = keyValueCacheUtility.GetUserDefaultsKeyValue("Username");
                    Password = keyValueCacheUtility.GetUserDefaultsKeyValue("Password");

                    if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
                    {
                        await PostFeedSpokeStatic.LogonToHubFake(UserName, Password);
                    }

                    await ShowLocalNotifications();
                }
            }
            catch (Exception ex)
            {
                ProcessErrorReportingForHockeyApp(ex);
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Ejemplo n.º 3
0
        public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            try
            {
                Log.Info("DroidPlatform", "HOPEPH OnStartCommand running (PostFeed Service).");
                Contract.ContactK currentUser = ExtendedDataHolder.Instance.HasExtra("CurrentUser") ?
                                                JsonConvert.DeserializeObject <Contract.ContactK>(ExtendedDataHolder.Instance.GetExtra("CurrentUser").ToString()) : null;
                Contract.PostFeedK currentPost = ExtendedDataHolder.Instance.HasExtra("CurrentPost") ?
                                                 JsonConvert.DeserializeObject <Contract.PostFeedK>(ExtendedDataHolder.Instance.GetExtra("CurrentPost").ToString()) : null;

                string operation = "";

                if (ExtendedDataHolder.Instance.HasExtra("Operation"))
                {
                    operation = ExtendedDataHolder.Instance.GetExtra("Operation").ToString();
                }
                else
                {
                    throw new ArgumentNullException("Operation in PostFeedService android is null.");
                }

                Task.Run(async() =>
                {
                    switch (operation.ToLower())
                    {
                    case "deletepostfeed":
                        await PostFeedSpokeStatic.DeleteSelfPostToRemote(currentPost.PostFeedID);
                        break;

                    case "likeorunlikepost":
                        await PostFeedSpokeStatic.LikeOrUnlikePost(true, currentPost.PostFeedID, currentUser.Id);
                        break;

                    case "addupdatepost":
                        await PostFeedSpokeStatic.AddOrUpdatePostFeed(currentPost);
                        break;

                    case "logontohub":
                    default:
                        await PostFeedSpokeStatic.LogonToHub(currentUser.UserName, currentUser.Password);
                        break;
                    }
                });
            }
            catch (System.OperationCanceledException ex)
            {
                ProcessErrorReportingForHockeyApp(ex);
            }
            catch (System.Exception ex)
            {
                ProcessErrorReportingForHockeyApp(ex);
            }

            return(StartCommandResult.Sticky);
        }
Ejemplo n.º 4
0
 protected override void OnSleep()
 {
     try
     {
         PostFeedSpokeStatic.StopConnection();
     }
     catch (Exception ex)
     {
         Container.GetContainer().Resolve <IDependencyService>().Get <ILogger>().Log(ex);
     }
 }
Ejemplo n.º 5
0
 protected override void OnSleep()
 {
     try
     {
         PostFeedSpokeStatic.StopConnection();
     }
     catch (Exception ex)
     {
         ProcessErrorReportingForHockeyApp(ex);
     }
 }
Ejemplo n.º 6
0
        public async Task Start(Contract.PostFeedK currentPost, Contract.ContactK currentUser, string operation)
        {
            Console.WriteLine("HOPEPH Creating task id for background ios");
            _cts = new CancellationTokenSource();

            try
            {
                switch (operation.ToLower())
                {
                case "deletepostfeed":
                    Console.WriteLine("HOPEPH Deleting Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("DeletingPostFeed", OnExpiration);
                    await PostFeedSpokeStatic.DeleteSelfPostToRemote(currentPost.PostFeedID);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "likeorunlikepost":
                    Console.WriteLine("HOPEPH Liking or Unliking Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LikingOrUnlikingPost", OnExpiration);
                    await PostFeedSpokeStatic.LikeOrUnlikePost(true, currentPost.PostFeedID, currentUser.Id);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "addupdatepost":
                    Console.WriteLine("HOPEPH Adding or Updating Post Feed");
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("AddingUpdatingPostFeed", OnExpiration);
                    await PostFeedSpokeStatic.AddOrUpdatePostFeed(currentPost);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;

                case "logontohub":
                default:
                    _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LogonToHub", OnExpiration);
                    await PostFeedSpokeStatic.LogonToHub(currentUser.UserName, currentUser.Password);

                    UIApplication.SharedApplication.EndBackgroundTask(_taskId);
                    break;
                }
            }
            catch (OperationCanceledException oex)
            {
                Console.WriteLine(string.Format("HOPEPH An error occured in backgrounding IOS {0}.", oex.Message));
            }
            finally
            {
                if (_cts.IsCancellationRequested)
                {
                    Console.WriteLine("HOPEPH Cancelled token.");
                }
            }
        }