Esempio n. 1
0
        private static List <string> GetDownloadFilePath(DownloadInfo info)
        {
            List <string> result = new List <string>();

            string[] lines = info.DownloadFilePath.Split('|');
            for (int i = 1; i < lines.Count(); i++)
            {
                result.Add(string.Format("{0}{1}", DownloadDirPath, lines[i].Split('$')[0]));
            }
            return(result);
        }
Esempio n. 2
0
        private static bool HaveDownloadFile(DownloadInfo info)
        {
            bool          result = true;
            List <string> files  = GetDownloadFilePath(info);

            if (!CommonFile.IsExist(files)) //如果缺少文件
            {
                ClearDownloadInfo(info);
                result = false;
            }
            return(result);
        }
Esempio n. 3
0
        public static void AddDownloadInfo(DownloadInfo info)
        {
            DownloadInfo currInfo = FindDownloadInfo(info);

            if (currInfo == null)
            {
                _downloadInfos.Add(info);
            }
            else
            {
                currInfo.DownloadFilePath = info.DownloadFilePath;
                currInfo.CreateDate       = info.CreateDate;
            }
        }
Esempio n. 4
0
        private static bool IsExpire(DownloadInfo info, int Interval)
        {
            TimeSpan ts = DateTime.Now - Convert.ToDateTime(info.CreateDate);

            if (ts.TotalMinutes > Interval)
            {
                //在此处可以先清理对应的文件
                ClearDownloadInfo(info);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
 private static void ClearDownloadInfo(DownloadInfo info)
 {
     GetDownloadInfos().Remove(info);
 }
Esempio n. 6
0
 private static DownloadInfo FindDownloadInfo(DownloadInfo info)
 {
     return(GetDownloadInfos().Find(x => x.Yljgbm == info.Yljgbm && x.OpType == info.OpType));
 }