Advertisement
Guest User

Codebot.Web Cloud File Manager HomePage

a guest
Mar 31st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using Codebot.Web;
  2.  
  3. namespace Codebot.Blob.Web
  4. {
  5.     public class HomePage : PageHandler
  6.     {
  7.         private FileManager manager;
  8.         public Global App { get { return Context.ApplicationInstance as Global; } }
  9.         public FileUser User { get { return Context.User as FileUser; } }
  10.        
  11.         protected override void Run()
  12.         {
  13.             manager = new FileManager(this);
  14.             base.Run();
  15.         }
  16.  
  17.         protected override void EmptyPage()
  18.         {
  19.             var url = PathAndQuery;
  20.             if (url.Path == "/" || url.Path == "/home.ashx")
  21.             {
  22.                 ContentType = "text/html";
  23.                 if (User.IsAnonymous)
  24.                     Include("/pages/login.html", true);
  25.                 else
  26.                     Include("/pages/manager.html", true);
  27.                 return;
  28.             }
  29.             manager.ProcessPage(url);
  30.         }
  31.  
  32.         private void WriteStatus(bool passed)
  33.         {
  34.             Write(passed ? "OK" : "FAIL");
  35.         }
  36.  
  37.         [MethodPage("login")]
  38.         public void LoginMethod()
  39.         {
  40.             var status = User.Login(App, Read("name"), Read("password"), Request.UserAgent);
  41.             WriteStatus(status);
  42.         }
  43.  
  44.         [MethodPage("logout")]
  45.         public void LogoutMethod()
  46.         {
  47.             User.Logout(App);
  48.             Redirect("/");
  49.         }
  50.  
  51.         [MethodPage("adduser")]
  52.         public void AddUserMethod()
  53.         {
  54.             var status =App.AddUser(Read("name"), Read("password"));
  55.             WriteStatus(status);
  56.         }
  57.  
  58.         [MethodPage("deleteuser")]
  59.         public void DeleteUserMethod()
  60.         {
  61.             var status = App.DeleteUser(Read("name");
  62.             WriteStatus(status);
  63.         }
  64.  
  65.         [MethodPage("files")]
  66.         public void FilesMethod()
  67.         {
  68.             manager.ProcessAction();
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement