Exemplo n.º 1
0
        protected override bool ServiceAction(object args)
        {
            var query = args as ISearchQuery;

            if (query == null)
            {
                return(false);
            }

            var sql = SearchQuerySqlFactory.GetSql(query);

            sql += $" SELECT id FROM {SearchQuerySqlFactory.TableName} LIMIT {query.ResultLimit};";

            Debug.WriteLine(sql);

            var result = Repository.Connection.Query(sql);

            ReportProgress(0, query.ResultLimit);

            var i = 0;

            while (result.Read())
            {
                ReportProgress(i++, query.ResultLimit, Repository.Find(result["id"].ToString()));
            }
            return(true);
        }
Exemplo n.º 2
0
        protected override bool ServiceAction(object args)
        {
            var query = args as ISearchQuery;

            if (query == null)
            {
                return(false);
            }

            var sql = SearchQuerySqlFactory.GetSql(query);

            var where = "";
            if (query.SelectedTags.Count > 0)
            {
                var filterList = "'" + string.Join("', '", query.SelectedTags.Select(tag => tag.Text)) + "'";

                where = $"WHERE content NOT IN ({filterList}) ";
            }

            sql +=
                $"SELECT content, count(content) as weight FROM Tag JOIN {SearchQuerySqlFactory.TableName} ON {SearchQuerySqlFactory.TableName}.id = Tag.business_object {where} GROUP BY content ORDER BY COUNT(content) DESC LIMIT {query.TagLimit};";
            var tagReader = Connection.Query(sql);



            Debug.WriteLine(sql);
            var i = 0;

            ReportProgress(i, query.TagLimit);
            while (tagReader.Read())
            {
                ReportProgress(i++, query.TagLimit, new Tag {
                    Text = tagReader["content"].ToString(), Weight = Convert.ToInt32(tagReader["weight"])
                });
            }

            return(true);
        }