Example #1
0
        public ActionResult Index(string keyword, int pageIndex = 1)
        {
            SearchOpt opt = new SearchOpt();

            opt.CurrentIndex  = pageIndex;
            opt.Keyword       = keyword;
            opt.PageSize      = 10;
            ViewBag.pageIndex = pageIndex;
            ViewBag.keyword   = keyword;

            var data = userService.Search(opt);

            return(View(data));
        }
Example #2
0
        public SearchUserResult Search(SearchOpt options)
        {
            using (MyDbContext ctx = new MyDbContext())
            {
                BaseService <UserEntity> bs = new BaseService <UserEntity>(ctx);
                var items = bs.GetAll();
                if (!string.IsNullOrWhiteSpace(options.Keyword))
                {
                    items.Where(e => e.UserName.Contains(options.Keyword));
                }

                SearchUserResult res = new SearchUserResult();
                res.totalCount = items.LongCount();
                res.result     = items.ToList().Select(e => ToDTO(e)).ToArray();
                return(res);
            }
        }
Example #3
0
        public void GetFilesTest()
        {
            string queryDir = @"D:\Projects\_ObservationGround\_DevBook\Regex\Regular_Expression_Recipes_for_Windows_Developers";

            FileDirSearchOpt fso       = new FileDirSearchOpt();
            SearchOpt        searchOpt = new SearchOpt();

            searchOpt.IncludeFilter = @"\w+.cs$";
            searchOpt.ExcludeFilter = @"2-\d+.cs";
            searchOpt.RegexOptionList.Add(RegexOptions.IgnoreCase);
            fso.QueryDirectory = queryDir;
            fso.SearchOptions  = searchOpt;
            fso.Recursive      = true;

            List <string> fileList = FileDirLister.GetFiles(fso);

            Zen.Utilities.ObjSerializer.Save(@"c:\test.log", fileList);
        }
Example #4
0
        public ActionResult List(long?TypeId, int?IsLook, string keywords, int pageIndex = 1)
        {
            SearchOpt opt = new SearchOpt();

            opt.CurrentIndex  = pageIndex;
            opt.TypeId        = TypeId;
            opt.Keywords      = keywords;
            opt.IsLook        = IsLook;
            opt.PageSize      = 10;
            ViewBag.pageIndex = pageIndex;
            ViewBag.IsLook    = IsLook;
            ViewBag.TypeId    = TypeId;
            ViewBag.keywords  = keywords;

            var data = examService.Search(opt);

            return(View(data));
        }
Example #5
0
        public SearchWorkPostResult Search(SearchOpt options)
        {
            using (MyDbContext ctx = new MyDbContext())
            {
                BaseService <WorkPostEntity> bs = new BaseService <WorkPostEntity>(ctx);
                var items = bs.GetAll();
                items.Include(e => e.Project);
                if (!string.IsNullOrEmpty(options.Keyword))
                {
                    items = items.Where(e => e.Position == options.Keyword);
                }
                var totalCount = items.LongCount();
                items = items.Skip((options.CurrentIndex - 1) * options.PageSize)
                        .Take(options.PageSize);
                SearchWorkPostResult searchResult = new SearchWorkPostResult();
                searchResult.totalCount = totalCount;
                searchResult.result     = items.ToList().Select(e => ToDTO(e)).ToArray();

                return(searchResult);
            }
        }
Example #6
0
        public void GetDirectoriesTest()
        {
            string queryDir = @"D:\Projects\_ObservationGround";

            FileDirSearchOpt fso       = new FileDirSearchOpt();
            SearchOpt        searchOpt = new SearchOpt();

            searchOpt.IncludeFilter = @"(Net|CSharp|C#)";
            searchOpt.ExcludeFilter = @"(InterNet|Telnet)";
            searchOpt.RegexOptionList.Add(RegexOptions.IgnoreCase);
            fso.QueryDirectory = queryDir;
            fso.SearchOptions  = searchOpt;
            fso.Recursive      = true;

            try
            {
                List <string> dirList = FileDirLister.GetDirectories(fso);
            }
            catch (Exception)
            {
            }
        }
Example #7
0
        public SearchResult Search(SearchOpt options)
        {
            using (MyDbContext ctx = new MyDbContext())
            {
                BaseService <ExamEntity>     bs     = new BaseService <ExamEntity>(ctx);
                BaseService <ExamTypeEntity> bsType = new BaseService <ExamTypeEntity>(ctx);
                var items = bs.GetAll();
                if (options.TypeId != null && options.TypeId != 9999)
                {
                    items = items.Where(t => t.ExamTypes.Id == options.TypeId);
                }
                if (!string.IsNullOrEmpty(options.Keywords))
                {
                    items = items.Where(t => t.StuName == options.Keywords ||
                                        t.SFZCode == options.Keywords ||
                                        t.ZKZCode == options.Keywords);
                }
                if (options.IsLook != null && options.IsLook != 2)
                {
                    if (options.IsLook == 0)
                    {
                        items = items.Where(t => t.IsLook == false);
                    }
                    else
                    {
                        items = items.Where(t => t.IsLook == true);
                    }
                }
                var typeids = bsType.GetAll().Select(e => e.Id);
                items = items.Where(m => typeids.Contains(m.TypeId));

                long totalCount = items.LongCount();//总搜索结果条数
                items = items.Include(e => e.ExamTypes).OrderByDescending(t => t.CreateDateTime).Skip((options.CurrentIndex - 1) * options.PageSize)
                        .Take(options.PageSize);
                SearchResult res = new SearchResult();
                res.totalCount = totalCount;
                List <ExamDTO> exams = new List <ExamDTO>();
                foreach (var item in items)
                {
                    exams.Add(ToDTO(item));
                }
                res.result = exams.ToArray();
                List <ExamTypeDTO> examTypes = new List <ExamTypeDTO>();
                var efexamTypes = bsType.GetAll();


                ExamTypeDTO dtotype2 = new ExamTypeDTO();
                dtotype2.Description = "所有";
                dtotype2.Name        = "全部";
                dtotype2.Id          = 9999;
                examTypes.Add(dtotype2);
                foreach (var item in efexamTypes)
                {
                    ExamTypeDTO dtotype = new ExamTypeDTO();
                    dtotype.Description = item.Description;
                    dtotype.Name        = item.Name;
                    dtotype.Id          = item.Id;
                    examTypes.Add(dtotype);
                }
                res.examType = examTypes.ToArray();
                return(res);
            }
        }