| | |
| | | /// </summary> |
| | | public bool Copy(Model.WorkBenchBase workBench) |
| | | { |
| | | |
| | | if (workBench.LinkType == Model.eLinkType.KeDi) |
| | | { |
| | | var new_workBench = new Model.WorkBenchBase(workBench); |
| | |
| | | var new_workBench_id = _dal.Insert(entity_new_workBench); |
| | | new_workBench.ID = new_workBench_id; |
| | | |
| | | var bllMp = new BLL.WorkBenchMonitorPoint(); |
| | | var allMonitorPoints = bllMp.GetByBenchID(workBench.ID); |
| | | if (allMonitorPoints != null && allMonitorPoints.Count > 0) |
| | | { |
| | | var new_allMonitorPoints = new List<Model.WorkBenchMonitorPoint>(); |
| | | var mp_codes = bllMp.CreateNO(allMonitorPoints.Count); |
| | | for (int i = 0; i < allMonitorPoints.Count; i++) |
| | | { |
| | | Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(allMonitorPoints[i]); |
| | | new_monitorPoint.ID = 0; |
| | | new_monitorPoint.Code = mp_codes[i]; |
| | | new_monitorPoint.BenchID = new_workBench_id; |
| | | new_allMonitorPoints.Add(new_monitorPoint); |
| | | } |
| | | bllMp.Inserts(new_allMonitorPoints); |
| | | } |
| | | //var bllMp = new BLL.WorkBenchMonitorPoint(); |
| | | //var allMonitorPoints = bllMp.GetByBenchID(workBench.ID); |
| | | //if (allMonitorPoints != null && allMonitorPoints.Count > 0) |
| | | //{ |
| | | // var new_allMonitorPoints = new List<Model.WorkBenchMonitorPoint>(); |
| | | // var mp_codes = bllMp.CreateNO(allMonitorPoints.Count); |
| | | // for (int i = 0; i < allMonitorPoints.Count; i++) |
| | | // { |
| | | // Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(allMonitorPoints[i]); |
| | | // new_monitorPoint.ID = 0; |
| | | // new_monitorPoint.Code = mp_codes[i]; |
| | | // new_monitorPoint.BenchID = new_workBench_id; |
| | | // new_allMonitorPoints.Add(new_monitorPoint); |
| | | // } |
| | | // bllMp.Inserts(new_allMonitorPoints); |
| | | //} |
| | | var allInstruments = new BLL.WorkBenchInstrumentKedi().GetByBenchID(workBench.ID); |
| | | if (allInstruments != null && allInstruments.Count > 0) |
| | | { |
| | |
| | | new_workBench.ID = new_workBench_id; |
| | | |
| | | |
| | | var bllMp = new BLL.WorkBenchMonitorPoint(); |
| | | var old_allMonitorPoints = bllMp.GetByBenchID(workBench.ID); |
| | | if (old_allMonitorPoints != null && old_allMonitorPoints.Count > 0) |
| | | { |
| | | List<Model.WorkBenchMonitorPoint> new_allMonitorPoints1 = new List<Model.WorkBenchMonitorPoint>(); |
| | | var mp_codes = bllMp.CreateNO(old_allMonitorPoints.Count); |
| | | for (int i = 0; i < old_allMonitorPoints.Count; i++) |
| | | { |
| | | Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(old_allMonitorPoints[i]); |
| | | new_monitorPoint.ID = 0; |
| | | new_monitorPoint.Code = mp_codes[i]; |
| | | new_monitorPoint.BenchID = new_workBench_id; |
| | | new_allMonitorPoints1.Add(new_monitorPoint); |
| | | } |
| | | bllMp.Inserts(new_allMonitorPoints1); |
| | | } |
| | | var new_allMonitorPoints = bllMp.GetByBenchID(new_workBench_id); |
| | | //var bllMp = new BLL.WorkBenchMonitorPoint(); |
| | | //var old_allMonitorPoints = bllMp.GetByBenchID(workBench.ID); |
| | | //if (old_allMonitorPoints != null && old_allMonitorPoints.Count > 0) |
| | | //{ |
| | | // List<Model.WorkBenchMonitorPoint> new_allMonitorPoints1 = new List<Model.WorkBenchMonitorPoint>(); |
| | | // var mp_codes = bllMp.CreateNO(old_allMonitorPoints.Count); |
| | | // for (int i = 0; i < old_allMonitorPoints.Count; i++) |
| | | // { |
| | | // Model.WorkBenchMonitorPoint new_monitorPoint = new Model.WorkBenchMonitorPoint(old_allMonitorPoints[i]); |
| | | // new_monitorPoint.ID = 0; |
| | | // new_monitorPoint.Code = mp_codes[i]; |
| | | // new_monitorPoint.BenchID = new_workBench_id; |
| | | // new_allMonitorPoints1.Add(new_monitorPoint); |
| | | // } |
| | | // bllMp.Inserts(new_allMonitorPoints1); |
| | | //} |
| | | //var new_allMonitorPoints = bllMp.GetByBenchID(new_workBench_id); |
| | | var bll_sz02 = new BLL.WorkBenchInstrumentShun(); |
| | | var old_allSz02s = bll_sz02.GetByBenchID(workBench.ID); |
| | | |
| | |
| | | Model.WorkBenchInstrumentShunPortAna new_ana_port = |
| | | new Model.WorkBenchInstrumentShunPortAna(old_ana); |
| | | new_ana_port.LinkID = new_sz02.ID; |
| | | if (old_ana.MonitorPointID > 0) |
| | | { |
| | | var old_Monitor = old_allMonitorPoints.Find(x => x.ID == old_ana.MonitorPointID); |
| | | var new_Monitor = new_allMonitorPoints.Find(x => x.MonitorType == old_Monitor.MonitorType && |
| | | x.Property == old_Monitor.Property); |
| | | new_ana_port.MonitorPointID = new_Monitor.ID; |
| | | } |
| | | //if (old_ana.MonitorPointID > 0) |
| | | //{ |
| | | // var old_Monitor = old_allMonitorPoints.Find(x => x.ID == old_ana.MonitorPointID); |
| | | // var new_Monitor = new_allMonitorPoints.Find(x => x.MonitorType == old_Monitor.MonitorType && |
| | | // x.Property == old_Monitor.Property); |
| | | // new_ana_port.MonitorPointID = new_Monitor.ID; |
| | | //} |
| | | bll_ana.Insert(new_ana_port); |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public long InsertExParas( |
| | | Model.WorkBenchBase BenchBase, |
| | | List<Model.WorkBenchMonitorPoint> allMonitorPoints) |
| | | List<long> allMonitorPointIDs) |
| | | { |
| | | _allWorkBenchs = null; |
| | | BLL.WorkBenchMonitorPoint.ClearChache(); |
| | |
| | | var entity_base = Model2Entity(BenchBase); |
| | | |
| | | |
| | | List<Entity.WorkBenchMonitorPoint> entities_allMonitorPoints = null; |
| | | if (allMonitorPoints != null && allMonitorPoints.Count > 0) |
| | | { |
| | | var bll_point = new BLL.WorkBenchMonitorPoint(); |
| | | var Codes = bll_point.CreateNO(allMonitorPoints.Count); |
| | | for (int i = 0; i < allMonitorPoints.Count; i++) |
| | | { |
| | | var item = allMonitorPoints[i]; |
| | | item.CreateTime = DateTime.Now; |
| | | item.UpdateTime = DateTime.Now; |
| | | item.Code = Codes[i]; |
| | | } |
| | | var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>()).CreateMapper(); |
| | | entities_allMonitorPoints = mapper.Map<List<TProduct.Model.WorkBenchMonitorPoint>, List<TProduct.Entity.WorkBenchMonitorPoint>>(allMonitorPoints); |
| | | } |
| | | //List<Entity.WorkBenchMonitorPoint> entities_allMonitorPoints = null; |
| | | //if (allMonitorPoints != null && allMonitorPoints.Count > 0) |
| | | //{ |
| | | // var bll_point = new BLL.WorkBenchMonitorPoint(); |
| | | // var Codes = bll_point.CreateNO(allMonitorPoints.Count); |
| | | // for (int i = 0; i < allMonitorPoints.Count; i++) |
| | | // { |
| | | // var item = allMonitorPoints[i]; |
| | | // item.CreateTime = DateTime.Now; |
| | | // item.UpdateTime = DateTime.Now; |
| | | // item.Code = Codes[i]; |
| | | // } |
| | | // var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TProduct.Model.WorkBenchMonitorPoint, TProduct.Entity.WorkBenchMonitorPoint>()).CreateMapper(); |
| | | // entities_allMonitorPoints = mapper.Map<List<TProduct.Model.WorkBenchMonitorPoint>, List<TProduct.Entity.WorkBenchMonitorPoint>>(allMonitorPoints); |
| | | //} |
| | | |
| | | return _dal.InsertExParas(entity_base, entities_allMonitorPoints); |
| | | return _dal.InsertExParas(entity_base, allMonitorPointIDs); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | /// </summary> |
| | | public bool Delete(Model.WorkBenchBase workBench) |
| | | { |
| | | new BLL.WorkBenchMonitorPoint().DeleteByWorkBenchID(workBench.ID); |
| | | new BLL.WorkBenchMonitorPointMap().DeleteByWorkBenchID(workBench.ID); |
| | | |
| | | if (workBench.LinkType == Model.eLinkType.KeDi) |
| | | { |
| | | new BLL.WorkBenchInstrumentKedi().DeleteByWorkBenchID(workBench.ID); |