活动页面添加参赛作品瀑布流
[PumpkinHouse.git] / PumpkinHouseWeb / Global.asax.cs
blobf9c2eafd9582981274a93ee4f9080caecf6398e9
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Web;
5 using System.Web.Security;
6 using System.Web.SessionState;
7 using PumpkinHouseDatabase;
8 using System.Configuration;
9 using log4net.Config;
10 using PumpkinHouse.Utils;
11 using Mail;
13 namespace PumpkinHouse
15 public class Global : System.Web.HttpApplication
17 void Application_Start(object sender, EventArgs e)
19 // Configure Log4Net
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);
57 if (user == null)
59 user = utils.FindUserByUsername(Context.User.Identity.Name);
61 if (user != null)
63 Session["username"] = user.Username;
65 foreach (var aa in user.DB_Account_Association)
67 if (aa.Token_Expire_Time > DateTime.Now)
72 else
74 FormsAuthentication.SignOut();
75 Session.Abandon();
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.