예제 #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);
        }
예제 #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);
        }
예제 #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;
            }
        }
예제 #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);
            }
        }
예제 #5
0
 private static void ClearDownloadInfo(DownloadInfo info)
 {
     GetDownloadInfos().Remove(info);
 }
예제 #6
0
 private static DownloadInfo FindDownloadInfo(DownloadInfo info)
 {
     return(GetDownloadInfos().Find(x => x.Yljgbm == info.Yljgbm && x.OpType == info.OpType));
 }