Ejemplo n.º 1
0
        // GET: User
        public ActionResult Index(int page = 1)
        {
            var data = new PageableData <User>(Repository.Users, page, 30);

            //var users = Repository.Users.ToList();
            return(View(data));
        }
Ejemplo n.º 2
0
        public ActionResult Index(int page = 1, int itemPerPage = 10)
        {
            var products = presentsDB.Products.ToList();
            var data     = new PageableData <Product>(products.OrderByDescending(e => e.Popularity).Take(8).ToList(), page, itemPerPage);

            return(View(data));
        }
Ejemplo n.º 3
0
 public ActionResult Index(int page = 1)
 {
     var list = Repository.Posts.OrderByDescending(p => p.AddedDate);
     var data = new PageableData<Post>(list, page);
     data.List.ForEach(p => p.CurrentLang = CurrentLang.ID);
     return View(data);
 }
Ejemplo n.º 4
0
        public JsonResult Search(int limit, int offset, string organizationName, string Name, string lineIP)
        {
            var user = CookieHelper.GetInstance(HelperKeys.UserIdCookieKey).GetCookie <UserModel>(Request);
            PageableData <AlarmModel> temp = _business.GetPage(Name, organizationName, lineIP, user.OrganId, limit, offset);

            PageableData <object> list = new PageableData <object>()
            {
                total = temp.total,
                rows  = temp.rows.Select(n => new
                {
                    n.Id,
                    n.LineName,
                    n.IP,
                    n.OrganName,
                    FirstTime = n.FirstTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    LastTime  = n.LastTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    n.AlarmCount,
                    State = n.State.GetDescription(),
                    Type  = n.Type.GetDescription(),
                    n.Confirm
                    //LineState = n.LineState ? "连通" : "断开"
                })
            };

            return(Json(list));
        }
Ejemplo n.º 5
0
        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context).ConfigureAwait(false);

            IValueNode sortArgument = context.Argument <IValueNode>(_contextData.ArgumentName);

            if (sortArgument is null || sortArgument is NullValueNode)
            {
                return;
            }

            IQueryable <T>?  source = null;
            PageableData <T>?p      = null;

            if (context.Result is IQueryable <T> q)
            {
                source = q;
            }
            else if (context.Result is IEnumerable <T> e)
            {
                source = e.AsQueryable();
            }

            if (context.Result is PageableData <T> pb)
            {
                source = pb.Source;
                p      = pb;
            }

            if (source != null &&
                context.Field.Arguments[_contextData.ArgumentName].Type is InputObjectType iot &&
                iot is ISortInputType fit &&
                fit.EntityType is { })
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="orderby"></param>
        /// <param name="startIndex"></param>
        /// <param name="endIndex"></param>
        /// <returns></returns>
        public PageableData <Model.PURTC> GetPageList(string strWhere, string orderby, int startIndex, int endIndex)
        {
            PageableData <Model.PURTC> result = null;
            string        totalsql            = string.Format("select  count(*) from PURTC where 1=1 and  {0}", strWhere);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT *  FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.TC003 desc");
            }
            strSql.Append(")AS Row, T.*  from PURTC T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);

            using (SqlConnection conn = new SqlConnection(ConnStrManage.WSGCDB))
            {
                var reader = conn.Query <Model.PURTC>(strSql.ToString(), null);
                result = new PageableData <Model.PURTC>()
                {
                    total = conn.Query <int>(totalsql).FirstOrDefault(),
                    rows  = reader
                };
            }
            return(result);
        }
Ejemplo n.º 7
0
        public ActionResult Catalog(int page = 1, int itemPerPage = 10, int sort = 0)
        {
            List <ProductFrequency> listPr = (List <ProductFrequency>)Session["finalResult"];

            ViewBag.sortType = sort;
            List <ProductFrequency> helpList = new List <ProductFrequency>();

            switch (sort)
            {
            case 0: helpList = listPr.OrderBy(x => x.productCore.Price).ToList();
                break;

            case 1: helpList = listPr.OrderByDescending(x => x.productCore.Price).ToList();
                break;

            case 2: helpList = listPr.OrderByDescending(x => x.Frequency).ToList();
                break;

            default:
                helpList = listPr;
                break;
            }
            Session["finalResult"] = helpList;
            var data = new PageableData <ProductFrequency>(helpList, page, itemPerPage);

            return(View(data));
        }
Ejemplo n.º 8
0
        public ViewResult LogList(int page = 1, int sort = 0, int itemsPerPage = 0)
        {
            itemsPerPage = itemsPerPage == 0 ? Globals.itemsPerPage : itemsPerPage; //определяем текущее кол-во элементов на странице

            ViewBag.sort      = sort;
            ViewBag.ItemsPage = itemsPerPage;
            IQueryable <Models.Action> actions;

            switch (sort)
            {
            case 1:
                actions = Repository.Actions.OrderBy(name => name.User.Username);
                break;

            case 2:
                actions = Repository.Actions.OrderBy(name => name.Item.Itemname);
                break;

            case 3:
                actions = Repository.Actions.OrderBy(name => name.Todo);
                break;

            case 4:
                actions = Repository.Actions.OrderBy(name => name.When);
                break;

            default:
                actions = Repository.Actions.OrderByDescending(name => name.When);
                break;
            }
            var data = new PageableData <Models.Action>(actions, page, itemsPerPage);

            return(View(data));  //выводим лог список
        }
Ejemplo n.º 9
0
        public ActionResult Index(int page = 1)
        {
            var list = Repository.Posts.OrderByDescending(p => p.AddedDate);
            var data = new PageableData <Post>(list, page);

            data.List.ForEach(p => p.CurrentLang = CurrentLang.ID);
            return(View(data));
        }
Ejemplo n.º 10
0
 public ActionResult Index(int page = 1)
 {
     var list = Repository.Users.OrderBy(p => p.ID);
     var data = new PageableData<User>();
     data.Init(list, page, "Index");
     data.List.ForEach(p => p.CurrentLang = CurrentLang.ID);
     return View(data);
 }
Ejemplo n.º 11
0
        // GET: Test
        //public ActionResult Index()
        //{
        //    var carmodels = Repository.CarModelss.ToList();
        //    return View(carmodels);
        //}
        public ActionResult Index(int page = 1)
        {
            ExistParser pasd = new ExistParser();

            pasd.Parse("Tesla");
            ViewData.Add("List", Repository.CarModelss);
            var data = new PageableData <CarModels>(Repository.CarModelss, page, 30);

            return(View(data));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Renders a pager based on the PageableData object, which is itself a standardized collection for carrying pages of objects from a collection.
        /// </summary>
        /// <param name="page">PageableData object which pager will represent</param>
        /// <param name="pagesPerGroup">Number of page links to occur on pager. If more pages than this are possible, a "next" link is rendered.</param>
        /// <param name="baseurl">Nullable. Use if the existing url already has query string arguments in it. Paging args will be appended to url preserving existing.</param>
        /// <param name="pageQueryStringArg">Name of page query string argument</param>
        /// <returns>Rendered Html of pager.</returns>
        public string Render <T>(PageableData <T> page, int pagesPerGroup, string baseurl, string pageQueryStringArg, string hash = "")
        {
            this.Calculate(page.VirtualItemCount, page.PageIndex, page.PageSize, pagesPerGroup);
            if (this.NotEnoughDataToPage)
            {
                return(string.Empty);
            }

            return(this.RenderPageLinks(page.PageIndex, pagesPerGroup, baseurl, pageQueryStringArg, hash));
        }
        public ActionResult Index(int page = 1)
        {
            var userEmail = Convert.ToString(HttpContext.Request.Cookies["Email"].Value);

            var user = Repository.Users.FirstOrDefault(p => p.Email == userEmail);
            var bookmarkView = new BookmarkView();
            bookmarkView.UserId = user.ID;
            ViewBag.ID = bookmarkView.UserId;
            var data = new PageableData<Bookmarks>(Repository.Bookmark.OrderBy(p => p.UserID).Where(x => x.UserID == bookmarkView.UserId), page, 12);
            return View(data);
        }
        public ActionResult Index(int page = 1)
        {
            var userEmail = Convert.ToString(HttpContext.Request.Cookies["Email"].Value);

            var user = Repository.Users.FirstOrDefault(p => p.Email == userEmail);
            var calendarView = new CalendarView();
            calendarView.UserId = user.ID;
            ViewBag.ID = calendarView.UserId;
            var data = new PageableData<Calendar>(Repository.Calendar.Where(x => x.UserID == calendarView.UserId).Where(d => d.Date.Day == DateTime.Now.Day).OrderBy(p => p.Date).OrderBy(p => p.Time), page, 10);
            return View(data);
        }
Ejemplo n.º 15
0
 public ActionResult Index(int page = 1, string searchString = null)
 {
     ViewBag.Search = searchString;
     if (!string.IsNullOrWhiteSpace(searchString))
     {
         var list = SearchEngine.Search(searchString, Repository.Users).AsQueryable();
         var data = new PageableData<User>(list, page, 5);
         return View(data);
     }
     else
     {
         var data = new PageableData<User>(Repository.Users, page, 5);
         return View(data);
     }
 }
Ejemplo n.º 16
0
 public ActionResult Index(int page = 1, string searchString = null)
 {
     ViewBag.Search = searchString;
     if (!string.IsNullOrWhiteSpace(searchString))
     {
         var list = SearchEngine.Search(searchString, Repository.Users).AsQueryable();
         var data = new PageableData <User>(list, page, 5);
         return(View(data));
     }
     else
     {
         var data = new PageableData <User>(Repository.Users, page, 5);
         return(View(data));
     }
 }
Ejemplo n.º 17
0
        public IActionResult Packages(int page)
        {
            // user-facing page values start at 1 instead of 0. reset
            if (page != 0)
            {
                page--;
            }

            Pager pager = new Pager();
            PageableData <Package> packages = _packageList.GetPage(page, _settings.ListPageSize);

            ViewData["pager"]    = pager.Render(packages, _settings.PagesPerPageGroup, "/packages", "page");
            ViewData["packages"] = packages;
            return(View());
        }
Ejemplo n.º 18
0
 public ActionResult List(int? page, Search search)
 {
     IEnumerable<users> requestedUsers = DataBase.Users.Get();
     if (!page.HasValue)
         page = 1;
     if (search == null)
         ViewBag.Search = new Search();
     else
     {
         ViewBag.Search = search;
         requestedUsers= DataBase.Users.Search(search);
     }
     var requestedUsersView = requestedUsers.Select(u => new UserView(u)).AsQueryable();
     var a = new PageableData<UserView>(requestedUsersView, (int)page, 15);
     return View("List", a);
 }
Ejemplo n.º 19
0
        public object GetPage(string condition, object searchObj, string order, int offset, int limit)
        {
            string sql = GetPageSqlFromView("tb_organization", "*", order, condition, offset, limit);
            PageableData <OrganModel> result = null;

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                var reader = conn.QueryMultiple(sql, searchObj);
                result = new PageableData <OrganModel>()
                {
                    total = reader.Read <int>().FirstOrDefault(),
                    rows  = reader.Read <OrganModel>()
                };
            }
            return(result);
        }
Ejemplo n.º 20
0
        public PageableData <LogModel> GetPage(string condition, object searchObj, string order, int begin, int end)
        {
            string sql = GetPageSql(" * ", order, condition, begin, end);
            PageableData <LogModel> result = null;

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                var reader = conn.QueryMultiple(sql, searchObj);
                result = new PageableData <LogModel>()
                {
                    total = reader.Read <int>().FirstOrDefault(),
                    rows  = reader.Read <LogModel>()
                };
            }
            return(result);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 获取一条订单的单身所有信息
        /// </summary>
        /// <param name="db"></param>
        /// <param name="dh"></param>
        /// <returns></returns>
        public PageableData <Model.COPTD> CoptdList(string db, string dh)
        {
            PageableData <Model.COPTD> result = null;
            string sql = string.Format("select* from COPTD where 1 = 1 and TD001 = '{0}' and TD002 = '{1}'", db, dh);

            using (SqlConnection conn = new SqlConnection(ConnStrManage.WSGCDB))
            {
                var reader = conn.Query <Model.COPTD>(sql.ToString(), null);
                result = new PageableData <Model.COPTD>()
                {
                    total = reader.Count(),
                    rows  = reader
                };
            }
            return(result);
        }
Ejemplo n.º 22
0
        public void PageDataTest()
        {
            var data = new List <Item>();

            for (var i = 0; i < 6; i++) //создаём тестовый список
            {
                data.Add(new Item {
                    ID_Item = Guid.NewGuid(), Itemname = "Item" + i.ToString()
                });
            }
            var pd = new PageableData <Item>(data.AsQueryable(), 1, 5);

            Assert.AreEqual(pd.CountPage, 2);                       //проверяем кол-во страниц
            Assert.AreEqual(pd.List.Count(), 5);                    //проверяем кол-во элементов на странице
            Assert.AreEqual(pd.List.ToList()[4].Itemname, "Item4"); //проверяем последний элемент списка
        }
Ejemplo n.º 23
0
        public PageableData <DBModel> GetPage(string condition, object searchObj, string order, int begin, int end)
        {
            string sql = GetPageSqlFromView("tb_dataconfig", " *", order, condition, begin, end);
            PageableData <DBModel> result = null;

            using (MySqlConnection conn = new MySqlConnection(ConfigManage.GetInstance().GetSysConnStr()))
            {
                var reader = conn.QueryMultiple(sql, searchObj);
                result = new PageableData <DBModel>()
                {
                    total = reader.Read <int>().FirstOrDefault(),
                    rows  = reader.Read <DBModel>()
                };
            }
            return(result);
        }
Ejemplo n.º 24
0
        public async Task<PageableData<UserMiniDto>> GetUsersDtoAsync(UserFiltersDto dto)
        {
            Expression<Func<User, bool>> filter = x => true;
            if (dto.RoleGroupId.HasValue)
            {
                filter = filter.And(x => x.RoleGroupId == dto.RoleGroupId.Value);
            }
            if (!string.IsNullOrWhiteSpace(dto.UserName))
            {
                filter = filter.And(x => x.UserName.Contains(dto.UserName));
            }

            var users = await _userRepository.GetListAsync(dto.Page, filter: filter);
            var usersDto = _mapper.Map<IEnumerable<UserMiniDto>>(users);
            var allUsersCount = await _userRepository.GetCountAsync(filter);
            var result = new PageableData<UserMiniDto>(usersDto, dto.Page, allUsersCount);
            return result;
        }
Ejemplo n.º 25
0
        public ViewResult ListWithFilter(string filterDiscr = "", int page = 1)
        {
            var categories = repository.Products;

            if (filterDiscr != "")
            {
                List <string> categor = new List <string>();
                foreach (var word in Regex.Split(filterDiscr, "_or_"))
                {
                    categor.Add(word);
                }
                ViewBag.FilterDiscr = filterDiscr;
                categories          = categories.Where(e => categor.Contains(e.CategoryUrl));
            }
            var data = new PageableData <Product>(categories.ToList(), page, PageSize);

            return(View(data));
        }
Ejemplo n.º 26
0
        public JsonResult Search(int limit, int offset, DateTime?startTime, DateTime?endTime, int?LogType)
        {
            PageableData <LogModel> temp = _business.GetPage(LogType, startTime, endTime, limit, offset);
            PageableData <object>   list = new PageableData <object>()
            {
                total = temp.total,
                rows  = temp.rows.Select(n => new
                {
                    n.Id,
                    n.Content,
                    Time = n.Time.ToString("yyyy-MM-dd HH:mm:ss"),
                    n.Username,
                    Type = n.Type.GetDescription()
                })
            };

            return(Json(list));
        }
        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context).ConfigureAwait(false);

            IValueNode filter = context.Argument <IValueNode>(_contextData.ArgumentName);

            if (filter is null || filter is NullValueNode)
            {
                return;
            }

            IQueryable <T>?  source = null;
            PageableData <T>?p      = null;

            if (context.Result is PageableData <T> pd)
            {
                source = pd.Source;
                p      = pd;
            }

            if (context.Result is IQueryable <T> q)
            {
                source = q;
            }
            else if (context.Result is IEnumerable <T> e)
            {
                source = e.AsQueryable();
            }

            if (source != null &&
                context.Field.Arguments[_contextData.ArgumentName].Type is InputObjectType iot &&
                iot is IFilterInputType fit)
            {
                var visitorContext = new QueryableFilterVisitorContext(
                    iot, fit.EntityType, _converter, source is EnumerableQuery);
                QueryableFilterVisitor.Default.Visit(filter, visitorContext);

                source = source.Where(visitorContext.CreateFilter <T>());

                context.Result = p is null
                    ? (object)source
                    : new PageableData <T>(source, p.Properties);
            }
        }
Ejemplo n.º 28
0
        public ActionResult Index(int id = -1, bool isCategory = false, int page = 1, int itemPerPage = 10, int sort = 0)
        {
            ViewBag.sort = sort;
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }
            var products     = new List <Product>();
            var notOrderList = presentsDB.Products.Where(e => e.IsValid == true).ToList();

            switch (sort)
            {
            case 0: products = notOrderList.OrderBy(e => e.Name).ToList();
                break;

            case 1: products = notOrderList.OrderByDescending(e => e.Name).ToList();
                break;

            case 2: products = notOrderList.OrderBy(e => e.Price).ToList();
                break;

            case 3: products = notOrderList.OrderByDescending(e => e.Price).ToList();
                break;

            case 4: products = notOrderList.OrderBy(e => e.Quantity).ToList();
                break;

            case 5: products = notOrderList.OrderByDescending(e => e.Quantity).ToList();
                break;

            case 6: products = notOrderList.OrderBy(e => e.Popularity).ToList();
                break;

            case 7: products = notOrderList.OrderByDescending(e => e.Popularity).ToList();
                break;

            default: products = notOrderList;
                break;
            }
            var data = new PageableData <Product>(products.ToList(), page, itemPerPage);

            return(View(data));
        }
Ejemplo n.º 29
0
        public PageableData <T> GetPage <T>(string condition, object searchObj, string order, int begin, int end, string viewName = "")
        {
            if (string.IsNullOrEmpty(viewName))
            {
                viewName = _tableName;
            }
            string           sql    = GetPageSqlFromView(viewName, "*", order, condition, begin, end);
            PageableData <T> result = null;

            using (MySqlConnection conn = new MySqlConnection(ConnStrManage.DB))
            {
                var reader = conn.QueryMultiple(sql, searchObj);
                result = new PageableData <T>()
                {
                    total = reader.Read <int>().FirstOrDefault(),
                    rows  = reader.Read <T>()
                };
            }
            return(result);
        }
Ejemplo n.º 30
0
        public JsonResult Search(int limit, int offset, string username, int?state, int?typeId)
        {
            var temp = _business.GetPage(username, state, typeId, limit, offset);
            PageableData <object> list = new PageableData <object>()
            {
                rows = temp.rows.Select(n => new
                {
                    n.Email,
                    n.Id,
                    n.RealName,
                    n.Username,
                    n.Telphone,
                    RoleName = n.RoleId.GetDescription(),
                    n.State,
                    n.OrganName
                }),
                total = temp.total
            };

            return(Json(list));
        }
Ejemplo n.º 31
0
        public void Basic()
        {
            Directory.CreateDirectory(Path.Combine(Settings.PackagePath, "package2003"));
            Directory.CreateDirectory(Path.Combine(Settings.PackagePath, "package2002"));
            Directory.CreateDirectory(Path.Combine(Settings.PackagePath, "package2001"));

            File.WriteAllText(Path.Combine(Settings.PackagePath, "package2003", "manifest.json"), JsonConvert.SerializeObject(new Manifest()));
            File.WriteAllText(Path.Combine(Settings.PackagePath, "package2002", "manifest.json"), JsonConvert.SerializeObject(new Manifest()));
            File.WriteAllText(Path.Combine(Settings.PackagePath, "package2001", "manifest.json"), JsonConvert.SerializeObject(new Manifest()));

            Assert.Equal("package2001", this.PackageList.GetPage(0, 1).Page.First().Id);
            Assert.Equal("package2002", this.PackageList.GetPage(1, 1).Page.First().Id);
            Assert.Equal("package2003", this.PackageList.GetPage(2, 1).Page.First().Id);

            PageableData <Package> page = this.PackageList.GetPage(0, 1);

            Assert.Equal(3, page.VirtualItemCount);
            Assert.Equal(3, page.TotalPages);
            Assert.Equal(1, page.PageSize);
            Assert.Equal(0, page.PageIndex);
        }
Ejemplo n.º 32
0
        public ActionResult Catalog()
        {
            Dictionary <Product, int> frequencies = new Dictionary <Product, int>();

            foreach (var subcategory in db.Subcategories.Where(e => e.Question.Length > 0).ToList())
            {
                string ansver = Request[subcategory.SubcategoryId.ToString()];
                if (ansver != null && ansver.Equals("yes"))
                {
                    foreach (var product in subcategory.Products)
                    {
                        if (frequencies.ContainsKey(product))
                        {
                            frequencies[product] += 1;
                        }
                        else
                        {
                            frequencies.Add(product, 1);
                        }
                    }
                }
            }

            if (frequencies.Count == 0)
            {
                return(RedirectToAction("Browse", "Store", new { id = 1, isCategory = true }));
            }
            IOrderedEnumerable <KeyValuePair <Product, int> > orderByDescending = frequencies.OrderByDescending(i => i.Value);
            List <ProductFrequency> helpList = new List <ProductFrequency>();

            foreach (var keyValuePair in orderByDescending)
            {
                helpList.Add(new ProductFrequency(keyValuePair.Key, keyValuePair.Value));
            }
            Session["finalResult"] = helpList;
            ViewBag.sortType       = 2;
            var data = new PageableData <ProductFrequency>(helpList, 1, 10);

            return(View(data));
        }
Ejemplo n.º 33
0
        public ActionResult Browse(int id, bool isCategory, int page = 1, int itemPerPage = 10, int sort = 0)
        {
            ViewBag.categoryId = id;
            ViewBag.sort       = sort;
            ViewBag.IsCategory = isCategory;
            List <Product> products = new List <Product>();

            if (isCategory)
            {
                var categoryName = presentsDB.Categories.FirstOrDefault(e => e.CategoryId == id).Name;
                ViewBag.categoryName = categoryName;
                Category category = presentsDB.Categories.Find(id);
                foreach (var sub in category.Subcategories)
                {
                    products.AddRange(sub.Products);
                }
            }
            else
            {
                var categoryName = presentsDB.Subcategories.FirstOrDefault(e => e.SubcategoryId == id).Name;
                ViewBag.categoryName = categoryName;
                products             = presentsDB.Subcategories.Find(id).Products.ToList();
            }
            products = products.Distinct().ToList();
            products = products.Where(e => e.IsValid).ToList();

            if (sort == 0)
            {
                products = products.OrderBy(x => x.Price).ToList();
            }
            else if (sort == 1)
            {
                products = products.OrderByDescending(x => x.Price).ToList();
            }
            var data = new PageableData <Product>(products, page, itemPerPage);

            return(View(data));
        }
Ejemplo n.º 34
0
        public JsonResult Search(int limit, int offset, string organizationName, string name, string lineIp)
        {
            var user = GetUser();
            var temp = _business.GetPage(organizationName, name, lineIp, user.OrganId, limit, offset);
            PageableData <object> list = new PageableData <object>()
            {
                total = temp.total,
                rows  = temp.rows.Select(n => new
                {
                    n.Id,
                    n.Name,
                    n.LineIP,
                    n.Description,
                    LineType        = n.LineType.GetDescription(),
                    ServiceProvider = n.ServiceProvider.GetDescription(),
                    n.OrganizationName,
                    n.ParentOrganizationName,
                    ConnectState = n.ConnectState ? "连通" : "断开"
                })
            };

            return(Json(list));
        }
Ejemplo n.º 35
0
        [ValidateInput(false)]  //Аттрибут отключает проверку (чтоб не возникало HttpRequestValidationException)
        public ViewResult UserList(int page = 1, int sorted = 0, int itemsPerPage = 0, string searchString = null)
        {
            //Сортируем пользователей по полю (сортед = 1 - по должности)
            var sortItems = sorted == 0 ? Repository.Users.OrderBy(name => name.Username) : Repository.Users.OrderByDescending(name => name.Post);

            itemsPerPage = itemsPerPage == 0 ? Globals.itemsPerPage : itemsPerPage; //определяем текущее кол-во элементов на странице

            ViewBag.ItemsPage = itemsPerPage;
            ViewBag.Sorted    = sorted;
            ViewBag.Search    = searchString;
            if (!string.IsNullOrWhiteSpace(searchString))
            {
                var list = SearchEngine <User> .Search(searchString, sortItems).AsQueryable();

                var data = new PageableData <User>(list, page, itemsPerPage);
                return(View(data)); //выводим результаты поиска
            }
            else
            {
                var data = new PageableData <User>(sortItems, page, itemsPerPage);
                return(View(data));  //выводим список пользователей
            }
        }
Ejemplo n.º 36
0
        [ValidateInput(false)]  //по аналогии с UserController
        public ViewResult EquipList(int page = 1, int sorted = 0, int itemsPerPage = 0, string searchString = null)
        {
            //Выводим итемы по их типу (если sorted = 0 то выводим всё подряд)
            var typeItems = sorted != 0 ? Repository.Items.Where(itm => itm.Cast == sorted).OrderBy(name => name.Itemname) : Repository.Items.OrderBy(name => name.Itemname);

            itemsPerPage = itemsPerPage == 0 ? Globals.itemsPerPage : itemsPerPage; //определяем текущее кол-во элементов на странице

            ViewBag.ItemsPage = itemsPerPage;
            ViewBag.Search    = searchString;
            ViewBag.Sorted    = sorted;
            if (!string.IsNullOrWhiteSpace(searchString))
            {
                var list = SearchEngine <Item> .Search(searchString, typeItems).AsQueryable();

                var data = new PageableData <Item>(list, page, itemsPerPage);
                return(View(data)); //выводим результаты поиска
            }
            else
            {
                var data = new PageableData <Item>(typeItems, page, itemsPerPage);
                return(View(data)); //отображаем список предметов
            }
        }
Ejemplo n.º 37
0
        public async Task<PageableData<MaterialMiniDto>> GetDtoAllAsync(MaterialFiltersDto filters)
        {
            var itemPerPage = GlobalConstants.NewsPerPage;
            Expression<Func<Material, bool>> filter = x => x.Type == filters.MaterialType;
            if (filters.CategoryId.HasValue)
            {
                filter = filter.And(x => x.CategoryId == filters.CategoryId.Value);
            }

            if (!string.IsNullOrWhiteSpace(filters.UserName))
            {
                Expression<Func<Material, bool>> newFilter = x => x.Author.UserName.Contains(filters.UserName);
                filter = filter.And(newFilter);
            }

            ICollection<Material> topNews = new List<Material>();
            if (filters.Page == GlobalConstants.FirstPage)
            {
                topNews = await _materialRepository.GetTopMaterialsAsync(filter);

                itemPerPage = GlobalConstants.NewsPerPage - topNews.Count > 0
                    ? GlobalConstants.NewsPerPage - topNews.Count
                    : 0;
            }

            var allNewsCount = await _materialRepository.GetCountAsync(filter);
            
            var news =
                await
                    _materialRepository.GetOrderedByDescAndNotTopAsync(filters.Page, itemPerPage, filter,
                        x => x.AdditionTime);
            var newsForView = topNews.Concat(news);
            var newsDtos = _mapper.Map<IEnumerable<MaterialMiniDto>>(newsForView);
            var result = new PageableData<MaterialMiniDto>(newsDtos, filters.Page, allNewsCount);
            return result;
        }
Ejemplo n.º 38
0
        public PageableData <AlarmModel> GetPage(string condition, object searchObj, string order, int begin, int end)
        {
            string sql = GetPageSqlFromView("tb_alarm", " * ", order, condition, begin, end);
            //string sql = GetSelectSqlByName("view_alarm", "*", condition, order);
            PageableData <AlarmModel> result = null;

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                var reader = conn.QueryMultiple(sql, searchObj);
                result = new PageableData <AlarmModel>()
                {
                    total = reader.Read <int>().FirstOrDefault(),
                    rows  = reader.Read <AlarmModel>()
                };
                //var result = conn.Query<AlarmModel>(sql, searchObj);
                //result.rows.ToList().ForEach(delegate (AlarmModel n)
                //{
                //    n.LastTime = string.IsNullOrEmpty(n.LastTime) ? "" : n.LastTime.Replace('T', ' ');
                //    n.FirstTime = string.IsNullOrEmpty(n.FirstTime) ? "" : n.FirstTime.Replace('T', ' ');
                //    n.TypeStr = ((AlarmType)n.Type).GetDescription();
                //});
                return(result);
            }
        }
Ejemplo n.º 39
0
 public ActionResult AllNews(int page = 1)
 {
     List<News> ne = Repository.AllNews.ToList();
     var data = new PageableData<News>(Repository.AllNews.OrderByDescending(s => s.DateNew), page, 5);
     return View(data);
 }
Ejemplo n.º 40
0
 public ActionResult My()
 {
     return View("developing");
     var at = Request.Cookies["access_token"].Value;
     var qs = DataBase.Missions.GetByAccess(at).Select(q => new MissionView(q));
     var page = 1;
     var a = new PageableData<MissionView>(qs.AsQueryable(), (int)page, 5);
     return View("My", a);
 }
Ejemplo n.º 41
0
 // GET: Admin/PHoto
 public ActionResult Index(int page=1, int itemPerPage=16)
 {
     var listOptions = new SelectItemPerPageList();
     var list = db.JewelPHotos.OrderBy(x => x.Caption).AsQueryable();
     if (listOptions.Options.Any(x => x == itemPerPage) == false)
     {
         itemPerPage = 16;
     }
     var pd = new PageableData<JewelPHoto>(list,page,itemPerPage);
     ViewBag.OptionsListViewItems = listOptions.GetSelectListItems(itemPerPage);
     return View(pd);
 }