예제 #1
0
        protected override bool PrepareAndCheckIfCanRun(object[] args)
        {
            if (ConfigurationManager.Config.ShouldUpdateOnlyUnfinishedEntries)
            {
                animes = animeService.GetCustom(e => e.Status != ContentStatus.FINISHED);
                mangas = mangaService.GetCustom(e => e.Status != ContentStatus.FINISHED);
            }
            else
            {
                animes = animeService.GetAll();
                mangas = mangaService.GetAll();
            }

            if (!animes.Any() && !mangas.Any())
            {
                ToastEvent.ShowToast(
                    ConfigurationManager.Config.ShouldUpdateOnlyUnfinishedEntries
                                                ? "Update didn't start - No unfinished animes or mangas to update."
                                                : "Update didn't start - No animes or mangas to update.",
                    ToastType.WARNING);

                return(false);
            }

            jobTitle       = "Animes and mangas update";
            jobMaxProgress = (animes.Count() + mangas.Count()) * 2;
            jobDescription = "Updating saved animes and mangas with latest info from anilst";

            return(true);
        }
예제 #2
0
        protected async virtual Task StartJob()
        {
            watch.Start();

            await JobEvent.StartJob(jobDescription, jobMaxProgress);

            LogEvent.LogMessage(JobStartMessage);
            if (!string.IsNullOrEmpty(jobTitle))
            {
                ToastEvent.ShowToast(JobStartMessage, ToastType.INFO);
            }
        }
예제 #3
0
#pragma warning restore CS1998

        protected async virtual Task EndJob(Exception ex = null)
        {
            watch.Stop();
            await JobEvent.EndJob();

            if (ex == null)
            {
                LogEvent.LogMessage($"{JobSuccessMessage} Elapsed time: {watch.Elapsed}.");
                if (!string.IsNullOrEmpty(jobTitle))
                {
                    ToastEvent.ShowToast(JobSuccessMessage, ToastType.SUCCESS);
                }
            }
            else
            {
                LogEvent.LogError(ex, $"{JobFailMessage} Elapsed time: {watch.Elapsed}.");

                if (!string.IsNullOrEmpty(jobTitle))
                {
                    ToastEvent.ShowToast($"{JobFailMessage} Reason: {ex.Message}.", ToastType.DANGER);
                }
            }
        }