Advertisement
Guest User

codebotsharpweb

a guest
Nov 17th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using System.Web.SessionState;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Data;
  9. using System.Data.Common;
  10. using Codebot.Web;
  11. using Codebot.Data;
  12. using Codebot.Runtime;
  13.  
  14. namespace Codebot.Lazaurs.Web.Docs
  15. {
  16.     /* When IsTemplate is true the page will attempt to substitute values */
  17.     [DefaultPage("/index.html", IsTemplate = false), Logged]
  18.     public class HomePage : Codebot.Web.PageHandler
  19.     {
  20.         /* Sql scripts are reusable resources */
  21.         private static string logHitSql = "loghit.sql".LoadResourceText();
  22.  
  23.         /* A named method invoked to record selections from the drop down
  24.          * It is used to later rank the results */
  25.         [MethodPage("hit")]
  26.         public void InvokeHit()
  27.         {
  28.             /* Validate the input */
  29.             var path = Read("path").Trim();
  30.             if (path.Length < 3)
  31.                 return;
  32.             /* Save the hit returning nothing */
  33.             DataCommand.Prepare(logHitSql)
  34.                 .Add("@path", path)
  35.                 .ExecuteNonQuery();
  36.         }
  37.  
  38.  
  39.         /* A named method invoked when the user does a search */
  40.         [MethodPage("codesearch")]
  41.         public void InvokeCodeSearch()
  42.         {
  43.             /* Delegate this method to a template page */
  44.             WriteTemplate<CodeSearchTemplate>();
  45.         }
  46.  
  47.         /* Run returns default page if no ajax method is specified */
  48.         protected override void Run()
  49.         {
  50.             /* Record the number of requests in a simple text file */
  51.             if (IsPlainRequest && IsHuman)
  52.             {
  53.                 string filename = MapPath("hits.txt");
  54.                 int hits = 1;
  55.                 if (File.Exists(filename))
  56.                 {
  57.                     int.TryParse(File.ReadAllText(filename), out hits);
  58.                     hits++;
  59.                 }
  60.                 File.WriteAllText(filename, hits.ToString());
  61.             }
  62.             /* Write out the template or the default page */
  63.             base.Run();
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement