示例#1
0
        public void Add(NetDiskFile file, string path)
        {
            if (Contains(path))
            {
                return;
            }


            _info.Tasks.Add(new TaskInfo()
            {
                DownloadFileInfo = file,
                DownloadPath     = path,
            });

            var data = new DownloadingFileData()
            {
                Info         = null,
                DownloadPath = path,
                FileInfo     = file,
            };

            data.Save();
            _info.DownloadingList.Add(data);
            Save();
        }
示例#2
0
        public NextResult CreateData(DownloadingFileData info, DownloadResult result)
        {
            try
            {
                var httpInfo = HttpDownload.CreateTaskInfo(result.Urls, info.DownloadPath);

                info.Info = httpInfo;
                info.Save();


                return(new NextResult(httpInfo, 0, string.Empty));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#3
0
        private void Reload()
        {
            string temp;

            if (!File.Exists(taskListFile) || string.IsNullOrEmpty(temp = File.ReadAllText(taskListFile)))
            {
                _info = new TaskList();
                Save();
                return;
            }
            else
            {
                _info = JsonConvert.DeserializeObject <TaskList>(temp);
            }

            foreach (var path in _info.Tasks.Select(v => v.DownloadPath))
            {
                if (File.Exists(path + ".downloading"))
                {
                    _info.DownloadingList.Add(DownloadingFileData.Load(path + ".downloading"));
                }
            }
        }