public void Do() { this.msgFileFtpList = FTPFactory.CreateMsgFtpList(); //var test = "D0201010000H0000001H 43132*****201511130934420020151113093442002015111309350000001100J16155450224AH 43132"; //var time = test.Substring(66, 14); //CreateMessageFile("1", "1234", "222", "20181213194533"); //CreateMessageFile("0", "1234", "222", "20180128194533"); // 传感器 Thread thread = new Thread(RunThread); thread.Start(); // 摄像头 if (Param.CHostList.Count > 0) { for (var i = 0; i < Param.CHostList.Count; i++) { var host = Param.CHostList[i]; if (host.Host == null || host.Host == "") { continue; } cLastTime.Add(host, DateTime.Now.AddMinutes(-1)); Thread threadc = new Thread(new ParameterizedThreadStart(RunThreadC)); threadc.Start(host); } } }
private bool UploadCameraFile(string fileName, string inout, CHostConfig host) { fileName = Application.StartupPath + @"\datas\" + host.Key + @"\" + fileName; int destIndex = -1; for (var i = 0; i < Param.HostList.Count; i++) { if (Param.HostList[i].Key == host.Dest) { destIndex = i; break; } } if (destIndex < 0) { File.Delete(fileName); Log.WriteLine(string.Format("找不到目标主机地址")); return(false); } var helper = FTPFactory.CreateDestFtp(destIndex); if (helper == null) { File.Delete(fileName); Log.WriteLine(string.Format("找不到相关ftp配置,文件名:{0},出入库类型:{1}。", fileName, inout)); return(false); } Log.WriteLine(string.Format("文件名称:{0},出入库类型:{1},目标ftp服务器:{2}。", fileName, inout, helper.FtpServerIP)); var toFile = Application.StartupPath + @"\datas\" + host.Key + @"\notify.txt"; if (File.Exists(toFile)) { File.Delete(toFile); } File.Copy(fileName, toFile); bool flag = helper.Upload(toFile); if (!flag) { Thread.Sleep(500); flag = helper.Upload(toFile); } if (flag) { Log.WriteLine(string.Format("文件名称:{0},上传完毕。", fileName)); } else { Log.WriteLine(string.Format("文件名称:{0},上传失败!", fileName)); } //上传完毕,删除本地 File.Delete(toFile); File.Delete(fileName); // 先不进行删除 // Move(fileName); // 保存本地文件到具体目录 return(true); }
private bool Download(string fileName, string subpath, CHostConfig host) { FTPHelper helper = host == null?FTPFactory.CreateSrcFtp() : FTPFactory.CreateSrcFtp(host); if (helper == null) { return(false); } helper.Download(@".\" + subpath, fileName); return(true); }
private void UploadDefault(int fileNo) { var helper = FTPFactory.CreateDestFtp(fileNo); if (helper == null) { return; } File.WriteAllText("notify.txt", Param.DEFAULT, Encoding.Default); bool flag = helper.Upload(@".\notify.txt"); if (!flag) { Thread.Sleep(500); helper.Upload(@".\notify.txt"); } //上传完毕,删除本地 File.Delete("notify.txt"); }
private bool Upload(string fileName, string inout) { var helper = FTPFactory.CreateDestFtp(fileName, inout); var path = Application.StartupPath + @"\datas\"; if (helper == null) { File.Delete(fileName); Log.WriteLine(string.Format("找不到相关ftp配置,文件名:{0},出入库类型:{1}。", fileName, inout)); return(false); } Log.WriteLine(string.Format("文件名称:{0},出入库类型:{1},目标ftp服务器:{2}。", fileName, inout, helper.FtpServerIP)); if (File.Exists(path + "notify.txt")) { File.Delete(path + "notify.txt"); } File.Copy(path + fileName, path + "notify.txt"); bool flag = helper.Upload(path + "notify.txt"); if (!flag) { Thread.Sleep(500); flag = helper.Upload(path + "notify.txt"); } if (flag) { Log.WriteLine(string.Format("文件名称:{0},上传完毕。", fileName)); } else { Log.WriteLine(string.Format("文件名称:{0},上传失败!", fileName)); } //上传完毕,删除本地 File.Delete(path + "notify.txt"); File.Delete(path + fileName); // 先不进行删除 // Move(fileName); // 保存本地文件到具体目录 return(true); }