public int ProcessInsertData(int areaCode, string targetDbName) { try { var sList = new TLedWindowDAL(areaCode.ToString()).GetModelList().Where(c => c.sysFlag == 0).ToList(); sList.ForEach(s => { s.areaCode = areaCode; s.areaId = s.ID; }); var dal = new TLedWindowDAL(targetDbName); var odal = new TLedWindowDAL(areaCode.ToString()); foreach (var s in sList) { dal.Insert(s); s.ID = s.areaId; s.sysFlag = 2; odal.Update(s); } return(sList.Count); } catch { return(-1); } }
public int ProcessUpdateData(int areaCode, string targetDbName) { try { var sdal = new TLedWindowDAL(areaCode.ToString()); var tdal = new TLedWindowDAL(targetDbName); var sList = sdal.GetModelList(p => p.sysFlag == 1); foreach (var s in sList) { var id = s.ID; var nData = tdal.GetModelList(p => p.areaCode == areaCode && p.areaId == s.ID).FirstOrDefault(); if (nData == null) { s.areaCode = areaCode; s.areaId = s.ID; tdal.Insert(s); s.ID = s.areaId; s.sysFlag = 2; sdal.Update(s); } else { var data = s; data.ID = nData.ID; data.areaCode = nData.areaCode; data.areaId = nData.areaId; tdal.Update(data); s.sysFlag = 2; s.ID = id; sdal.Update(s); } } return(sList.Count); } catch { return(-1); } }
public TLedWindowBLL(string dbKey) { this.dal = new TLedWindowDAL(dbKey); }
public TLedWindowBLL() { this.dal = new TLedWindowDAL(); }