123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using EMISOnline.WinService.Common;
- using System.Configuration;
- using System.IO;
- using System.Text.RegularExpressions;
- using DSOFile;
- namespace EMISOnline.WinService
- {
- public class FtpTimer
- {
- public FtpTimer()
- {
- }
- public void CheckFiles()
- {
- Log.Info(this.GetType().ToString(), "Start checking...");
-
- List<string> overFiles = UploadOverFiles();
-
- List<FileInfo> lists = FileHelper.GetAllFiles(Config.FtpPath,Config.FtpFileType);
- foreach (FileInfo file in lists)
- {
- string Comments = FileHelper.GetFilePropertiesComments(file.FullName);
- if (string.IsNullOrEmpty(Comments)) Comments = "";
-
- if (Comments.IndexOf("UploadOver") >= 0) continue;
- bool isUpLoadOver = overFiles.Contains(file.FullName.ToLower());
- Log.Info(this.GetType().ToString(), "检查到文件:" + file.FullName + " 是否上传成功:" + isUpLoadOver.ToString());
-
-
-
- if (isUpLoadOver)
- {
- FileHelper.SaveFilePropertiesComments(file.FullName, "UploadOver");
-
-
- string mp4Url = Config.FTPServer + file.FullName.Replace(Config.FtpPath, "").Replace("\\", "/");
- M3u8Timer.SaveFtpFile(file.FullName, "",mp4Url, "", file.Name, 1);
- }
- else
- {
-
- M3u8Timer.SaveFtpFile(file.FullName, "", "", "", file.Name, 0);
- }
- }
- }
-
- public List<string> UploadOverFiles()
- {
- List<string> lines = FileHelper.ReadTxt(Config.ServUFile);
- List<string> rtn = new List<string>();
- foreach (string line in lines)
- {
-
- Match match = Regex.Match(line, Config.ServURegex);
- if (match.Success)
- {
- if (rtn.Contains(match.Groups[1].Value)) continue;
- rtn.Add(match.Groups[1].Value);
-
- }
- }
- return rtn;
- }
- }
- }
|