Пример #1
0
        public static void ThreadTaskInitialisation(Context baseContext)
        {
            Initialisation init = new Initialisation();

            Log.Info(TAG, "ThreadTaskInitialisation: Initialising MoodList array...");
            init.CreateMoodListArray(Context);

            Log.Info(TAG, "ThreadTaskInitialisation: Forcing first time use of Database");
            Globals dbHelp = new Globals();

            dbHelp.OpenDatabase();
            dbHelp.CloseDatabase();

            //early setup for settings
            GetAllApplicationSettings();

            Log.Info(TAG, "ThreadTaskInitialisation: Initialising MoodList...");
            if (MoodlistArray.Length > 0)
            {
                //does the length match what the constant says it should be
                if (MoodlistArray.Length != ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS)
                {
                    //if there is a difference in length then recreate the array
                    init.CreateMoodListArray(Context);
                    Log.Info(TAG, "ThreadTaskInitialisation: Recreating Mood List array because array length (" + MoodlistArray.Length.ToString() + ") is not the same as the defined constant (" + ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS.ToString() + ")");
                }
                else
                {
                    Log.Info(TAG, "ThreadTaskInitialisation: MoodList array has a length that agrees with the defined constant (" + ConstantsAndTypes.MAX_NUMBER_OF_MOODLIST_ITEMS.ToString() + ")");
                }
            }
            else
            {
                //we need to recreate it anyway
                init.CreateMoodListArray(Context);
                Log.Info(TAG, "ThreadTaskInitialisation: Creating Mood List array from scratch");
            }
            Log.Info(TAG, "ThreadTaskInitialisation: Creating Mood List...");
            init.CreateMoodList();
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Achievement Chart Types...");
            init.CreateAchievementChartTypes(Context);
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Colour List...");
            init.CreateColourList();
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Medication Types...");
            init.CreateMedicationTypes(baseContext);
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Medication List...");
            init.CreateMedicationList(baseContext);

            Log.Info(TAG, "ThreadTaskInitialisation: Building list of Contacts...");
            //Cannot do this if the user has not given permission yet!
            if (PermissionsHelper.HasPermission(Context, ConstantsAndTypes.AppPermission.ReadContacts) &&
                PermissionsHelper.PermissionGranted(Context, ConstantsAndTypes.AppPermission.ReadContacts))
            {
                ContactItems = init.RetrieveAllContacts(baseContext);
            }

            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Emergency Contacts...");
            init.RetrieveEmergencyContacts(baseContext);
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Tell Myself items...");
            init.RetrieveAllTellMyselfEntries();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Generic Text items...");
            init.RetrieveAllGenericTextEntries();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Safety Plan Card items...");
            init.RetrieveAllSafetyPlanCardEntries();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Medication list items...");
            init.RetrieveMedicationList();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Activity list for current week...");
            init.RetrieveActivitesForCurrentWeek();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Reactions List...");
            init.RetrieveAllReactions();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Feelings List...");
            init.RetrieveAllFeelings();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Attitudes List...");
            init.RetrieveAllAttitudes();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Relationships List...");
            init.RetrieveAllRelationships();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Health List...");
            init.RetrieveAllHealth();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Fantasies List...");
            init.RetrieveAllFantasies();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Problems List...");
            init.RetrieveAllProblems();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Solution Plan List...");
            init.RetrieveAllSolutionPlans();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Affirmation List...");
            init.RetrieveAllAffirmations();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving Images List...");
            init.RetrieveAllImages();
            Log.Info(TAG, "ThreadTaskInitialisation: Retrieving PlayLists List...");
            init.RetrieveAllPlayLists();
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Appointment Types");
            init.CreateAppointmentTypes(Context);
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Resource Medication Types");
            init.RetrieveAllResourceMedicationTypes();
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Resource Conditions");
            init.RetrieveAllResourceConditions();
            Log.Info(TAG, "ThreadTaskInitialisation: Initialising Settings");
            init.RetrieveAllSettings();
            init.GetErrorAlertShowSetting();

            AchievementChartItems = new List <AchievementChart>();
        }