//GET: InspectionTrack/CreateItem public ActionResult CreateItem(int id) { PatrolPointItem PatrolPointItem = new PatrolPointItem(); PatrolPointItem.ParentId = id; return(View(PatrolPointItem)); }
//GET: InspectionTrack/Clock public ActionResult Clock(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PatrolPointItem PatrolPointItem = bll.PatrolPointItems.Find(id); if (PatrolPointItem == null) { return(HttpNotFound()); } return(View(PatrolPointItem)); }
public ActionResult EditItem(PatrolPointItem PatrolPointItem) { int Id = PatrolPointItem.ParentId; if (ModelState.IsValid) { bll.PatrolPointItems.Edit(PatrolPointItem); } PatrolPoint PatrolPoint = bll.PatrolPoints.Find(Id); //InspectionTrack InspectionTrack = bll.InspectionTracks.Find(Id); if (PatrolPoint == null) { return(HttpNotFound()); } return(RedirectToAction("EditPoint", PatrolPoint)); }
private void DealPatrolPointItem(Bll bll, List <InspectionTrack> All, List <InspectionTrackHistory> HAdd, List <PatrolPoint> PAll, List <PatrolPoint> PDelete, List <PatrolPointHistory> PHAdd, WebApiLib.Clients.BaseDataClient client) { try { List <PatrolPointItem> ppiList = bll.PatrolPointItems.ToList(); List <PatrolPointItemHistory> ppiHList = bll.PatrolPointItemHistorys.ToList(); if (ppiList == null) { ppiList = new List <PatrolPointItem>(); } if (ppiHList == null) { ppiHList = new List <PatrolPointItemHistory>(); } List <PatrolPointItem> PIAll = new List <PatrolPointItem>(); List <PatrolPointItem> PIAdd = new List <PatrolPointItem>(); List <PatrolPointItem> PIEdit = new List <PatrolPointItem>(); List <PatrolPointItem> PIDelete = new List <PatrolPointItem>(); List <PatrolPointItemHistory> PIHAdd = new List <PatrolPointItemHistory>(); foreach (PatrolPoint item in PAll) { int Id = item.Id; string deviceId = item.DeviceId; int ParentId = item.ParentId; InspectionTrack it = All.Find(p => p.Id == ParentId); if (it == null) { continue; } int patrolId = (int)it.Abutment_Id; CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints recv = client.Getcheckresults(patrolId, deviceId); if (recv == null || recv.checks.Count() <= 0) { continue; } foreach (CommunicationClass.SihuiThermalPowerPlant.Models.results item2 in recv.checks) { PatrolPointItem now = ppiList.Find(p => p.CheckId == item2.checkId && p.ParentId == Id); if (now == null) { now = new PatrolPointItem(); now.ParentId = Id; now.KksCode = item2.kksCode; now.CheckItem = item2.checkItem; now.StaffCode = item2.staffCode; now.CheckTime = null; now.dtCheckTime = null; if (item2.checkTime != null) { now.CheckTime = (item2.checkTime + nEightHourSecond) * 1000; now.dtCheckTime = TimeConvert.TimeStampToDateTime((long)now.CheckTime); } now.CheckId = item2.checkId; now.CheckResult = item2.checkResult; PIAdd.Add(now); } else { if (item2.checkTime != null) { now.CheckTime = (item2.checkTime + nEightHourSecond) * 1000; now.dtCheckTime = TimeConvert.TimeStampToDateTime((long)now.CheckTime); } now.CheckResult = item2.checkResult; PIEdit.Add(now); } } } foreach (PatrolPoint item in PDelete) { int Id = item.Id; List <PatrolPointItem> lstDelete = ppiList.FindAll(p => p.ParentId == Id).ToList(); if (lstDelete != null && lstDelete.Count() > 0) { PIDelete.AddRange(lstDelete); } } foreach (PatrolPointHistory item in PHAdd) { int Id = item.Id; string deviceId = item.DeviceId; int ParentId = item.ParentId; InspectionTrackHistory ith = HAdd.Find(p => p.Id == ParentId); if (ith == null) { continue; } int patrolId = (int)ith.Abutment_Id; CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints recv = client.Getcheckresults(patrolId, deviceId); if (recv == null || recv.checks.Count() <= 0) { continue; } foreach (CommunicationClass.SihuiThermalPowerPlant.Models.results item2 in recv.checks) { PatrolPointItemHistory history = bll.PatrolPointItemHistorys.Find(p => p.CheckId == item2.checkId && p.ParentId == Id); if (history == null) { history = new PatrolPointItemHistory(); history.ParentId = Id; history.KksCode = item2.kksCode; history.CheckItem = item2.checkItem; history.StaffCode = item2.staffCode; history.CheckTime = null; history.dtCheckTime = null; if (item2.checkTime != null) { history.CheckTime = (item2.checkTime + nEightHourSecond) * 1000; history.dtCheckTime = TimeConvert.TimeStampToDateTime((long)history.CheckTime); } history.CheckId = item2.checkId; history.CheckResult = item2.checkResult; PIHAdd.Add(history); } } } bll.PatrolPointItems.AddRange(PIAdd); bll.PatrolPointItems.EditRange(PIEdit); bll.PatrolPointItems.RemoveList(PIDelete); bll.PatrolPointItemHistorys.AddRange(PIHAdd); } catch (Exception ex) { string strMessage = ex.Message; } return; }