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; } }
public string ProcessSaveAs(ProcessMaintainInfo processInfo, string oldProcess) { string processName = processInfo.Process; string result = processName; try { Process processObjOld = processRepository.Find(oldProcess); if (processObjOld == null) { //Copy的process源已经不存在 FisException ex; List<string> paraError = new List<string>(); ex = new FisException("DMT141", paraError); throw ex; } processInfo.Cdt = DateTime.Now; processInfo.Udt = DateTime.Now; //检查是否已存在相同的Process if (processRepository.CheckExistedProcess(processInfo.Process) > 0) { FisException ex; List<string> paraError = new List<string>(); ex = new FisException("DMT037", paraError); throw ex; } Process processObj = new Process(); processObj = convertToObjFromMaintainInfo(processObj, processInfo); List<ProcessStation> tmpProcessStationList = (List<ProcessStation>)processRepository.GetProcessStationList(oldProcess); List<ProcessStation> processStationList = new List<ProcessStation>(); for (int i = 0; i < tmpProcessStationList.Count; i++) { //!!!拷贝station时状态也拷贝,是吧? ProcessStation item = new ProcessStation(); item.Cdt = DateTime.Now; item.Udt = DateTime.Now; item.Editor = processInfo.Editor; item.PreStation = tmpProcessStationList[i].PreStation; item.ProcessID = processName; item.StationID = tmpProcessStationList[i].StationID; item.Status = tmpProcessStationList[i].Status; processStationList.Add(item); } IUnitOfWork work = new UnitOfWork(); processRepository.Add(processObj, work); processRepository.AddProcessStationsDefered(work, processStationList); work.Commit(); } catch (Exception) { throw; } return result; }
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; }
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; }
/// <summary> /// 上传一个excel中的内容, 以添加的形式添加process和processStation /// </summary> /// <returns></returns> public string UploadProcess(ProcessMaintainInfo processInfo, List<ProcessStationMaintainInfo> processStationList) { string processName = processInfo.Process; FisException ex; List<string> paraError = new List<string>(); try { //检查是否已存在相同的Process if (processRepository.CheckExistedProcess(processInfo.Process) > 0) { ex = new FisException("DMT037", paraError); throw ex; } Process processObj = new Process(); processObj = convertToObjFromMaintainInfo(processObj, processInfo); List<ProcessStation> stationList = new List<ProcessStation>(); for (int i = 0; i < processStationList.Count; i++) { ProcessStation item = new ProcessStation(); item.PreStation = processStationList[i].PreStation; item.Status = processStationList[i].Status; item.StationID = processStationList[i].Station; item.Editor = processStationList[i].Editor; item.Cdt = processStationList[i].Cdt; item.Udt = processStationList[i].Udt; item.ProcessID = processName; stationList.Add(item); } IUnitOfWork work = new UnitOfWork(); processRepository.Add(processObj, work); processRepository.AddProcessStationsDefered(work, stationList); work.Commit(); } catch (FisException e) { logger.Error(e.mErrmsg); throw e; } catch (Exception e) { logger.Error(e.Message); throw; } return processName; }