public List <CacheStackTray> SelectCacheTable() { List <CacheStackTray> cacheList = new List <CacheStackTray>(); using (BaseAccess access = new BaseAccess()) { //BaseCondition condition = new Column(CacheStackTray.FLAG).Equal(/*CommandValue.FLAG*/this.stackNumber); cacheList = access.ExecuteSelect <CacheStackTray>(string.Format("SELECT * FROM {0} WHERE Flag = {1}", lineDevice.PrefixTable + "CacheStackTray", this.stackNumber)); } return(cacheList); }
/// <summary> /// 查询历史数据 /// </summary> /// <returns></returns> public List <StackTrays> SelectStackTrays(string barCode = "", DateTime?startTime = null, DateTime?endTime = null) { List <StackTrays> list = new List <StackTrays>(); try { using (BaseAccess access = new BaseAccess()) { //BaseCondition condition = new Column(StackTrays.ID).IsNotNULL(); //if (!string.IsNullOrEmpty(barCode)) //{ // BaseCondition barCondition = new Column(StackTrays.BARCODE).Contains(barCode); // barCondition.Or(new Column(StackTrays.BATCH).Contains(barCode)); // condition.And(barCondition); //} //if (startTime != null) //{ // BaseCondition strCondition = new Column(StackTrays.UPDATE_TIME).MoreThan(startTime); // condition.And(strCondition); //} //if (endTime != null) //{ // BaseCondition endCondition = new Column(StackTrays.UPDATE_TIME).LessThan(endTime); // condition.And(endCondition); //} //OrderBy order = new OrderBy(StackTrays.UPDATE_TIME, Order.DESC); //list = access.Select<StackTrays>(condition, order); string whereStr = "Id IS NOT NULL"; if (!string.IsNullOrEmpty(barCode)) { whereStr += " AND (Barcode LIKE '%" + barCode + "%' OR Batch LIKE '%" + barCode + "%')"; } if (startTime != null) { whereStr += " AND UpdateTime > '" + startTime + "'"; } if (endTime != null) { whereStr += " AND UpdateTime < '" + endTime + "'"; } list = access.ExecuteSelect <StackTrays>(string.Format("SELECT * FROM {0} WHERE {1} ORDER BY UpdateTime DESC", lineDevice.PrefixTable + "StackTrays", whereStr)); } } catch (Exception ex) { PrintInfo.I(ex.Message); Console.WriteLine(ex.Message); } return(list); }
/// <summary> /// 查询托盘的Id /// </summary> /// <param name="trayCode">托盘条码</param> /// <param name="access">数据库对象实例</param> /// <returns>托盘在数据库中的Id</returns> private long SelectTraysId(string trayCode, BaseAccess access) { long traysId = -1; //BaseCondition condition = new Column(StackTrayFlow.BARCODE).Equal(trayCode); //BaseCondition condition2 = new Column(StackTrayFlow.USED).Equal(0); //OrderBy orderByDESC = new OrderBy(StackTrayFlow.ID, Order.DESC); //List<StackTrayFlow> traysIdList = access.Select<StackTrayFlow>(condition.And(condition2), orderByDESC); List <StackTrayFlow> traysIdList = access.ExecuteSelect <StackTrayFlow>(string.Format("SELECT * FROM {0} WHERE Barcode='{1}' AND Used=0 ORDER BY Id DESC", lineDevice.PrefixTable + "StackTrayFlow", trayCode)); if (traysIdList.Count > 0) { traysId = traysIdList[0].Id; } return(traysId); }
public static List <UserEventLog> SelectEventLog() { using (BaseAccess access = new BaseAccess()) { try { //BaseCondition condition = new Column(UserEventLog.EVENT_TIME).MoreThan(DateTime.Now.AddDays(-1)); List <UserEventLog> userEventLogList = access.ExecuteSelect <UserEventLog>(string.Format("SELECT * FROM {0} WHERE EventTime > '{1}'", tableName, DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"))); return(userEventLogList); } catch (System.Data.Common.DbException ex) { Log.Error(ex.StackTrace); return(null); } } }