コード例 #1
0
        /// <summary>
        /// 根据查询条件搜索日志信息
        /// </summary>
        /// <param name="searchKeys">搜索条件</param>
        /// <param name="users"></param>
        /// <returns></returns>
        public async Task <IEnumerable <SystemLogInfo> > Find(SearchKeys searchKeys, IEnumerable <User> users)
        {
            var filter = Builders <SystemLogInfo> .Filter;
            FilterDefinition <SystemLogInfo> temp = filter.Empty;
            string keyword  = searchKeys.Keyword;
            string sTime    = searchKeys.STime;
            string eTime    = searchKeys.ETime;
            int    page     = searchKeys.page;
            int    pagesize = searchKeys.pagesize;

            // 关键字作为查询条件
            if (!String.IsNullOrEmpty(keyword))
            {
                temp = filter.And(temp, filter.Or(filter.Regex("User", keyword), filter.Regex("IP", keyword), filter.Regex("LogInfo", keyword)));
            }
            // 时间作为查询条件
            if (!String.IsNullOrEmpty(sTime))
            {
                temp = filter.And(temp, filter.Gte("LogTime", sTime + " 00:00:01"));
            }
            if (!String.IsNullOrEmpty(eTime))
            {
                temp = filter.And(temp, filter.Lte("LogTime", eTime + " 23:59:59"));
            }
            // 部门作为查询条件
            if (!(users is null))
            {
                temp = filter.And(temp, filter.In("User", users.Select(u => u.LoginName)));
            }

            return(await this.db.Find <SystemLogInfo>(temp).Skip((page - 1) * pagesize).Limit(pagesize).ToListAsync());
        }
コード例 #2
0
 public object Any(SearchKeys request)
 {
     return(new SearchKeysResponse
     {
         Keys = new ArrayOfString(Redis.SearchKeys(request.Pattern))
     });
 }
コード例 #3
0
        public void Post(SearchKeys searchKey)
        {
            switch (searchKey.SearchType)
            {
            case "Title":
                reviews = new List <Review>(PrincessDb.searchReviewByTitle(searchKey.SearchString));
                break;

            case "Domain":
                reviews = new List <Review>(PrincessDb.searchReviewByDomain(searchKey.SearchString));
                break;

            case "Writer":
                reviews = new List <Review>(PrincessDb.searchReviewByWriter(searchKey.SearchString));
                break;

            default:
                reviews = new List <Review>(PrincessDb.searchReviewByTitle(searchKey.SearchString));
                break;
            }

            for (int i = 0; i < reviews.Count(); i++)
            {
                rev.Add(new ReviewFormat
                {
                    Url        = reviews.ElementAt(i).getUrl(),
                    Title      = reviews.ElementAt(i).getTitle(),
                    Rating     = reviews.ElementAt(i).getRating(),
                    ReviewText = reviews.ElementAt(i).getReviewText(),
                    Writer     = reviews.ElementAt(i).getWriter(),
                    DomainUrl  = reviews.ElementAt(i).getDomainUrl(),
                });
            }

            string JSONresult = JsonConvert.SerializeObject(rev);
            string path       = @"C:\PRINCESS\PRINCESS\princess\src\components\JsonData\reviews.json";

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
                using (var tw = new StreamWriter(path, true))
                {
                    tw.WriteLine(JSONresult.ToString());
                    tw.Close();
                }
            }
            else if (!System.IO.File.Exists(path))
            {
                using (var tw = new StreamWriter(path, true))
                {
                    tw.WriteLine(JSONresult.ToString());
                    tw.Close();
                }
            }

            Console.WriteLine(reviews);
            //PrincessDb.disconnect();
        }
コード例 #4
0
    public static DataTable GetCamperApplicationsWithSearchCriteria(int CampYearID, SearchKeys SearchKey, string SearchText)
    {
        SQLDBAccess db = new SQLDBAccess("CIPMS");

        db.AddParameter("@Action", "SearchCamperApps");
        db.AddParameter("@CampYearID", CampYearID);

        string SearchQuery = "";

        if (SearchKey == SearchKeys.Name)
        {
            if (SearchText.Contains(" "))
            {
                string[] names = SearchText.Split(new char[] { });
                SearchQuery = "LastName LIKE '%" + names[1] + "%' AND FirstName LIKE '%" + names[0] + "%'";
            }
            else
            {
                SearchQuery = "LastName LIKE '%" + SearchText + "%' OR FirstName LIKE '%" + SearchText + "%'";
            }
        }
        else if (SearchKey == SearchKeys.Address)
        {
            SearchQuery = "ADDRESS LIKE '%" + SearchText + "%'";
        }
        else if (SearchKey == SearchKeys.Email)
        {
            SearchQuery = "Email LIKE '%" + SearchText + "%'";
        }
        else if (SearchKey == SearchKeys.BirthDate)
        {
            DateTime myDate;
            try
            {
                myDate = DateTime.Parse(SearchText);
            }
            catch
            {
                myDate = DateTime.Now;
            }
            SearchQuery = "DateOfBirth = '" + myDate.ToShortDateString() + "'";
        }

        db.AddParameter("@SearchQueryText", SearchQuery);
        return(db.FillDataTable("usprsCamperApplications_Select"));
    }
コード例 #5
0
        public void Post(SearchKeys searchKey)
        {
            switch (searchKey.SearchType)
            {
            case "Title":
                reviews = new List <Review>(PrincessDb.searchReviewByTitle(searchKey.SearchString, searchKey.SortBy));
                break;

            case "Domain":
                reviews = new List <Review>(PrincessDb.searchReviewByDomain(searchKey.SearchString, searchKey.SortBy));
                break;

            case "Writer":
                reviews = new List <Review>(PrincessDb.searchReviewByWriter(searchKey.SearchString, searchKey.SortBy));
                break;

            default:
                reviews = new List <Review>(PrincessDb.searchReviewByTitle(searchKey.SearchString, searchKey.SortBy));
                break;
            }

            string JSONresult = JsonConvert.SerializeObject(reviews);
            string path       = @"C:\PRINCESS\PRINCESS\princess\src\components\JsonData\reviews.json";

            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
                using (var tw = new StreamWriter(path, true))
                {
                    tw.WriteLine(JSONresult.ToString());
                    tw.Close();
                }
            }
            else if (!System.IO.File.Exists(path))
            {
                using (var tw = new StreamWriter(path, true))
                {
                    tw.WriteLine(JSONresult.ToString());
                    tw.Close();
                }
            }
        }
コード例 #6
0
        public ActionResult <ICollection <ArtistDto> > Get(SearchKeys key, string value)
        {
            try
            {
                switch (key)
                {
                case SearchKeys.Genre:
                    return(Ok(_artistBll.GetByGenre(value).Select(a => new ArtistDto().MapFromModel(a)).ToList()));

                case SearchKeys.Country:
                    return(Ok(_artistBll.GetByCountry(value).Select(a => new ArtistDto().MapFromModel(a)).ToList()));

                default:
                    throw new ArgumentOutOfRangeException(nameof(key), key, null);
                }
            }
            catch (ArgumentOutOfRangeException exception)
            {
                Console.Write(exception.Message);
                return(NotFound());
            }
        }
コード例 #7
0
        public void ShouldDeserialize(string json, SearchKeys expected)
        {
            var values = JsonConvert.DeserializeObject <SearchKeys>(json);

            Assert.AreEqual(expected, values);
        }
コード例 #8
0
        public void ShouldSerialize(SearchKeys values, string expected)
        {
            var json = JsonConvert.SerializeObject(values);

            Assert.AreEqual(expected, json);
        }
コード例 #9
0
 protected object SearchValue(SearchKeys key)
 {
     return(SearchValue(key.ToString()));
 }