Пример #1
0
        private void downloadStatusCallback() //see below for definition of each index in this array
        {
            Object progress     = irc.getDownloadProgress("progress");
            Object speedkbps    = irc.getDownloadProgress("kbps");
            Object status       = irc.getDownloadProgress("status");
            Object filename     = irc.getDownloadProgress("filename");
            Object filesize     = irc.getDownloadProgress("size");
            long   filesizeinmb = (long.Parse(filesize.ToString().Trim()) / 1048576);

            if (status.ToString().Contains("DOWNLOADING") && status.ToString().Contains("WAITING"))
            {
                SharedData.currentlyDownloading = true;
            }
            else if (status.ToString().Contains("FAILED") || status.ToString().Contains("COMPLETED") || status.ToString().Contains("ABORTED"))
            {
                SharedData.currentlyDownloading = false;
            }

            JsonDownloadUpdate update = new JsonDownloadUpdate();

            update.id       = SharedData.currentDownloadId;
            update.progress = progress.ToString();
            update.speed    = speedkbps.ToString();
            update.status   = status.ToString();
            update.filename = filename.ToString();
            update.filesize = filesizeinmb.ToString();


            SharedData.AddToMessageList(JsonConvert.SerializeObject(update, Formatting.Indented));

            Debug.WriteLine("DEBUG-IRCHANDLER: Download upsate: " + JsonConvert.SerializeObject(update, Formatting.Indented));
        }
Пример #2
0
        private void getDownloads()
        {
            string[] filePaths = Directory.GetFiles(SharedData.currentDownloadLocation);
            int      a         = 0;
            JsonAlreadyDownloaded alreadyDownloadedList = new JsonAlreadyDownloaded();

            List <JsonDownloadUpdate> listWithFiles = new List <JsonDownloadUpdate>();

            foreach (string filePath in filePaths)
            {
                if (utilityMethods.IsMediaFile(filePath))
                {
                    string   filename = Path.GetFileName(filePath);
                    FileInfo info     = new FileInfo(filePath);
                    int      filesize = (int)(info.Length / 1048576);

                    JsonDownloadUpdate alreadyDownloaded = new JsonDownloadUpdate();
                    alreadyDownloaded.id       = a.ToString();
                    alreadyDownloaded.progress = "100";
                    alreadyDownloaded.speed    = "0";
                    alreadyDownloaded.status   = "ALREADYDOWNLOADED";
                    alreadyDownloaded.filename = filename;
                    alreadyDownloaded.filesize = filesize.ToString();
                    listWithFiles.Add(alreadyDownloaded);

                    a++;
                }
            }
            alreadyDownloadedList.alreadyDownloaded = listWithFiles;

            SharedData.AddToMessageList(JsonConvert.SerializeObject(alreadyDownloadedList, Formatting.Indented));
        }