Exemplo n.º 1
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="args">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] args)
        {
            var ModList    = new List <string>();
            var ModCheck   = new List <IMod>();
            var camConfirm = (ConfirmActionMethod)args[0];

            var ModInstallDirectory = CurrentGameModeModDirectory.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;

            OverallMessage          = "Updating categories info: setup search..";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = false;
            OverallProgressMaximum  = 2;

            OverallMessage = "Retrieving the categories list... 1/2";
            StepOverallProgress();
            try
            {
                var lstCategories = ModRepository.GetCategories(ModRepository.GameDomainName);

                var i = 1;

                if (lstCategories.Count > 0)
                {
                    foreach (var category in lstCategories)
                    {
                        OverallMessage = "Saving the categories list... " + i + "/" + lstCategories.Count();
                        StepOverallProgress();

                        var modCategory = CategoryManager.FindCategory(category.Id);
                        if (modCategory != null && modCategory.Id != 0)
                        {
                            CategoryManager.RenameCategory(modCategory.Id, category.Name);
                        }
                        else
                        {
                            CategoryManager.AddCategory(new ModCategory(category.Id, category.Name, category.Name));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(null);
        }