Global.asax 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <%@ Application Language="C#" %>
  2. <%@ Import Namespace="Castle.ActiveRecord" %>
  3. <%@ Import Namespace="Castle.ActiveRecord.Framework.Config" %>
  4. <%@ Import Namespace="BizCom" %>
  5. <%@ Import Namespace="Utils" %>
  6. <%@ Import Namespace="System.Threading" %>
  7. <script RunAt="server">
  8. System.Threading.Timer gtimer;
  9. void Application_Start(object sender, EventArgs e)
  10. {
  11. //log4net.Config.XmlConfigurator.Configure();
  12. // Code that runs on application startup
  13. InPlaceConfigurationSource source = new InPlaceConfigurationSource();
  14. System.Collections.Generic.IDictionary<string, string> properties = new System.Collections.Generic.Dictionary<string, string>();
  15. properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
  16. properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle");
  17. properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect");
  18. properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
  19. string conn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
  20. properties.Add("connection.connection_string", SecurityHelper.DecryptSymmetric(conn));
  21. source.Add(typeof(ActiveRecordBase), properties);
  22. source.IsRunningInWebApp = true;
  23. //IConfigurationSource source =ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
  24. Type[] acTypes = new[]
  25. {
  26. typeof(CeErpTrade),
  27. typeof(CeErpTradeCell),
  28. typeof(XLog),
  29. typeof(CeErpTradeLog),
  30. typeof(CeErpDataSendOrderInfo),
  31. };
  32. ActiveRecordStarter.Initialize(source, acTypes);
  33. }
  34. void global_elapsed(object state)
  35. {
  36. }
  37. void Application_End(object sender, EventArgs e)
  38. {
  39. // Code that runs on application shutdown
  40. }
  41. void Application_BeginRequest(Object sender, EventArgs e)
  42. {
  43. }
  44. void Application_Error(object sender, EventArgs e)
  45. {
  46. // Code that runs when an unhandled error occurs
  47. //if (config.Instance.Site.SpiderIp.Contains(CommonHelper.ClientIP))return;
  48. //SyLog.WriteLog(Server.GetLastError());
  49. }
  50. void Session_Start(object sender, EventArgs e)
  51. {
  52. // Code that runs when a new session is started
  53. }
  54. void Session_End(object sender, EventArgs e)
  55. {
  56. // Code that runs when a session ends.
  57. // Note: The Session_End event is raised only when the sessionstate mode
  58. // is set to InProc in the Web.config file. If session mode is set to StateServer
  59. // or SQLServer, the event is not raised.
  60. }
  61. </script>