예제 #1
0
 public IEnumerable <base_sbxx> Search(DeviceQueryParm parm, out int resultcount)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select sbbh, sbmc, gcdm, scx, gwh, sblx, txfs, ip, sfky, sflj, bz, lrr, lrsj, com, port from base_sbxx where 1=1 ");
         OracleDynamicParameters p = new OracleDynamicParameters();
         if (!string.IsNullOrEmpty(parm.keyword))
         {
             sql.Append(" and (sbbh like :key or sbmc like :key) ");
             p.Add(":key", "%" + parm.keyword + "%", OracleMappingType.Varchar2, System.Data.ParameterDirection.Input);
         }
         if (parm.explist.Count > 0)
         {
             sql.Append(" and ");
             sql.Append(Util.Tool.ComQueryExp(parm.explist));
         }
         using (var conn = new OraDBHelper(constr).Conn)
         {
             var q = conn.Query <base_sbxx>(sql.ToString(), p)
                     .OrderBy(t => t.sbbh)
                     .ToPagedList(parm.pageindex, parm.pagesize);
             resultcount = q.TotalItemCount;
             return(q);
         }
     }
     catch (Exception e)
     {
         log.Error(e.Message);
         throw;
     }
 }
예제 #2
0
 public IHttpActionResult List(DeviceQueryParm parm)
 {
     try
     {
         int           resultcount = 0;
         DeviceService ds          = new DeviceService();
         var           list        = ds.Search(parm, out resultcount);
         return(Json(new { code = 1, msg = "ok", list = list, resultcount = resultcount }));
     }
     catch (Exception)
     {
         throw;
     }
 }