<commit_before>﻿using Microsoft.Toolkit.Uwp;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using TUMCampusAppAPI;
using Windows.ApplicationModel.Background;

namespace TUMCampusApp.Classes.Helpers
{
    public class MyBackgroundTaskHelper
    {
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--
        private static readonly string BACKGROUND_TASK_NAME = "TUMCampusAppBackgroundTask";

        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        /// <summary>
        /// Registers a background task if necessarry.
        /// </summary>
        public async static void RegisterBackgroundTask()
        {
            if (BackgroundTaskHelper.IsBackgroundTaskRegistered(BACKGROUND_TASK_NAME))
            {
                return;
            }
            await BackgroundExecutionManager.RequestAccessAsync();
            BackgroundTaskHelper.Register(BACKGROUND_TASK_NAME, "TUMCampusApp.BackgroundTask.BackgroundTask", new TimeTrigger(60, false), false, true, new SystemCondition(SystemConditionType.FreeNetworkAvailable), new SystemCondition(SystemConditionType.UserNotPresent), new SystemCondition(SystemConditionType.InternetAvailable));

            //Activates when the device gets locked:
            //BackgroundTaskHelper.Register(BACKGROUND_TASK_NAME, "TUMCampusApp.BackgroundTask.BackgroundTask", new SystemTrigger(SystemTriggerType.UserAway, false), false, true, new SystemCondition(SystemConditionType.FreeNetworkAvailable), new SystemCondition(SystemConditionType.UserNotPresent), new SystemCondition(SystemConditionType.InternetAvailable));

            Logger.Info("Registered the " + BACKGROUND_TASK_NAME + " background task.");
        }

        /// <summary>
        /// Removes a background task if necessarry.
        /// </summary>
        public static void RemoveBackgroundTask()
        {
            BackgroundTaskHelper.Unregister(BACKGROUND_TASK_NAME);
            Logger.Info("Unregistered the " + BACKGROUND_TASK_NAME + " background task.");
        }

        #endregion<commit_msg>Doc typos<commit_after>﻿using Microsoft.Toolkit.Uwp;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using TUMCampusAppAPI;
using Windows.ApplicationModel.Background;

namespace TUMCampusApp.Classes.Helpers
{
    public class MyBackgroundTaskHelper
    {
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--
        private static readonly string BACKGROUND_TASK_NAME = "TUMCampusAppBackgroundTask";

        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        /// <summary>
        /// Registers a background task if necessary.
        /// </summary>
        public async static void RegisterBackgroundTask()
        {
            if (BackgroundTaskHelper.IsBackgroundTaskRegistered(BACKGROUND_TASK_NAME))
            {
                return;
            }
            await BackgroundExecutionManager.RequestAccessAsync();
            BackgroundTaskHelper.Register(BACKGROUND_TASK_NAME, "TUMCampusApp.BackgroundTask.BackgroundTask", new TimeTrigger(60, false), false, true, new SystemCondition(SystemConditionType.FreeNetworkAvailable), new SystemCondition(SystemConditionType.UserNotPresent), new SystemCondition(SystemConditionType.InternetAvailable));

            //Activates when the device gets locked:
            //BackgroundTaskHelper.Register(BACKGROUND_TASK_NAME, "TUMCampusApp.BackgroundTask.BackgroundTask", new SystemTrigger(SystemTriggerType.UserAway, false), false, true, new SystemCondition(SystemConditionType.FreeNetworkAvailable), new SystemCondition(SystemConditionType.UserNotPresent), new SystemCondition(SystemConditionType.InternetAvailable));

            Logger.Info("Registered the " + BACKGROUND_TASK_NAME + " background task.");
        }

        /// <summary>
        /// Removes a background task if necessary.
        /// </summary>
        public static void RemoveBackgroundTask()
        {
            BackgroundTaskHelper.Unregister(BACKGROUND_TASK_NAME);
            Logger.Info("Unregistered the " + BACKGROUND_TASK_NAME + " background task.");
        }

        #endregion
{'fraction_non_alphanumeric': 0.2533284023668639, 'fraction_numerical': 0.0007396449704142012, 'mean_word_length': 1.5562381852551985, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1366959', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1102, 'n_words': 234}