示例#1
0
        public object UserList(int limit, int page, string account, string name, string contact, string state)
        {
            var query = dal.QueryWhere();

            if (account != null)
            {
                query = query.Where(w => w.Account.Equals(account));
            }
            if (contact != null)
            {
                query = query.Where(w => w.Name.Equals(contact));
            }
            if (state != null)
            {
                if (state == Enums.OnWork.在职.ToString())
                {
                    state = "1";
                }
                if (state == Enums.OnWork.在职.ToString())
                {
                    state = "0";
                }
                query = query.Where(w => w.State.Equals(state));
            }
            if (name != null)
            {
                var nameres = cdal.QueryWhere(c => c.Name.Equals(name)).FirstOrDefault();
                if (nameres != null)
                {
                    query = query.Where(w => w.ClientID == nameres.ID);
                }
            }

            var res = query.OrderBy(o => o.ID).Skip((page - 1) * limit).Take(limit).ToList().Select(s => new {
                s.ID,
                s.Account,
                s.PassWord,
                s.Name,
                s.UserType,
                Sex = Enum.GetName(typeof(Enums.Sex), Convert.ToInt32(s.Sex)),
                s.IDNo,
                s.Cellphone,
                s.Email,
                ClientID = cdal.Find(new object[] { s.ClientID }).Name,
                s.Remark,
                State = Enum.GetName(typeof(Enums.OnWork), Convert.ToInt32(s.State))
            }).ToList();
            var count   = query.Count();
            var tranres = new
            {
                code = 0,
                msg  = "success",
                data = res,
                count
            };

            return(tranres);
        }
示例#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);
        }