コード例 #1
0
        /// <summary>
        /// Method that should be called when an action required for
        /// enable/disable the debug mode is done.
        /// </summary>
        public static void ChangeStatusAction()
        {
            if (_changeStatusActionCounter == 0)
            {
                UiService.OnUiThread(() =>
                {
                    if (_timerDebugMode == null)
                    {
                        _timerDebugMode          = new DispatcherTimer();
                        _timerDebugMode.Interval = new TimeSpan(0, 0, 5);
                        _timerDebugMode.Tick    += (obj, args) => StopDebugModeTimer();
                    }
                    _timerDebugMode.Start();
                });
            }

            _changeStatusActionCounter++;

            if (_changeStatusActionCounter >= 5)
            {
                StopDebugModeTimer();
                DebugSettings.IsDebugMode = !DebugSettings.IsDebugMode;

                // To avoid change API URL accidentally
                SdkService.ChangeApiUrlActionFinished(true);
            }
        }
コード例 #2
0
        /// <summary>
        /// Activate or deactivate the background task
        /// </summary>
        /// <param name="status">TRUE to activate and FALSE to deactivate.</param>
        /// <returns>TRUE if no error or FALSE in other case.</returns>
        public static async Task <bool> SetBackgroundTaskAsync(bool status)
        {
            if (status)
            {
                var task = await TaskService.RegisterBackgroundTaskAsync(
                    TaskEntryPoint, TaskName, new TimeTrigger(TaskTimeTrigger, false));

                if (task == null)
                {
                    LogService.Log(MLogLevel.LOG_LEVEL_WARNING,
                                   "Can't enable CAMERA UPLOADS service (background tasks not allowed)");
                    return(false);
                }

                LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Enable CAMERA UPLOADS service");
                await SdkService.GetCameraUploadRootNodeAsync();

                return(true);
            }

            TaskService.UnregisterBackgroundTask(TaskEntryPoint, TaskName);

            LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Disable CAMERA UPLOADS service");

            // Reset the date
            SettingsService.SaveSettingToFile(SettingsService.ImageDateSetting, DateTime.MinValue);

            return(true);
        }