Ejemplo n.º 1
0
        private IList<Device> load_device(string pname, string mtcode, string pindex, int tpcode, bool isallowpage, string orderby)
        {
            int mCode = 0;
            int.TryParse(mtcode, out mCode);
            IList<Device> devices = new List<Device>();
            IList<Plant> plants = plantService.Getplantlikepname(pname);

            foreach (Plant plant in plants)
            {
                foreach (Device d in plant.deviceList())
                {
                    if (d.deviceTypeCode.Equals(tpcode) && (d.deviceModelCode.Equals(mCode) || mCode.Equals(-1)))
                    {
                        //从18版本调整设备和电站的逻辑关系为已经plantunitid后,无需这样处理了
                        //d.plant = plant;
                        devices.Add(d);
                    }
                }
            }

            int.TryParse(pindex, out mCode);
            Pager page = new Pager();
            page.PageSize = ComConst.PageSize;
            page.PageIndex = mCode;
            page.RecordCount = devices.Count;
            ViewData["page"] = page;
            if (isallowpage)
                devices = devices.Skip((mCode - 1) * page.PageSize).Take(page.PageSize).ToList<Device>();
            switch (orderby)
            {
                case "pltname":
                    devices = devices.OrderBy(m => m.plant.name).ToList<Device>();
                    break;
                case "dtype":
                    devices = devices.OrderBy(m => m.xinhaoName).ToList<Device>();
                    break;
                default:
                    break;
            }
            return devices;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dids"></param>
        /// <param name="gids"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="rowCount"></param>
        /// <returns></returns>
        protected List<P_PersonInfo> GetPersonListByGroupDepartment(string dids, string gids,out int rowCount, int pageSize=-1,int pageIndex=-1)
        {
            List<int> list_dids = new List<int>();
            List<int> list_gids = new List<int>();
            if (dids != "")
            {
                var list_dids_temp = (from g in dids.Split(',')
                                      where g != ""
                                      select g).ToList();
                list_dids_temp.ForEach(g => list_dids.Add(int.Parse(g)));
            }
            if (gids != "")
            {
                var list_gids_temp = (from g in gids.Split(',')
                                 where g != ""
                                 select g).ToList();
                list_gids_temp.ForEach(g => list_gids.Add(int.Parse(g)));
            }

            //2 根据department以及group的id查询其对应的Person对象集合
            List<P_PersonInfo> list_person = new List<P_PersonInfo>();
            var list_department = departmentBLL.GetListByIds(list_dids);
            list_department.ForEach(d => list_person.AddRange(d.P_PersonInfo));
            var list_group = groupBLL.GetListByIds(list_gids);
            list_group.ForEach(g => list_person.AddRange(g.P_PersonInfo));

            //3 将联系人集合去重
            list_person = list_person.Distinct(new P_PersonEqualCompare()).ToList().Select(p => p.ToMiddleModel()).ToList();
            list_person = list_person.OrderByDescending(a => a.isVIP).ToList();
            rowCount = list_person.Count();

            if (pageIndex != -1 && pageSize != -1)
            {
                //分页
                list_person = list_person.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            }
            return list_person;
        }