Esempio n. 1
0
 public void Stop()
 {
     IrcClientHandler.StopDownload();
     IrcClientHandler.StopConnection();
     DownloadHandler.StopQueue();
     WebSocketHandler.StopServer();
 }
Esempio n. 2
0
        public async Task <string> AbortDownload(string id = null, string filePath = null)
        {
            DebugHandler.TraceMessage("AbortDownload Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage("ID: " + id + ", FILEPATH: " + filePath, DebugSource.TASK, DebugType.PARAMETERS);

            try
            {
                if (IrcClientHandler.IsDownloading() && DownloadProcesOnGoing)
                {
                    if (CurrentlyDownloading.id == id)
                    {
                        DebugHandler.TraceMessage("Stopping the current download!", DebugSource.TASK, DebugType.INFO);
                        IrcClientHandler.StopDownload();
                    }
                }

                while (IrcClientHandler.IsDownloading())
                {
                    DebugHandler.TraceMessage("Current download still running!", DebugSource.TASK, DebugType.INFO);
                    await Task.Delay(100);
                }

                DebugHandler.TraceMessage("Current download stopped!", DebugSource.TASK, DebugType.INFO);
                JsonSuccess succes = new JsonSuccess()
                {
                    message = "Succesfully aborted download from download queue by download json."
                };

                return(succes.ToJson());
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage("Could not remove download from queue by download json and stop the download.", DebugSource.TASK, DebugType.WARNING);
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.WARNING);
                JsonError error = new JsonError()
                {
                    type         = "remove_download_error",
                    errormessage = "Could not remove download from queue by download json.",
                    errortype    = "exception"
                };
                return(error.ToJson());
            }
        }