public void Delete(AscmReadingHead ascmReadingHead) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmReadingHead>(ascmReadingHead); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmReadingHead)", ex); throw ex; } }
public ContentResult ReadingHeadSave(AscmReadingHead ascmReadingHead_Model, int? id) { JsonObjectResult jsonObjectResult = new JsonObjectResult(); try { AscmReadingHead ascmReadingHead = null; if (id.HasValue) { ascmReadingHead = AscmReadingHeadService.GetInstance().Get(id.Value); } else { ascmReadingHead = new AscmReadingHead(); } if (ascmReadingHead == null) throw new Exception("保存RFID读头信息失败!"); //if (string.IsNullOrEmpty(ascmReadingHead_Model.bindType)) // throw new Exception("必须选择RFID类型!"); if (string.IsNullOrEmpty(ascmReadingHead_Model.ip)) throw new Exception("必须输入ip地址!"); //if (ascmReadingHead_Model.plateNumber == null || ascmReadingHead_Model.plateNumber.Trim() == "") // throw new Exception("员工车辆车牌号不能为空!"); ascmReadingHead.bindType = ascmReadingHead_Model.bindType; ascmReadingHead.bindId = ""; ascmReadingHead.ip = ascmReadingHead_Model.ip.Trim(); ascmReadingHead.port = ascmReadingHead_Model.port; ascmReadingHead.status = ""; if (ascmReadingHead_Model.address != null && ascmReadingHead_Model.address != "") ascmReadingHead.address = ascmReadingHead_Model.address.Trim(); if (!id.HasValue) { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmReadingHead where ip='" + ascmReadingHead_Model.ip.Trim() + "'"); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此ip【" + ascmReadingHead_Model.ip.Trim() + "】!"); int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmReadingHead"); ascmReadingHead.id = maxId + 1; } else { object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmReadingHead where ip='" + ascmReadingHead_Model.ip.Trim() + "' and id<>" + id.Value + ""); if (object1 == null) throw new Exception("查询异常!"); int iCount = 0; if (int.TryParse(object1.ToString(), out iCount) && iCount > 0) throw new Exception("已经存在此ip【" + ascmReadingHead_Model.ip.Trim() + "】!"); //AscmEmployeeCarService.GetInstance().Update(ascmEmployeeCar); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (!id.HasValue) { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmReadingHead); } else { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmReadingHead); } tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } jsonObjectResult.result = true; jsonObjectResult.message = ""; jsonObjectResult.id = ascmReadingHead.id.ToString(); jsonObjectResult.entity = ascmReadingHead; } catch (Exception ex) { jsonObjectResult.message = ex.Message; } string sReturn = JsonConvert.SerializeObject(jsonObjectResult); return Content(sReturn); }
public void AddForkliftContainerLog(string forkliftRfid, AscmReadingHead ascmReadingHead, AscmForklift ascmForklift, List<string> listRfid, string sessionKey) { try { if (listRfid.Count > 0) { DateTime dtServer = DateTime.Now; int times = 0; //该叉车最后一次读取 YnBaseDal.YnPage ynPage = new YnBaseDal.YnPage(); ynPage.SetPageSize(1); string sql = "from AscmForkliftContainerLog where passDate='" + dtServer.ToString("yyyy-MM-dd") + "' and forkliftId=" + ascmForklift.id + ""; IList<AscmForkliftContainerLog> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmForkliftContainerLog>(sql + " order by times desc", sql, ynPage, sessionKey); if (ilist != null && ilist.Count > 0) { AscmForkliftContainerLog ascmForkliftContainerLog = ilist[0]; DateTime dtCreateTime = Convert.ToDateTime(ascmForkliftContainerLog.createTime); TimeSpan ts = dtServer.Subtract(dtCreateTime); if (ascmForkliftContainerLog.readingHeadId == ascmReadingHead.id) { if (ts.TotalMinutes < 10)//10分钟同一叉车不重复计入 return; times = ascmForkliftContainerLog.times; } } //开始加入 times++; string maxIdKey = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmForkliftContainerLog", "", "", 10, listRfid.Count, sessionKey); long maxId = Convert.ToInt64(maxIdKey); List<AscmForkliftContainerLog> listAscmForkliftContainerLog = new List<AscmForkliftContainerLog>(); foreach (string rfid in listRfid) { AscmForkliftContainerLog ascmForkliftContainerLog = new AscmForkliftContainerLog(); ascmForkliftContainerLog.id = ++maxId; ascmForkliftContainerLog.forkliftId = ascmForklift.id; ascmForkliftContainerLog.forkliftIdRfidId = forkliftRfid; ascmForkliftContainerLog.containerRfidId = rfid; ascmForkliftContainerLog.createTime = dtServer.ToString("yyyy-MM-dd HH:mm"); ascmForkliftContainerLog.passDate = dtServer.ToString("yyyy-MM-dd"); ascmForkliftContainerLog.times = times; ascmForkliftContainerLog.readingHeadId = ascmReadingHead.id; ascmForkliftContainerLog.readingHeadIp = ascmReadingHead.ip; ascmForkliftContainerLog.status = ""; listAscmForkliftContainerLog.Add(ascmForkliftContainerLog); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(sessionKey).BeginTransaction()) { try { if (listAscmForkliftContainerLog.Count > 0) YnDaoHelper.GetInstance().nHibernateHelper.SaveList(listAscmForkliftContainerLog, sessionKey); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } //建立领料员单次领料与领料单的关联 AscmWmsMtlRequisitionMainService.GetInstance().WmsStoreIssueCheck(forkliftRfid, times, dtServer.ToString("yyyy-MM-dd HH:mm"), sessionKey); } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("记录日志失败(Find AscmForkliftContainerLog)", ex); throw ex; } }
public void Update(AscmReadingHead ascmReadingHead) { //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmReadingHead where id<>" + ascmReadingHead.id + " and docNumber='" + ascmReadingHead.docNumber + "'"); //if (count == 0) //{ // using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) // { // try // { // YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmReadingHead>(ascmReadingHead); // tx.Commit();//正确执行提交 // } // catch (Exception ex) // { // tx.Rollback();//回滚 // YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmReadingHead)", ex); // throw ex; // } // } //} //else //{ // throw new Exception("已经存在员工编号\"" + ascmReadingHead.name + "\"!"); //} }
public void Save(AscmReadingHead ascmReadingHead) { try { //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmReadingHead where docNumber='" + ascmReadingHead.docNumber + "'"); //if (count == 0) //{ // int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmReadingHead"); // using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) // { // try // { // maxId++; // ascmReadingHead.id = maxId; // YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmReadingHead); // tx.Commit();//正确执行提交 // } // catch (Exception ex) // { // tx.Rollback();//回滚 // throw ex; // } // } //} //else //{ // throw new Exception("已经存在员工编号\"" + ascmReadingHead.name + "\"!"); //} } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmReadingHead)", ex); throw ex; } }