public ActionResult QueryUndo(string lotNumber) { MethodReturnResult result = GetLot(lotNumber); if (result.Code > 0) { return(Json(result)); } using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("LotNumber='{0}' AND UndoFlag=0 AND Activity>'{1}'" , lotNumber , Convert.ToInt32(EnumLotActivity.Undo)), OrderBy = "CreateTime DESC" }; MethodReturnResult <IList <LotTransaction> > rst = client.GetTransaction(ref cfg); if (rst.Code > 0) { return(Json(rst)); } ViewBag.TransactionList = rst.Data; return(PartialView("_UndoListPartial", new LotViewModel())); } }
public MethodReturnResult GetLotTransaction(string key) { MethodReturnResult result = new MethodReturnResult(); LotTransaction obj = null; using (LotQueryServiceClient client = new LotQueryServiceClient()) { MethodReturnResult <LotTransaction> rst = client.GetTransaction(key); if (rst.Code <= 0 && rst.Data != null) { obj = rst.Data; } else { result.Code = rst.Code; result.Message = rst.Message; result.Detail = rst.Detail; return(result); } } if (obj == null) { result.Code = 2001; result.Message = "被撤销操作不存在。"; return(result); } //判断用户拥有的工序权限 IList <Resource> lstResource = new List <Resource>(); using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient()) { MethodReturnResult <IList <Resource> > rst = client.GetResourceList(User.Identity.Name, ResourceType.RouteOperation); if (rst.Code <= 0 && rst.Data != null) { lstResource = rst.Data; } else { result.Code = rst.Code; result.Message = rst.Message; result.Detail = rst.Detail; return(result); } } var lnq = from item in lstResource where item.Data == obj.RouteStepName select item; if (lnq.Count() == 0) { result.Code = 1; result.Message = string.Format("用户({0})权限不足,对工序({1})的操作不能撤销。", User.Identity.Name, obj.RouteStepName); return(result); } return(result); }
public async Task <ActionResult> Query(CheckDataQueryViewModel model) { if (ModelState.IsValid) { using (LotQueryServiceClient client = new LotQueryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { OrderBy = "CreateTime DESC", Where = GetQueryCondition(model) }; MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg); string where = GetQueryCountCondition(model); MethodReturnResult <DataSet> count = client.GetLotCount(where); if (count.Code == 0 && count.Data.Tables[0].Rows.Count > 0) { string qty = count.Data.Tables[0].Rows[0][0].ToString(); ViewBag.count = qty; ViewBag.stime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", model.StartCheckTime); ViewBag.etime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", model.EndCheckTime); } if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", new CheckDataViewModel())); } else { return(View("Index", model)); } }
/// <summary> 获取最新的一条加工历史数据/// </summary> /// <param name="LotNumber"></param> /// <returns></returns> public LotTransaction GetLotLastTransaction(string LotNumber) { LotTransaction obj = null; using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("LotNumber='{0}' AND UndoFlag=0 AND Activity!='{1}'" , LotNumber , Convert.ToInt32(EnumLotActivity.Undo)), OrderBy = "EditTime DESC" }; MethodReturnResult <IList <LotTransaction> > rst = client.GetTransaction(ref cfg); obj = rst.Data[0]; } return(obj); }
// //POST: /WIP/LotQuery/GetLotTransaction public async Task <ActionResult> GetLotTransactionWS(string lotNumber) { using (LotQueryServiceClient client = new LotQueryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("LotNumber='{0}' AND Activity>-1", lotNumber), OrderBy = "CreateTime" }; MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg); if (result.Code == 0) { ViewBag.TransactionList = result.Data; } }); } return(PartialView("_TransactionListPartial_ws")); }
public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (LotQueryServiceClient client = new LotQueryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial", new CheckDataViewModel())); }
public ActionResult Delete(string packageNo, int itemNo, string lotNumber) { MethodReturnResult result = new MethodReturnResult(); try { //获取包装记录 using (PackageQueryServiceClient client = new PackageQueryServiceClient()) { MethodReturnResult <Package> rst1 = client.Get(packageNo); if (rst1.Code > 0 || rst1.Data == null) { return(Json(rst1)); } //判断包装记录目前是否处于包装中状态。 if (rst1.Data.PackageState != EnumPackageState.Packaging) { result.Code = 1001; result.Message = string.Format("包装{0}为非{1}状态,不能删除。" , packageNo , EnumPackageState.Packaging.GetDisplayName()); return(Json(result)); } } //获取最后一笔包装记录。 IList <string> lstTransactionKey = new List <string>(); using (LotQueryServiceClient client = new LotQueryServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("LotNumber='{0}' AND UndoFlag=0" , lotNumber) }; MethodReturnResult <IList <LotTransaction> > rst1 = client.GetTransaction(ref cfg); if (rst1.Code <= 0 && rst1.Data != null) { var lnq = from item in rst1.Data orderby item.CreateTime descending select item; foreach (LotTransaction item in lnq) { lstTransactionKey.Add(item.Key); if (item.Activity == EnumLotActivity.Package) { break; } } } else { return(Json(rst1)); } } //可撤销操作主键不为空。 if (lstTransactionKey.Count > 0) { UndoParameter p = new UndoParameter() { Creator = User.Identity.Name, LotNumbers = new List <string>(), OperateComputer = Request.UserHostAddress, Operator = User.Identity.Name, UndoTransactionKeys = new Dictionary <string, IList <string> >() }; p.LotNumbers.Add(lotNumber); p.UndoTransactionKeys.Add(lotNumber, lstTransactionKey); using (LotUndoServiceClient client = new LotUndoServiceClient()) { result = client.Undo(p); if (result.Code == 0) { result.Message = string.Format("删除 ({0}:{1}:{2}) 成功。" , packageNo, itemNo, lotNumber); } } } } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(Json(result)); }
public async Task <ActionResult> ExportToExcel(LotDefectQueryViewModel model) { IList <LotTransactionDefect> lst = new List <LotTransactionDefect>(); using (LotQueryServiceClient client = new LotQueryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false, OrderBy = "EditTime", Where = GetQueryCondition(model) }; MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg); if (result.Code == 0) { lst = result.Data; } }); } //创建工作薄。 IWorkbook wb = new HSSFWorkbook(); //设置EXCEL格式 ICellStyle style = wb.CreateCellStyle(); style.FillForegroundColor = 10; //有边框 style.BorderBottom = BorderStyle.THIN; style.BorderLeft = BorderStyle.THIN; style.BorderRight = BorderStyle.THIN; style.BorderTop = BorderStyle.THIN; IFont font = wb.CreateFont(); font.Boldweight = 10; style.SetFont(font); ICell cell = null; IRow row = null; ISheet ws = null; for (int j = 0; j < lst.Count; j++) { if (j % 65535 == 0) { ws = wb.CreateSheet(); row = ws.CreateRow(0); #region //列名 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(StringResource.ItemNo); //项目号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.LotNumber); //批次号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("工单号"); //工单号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("工序"); //工序 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("线别"); //线别 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_DefectQuantity); //数量 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.ReasonCodeCategoryName); //原因代码组 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.ReasonCodeName); //原因代码 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.ReasonDescription); //原因描述 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_RouteOperationName); //责任工序 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_ResponsiblePerson); //责任人 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(StringResource.Description); //描述 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("操作时间"); //操作时间 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("操作人"); //操作人 #endregion font.Boldweight = 5; } LotTransactionDefect obj = lst[j]; LotTransaction transObj = null; LotTransactionHistory lotHisObj = null; using (LotQueryServiceClient client = new LotQueryServiceClient()) { MethodReturnResult <LotTransaction> result = client.GetTransaction(obj.Key.TransactionKey); if (result.Code == 0) { transObj = result.Data; } MethodReturnResult <LotTransactionHistory> result1 = client.GetLotTransactionHistory(obj.Key.TransactionKey); if (result1.Code == 0) { lotHisObj = result1.Data; } } row = ws.CreateRow(j + 1); #region //数据 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(j + 1); //项目号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(transObj.LotNumber); //批次号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(transObj.OrderNumber); //工单号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(transObj.RouteStepName); //工序 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty); //线别 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Quantity); //数量 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Key.ReasonCodeCategoryName); //原因代码组 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Key.ReasonCodeName); //原因代码 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Description); //原因描述 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.RouteOperationName); //责任工序 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.ResponsiblePerson); //责任人 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Description); //描述 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime)); //操作时间 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(obj.Editor); //操作人 #endregion } MemoryStream ms = new MemoryStream(); wb.Write(ms); ms.Flush(); ms.Position = 0; return(File(ms, "application/vnd.ms-excel", "LotDefectData.xls")); }
public async Task <ActionResult> ExportToExcel(CheckDataQueryViewModel model) { IList <LotTransaction> lstCheckData = new List <LotTransaction>(); CheckDataViewModel m = new CheckDataViewModel(); using (LotQueryServiceClient client = new LotQueryServiceClient()) { await Task.Run(() => { PagingConfig cfg = new PagingConfig() { IsPaging = false, OrderBy = "CreateTime DESC", Where = GetQueryCondition(model) }; MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg); if (result.Code == 0) { lstCheckData = result.Data; } }); } //创建工作薄。 IWorkbook wb = new HSSFWorkbook(); //设置EXCEL格式 ICellStyle style = wb.CreateCellStyle(); style.FillForegroundColor = 10; //有边框 style.BorderBottom = BorderStyle.Thin; style.BorderLeft = BorderStyle.Thin; style.BorderRight = BorderStyle.Thin; style.BorderTop = BorderStyle.Thin; IFont font = wb.CreateFont(); font.Boldweight = 10; style.SetFont(font); ISheet ws = null; for (int j = 0; j < lstCheckData.Count; j++) { if (j % 65535 == 0) { ws = wb.CreateSheet(); IRow row = ws.CreateRow(0); #region //列名 ICell cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue(StringResource.ItemNo); //项目号 cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("批次号"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("工单号"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("产品料号"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("线别"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("等级"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("花色"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际功率"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际电流"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际最大电流"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际电压"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际最大电压"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("实际填充因子"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("分档名称"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("子分档代码"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("备注"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("检验时间"); cell = row.CreateCell(row.Cells.Count); cell.CellStyle = style; cell.SetCellValue("检验操作人"); #endregion font.Boldweight = 5; } LotTransaction obj = lstCheckData[j]; IRow rowData = ws.CreateRow(j + 1); Lot lotObj = m.GetLot(obj.LotNumber); IVTestData ivtestData = m.GetIVTestData(obj.LotNumber); LotTransactionHistory lotHisObj = m.GetLotTransactionHistory(obj.Key); #region //数据 ICell cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(j + 1); //项目号 cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.LotNumber); //批次号 cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.OrderNumber); //工单号 cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(lotHisObj != null ? lotHisObj.MaterialCode : string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(lotObj != null ? lotObj.Grade : string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(lotObj != null ? lotObj.Color : string.Empty); if (ivtestData != null) { cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefPM); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefISC); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefIPM); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefVOC); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefVPM); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.CoefFF); } else { cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); } if (ivtestData == null || string.IsNullOrEmpty(ivtestData.PowersetCode) || ivtestData.PowersetItemNo == null) { cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Empty); } else { string powersetName = m.GetPowersetName(ivtestData.Key.LotNumber, ivtestData.PowersetCode, ivtestData.PowersetItemNo.Value); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(powersetName); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(ivtestData.PowersetSubCode); } cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Description); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.CreateTime)); cellData = rowData.CreateCell(rowData.Cells.Count); cellData.CellStyle = style; cellData.SetCellValue(obj.Creator); #endregion } MemoryStream ms = new MemoryStream(); wb.Write(ms); ms.Flush(); ms.Position = 0; return(File(ms, "application/vnd.ms-excel", "CheckDataData.xls")); }
/// <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); } }