public int saveProcessStation(ProcessStationMaintainInfo processStationInfo) { FisException ex; List<string> paraError = new List<string>(); try { ProcessStation processStationObj = null; if (processStationInfo.Id != 0) { processStationObj = processRepository.GetProcessStation(processStationInfo.Id); } if (processStationObj == null) { IList<ProcessStation> processStationList = processRepository.GetProcessStationList(processStationInfo.Process); processStationObj = new ProcessStation(); processStationObj = convertToObjFromMaintainInfo(processStationObj, processStationInfo); IList<ProcessStation> checkExistProcessStationList = (from q in processStationList where q.PreStation == processStationObj.PreStation && q.StationID == processStationObj.StationID && q.Status == processStationObj.Status select q).ToList<ProcessStation>(); if (checkExistProcessStationList != null && checkExistProcessStationList.Count > 0) { ex = new FisException("DMT038", paraError); throw ex; } IUnitOfWork work = new UnitOfWork(); processRepository.AddProcessStationDefered(work, processStationObj); work.Commit(); //int count = processRepository.CheckExistedProcessStation(processStationInfo.Process, processStationInfo.Station, processStationInfo.PreStation); //if (count > 0) //{ // ex = new FisException("DMT038", paraError); // throw ex; //} //processStationObj = new ProcessStation(); //processStationObj = convertToObjFromMaintainInfo(processStationObj, processStationInfo); //IUnitOfWork work = new UnitOfWork(); //processRepository.AddProcessStationDefered(work, processStationObj); //work.Commit(); } else { processStationObj = convertToObjFromMaintainInfo(processStationObj, processStationInfo); IUnitOfWork work = new UnitOfWork(); processRepository.SaveProcessStationDefered(work, processStationObj); work.Commit(); } return processStationObj.ID; } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw; } }
//ok protected void btnSaveStation_Click(Object sender, EventArgs e) { int processStationID; string strProcessStationID; try { ProcessStationMaintainInfo tmpProcessStationInfo = new ProcessStationMaintainInfo(); //如果有processStationId,并且station, preStation下拉框内容没变, 表示将来需要通过processStationId保存 if ((hidProcessStationID.Value.Length != 0) && (hidStation.Value == selStation.InnerDropDownList.SelectedValue) && (hidPreStation.Value == selPreStation.InnerDropDownList.SelectedValue)) { strProcessStationID = hidProcessStationID.Value; } //否则,做新增 else { strProcessStationID = ""; } if (strProcessStationID.Length != 0) { tmpProcessStationInfo.Id = Int32.Parse(strProcessStationID); } tmpProcessStationInfo.Process = hidProcess.Value.Trim(); tmpProcessStationInfo.Station = selStation.InnerDropDownList.SelectedValue; tmpProcessStationInfo.PreStation = selPreStation.InnerDropDownList.SelectedValue; if (selStationStatus.Text == "PASS") { tmpProcessStationInfo.Status = 1; } else if (selStationStatus.Text == "FAIL")//"FAIL" { tmpProcessStationInfo.Status = 0; } else//PROCESSING { tmpProcessStationInfo.Status = 2; } tmpProcessStationInfo.Editor = this.HiddenUserName.Value; processStationID = iProcessManager.saveProcessStation(tmpProcessStationInfo); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowProcessStationList(); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "addSaveStationComplete", "AddUpdateStationComplete(\"" + processStationID.ToString() + "\");DealHideWait();", true); }
public ProcessStationMaintainInfo getProcessStation(int id) { ProcessStationMaintainInfo processStation = new ProcessStationMaintainInfo(); try { ProcessStation processStationObj = processRepository.GetProcessStation(id); processStation = convertToMaintainInfoFromObj(processStationObj); } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw; } return processStation; }
public IList<ProcessStationMaintainInfo> getProcessStationList(string process) { IList<ProcessStationMaintainInfo> processStationList = new List<ProcessStationMaintainInfo>(); try { IList<ProcessStation> tmpProcessStationList = processRepository.GetProcessStationList(process); foreach (ProcessStation temp in tmpProcessStationList) { ProcessStationMaintainInfo processStation = new ProcessStationMaintainInfo(); processStation = convertToMaintainInfoFromObj(temp); processStationList.Add(processStation); } } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw; } return processStationList; }
private ProcessStationMaintainInfo convertToMaintainInfoFromObj(ProcessStation temp) { ProcessStationMaintainInfo processStation = new ProcessStationMaintainInfo(); processStation.Id = temp.ID; processStation.PreStation = temp.PreStation; processStation.Station = temp.StationID; processStation.Process = temp.ProcessID; processStation.Status = temp.Status; processStation.Editor = temp.Editor; processStation.Cdt = temp.Cdt; processStation.Udt = temp.Udt; return processStation; }
private ProcessStation convertToObjFromMaintainInfo(ProcessStation obj, ProcessStationMaintainInfo temp) { obj.ID = temp.Id; obj.PreStation = temp.PreStation; obj.ProcessID = temp.Process; obj.StationID = temp.Station; obj.Status = temp.Status; obj.Editor = temp.Editor; return obj; }
protected void btnOK_ServerClick(Object sender, EventArgs e) { string fullFileName = ""; try { string fileName = dFileUpload.FileName; string filePath = HttpContext.Current.Server.MapPath("~"); string path = filePath + "\\tmp"; MakeDirIfNotExist(path); DataTable dt = new DataTable(); if (dFileUpload.FileName.Trim() == "") { pmtMessage4 = this.GetLocalResourceObject(Pre + "_pmtMessage4").ToString(); showErrorMessage(pmtMessage4); return; } if (dFileUpload.HasFile) { try { string extName = fileName.Substring(fileName.LastIndexOf(".")); //if (extName != ".xls" && extName != ".xlsx" && extName != ".xlsm") //if (extName != ".xls") //{ // pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); // showErrorMessage(pmtMessage2); // return; //} Guid guid = System.Guid.NewGuid(); fullFileName = path + "\\" + guid.ToString() + extName; dFileUpload.PostedFile.SaveAs(fullFileName); dt = ExcelManager.getExcelSheetData(fullFileName); } catch (Exception ex) { pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); showErrorMessage(ex.Message); return; } int startRow = EXCEL_DATA_START_ROW; int endRow = dt.Rows.Count + startRow; if (endRow < startRow) { pmtMessage3 = this.GetLocalResourceObject(Pre + "_pmtMessage3").ToString(); showErrorMessage(pmtMessage3); return; } ProcessMaintainInfo processInfo = new ProcessMaintainInfo(); List<ProcessStationMaintainInfo> processStationInfo = new List<ProcessStationMaintainInfo>(); //下面中B1,B2,B3固定存上传的process信息,Editor,Cdt,Udt有可能没有,有了也不要从这取 string tmpValueNPOI; tmpValueNPOI = dt.Rows[1][1].ToString(); string processName = tmpValueNPOI; if (processName == "" || processName.Length > 10) { pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + 1.ToString(); showErrorMessage(pmtMessage5); return; } string pcbType = Resources.ComboxFixValues.ResourceManager.GetString(Pre + "_CmbMaintainProcessTypeValue1"); string productType = Resources.ComboxFixValues.ResourceManager.GetString(Pre + "_CmbMaintainProcessTypeValue2"); //!!!目前只有2种类型的可以上传 tmpValueNPOI = dt.Rows[2][1].ToString(); string processType = tmpValueNPOI; if (processType == "" || (processType != pcbType && processType != productType)) { pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + 2.ToString(); showErrorMessage(pmtMessage5); return; } tmpValueNPOI = dt.Rows[3][1].ToString(); string processDescr = tmpValueNPOI; if (processDescr == "" || processDescr.Length > 80) { pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + 3.ToString(); showErrorMessage(pmtMessage5); return; } processInfo.Process = processName; processInfo.Type = processType; processInfo.Description = processDescr; processInfo.Editor = this.HiddenUserName.Value; int iRowsCountNPOI = dt.Rows.Count; int iColsCountNPOI = dt.Columns.Count; //从A1到A7搜寻Station List,这单元必有,找到后这行的下面一行就是数据标题,再下面一行是数据 int listStartRow = 0; for (int iRow = 1; iRow <= 8; iRow++) { string ValueNPOI = dt.Rows[iRow][0].ToString(); if (ValueNPOI == EXCEL_LIST_TITLE_STRING) { listStartRow = iRow; break; } } if (listStartRow == 0) { string pmtMessage6 = this.GetLocalResourceObject(Pre + "_pmtMessage6").ToString(); showErrorMessage(pmtMessage6); return; } int stationStartRow = listStartRow + 2; for (int iRow = stationStartRow; iRow < iRowsCountNPOI; iRow++) { int lineNum = iRow + EXCEL_DATA_START_ROW - 1; ProcessStationMaintainInfo item = new ProcessStationMaintainInfo(); string Value1NPOI = dt.Rows[iRow][2].ToString(); string Value2NPOI = dt.Rows[iRow][0].ToString(); string Value3NPOI = dt.Rows[iRow][1].ToString().ToUpper(); if (Value1NPOI == "" && Value2NPOI == "" && Value3NPOI == "") { continue; } //按数据库的长度 if (Value1NPOI == "" || (Value3NPOI != "FAIL" && Value3NPOI != "PASS" && Value3NPOI != "PROCESSING") || Value1NPOI.Length > 10 || Value2NPOI.Length > 10)//FAIL(0)、PASS(1)和PROCESSING { pmtMessage5 = this.GetLocalResourceObject(Pre + "_pmtMessage5").ToString() + " " + lineNum.ToString(); showErrorMessage(pmtMessage5); return; } item.Process = processName; item.Station = Value1NPOI; item.PreStation = Value2NPOI; if (Value3NPOI == "FAIL") { item.Status = 0; } else if (Value3NPOI == "PASS") { item.Status = 1; } else { item.Status = 2; } item.Editor = this.HiddenUserName.Value; item.Cdt = DateTime.Now; item.Udt = DateTime.Now; processStationInfo.Add(item); } string uploadProcess = iProcessManager.UploadProcess(processInfo, processStationInfo); this.hidIsSubmitOK.Value = "OK"; this.hidProcess.Value = uploadProcess; } else { pmtMessage2 = this.GetLocalResourceObject(Pre + "_pmtMessage2").ToString(); showErrorMessage(pmtMessage2); return; } } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { showErrorMessage(ex.Message); return; } finally { TryDeleteTempFile(fullFileName); } ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "OKComplete", "OKComplete();HideWait();", true); }