Esempio n. 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)
        {
            // Initialisation SDK succeeded
            scheduledAgent = this;

            // Log message to indicate that the service is invoked and the last exit reason
            LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Service invoked. Last exit reason: " +
                           task.LastExitReason);

            // Add notifications listener
            SdkService.MegaSdk.addGlobalListener(new MegaGlobalListener());

            // Abort the service when storage quota exceeded error is raised in the transferlistener
            // Abort will stop the service and it will not be launched again until the user
            // activates it in the main application
            var megaTransferListener = new MegaTransferListener();

            megaTransferListener.StorageQuotaExceeded += (sender, args) =>
            {
                scheduledAgent.Abort();
            };
            // Notify complete when tramsfer quota exceeded error is raised in the transferlistener
            // Notify complete will retry in the next task run
            megaTransferListener.TransferQuotaExceeded += (sender, args) =>
            {
                scheduledAgent.NotifyComplete();
            };

            // Add transfers listener
            SdkService.MegaSdk.addTransferListener(megaTransferListener);

            // Fast login with session token that was saved during MEGA app initial login
            FastLogin();
        }
Esempio n. 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)
        {
            // Initialisation SDK succeeded
            scheduledAgent = this;

            // Set the API to use depending on the settings
            SdkService.MegaSdk.changeApiUrl(SettingsService.LoadSetting <bool>("{BA40B745-D0F5-4AD5-A539-44B1403A9EB8}", false) ?
                                            "https://staging.api.mega.co.nz/" : "https://g.api.mega.co.nz/");

            // Log message to indicate that the service is invoked and the last exit reason
            LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Service invoked. Last exit reason: " +
                           task.LastExitReason);

            // Add notifications listener
            SdkService.MegaSdk.addGlobalListener(new MegaGlobalListener());

            // Notify complete when storage quota exceeded error is raised in the transferlistener
            // Notify complete will retry in the next task run
            var megaTransferListener = new MegaTransferListener();

            megaTransferListener.StorageQuotaExceeded += (sender, args) =>
            {
                scheduledAgent.NotifyComplete();
            };

            // Add transfers listener
            SdkService.MegaSdk.addTransferListener(megaTransferListener);

            // Fast login with session token that was saved during MEGA app initial login
            FastLogin();
        }