Пример #1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                {
                    return;
                }

                IAppSettingsStore settings = new AppSettingsStore(IsolatedStorageCacheManager.Instance);
                IFalconService    fService = new FalconWebServiceClient(ServiceLoginUrl);
                using (var updatesService = new CheckUpdatesService(settings, new RaptorService(fService, AESCipherManager.Instance), AESCipherManager.Instance))
                {
                    var updates = updatesService.Updates();


                    UpdateTile(updatesService.GetUpdateCount());

                    if (updates.Count() == 0)
                    {
#if DEBUG
                        ShellToast toast2 = new ShellToast();
                        toast2.Title   = "DEBUG: ";
                        toast2.Content = "No updates";
                        toast2.Show();
#endif
                    }
                    else
                    {
                        string message =
                            updates.Count() == 1
                            ? string.Format("Torrent {0} downloaded", updates.First())
                            : string.Format("{0} favorite torrents were downloaded", updates.Count());

                        ShellToast toast = new ShellToast();
                        toast.Title   = "Torrents: ";
                        toast.Content = message;
                        toast.Show();
                    }
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                ShellToast toast = new ShellToast();
                toast.Title   = "Error:";
                toast.Content = ex.Message;
                toast.Show();
#endif
            }
            finally
            {
#if DEBUG_AGENT
                ScheduledActionService.LaunchForTest(
                    task.Name, TimeSpan.FromSeconds(30));
#endif

                NotifyComplete();
            }
        }
Пример #2
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                    return;

                IAppSettingsStore settings = new AppSettingsStore(IsolatedStorageCacheManager.Instance);
                IFalconService fService = new FalconWebServiceClient(ServiceLoginUrl);
                using (var updatesService = new CheckUpdatesService(settings, new RaptorService(fService, AESCipherManager.Instance), AESCipherManager.Instance))
                {
                    var updates = updatesService.Updates();

                    UpdateTile(updatesService.GetUpdateCount());

                    if (updates.Count() == 0)
                    {
            #if DEBUG
                        ShellToast toast2 = new ShellToast();
                        toast2.Title = "DEBUG: ";
                        toast2.Content = "No updates";
                        toast2.Show();
            #endif
                    }
                    else
                    {
                        string message =
                            updates.Count() == 1
                            ? string.Format("Torrent {0} downloaded", updates.First())
                            : string.Format("{0} favorite torrents were downloaded", updates.Count());

                        ShellToast toast = new ShellToast();
                        toast.Title = "Torrents: ";
                        toast.Content = message;
                        toast.Show();
                    }
                }

            }
            catch (Exception ex)
            {
            #if DEBUG
                ShellToast toast = new ShellToast();
                toast.Title = "Error:";
                toast.Content = ex.Message;
                toast.Show();
            #endif
            }
            finally
            {

            #if DEBUG_AGENT
                ScheduledActionService.LaunchForTest(
                    task.Name, TimeSpan.FromSeconds(30));
            #endif

                NotifyComplete();
            }
        }