Exemple #1
0
        void DisplayQueryResults()
        {
            if (string.IsNullOrEmpty(_query.Value))
            {
                return;
            }

            try
            {
                Result r         = ApplicationIndex.Query(_query.Value, _revFirst.Value, _revLast.Value, IsPostBack);
                string htmlQuery = Server.HtmlEncode(r.Query);
                _hitsLabel.Text       = string.Format("<b>{0}</b> hits for <b>{1}</b>", r.Hits.Count, htmlQuery);
                _statisticsLabel.Text =
                    string.Format("<span style='color:#808080'>{0} documents searched in {1}ms. Index revision {2}</span>",
                                  r.Index.TotalCount, (int)r.SearchTime.TotalMilliseconds, r.Index.Revision);

                _dataPager.Visible = (_dataPager.MaximumRows < r.Hits.Count);
                // Reset to page 0
                if (!IsPostBack)
                {
                    _dataPager.SetPageProperties(0, _dataPager.MaximumRows, true);
                }
                _resultsPanel.Visible = true;
            }
            catch (Exception x)
            {
                _messsageLabel.Text =
                    "An error occured. Most probably your query has some wildcards that lead to too many results. Try narrowing down your query.</br></br><b>Details: </b>" +
                    "<pre>" + x + "</pre>";
                _messsageLabel.Visible = true;
            }
        }
Exemple #2
0
        protected void DownloadTargets_Click(object sender, EventArgs e)
        {
            Response.ContentType = "application/x-msdownload";
            string time = DateTime.Now.ToString("s").Replace(':', '-').Replace('T', '-');

            Response.AppendHeader("content-disposition", "attachment; filename=QueryResults_" + time + ".txt");

            var result = ApplicationIndex.Query(_query.Value, _revFirst.Value, _revLast.Value, true);

            foreach (Hit hit in result.Hits.OrderBy(hit => hit.Path, StringComparer.InvariantCultureIgnoreCase))
            {
                Response.Write(result.Index.RepositoryExternalUri + hit.Path + Environment.NewLine);
            }
            Response.End();
        }
Exemple #3
0
        protected void DownloadResults_Click(object sender, EventArgs e)
        {
            Response.ContentType = "application/x-msdownload";
            string time = DateTime.Now.ToString("s").Replace(':', '-').Replace('T', '-');

            Response.AppendHeader("content-disposition", "attachment; filename=QueryResults_" + time + ".tsv");

            Response.Write(Join("Path", "File", "Author", "Modified", "Revision", "Size"));
            var result = ApplicationIndex.Query(_query.Value, _revFirst.Value, _revLast.Value, true);

            foreach (Hit hit in result.Hits.OrderBy(hit => hit.Path, StringComparer.InvariantCultureIgnoreCase))
            {
                Response.Write(Join(hit.Path, hit.File, hit.Author, hit.LastModification.ToString("g"), hit.RevisionFirst, hit.SizeInBytes.ToString()));
            }
            Response.End();
        }