Esempio n. 1
0
		public virtual IActionResult SearchAction() {
			// 获取搜索请求
			var json = Request.Get<string>("json");
			var request = AjaxTableSearchRequest.FromJson(json);
			// 搜索图片列表
			// 分页时如果没有结果,使用最后一页的结果
			var imageManager = Application.Ioc.Resolve<ImageManager>();
			var names = imageManager.Query(CategoryLower);
			if (!string.IsNullOrEmpty(request.Keyword)) {
				names = names.Where(name => name.Contains(request.Keyword)).ToList();
			}
			var response = new AjaxTableSearchResponse();
			var result = response.Pagination.Paging(request, names.AsQueryable());
			// 返回搜索结果
			response.PageNo = request.PageNo;
			response.PageSize = request.PageSize;
			response.Rows.AddRange(result.Select(name => {
				var path = imageManager.GetImageWebPath(
					CategoryLower, name, imageManager.ImageExtension);
				var thumbnailPath = imageManager.GetImageWebPath(
					CategoryLower, name, imageManager.ImageThumbnailExtension);
				var storageFile = imageManager.GetImageStorageFile(
					CategoryLower, name, imageManager.ImageExtension);
				var lastWriteTime = storageFile.LastWriteTimeUtc.ToClientTimeString();
				var fileSize = FileUtils.GetSizeDisplayName(storageFile.Length);
				return new Dictionary<string, object>() {
					{ "name", name },
					{ "path", path },
					{ "thumbnailPath", thumbnailPath },
					{ "lastWriteTime", lastWriteTime },
					{ "fileSize", fileSize }
				};
			}));
			return new JsonResult(response);
		}
        public IActionResult AjaxTableSearch()
        {
            var json      = Request.Get <string>("json");
            var request   = AjaxTableSearchRequest.FromJson(json);
            var callbacks = new ExampleAjaxTableHandler().WithExtraHandlers();
            var response  = request.BuildResponse(callbacks);

            return(new JsonResult(response));
        }
        public IActionResult Ratings(Guid id)
        {
            var json     = Request.Get <string>("json");
            var request  = AjaxTableSearchRequest.FromJson(json);
            var handlers = new ProductRatingTableHandler().WithExtraHandlers();
            var response = request.BuildResponse(handlers);

            return(new JsonResult(response));
        }
        protected virtual IActionResult SearchAction()
        {
            // 获取参数并转换到搜索请求
            var json    = Request.Get <string>("json");
            var request = AjaxTableSearchRequest.FromJson(json);
            // 表格处理器,内置+使用Ioc注册的扩展回调
            var handlers = GetTableHandler().WithExtraHandlers();
            // 构建搜索回应
            var response = request.BuildResponse(handlers);

            return(new JsonResult(response));
        }
Esempio n. 5
0
        /// <summary>
        /// 搜索请求的处理函数
        /// </summary>
        /// <returns></returns>
        protected virtual IActionResult SearchAction()
        {
            // 检查权限
            var privilegeManager = Application.Ioc.Resolve <PrivilegeManager>();

            privilegeManager.Check(AllowedUserTypes, ViewPrivileges);
            // 获取参数并转换到搜索请求
            var json    = HttpManager.CurrentContext.Request.Get <string>("json");
            var request = AjaxTableSearchRequest.FromJson(json);
            // 表格回调,内置+使用Ioc注册的扩展回调
            var callbacks = GetTableCallback().WithExtensions();
            // 构建搜索回应
            var response = request.BuildResponseFromDatabase(callbacks);

            return(new JsonResult(response));
        }
        /// <summary>
        /// 搜索请求的处理函数
        /// </summary>
        /// <returns></returns>
        protected override IActionResult SearchAction()
        {
            // 检查权限
            var privilegeManager = Application.Ioc.Resolve <PrivilegeManager>();

            privilegeManager.Check(AllowedUserTypes, RequiredPrivileges);
            // 获取参数并转换到搜索请求
            var json    = HttpManager.CurrentContext.Request.Get <string>("json");
            var request = AjaxTableSearchRequest.FromJson(json);
            // 构建搜索回应
            var query = Translates.Select(t => new Translation()
            {
                Original = t.Key, Translated = t.Value
            });

            if (!string.IsNullOrEmpty(request.Keyword))
            {
                query = query.Where(q => q.Original.Contains(request.Keyword) || q.Translated.Contains(request.Keyword));
            }
            var response = new AjaxTableSearchResponse();
            var result   = response.Pagination.Paging(request, query.AsQueryable());

            response.PageNo   = request.PageNo;
            response.PageSize = request.PageSize;
            response.Rows.AddRange(result.Select(translation => new Dictionary <string, object>()
            {
                { "Id", HttpUtils.UrlEncode(translation.Original) },
                { "OriginalText", translation.Original },
                { "TranslatedText", translation.Translated },
                { "ToString", translation.ToString() }
            }));
            response.Columns.AddNoColumn();
            response.Columns.AddMemberColumn("OriginalText");
            response.Columns.AddMemberColumn("TranslatedText");
            var actionColumn = response.Columns.AddActionColumn("130");

            actionColumn.AddEditAction("Translation", EditUrl, dialogParameters: new { size = "size-wide" });
            actionColumn.AddDeleteAction("Translation", DeleteUrl);
            return(new JsonResult(response));
        }
        /// <summary>
        /// 搜索请求的处理函数
        /// </summary>
        /// <returns></returns>
        protected override IActionResult SearchAction()
        {
            var json    = Request.Get <string>("json");
            var request = AjaxTableSearchRequest.FromJson(json);
            var query   = Translates.Select(t =>
                                            new CustomTranslation()
            {
                Id = t.Key, Translated = t.Value
            });

            if (!string.IsNullOrEmpty(request.Keyword))
            {
                query = query.Where(q =>
                                    q.Id.Contains(request.Keyword) || q.Translated.Contains(request.Keyword));
            }
            var response = new AjaxTableSearchResponse();
            var result   = response.Pagination.Paging(request, query.AsQueryable());

            response.PageNo   = request.PageNo;
            response.PageSize = request.PageSize;
            response.Rows.AddRange(result.Select(translation => new Dictionary <string, object>()
            {
                { "Id", HttpUtils.UrlEncode(translation.Id) },
                { "OriginalText", translation.Id },
                { "TranslatedText", translation.Translated },
                { "ToString", translation.ToString() }
            }));
            response.Columns.AddNoColumn();
            response.Columns.AddMemberColumn("OriginalText");
            response.Columns.AddMemberColumn("TranslatedText");
            var actionColumn = response.Columns.AddActionColumn("130");

            actionColumn.AddEditAction("Translation", EditUrl, dialogParameters: new { size = "size-wide" });
            actionColumn.AddDeleteAction("Translation", DeleteUrl);
            return(new JsonResult(response));
        }