예제 #1
0
 private void Reload()
 {
     if (!File.Exists(TaskListFile))
     {
         _info = new TaskList();
         Save();
         return;
     }
     _info = JsonConvert.DeserializeObject <TaskList>(File.ReadAllText(TaskListFile));
     foreach (var path in _info.Tasks.Select(v => v.DownloadPath))
     {
         if (File.Exists(path + ".downloading"))
         {
             _info.DownloadingList.Add(DownloadingFileData.Load(path + ".downloading"));
         }
     }
 }
예제 #2
0
        public async Task <NextResult> CreateData(DownloadingFileData info, DownloadResult result)
        {
            try
            {
                foreach (var url in result.DownloadUrlList)
                {
                    var httpInfo = await HttpDownload.CreateTaskInfo(url.Value.UrlLists, info.DownloadPath, _user.DownloadThreadNumber,
                                                                     result.Cookies);

                    info.Info = httpInfo;
                    info.Save();
                    return(new NextResult(httpInfo, 0, string.Empty));
                }
                return(null);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
        public async Task <NextResult> CreateData(DownloadingFileData info, DownloadResult result)
        {
            try
            {
                foreach (var url in result.DownloadUrlList)
                {
                    var httpInfo = await HttpDownload.CreateTaskInfo(url.Value.UrlLists, info.DownloadPath, (int)Container.Resolve <ILocalConfigInfo>().SpeedLimit,
                                                                     result.Cookies);

                    info.Info = httpInfo;
                    info.Save();
                    return(new NextResult(httpInfo, 0, string.Empty));
                }
                return(null);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
예제 #4
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();
        }
        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"));
                }
            }
        }