public string GetTargetPath(ImageDeviceElement element) { //string strPath = ""; if (string.IsNullOrEmpty(element.TargetPathRoot) || Directory.Exists(element.TargetPathRoot) == false) { return(string.Empty); } string rootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar); string format = element.SourcePathFormat.Trim(Path.DirectorySeparatorChar); DateTime dtFileName = DateTime.Now; //根据测试机早上8点钟才会更换测试数据文件路径的属性,增加下面的判断 if (DateTime.Now >= Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 00:00:00") && DateTime.Now < Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 08:00:00")) { dtFileName = dtFileName.AddDays(-1); } string sourcePath = rootPath + Path.DirectorySeparatorChar + string.Format(format, dtFileName); if (Directory.Exists(sourcePath) == false) { Directory.CreateDirectory(sourcePath); } return(sourcePath); }
//public FTPManager ftpManager { get; private set; } /// <summary> /// 构造函数。 /// </summary> public ImageDataTransferThreadWrapper(ImageDeviceElement device, ParameterizedThreadStart threadStart) { this.Loop = true; this.Device = device; this.AutoResetEvent = new AutoResetEvent(false); this.Thread = new Thread(threadStart); }
/// <summary> /// 获取数据文件路径。先按照式化字符串中设置的格式寻找,如果没有匹配则返回文件夹中最新的文件夹路径。 /// </summary> /// <param name="element">图片设备配置。</param> /// <returns> /// 图片数据源文件夹路径。 /// </returns> public string GetSourcePath(ImageDeviceElement element) { if (string.IsNullOrEmpty(element.SourcePathRoot) || Directory.Exists(element.SourcePathRoot) == false) { return(string.Empty); } string rootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar); string format = element.SourcePathFormat.Trim(Path.DirectorySeparatorChar); DateTime dtFileName = DateTime.Now; //根据测试机早上8点钟才会更换测试数据文件路径的属性,增加下面的判断 if (DateTime.Now >= Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 00:00:00") && DateTime.Now < Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 08:00:00")) { dtFileName = dtFileName.AddDays(-1); } string sourcePath = rootPath + Path.DirectorySeparatorChar + string.Format(format, dtFileName); if (Directory.Exists(sourcePath)) { return(sourcePath); } DirectoryInfo TheFolder = new DirectoryInfo(element.SourcePathRoot); DirectoryInfo[] directoryInfos = TheFolder.GetDirectories(); DateTime dtLastWrite = DateTime.MinValue; DirectoryInfo diLastWrite = null; //获取最新的文件夹。 foreach (DirectoryInfo item in directoryInfos) { if (item.LastWriteTime > dtLastWrite) { dtLastWrite = item.LastWriteTime; diLastWrite = item; } } if (diLastWrite != null) { return(diLastWrite.FullName); } else { return(rootPath); } }
private void FrmImageDataTransfer_Load(object sender, EventArgs e) { this._section = (ImageConfigurationSection)ConfigurationManager.GetSection("mes.image"); if (_section.Devices.Count > 0) { this._deviceElement = _section.Devices[0]; } //this.txtFilePath.Text = this._deviceElement.SourcePathRoot; btnStart.Enabled = true; btnPause.Enabled = false; //txtEqpName.ReadOnly = true; //txtTestTime.ReadOnly = true; notifyIVData.Visible = false; }
private bool MoveFile(ImageDeviceElement element, string sourceFile, string targetFile) { bool blReturn = false; int count = 0; FileInfo fi = new FileInfo(sourceFile); long ss = fi.Length; FileStream fileStream = null; int iReturn = 0; string strError = ""; string strFilePath, strFileName; strFilePath = "ftp://10.0.3.238/IV/2016/06/20/"; strFileName = "123.jpg"; while (count < 5) { count++; try { //判断目标文件是否存在,若存在删除(后期是否改名称作为历史备份) if (File.Exists(targetFile)) { File.Delete(targetFile); } //判断文件是否打开(正在创建中) if (fi.Length > 0) { //压缩图形 CompressPIC(sourceFile, ref fileStream); //上传图形 //iReturn = FTPManager.FileUpload(fileStream, strFilePath, strFileName, targetFile, ref strError); iReturn = ftpManager.FileUpload(fileStream, targetFile, strFileName, ref strError); } //if (fi.Length > 0) //{ // yasuo(sourceFile, targetFile); //} //else //{ // File.Move(sourceFile, targetFile); //} count = 5; blReturn = true; } catch (IOException ex) { LogMessage(false, string.Format(element.Type + ":" + "等待30秒(copy {0} to {1}).错误原因{2}", sourceFile, targetFile, ex.Message)); System.Threading.Thread.Sleep(3000); continue; } catch (Exception ex) { LogMessage(false, element.Type + ":" + ex.Message); blReturn = false; } } return(blReturn); }
/// <summary> /// 将图片数据上传到MES中。 /// </summary> /// <param name="element">图片设备配置。</param> /// <returns>true:转置成功。false:转置失败。</returns> public void Execute(ImageDeviceElement element) { bool blFindFiles = false; bool blTransferDataResult = true; string strTransferDataMsg = ""; string sourceRootPath = ""; //数据来源文件路径 string targetRootPath = ""; //数据迁移根目录 try { //取得数据来源文件根目录。 sourceRootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar); //判断数据来源文件根目录是否存在 if (Directory.Exists(sourceRootPath) == false) { LogMessage(false, "数据来源文件路径:" + sourceRootPath + " 不存在!"); return; } //数据迁移根目录 targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar); #region 获取源文件夹下的未移转图片。 //取得数据来源文件目录对象 DirectoryInfo diSourcePath = new DirectoryInfo(sourceRootPath); //数据文件格式 string searchPattern = string.Format("*.{0}", element.FileExtensionName); //取得目录下所有文件 FileInfo[] fileInfos = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories); if (fileInfos != null && fileInfos.Length > 0) { blFindFiles = true; } //遍历文件夹文件。 int maxNumberForLoop = 5; int nIndexOfFile = 0; if (fileInfos.Length > maxNumberForLoop) { SortAsFileCreationTime(ref fileInfos); } #endregion //获取源文件夹路径。 string sourcePath = this.GetSourcePath(element); //if (string.IsNullOrEmpty(sourcePath)) //{ // blTransferDataResult = false; // strTransferDataMsg = string.Format("获取 {0} 源文件夹路径失败。", element.Name); //} //目标目录数据目标文件夹根路径 //string targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar); //设备名称; string targetPath = this.GetTargetPath(element); if (Directory.Exists(targetPath) == false) { Directory.CreateDirectory(targetPath); } //获取源文件夹下的未移转图片。 DirectoryInfo diSourcePath = new DirectoryInfo(sourcePath); string searchPattern = string.Format("*.{0}", element.FileExtensionName); FileInfo[] fileInfos = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories); if (fileInfos != null && fileInfos.Length > 0) { blFindFiles = true; } DateTime dtMaxTime = DateTime.MinValue; //遍历文件夹文件。 int maxNumberForLoop = 5; int nIndexOfFile = 0; if (fileInfos.Length > maxNumberForLoop) { SortAsFileCreationTime(ref fileInfos); } IList <LotAttribute> lstLotAttribute = new List <LotAttribute>(); foreach (FileInfo fiItem in fileInfos) { if (nIndexOfFile > maxNumberForLoop) { break; } nIndexOfFile = nIndexOfFile + 1; string targetFileName = fiItem.FullName.Replace(sourcePath, targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); #region 更新批次属性数据。 try { bool blFlag = true; //复制源文件到目标文件夹下。 //blFlag = this.MoveFile(element, fiItem.FullName, targetFileName); string lotNumber = ""; //if (blFlag) //{ // #region 更新 Lot属性 // lotNumber = fiItem.Name.Replace(fiItem.Extension, string.Empty).ToUpper().Split('_', '-')[0]; // lotNumber = lotNumber.Trim(); // string attributeName = string.Format("{0}ImagePath", element.Type); // string attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot); // attributeValue = attributeValue.Replace('\\', '/'); // LotAttribute obj = new LotAttribute() // { // Key = new LotAttributeKey() // { // LotNumber = lotNumber, // AttributeName = attributeName // }, // AttributeValue = attributeValue, // Editor = "system", // EditTime = DateTime.Now // }; // using (LotAttributeServiceClient client = new LotAttributeServiceClient()) // { // MethodReturnResult result = client.Modify(obj); // if (result.Code > 0) // { // strTransferDataMsg = string.Format("更新批次号{0}错误:{1}", lotNumber, result.Message); // LogMessage(false, element.Type + ":" + strTransferDataMsg); // client.Close(); // } // else // { // LogMessage(true, element.Type + ":" + lotNumber); // } // client.Close(); // } // #endregion //} } catch (Exception ex) { LogMessage(false, element.Type + ":" + ex.Message); } #endregion } } catch (Exception ex) { blTransferDataResult = false; LogMessage(false, element.Type + ":" + ex.Message); } if (blFindFiles == false) { strTransferDataMsg = ""; LogMessage(true, element.Type + ":" + strTransferDataMsg); } }
/// <summary> /// 将图片数据上传到MES中。 /// </summary> /// <param name="element">图片设备配置。</param> /// <returns>true:转置成功。false:转置失败。</returns> public bool Execute(ImageDeviceElement element) { try { //获取源文件夹路径。 string sourcePath = this.GetSourcePath(element); if (string.IsNullOrEmpty(sourcePath)) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("获取 {0} 源文件夹路径失败。", element.Name) , EventLogEntryType.Error); return(false); } //获取目标文件夹路径。 string sourceRootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar); string targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar); //string targetPath = sourcePath.Replace(sourceRootPath, targetRootPath); string targetPath = this.GetTargetPath(element); if (Directory.Exists(targetPath) == false) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("{0} 目标文件夹路径({1})不存在。", element.Name, targetPath) , EventLogEntryType.Warning); Directory.CreateDirectory(targetPath); } //获取源文件夹下的未移转图片。 DirectoryInfo diSourcePath = new DirectoryInfo(sourcePath); string searchPattern = string.Format("*.{0}", element.FileExtensionName); FileInfo[] fileInfos = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories); DateTime dtMaxTime = DateTime.MinValue; //移除最新的更新时间问题 /* * using (ClientConfigAttributeServiceClient client = new ClientConfigAttributeServiceClient()) * { * MethodReturnResult<ClientConfigAttribute> rst = client.Get(new ClientConfigAttributeKey() * { * ClientName = element.Name, * AttributeName = string.Format("{0}ImageDateTime", element.Type) * }); * if (rst.Code <= 0 && rst.Data != null) * { * dtMaxTime = DateTime.Parse(rst.Data.Value); * } * client.Close(); * } * var lnq = from item in fileInfos * where item.LastWriteTime > dtMaxTime * orderby item.LastWriteTime * select item; */ //遍历文件夹文件。 IList <LotAttribute> lstLotAttribute = new List <LotAttribute>(); foreach (FileInfo fiItem in fileInfos) { string targetFileName = fiItem.FullName.Replace(sourcePath, targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); //复制源文件到目标文件夹下。 File.Copy(fiItem.FullName, targetFileName, true); dtMaxTime = fiItem.LastWriteTime.AddMilliseconds(1); #region //更新批次属性数据。 try { string lotNumber = fiItem.Name.Replace(fiItem.Extension, string.Empty).ToUpper().Split('_', '-')[0]; lotNumber = lotNumber.Trim(); string attributeName = string.Format("{0}ImagePath", element.Type); string attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot); attributeValue = attributeValue.Replace('\\', '/'); LotAttribute obj = new LotAttribute() { Key = new LotAttributeKey() { LotNumber = lotNumber, AttributeName = attributeName }, AttributeValue = attributeValue, Editor = "system", EditTime = DateTime.Now }; using (LotAttributeServiceClient client = new LotAttributeServiceClient()) { MethodReturnResult result = client.Modify(obj); if (result.Code > 0) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, result.Message) , EventLogEntryType.Warning); client.Close(); continue; } client.Close(); } } catch (Exception ex) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, ex.Message) , EventLogEntryType.Error); System.Threading.Thread.Sleep(500); return(false); } #endregion #region //进行原文件的后续处理。 int count = 0; while (count < 5) { count++; try { //如设置删除源文件,则删除。 if (element.IsDeleteSourceFile) { File.Delete(fiItem.FullName); } else {//否则,移动到LocalFiles下。 //string copyFilePath = sourcePath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar + "LocalFiles"; //if (Directory.Exists(copyFilePath) == false) //{ // Directory.CreateDirectory(copyFilePath); //} //string copyFileName = fiItem.FullName.Replace(sourcePath, copyFilePath); //File.Copy(fiItem.FullName, copyFileName,true); //File.Delete(fiItem.FullName); } break; } catch (Exception ex) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, ex.Message) , EventLogEntryType.Error); System.Threading.Thread.Sleep(500); continue; } } #endregion #region 更新ClientConfig的最新更新时间 /* * using (ClientConfigServiceClient client = new ClientConfigServiceClient()) * { * MethodReturnResult<ClientConfig> rst = client.Get(element.Name); * if (rst.Data == null) * { * ClientConfig obj = new ClientConfig() * { * ClientType = EnumClientType.Other, * CreateTime = DateTime.Now, * Creator = "system", * Description = string.Empty, * Editor = "system", * EditTime = DateTime.Now, * IPAddress = element.Name, * Key = element.Name, * LocationName = null * }; * client.Add(obj); * } * client.Close(); * } * using (ClientConfigAttributeServiceClient client = new ClientConfigAttributeServiceClient()) * { * ClientConfigAttribute obj = null; * ClientConfigAttributeKey ccaKey = new ClientConfigAttributeKey() * { * ClientName = element.Name, * AttributeName = string.Format("{0}ImageDateTime",element.Type) * }; * MethodReturnResult<ClientConfigAttribute> rst = client.Get(ccaKey); * if (rst.Code <= 0 && rst.Data != null) * { * obj = rst.Data; * } * if (obj != null) * { * obj.Value = dtMaxTime.ToString("yyyy-MM-dd HH:mm:ss.fff"); * obj.Editor = "system"; * obj.EditTime = DateTime.Now; * client.Modify(obj); * } * else * { * obj = new ClientConfigAttribute() * { * Key = ccaKey, * Value = dtMaxTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), * Editor = "system", * EditTime = DateTime.Now * }; * client.Add(obj); * } * client.Close(); * } */ #endregion } } catch (Exception ex) { EventLog.WriteEntry(EVENT_SOURCE_NAME , string.Format("{0}:{1}", element.Name, ex.Message) , EventLogEntryType.Error); return(false); } return(true); }
private bool MoveFile(ImageDeviceElement element, string sourceFile, string targetFile) { bool blReturn = false; int count = 0; FileInfo fi = new FileInfo(sourceFile); long ss = fi.Length; while (count < 5) { count++; try { if (File.Exists(targetFile)) { //File.Delete(targetFile); // 列表中的原始文件全路径名 string oldStr = fi.Name; if (fi.Name.Substring(0, 2) != "JN") { string i = ""; string newStr = ""; i = oldStr.Substring(13, 2); if (i == "" || i == ".j") { int j = 1; string m = Convert.ToString(j); // 新文件名 newStr = fi.Name.Substring(0, 13) + "_" + m + fi.Name.Substring(13, 4); } else { i = oldStr.Substring(14, 1); int j = Convert.ToInt16(i); j = j + 1; string m = Convert.ToString(j); // 新文件名 newStr = fi.Name.Substring(0, 13) + "_" + j + fi.Name.Substring(15, 4); } //// 列表中的原始文件全路径名 string old = fi.DirectoryName + @"\" + oldStr; //// 新文件名 string new1 = fi.DirectoryName + @"\" + newStr; // 改名方法 FileInfo fi1 = new FileInfo(old); fi1.MoveTo(Path.Combine(new1)); sourceFile = fi1.FullName; targetFile = element.TargetPathRoot + @"\" + newStr; if (fi1.Length > 0) { yasuo(sourceFile, targetFile); } else { File.Move(sourceFile, targetFile); } } else { string i = ""; string newStr = ""; i = oldStr.Substring(15, 2); if (i == "" || i == ".j") { int j = 1; string m = Convert.ToString(j); // 新文件名 newStr = fi.Name.Substring(0, 15) + "_" + m + fi.Name.Substring(15, 4); } else { i = oldStr.Substring(16, 1); int j = Convert.ToInt16(i); j = j + 1; string m = Convert.ToString(j); // 新文件名 newStr = fi.Name.Substring(0, 15) + "_" + j + fi.Name.Substring(17, 4); } //// 列表中的原始文件全路径名 string old = fi.DirectoryName + @"\" + oldStr; //// 新文件名 string new1 = fi.DirectoryName + @"\" + newStr; // 改名方法 FileInfo fi1 = new FileInfo(old); fi1.MoveTo(Path.Combine(new1)); sourceFile = fi1.FullName; targetFile = element.TargetPathRoot + @"\" + newStr; if (fi1.Length > 0) { yasuo(sourceFile, targetFile); } else { File.Move(sourceFile, targetFile); } } } else { if (fi.Length > 0) { yasuo(sourceFile, targetFile); } else { File.Move(sourceFile, targetFile); } } count = 5; blReturn = true; } catch (IOException ex) { LogMessage(false, string.Format(element.Type + ":" + "等待30秒(copy {0} to {1}).错误原因{2}", sourceFile, targetFile, ex.Message)); System.Threading.Thread.Sleep(30000); continue; } catch (Exception ex) { LogMessage(false, element.Type + ":" + ex.Message); blReturn = false; } } return(blReturn); }
/// <summary> /// 将图片数据上传到MES中。 /// </summary> /// <param name="element">图片设备配置。</param> /// <returns>true:转置成功。false:转置失败。</returns> public void Execute(ImageDeviceElement element) { bool blFindFiles = false; bool blTransferDataResult = true; string strTransferDataMsg = ""; try { //获取源文件夹路径。 string sourcePath = this.GetSourcePath(element); if (string.IsNullOrEmpty(sourcePath)) { blTransferDataResult = false; strTransferDataMsg = string.Format("获取 {0} 源文件夹路径失败。", element.Name); } //获取目标文件夹路径。 string sourceRootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar); string targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar); //string targetPath = sourcePath.Replace(sourceRootPath, targetRootPath); string targetPath = this.GetTargetPath(element); if (Directory.Exists(targetPath) == false) { Directory.CreateDirectory(targetPath); } //获取源文件夹下的未移转图片。 DirectoryInfo diSourcePath = new DirectoryInfo(sourcePath); string searchPattern = string.Format("*.{0}", element.FileExtensionName); FileInfo[] fileInfos = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories); if (fileInfos != null && fileInfos.Length > 0) { blFindFiles = true; } DateTime dtMaxTime = DateTime.MinValue; //遍历文件夹文件。 int maxNumberForLoop = 5; int nIndexOfFile = 0; if (fileInfos.Length > maxNumberForLoop) { SortAsFileCreationTime(ref fileInfos); } IList <LotAttribute> lstLotAttribute = new List <LotAttribute>(); foreach (FileInfo fiItem in fileInfos) { if (nIndexOfFile > maxNumberForLoop) { break; } nIndexOfFile = nIndexOfFile + 1; string targetFileName = fiItem.FullName.Replace(sourcePath, targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); #region //更新批次属性数据。 try { bool blFlag = true; //复制源文件到目标文件夹下。 // blFlag = this.MoveFile(element, fiItem.FullName, targetFileName); string lotNumber = ""; if (blFlag) { #endregion #region //更新 Lot属性 lotNumber = fiItem.Name.Replace(fiItem.Extension, string.Empty).ToUpper().Split('_', '-')[0]; lotNumber = lotNumber.Trim(); #region//获取批次所在工序及状态 using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { Where = string.Format("LOT_NUMBER = '{0} '", lotNumber), OrderBy = "EditTime Desc" }; MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg); if (result.Code <= 0 && result.Data != null && result.Data.Count > 0 && result.Data[0].RouteStepName == "功率测试" && result.Data[0].Activity == EnumLotActivity.TrackOut) { string attributeName = string.Format("{0}ImagePath", element.Type); string attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot); attributeValue = attributeValue.Replace('\\', '/'); //获取批次属性是否已存在EL3的属性,如果不存在,则更新EL3图片属性 using (LotAttributeServiceClient client2 = new LotAttributeServiceClient()) { PagingConfig cfg1 = new PagingConfig() { Where = string.Format("Key.LotNumber = '{0}'and Key.AttributeName='ELImagePath'", lotNumber), OrderBy = "EditTime Desc" }; MethodReturnResult <IList <LotAttribute> > result2 = client.GetAttribute(ref cfg1); if (result2.Code <= 0 && result2.Data != null && result2.Data.Count > 0) { blFlag = this.MoveFile(element, fiItem.FullName, targetFileName); FileInfo[] fileInfos1 = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories); foreach (FileInfo fiItem1 in fileInfos1) { if (nIndexOfFile > maxNumberForLoop) { break; } nIndexOfFile = nIndexOfFile + 1; targetFileName = fiItem1.FullName.Replace(sourcePath, targetPath); Directory.CreateDirectory(Path.GetDirectoryName(targetFileName)); File.Delete(fiItem1.FullName); } attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot); LotAttribute obj = new LotAttribute() { Key = new LotAttributeKey() { LotNumber = lotNumber, AttributeName = attributeName }, AttributeValue = attributeValue, Editor = "system", EditTime = DateTime.Now }; using (LotAttributeServiceClient client1 = new LotAttributeServiceClient()) { MethodReturnResult result1 = client1.Modify(obj); if (result.Code > 0) { strTransferDataMsg = string.Format("更新批次号{0}错误:{1}", lotNumber, result.Message); LogMessage(false, element.Type + ":" + strTransferDataMsg); client.Close(); } else { LogMessage(true, element.Type + ":" + lotNumber); } client.Close(); } } else { LotAttribute obj = new LotAttribute() { Key = new LotAttributeKey() { LotNumber = lotNumber, AttributeName = attributeName }, AttributeValue = attributeValue, Editor = "system", EditTime = DateTime.Now }; using (LotAttributeServiceClient client1 = new LotAttributeServiceClient()) { MethodReturnResult result1 = client1.Modify(obj); if (result.Code > 0) { strTransferDataMsg = string.Format("更新批次号{0}错误:{1}", lotNumber, result.Message); LogMessage(false, element.Type + ":" + strTransferDataMsg); client.Close(); } else { LogMessage(true, element.Type + ":" + lotNumber); } client.Close(); } blFlag = this.MoveFile(element, fiItem.FullName, targetFileName); File.Delete(fiItem.FullName); } } } else { result.Message = "组件批次不在功率测试出站"; strTransferDataMsg = string.Format("批次号{0}错误:{1}", lotNumber, result.Message); blFlag = this.MoveFile(element, fiItem.FullName, targetFileName); File.Delete(fiItem.FullName); } #endregion } } } catch (Exception ex) { LogMessage(false, element.Type + ":" + ex.Message); } #endregion } } catch (Exception ex) { blTransferDataResult = false; LogMessage(false, element.Type + ":" + ex.Message); } if (blFindFiles == false) { strTransferDataMsg = ""; LogMessage(true, element.Type + ":" + strTransferDataMsg); } }