Esempio n. 1
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();

            try
            {
                WhirlMonData.WhirlPoolAPIClient.SaveConfig();
            }
            catch (Exception x)
            {
                WhirlPoolAPIClient.ShowErrorToast("App.OnSuspending", x);
            }

            deferral.Complete();
        }
Esempio n. 2
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();

            try
            {
                WhirlPoolAPIClient.LoadConfig();

                await WhirlPoolAPIClient.GetDataAsync(WhirlPoolAPIClient.EWhirlPoolData.wpAll);
            }
            catch (Exception x)
            {
                WhirlPoolAPIClient.ShowErrorToast("MainBackground", x);
            }
            _deferral.Complete();
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            try
            {
                WhirlMonData.WhirlPoolAPIClient.LoadConfig();
                WhirlMonWatchedTask.BackgroundTasks.Register();
            }
            catch (Exception x)
            {
                WhirlPoolAPIClient.ShowErrorToast("App", x);
            }
        }
Esempio n. 4
0
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            try
            {
                InitRoot(null, "");

                if (args.Kind == ActivationKind.ToastNotification)
                {
                    var toastArgs = args as ToastNotificationActivatedEventArgs;
                    var argument  = toastArgs.Argument;

                    string[] arguments = argument.Split(',');
                    string   sid       = arguments.Length > 0 ? arguments[0] : "";
                    string   lastpage  = arguments.Length > 1 ? arguments[1] : "";
                    string   lastread  = arguments.Length > 2 ? arguments[2] : "";
                    int      id        = 0;
                    int.TryParse(sid, out id);

                    if (lastpage != "")
                    {
                        String url     = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p={1}&#r{2}", sid, lastpage, lastread);
                        var    uri     = new Uri(url);
                        var    success = await Windows.System.Launcher.LaunchUriAsync(uri);

                        if (success)
                        {
                            await WhirlMonData.WhirlPoolAPIClient.MarkThreadReadAsync(id, false);
                        }
                    }
                    else
                    {
                        await WhirlMonData.WhirlPoolAPIClient.MarkThreadReadAsync(id, false);

                        await WhirlPoolAPIClient.GetWatchedAsync();
                    }
                }
            }
            catch (Exception x)
            {
                WhirlPoolAPIClient.ShowErrorToast("App.OnActivated", x);
            }
        }
Esempio n. 5
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();

            try
            {
                WhirlPoolAPIClient.LoadConfig();
                var      details   = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail;
                var      arguments = details.Argument;
                string[] args      = arguments.Split(',');
                string   sid       = args.Length > 0 ? args[0] : "";
                string   lastpage  = args.Length > 1 ? args[1] : "";
                string   lastread  = args.Length > 2 ? args[2] : "";
                int      id        = 0;
                int.TryParse(sid, out id);

                if (lastpage != "")
                {
                    String url     = string.Format(@"http://forums.whirlpool.net.au/forum-replies.cfm?t={0}&p={1}&#r{2}", sid, lastpage, lastread + 1);
                    var    uri     = new Uri(url);
                    var    success = await Windows.System.Launcher.LaunchUriAsync(uri);

                    if (success)
                    {
                        await WhirlPoolAPIClient.MarkThreadReadAsync(id, false);
                    }
                }
                else
                {
                    await WhirlPoolAPIClient.MarkThreadReadAsync(id, false);
                }
            }
            catch (Exception x)
            {
                WhirlPoolAPIClient.ShowErrorToast("ToastBackground", x);
            }

            _deferral.Complete();
        }