Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text.RegularExpressions;
- using System.Text;
- using System.Web.SessionState;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- using System.Data.Common;
- using Codebot.Web;
- using Codebot.Data;
- using Codebot.Runtime;
- namespace Codebot.Lazaurs.Web.Docs
- {
- /* When IsTemplate is true the page will attempt to substitute values */
- [DefaultPage("/index.html", IsTemplate = false), Logged]
- public class HomePage : Codebot.Web.PageHandler
- {
- /* Sql scripts are reusable resources */
- private static string logHitSql = "loghit.sql".LoadResourceText();
- /* A named method invoked to record selections from the drop down
- * It is used to later rank the results */
- [MethodPage("hit")]
- public void InvokeHit()
- {
- /* Validate the input */
- var path = Read("path").Trim();
- if (path.Length < 3)
- return;
- /* Save the hit returning nothing */
- DataCommand.Prepare(logHitSql)
- .Add("@path", path)
- .ExecuteNonQuery();
- }
- /* A named method invoked when the user does a search */
- [MethodPage("codesearch")]
- public void InvokeCodeSearch()
- {
- /* Delegate this method to a template page */
- WriteTemplate<CodeSearchTemplate>();
- }
- /* Run returns default page if no ajax method is specified */
- protected override void Run()
- {
- /* Record the number of requests in a simple text file */
- if (IsPlainRequest && IsHuman)
- {
- string filename = MapPath("hits.txt");
- int hits = 1;
- if (File.Exists(filename))
- {
- int.TryParse(File.ReadAllText(filename), out hits);
- hits++;
- }
- File.WriteAllText(filename, hits.ToString());
- }
- /* Write out the template or the default page */
- base.Run();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement