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); }
private static bool HaveDownloadFile(DownloadInfo info) { bool result = true; List <string> files = GetDownloadFilePath(info); if (!CommonFile.IsExist(files)) //如果缺少文件 { ClearDownloadInfo(info); result = false; } return(result); }
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; } }
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); } }
private static void ClearDownloadInfo(DownloadInfo info) { GetDownloadInfos().Remove(info); }
private static DownloadInfo FindDownloadInfo(DownloadInfo info) { return(GetDownloadInfos().Find(x => x.Yljgbm == info.Yljgbm && x.OpType == info.OpType)); }