2 using System
.Collections
.Generic
;
5 using System
.Web
.Security
;
6 using System
.Web
.SessionState
;
7 using PumpkinHouseDatabase
;
8 using System
.Configuration
;
10 using PumpkinHouse
.Utils
;
13 namespace PumpkinHouse
15 public class Global
: System
.Web
.HttpApplication
17 void Application_Start(object sender
, EventArgs e
)
20 XmlConfigurator
.Configure();
22 // Configure Email Client
23 MailClient
.LoadConfiguration(System
.AppDomain
.CurrentDomain
.BaseDirectory
.ToString() + ConfigurationManager
.AppSettings
["mail.Config"]);
25 // Init Keyword Filter List
26 KeywordFilterHelper
.LoadKeywords(System
.AppDomain
.CurrentDomain
.BaseDirectory
.ToString() + "data\\keywords.txt");
28 // Code that runs on application startup
29 DataUtils
.ConnectionString
= ConfigurationManager
.ConnectionStrings
["DatabaseConnectionString"].ConnectionString
;
31 ImageHelper
.ImageFilesRootPath
= ConfigurationManager
.AppSettings
["imageRootFolder"];
32 ImageHelper
.ProfilePhotoRootFolder
= ConfigurationManager
.AppSettings
["profilePhotoRootFolder"];
34 KeywordHelper
.GetKeywords(false);
37 void Application_End(object sender
, EventArgs e
)
39 // Code that runs on application shutdown
43 void Application_Error(object sender
, EventArgs e
)
45 // Code that runs when an unhandled error occurs
49 void Session_Start(object sender
, EventArgs e
)
51 // Code that runs when a new session is started
52 if (string.IsNullOrEmpty(Session
["username"] as string) && Context
.User
.Identity
.Name
!= "")
54 using (DataUtils utils
= new DataUtils())
56 DB_User user
= utils
.FindUserByEmail(Context
.User
.Identity
.Name
);
59 user
= utils
.FindUserByUsername(Context
.User
.Identity
.Name
);
63 Session
["username"] = user
.Username
;
65 foreach (var aa
in user
.DB_Account_Association
)
67 if (aa
.Token_Expire_Time
> DateTime
.Now
)
74 FormsAuthentication
.SignOut();
76 Response
.Redirect("/Account/Login.aspx");
82 void Session_End(object sender
, EventArgs e
)
84 // Code that runs when a session ends.
85 // Note: The Session_End event is raised only when the sessionstate mode
86 // is set to InProc in the Web.config file. If session mode is set to StateServer
87 // or SQLServer, the event is not raised.