Beispiel #1
0
        public void Search()
        {
            var function = new FunctionSearch();
            var context  = new TestLambdaContext();
            var request  = new QueryModel
            {
                PetType = (int)PetType.Cat,
                PetAge  = (int)PetAge.Baby,
                Color   = "preto",
                id      = "cwZJOWsBfKkxXf3ETJ4k"
            };
            var apiGateway = new APIGatewayProxyRequest
            {
                HttpMethod = "POST",
                Path       = "search",
                Body       = JsonConvert.SerializeObject(request),
                Headers    = new Dictionary <string, string>()
                {
                    { "Content-Type", "application/json" }
                }
            };
            var _return = function.FunctionHandler(apiGateway, context);

            Assert.Equal(200, _return.StatusCode);
        }
        public async Task <IActionResult> List(long?parentId, int page = 1, int rows = 10)
        {
            var search = new FunctionSearch();

            search.ParentId = parentId;
            var data = await _service.GetListAsync(page, rows, search, null);

            return(PagerData(data.items, page, rows, data.count));
        }
Beispiel #3
0
        internal IReadOnlyList <INamedItemInfo> LoadFunctionInfoFromPackageHelpIndex()
        {
            List <INamedItemInfo> functions = new List <INamedItemInfo>();
            string content = null;

            try {
                string htmlFile = Path.Combine(this.InstallPath, this.Name, "html", "00index.html");
                if (File.Exists(htmlFile))
                {
                    using (StreamReader sr = new StreamReader(htmlFile, Encoding.UTF8)) {
                        content = sr.ReadToEnd();
                    }
                }
            } catch (IOException) { }

            if (!string.IsNullOrEmpty(content))
            {
                HtmlTree tree = new HtmlTree(new TextStream(content));
                tree.Build();

                FunctionSearch functionSearch = new FunctionSearch(functions);
                tree.Accept(functionSearch, null);
            }

            Dictionary <string, INamedItemInfo> functionIndex = new Dictionary <string, INamedItemInfo>();

            foreach (INamedItemInfo ni in functions)
            {
                functionIndex[ni.Name] = ni;
            }

            IReadOnlyDictionary <string, string> mappedNames = GetMappedNames();

            foreach (string mappedName in mappedNames.Keys)
            {
                INamedItemInfo ni;
                string         actualName = mappedNames[mappedName];
                if (functionIndex.TryGetValue(actualName, out ni))
                {
                    INamedItemInfo niAlias = new NamedItemInfo()
                    {
                        Name        = mappedName,
                        Description = ni.Description,
                        ItemType    = ni.ItemType
                    };
                    functions.Add(niAlias);
                }
            }

            return(functions);
        }
Beispiel #4
0
        public PageResult <FunctionModel> GetSearchPaging(FunctionSearch search)
        {
            var query = _functionRepository.FindAll();

            //if (search.Id > 0)
            //{
            //    query = query.Where(r => r.Id == search.Id);
            //}

            //if (!string.IsNullOrEmpty(search.Name))
            //{
            //    query = query.Where(r => r.Name.Contains(search.Name));
            //}
            //if (!string.IsNullOrEmpty(search.Description))
            //{
            //    query = query.Where(r => r.Description.Contains(search.Description));
            //}

            var Total = query.Count();

            var data = query
                       .OrderByDescending(f => f.CreatedDate)
                       .Skip((search.PageIndex - 1) * search.PageSize)
                       .Take(search.PageSize)
                       .Select(f => f.ToModel())
                       .ToList();

            foreach (var item in data)
            {
                if (item.ParentId != null && item.ParentId > 0)
                {
                    var nameParent = data.Where(f => f.Id == item.ParentId).FirstOrDefault().Name;
                    item.NameParent = nameParent;
                }
            }

            var result = new PageResult <FunctionModel>()
            {
                Results   = data,
                PageIndex = search.PageIndex,
                PageSize  = search.PageSize,
                Total     = Total,
            };

            return(result);
        }
Beispiel #5
0
        public IActionResult GetPaging(FunctionSearch search)
        {
            var model = _functionService.GetSearchPaging(search);

            return(new OkObjectResult(model));
        }
Beispiel #6
0
        internal IReadOnlyList<INamedItemInfo> LoadFunctionInfoFromPackageHelpIndex() {
            List<INamedItemInfo> functions = new List<INamedItemInfo>();
            string content = null;

            try {
                string htmlFile = Path.Combine(this.InstallPath, this.Name, "html", "00index.html");
                if (File.Exists(htmlFile)) {
                    using (StreamReader sr = new StreamReader(htmlFile, Encoding.UTF8)) {
                        content = sr.ReadToEnd();
                    }
                }
            } catch (IOException) { }

            if (!string.IsNullOrEmpty(content)) {
                HtmlTree tree = new HtmlTree(new Microsoft.Web.Core.Text.TextStream(content));
                tree.Build();

                FunctionSearch functionSearch = new FunctionSearch(functions);
                tree.Accept(functionSearch, null);
            }

            Dictionary<string, INamedItemInfo> functionIndex = new Dictionary<string, INamedItemInfo>();
            foreach (INamedItemInfo ni in functions) {
                functionIndex[ni.Name] = ni;
            }

            IReadOnlyDictionary<string, string> mappedNames = GetMappedNames();
            foreach (string mappedName in mappedNames.Keys) {
                INamedItemInfo ni;
                string actualName = mappedNames[mappedName];
                if (functionIndex.TryGetValue(actualName, out ni)) {
                    INamedItemInfo niAlias = new NamedItemInfo() {
                        Name = mappedName,
                        Description = ni.Description,
                        ItemType = ni.ItemType
                    };
                    functions.Add(niAlias);
                }
            }

            return functions;
        }
Beispiel #7
0
        public async Task <IActionResult> OnPostDataAsync(int page, int rows, FunctionSearch where)
        {
            var data = await _service.GetListAsync(page, rows, where, null);

            return(PagerData(data.items, page, rows, data.count));
        }