Esempio n. 1
0
        public List <Model.BB_Factory> QueryAll()
        {
            var res = dal.QueryWhere().ToList();

            return(res);
        }
Esempio n. 2
0
        public object StationListJson(int limit, int page, string code)
        {
            var     query = dal.QueryWhere();
            int     num;
            decimal dnum;

            if (code != null)
            {
                if (int.TryParse(code, out num))
                {
                    num   = Convert.ToInt32(code);
                    query = query.Where(x => x.ID == num || x.GasMainSize == num);
                }
                else if (decimal.TryParse(code, out dnum))
                {
                    dnum  = Convert.ToDecimal(code);
                    query = query.Where(x => x.Latitude.Equals(dnum) || x.Longtitude == dnum || x.StationArea == dnum || x.NearGasArea == dnum);
                }
                else
                {
                    if (code == "有效")
                    {
                        query = query.Where(x => x.Valid.Equals("1"));
                    }
                    else if (code == "无效")
                    {
                        query = query.Where(x => x.Valid.Equals("0"));
                    }
                    else
                    {
                        var fac = facdal.QueryWhere(x => x.Name.Contains(code)).ToList();
                        if (fac.Count() > 0)
                        {
                            foreach (var item in fac)
                            {
                                query = query.Where(x => x.FactoryID == item.ID);
                            }
                        }
                        else
                        {
                            var cli = clidal.QueryWhere(x => x.Name.Contains(code)).ToList();
                            if (cli.Count() > 0)
                            {
                                foreach (var item in cli)
                                {
                                    query = query.Where(x => x.ClientID == item.ID);
                                }
                            }
                            else
                            {
                                query = query.Where(x => x.Introduction.Contains(code) || x.Name.Contains(code) || x.StationControlSystem.Contains(code) || x.Code.Contains(code) || x.DeviceBindMode.Contains(code));
                            }
                        }
                    }
                }
            }
            var res = query.OrderBy(o => o.ID).Skip((page - 1) * limit).Take(limit).ToList().Select(s => new
            {
                s.ID,
                s.Code,
                s.Name,
                s.Introduction,
                s.Latitude,
                s.Longtitude,
                FactoryID = facdal.Find(new object[] { s.FactoryID }).Name,
                ClientID  = clidal.Find(new object[] { s.ClientID }).Name,
                s.GasMainSize,
                s.DeviceBindMode,
                s.StationArea,
                s.NearGasArea,
                s.StationControlSystem,
                Valid = Enum.GetName(typeof(Enums.Valid), Convert.ToInt32(s.Valid)),
                s.Remark
            }).ToList();
            var count   = query.Count();
            var tranres = new
            {
                code = 0,
                msg  = "success",
                data = res,
                count
            };

            return(tranres);
        }