private async void OnDownloadUpdateEvent(object sender, DownloadUpdateEventArgs args)
        {
            DebugHandler.TraceMessage("OnDownloadUpdateEvent called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(args.ToString(), DebugSource.TASK, DebugType.PARAMETERS);

            try
            {
                JsonDownloadInfo update = new JsonDownloadInfo()
                {
                    id        = args.id,
                    animeInfo = new JsonAnimeInfo()
                    {
                        anime_cover_original = args.animeCoverOriginal,
                        anime_id             = args.animeid,
                        anime_cover_small    = args.animeCoverSmall,
                        anime_title          = args.animeTitle
                    },
                    episodeNumber = args.episodeNumber,
                    bot           = args.bot,
                    pack          = args.pack,
                    progress      = args.progress,
                    speed         = args.speed,
                    status        = args.status,
                    filename      = args.filename,
                    filesize      = args.filesize,
                    downloadIndex = args.downloadIndex,
                    fullfilepath  = args.fullfilepath
                };

                await WebSocketHandler.SendMessage(update.ToJson());

                if (update.filename != null && update.fullfilepath != null)
                {
                    FileHistoryHandler.AddFileToFileHistory(update);
                }

                if (update.status == "FAILED" || update.status == "ABORTED")
                {
                    FileHistoryHandler.RemoveFileFromFileHistory(update.id);
                }
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.WARNING);
            }
        }
예제 #2
0
        private async Task DownloadQueueHandler()
        {
            DebugHandler.TraceMessage("DownloadQueueHandler Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);

            while (!Stop)
            {
                if (DownloadQueue.Count > 0 && !DownloadProcesOnGoing)
                {
                    DownloadProcesOnGoing = true;
                    CurrentlyDownloading  = DownloadQueue[0];

                    DebugHandler.TraceMessage("Requesting start of the following download: " + CurrentlyDownloading.ToJson(), DebugSource.TASK, DebugType.INFO);

                    IrcClientHandler.StartDownload(CurrentlyDownloading);
                }

                await Task.Delay(1000);
            }
        }
예제 #3
0
 public string GetCurrentlyDownloading()
 {
     DebugHandler.TraceMessage("GetCurrentlyDownloading Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
     return(CurrentlyDownloading.ToJson());
 }