//取商品列表安卓 public List <AndroidProductModel> GetProductAndroid(AndroidProductModel machineInfo) { var conditions = new List <Condition>(); if (!string.IsNullOrEmpty(machineInfo.MachineId)) { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "MachineId", DbColumnName = "a.machine_id", ParamValue = machineInfo.MachineId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); } conditions.Add(new Condition { LeftBrace = " ", ParamName = "ResourceUrl", DbColumnName = "", ParamValue = ConfigHandler.ResourceUrl, Operation = ConditionOperate.None, RightBrace = "", Logic = "" }); if (string.IsNullOrEmpty(machineInfo.WaresTypeId)) { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "WaresTypeId", DbColumnName = "b.wares_type_id", ParamValue = machineInfo.WaresTypeId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); } conditions.Add(new Condition { LeftBrace = " ", ParamName = "", DbColumnName = "a.wares_id", ParamValue = "", Operation = ConditionOperate.GroupBy, RightBrace = "", Logic = "" }); conditions.AddRange(CreatePaginConditions(machineInfo.PageIndex, machineInfo.PageSize)); return(GenerateDal.LoadByConditions <AndroidProductModel>(CommonSqlKey.GetProductAndroid, conditions)); }
public ResultObj <List <AndroidProductModel> > GetProductByMachine(string machineId, string waresTypeId = "", int pageIndex = 1, int pageSize = 10) { if (string.IsNullOrEmpty(machineId)) { return(Content(new List <AndroidProductModel>())); } //KeyJsonModel keyJsonInfo = AnalizeKey(k); // IProduct service = new ProductService(); //List<ProductModel> products = service.GetAllProducts(); //k = "ABC123456789"; //机器运行情况 /* * DataTable dt = _IMachine.GetMachineByMachineId(k); * if (dt == null || dt.Rows.Count == 0) * { * return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不存在", new Pagination { }); * } * //判断机器是否在线 时间大于十五分钟为离线 * if (string.IsNullOrEmpty(dt.Rows[0][0].ToString())) * { * return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination { }); * } * int intval = Convert.ToInt32(dt.Rows[0][0]); * if (intval > 900) * { * return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination { }); * } */ /* * if (!MachineHelper.IsOnline(machineId)) * { * return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination { }); * } */ AndroidProductModel machineInfo = new AndroidProductModel(); machineInfo.MachineId = machineId; machineInfo.PageIndex = pageIndex; machineInfo.PageSize = pageSize; IAndroid imachine = new AndroidService(); var data = imachine.GetProductAndroid(machineInfo); //int totalcount = imachine.GetProductAndroidCount(machineInfo); //var pagination = new Pagination { PageSize = pageSize, PageIndex = pageIndex, StartIndex = 0, TotalRows = totalcount, TotalPage = 0 }; return(Content(data)); }