Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HitViewModel hitViewModel = ApplicationIndex.GetHitById(Context.Request.QueryString["id"]);
            string       path         = hitViewModel.Path;
            int          revision     = hitViewModel.Revision;

            // getting _properties from the index
            Title               = path.Substring(path.LastIndexOf('/') + 1);
            _header.InnerText   = path;
            _author.InnerText   = hitViewModel.Author;
            _modified.InnerText = hitViewModel.LastModification;
            if (hitViewModel.MaxSize > 0)
            {
                _size.InnerText = hitViewModel.Size;
            }
            else
            {
                _sizeRow.Visible = false;
            }
            _revisions.InnerText = hitViewModel.RevFirst + " - " + hitViewModel.RevLast;

            // getting _properties from subversion
            _message.InnerText = Svn.GetLogMessage(revision);

            if (path[0] == '$')
            {
                return;                 // Revision Log
            }
            bool binary = InitProperties(Svn.GetPathProperties(path, revision));

            if (hitViewModel.MaxSize > 512 * 1024)
            {
                _contentWarning.InnerText = "Content size is too big to display";
            }
            else if (binary)
            {
                _contentWarning.InnerText = "Content type is binary";
            }
            else if (hitViewModel.MaxSize > 0)
            {
                _content.InnerText = Svn.GetPathContent(path, revision, hitViewModel.MaxSize);

                var syntaxHighlighter = new SyntaxHighlightBrushMapper(path);
                if (syntaxHighlighter.IsAvailable)
                {
                    AddScriptInclude(syntaxHighlighter.GetScript());
                    AddStartupScript();
                    _content.Attributes.Add("class", syntaxHighlighter.GetClass());
                }
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
        }