/// <summary> /// 更新 /// </summary> /// <param name="item"></param> /// <returns></returns> public virtual int Update(CardAnnal item) { var result = -1; using (var db = new MbContext()) { db.CardAnnal.AddOrUpdate(item); result = db.SaveChanges(); } return(result); }
/// <summary> /// 增加 /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual int Save(CardAnnal model) { var result = -1; using (var db = new MbContext()) { db.CardAnnal.Add(model); result = db.SaveChanges(); } return(result); }
public void FTPAnnal(string fullName, string p, string sbbh) { var paths = fullName.Split('\\'); var path = "../../" + paths[2] + "/" + paths[3] + "/" + paths[4] + "/" + paths[5]; var cardAnnalSvr = new CardAnnalSvr(); var waveAnnalSvr = new WaveAnnanSvr(); var waveAnnal = waveAnnalSvr.GetFirst(); TimeSpan ts = DateTime.Now - waveAnnal.CreateTime; var car = new CarSvr().GetItem(p); var equId = 2L; var state = "进"; var equ = new EquipmentSvr().GetItemBySerialno(sbbh); if (equ != null) { equId = equ.EquipmentId; var aae = new AreaAndEquSvr().GetItemByEquId(equId); if (aae != null) { state = aae.State; } } var cardAnnal = new CardAnnal { CreateTime = DateTime.Now, AreaId = 1, EquipmentId = equId, License = p, ImagePath = path, State = state }; if (car != null || ts.TotalSeconds <= 10) { cardAnnal.IsBreak = 0; } else { cardAnnal.IsBreak = 1; } cardAnnalSvr.Save(cardAnnal); }
public virtual int AddAnnal(string license, string imagePath) { var result = -1; using (var db = new MbContext()) { var model = new CardAnnal() { AreaId = 1, CreateTime = DateTime.Now, IsBreak = 0, License = license, ImagePath = imagePath }; } return(result); }
//写入车辆出入记录 public virtual bool CreateAnnal(string license, string imagePath, Equipment equipemnt, AreaAndEqu areaAndEqu) { var cardAnnalSvr = new CardAnnalSvr(); var waveAnnalSvr = new WaveAnnanSvr(); var waveAnnal = waveAnnalSvr.GetFirst(); TimeSpan ts = DateTime.Now - waveAnnal.CreateTime; var car = new CarSvr().GetItem(license); var annal = cardAnnalSvr.GetItem(license); if ((DateTime.Now - annal.CreateTime).TotalSeconds < 10) { return(false); } var cardAnnal = new CardAnnal { CreateTime = DateTime.Now, AreaId = areaAndEqu.AreaId, EquipmentId = equipemnt.EquipmentId, License = license, ImagePath = imagePath, State = areaAndEqu.State }; if (car != null || ts.TotalSeconds <= 10) { cardAnnal.IsBreak = 0; } else { cardAnnal.IsBreak = 1; } return(cardAnnalSvr.Save(cardAnnal) > 0); }