Example #1
0
        public static bool MatchBody(SqlIndex sqlIndex, string search, params Func <searchOpt, searchOpt>[] opts)
        {
            var opt = new searchOpt
            {
                regex           = false,
                word            = false,
                includesCaption = false,
            };

            foreach (var optfunc in opts)
            {
                opt = optfunc(opt);
            }

            if (SqlMacher.General(sqlIndex.Sql, search, opt) >= 0)
            {
                return(true);
            }

            if (opt.includesCaption && SqlMacher.General(sqlIndex.Title, search, opt) >= 0)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
        private SqlIndex map2index(Dictionary <string, string> map)
        {
            var idx = new SqlIndex();

            idx.CreateAt = new DateTime();

            idx.Sql = Read(map, "sql") ?? "";

            var titles = (new List <string> {
                Read(map, "tag1") ?? "", Read(map, "tag2") ?? "", Read(map, "tag3") ?? ""
            }).Where(t => t != "").ToList();

            idx.Title = string.Join("-", titles);

            return(idx);
        }
Example #3
0
        public List <SqlIndex> FromCsv(Stream input)
        {
            var list   = new List <SqlIndex>();
            var reader = new CsvReader(input);
            var parser = new CsvParser();

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                var cols = parser.ParseLine(line);

                SqlIndex idx = new SqlIndex();
                idx.Title = cols.Count >= 1 ? cols[0] : "";
                idx.Sql   = cols.Count >= 2 ? cols[1] : "";

                list.Add(idx);
            }
            return(list);
        }