protected void Prepared() { //获取业务服务程序集 Assembly businessdll = Assembly.Load("EarlySite.Business"); //获取业务服务程序集 Assembly cachedll = Assembly.Load("EarlySite.Cache"); //注册业务服务程序集 ServiceObjectContainer.Load(businessdll); ServiceObjectContainer.Load(cachedll); Thread work = Thread.CurrentThread; lock (work) { if (WorkThreadDictionary.Get(work) == null) { WorkThreadDictionary.Create(Thread.CurrentThread); //EarlySite.Cache.Session.Deployment(); EarlySite.Cache.Session.DeploymentForWeb(); } } //加载Redis //RedisClientManager.ReadOnlyHosts = new string[] { "192.168.11.103:6379" }; //RedisClientManager.ReadOnlyHosts = new string[] { "192.168.11.103:6379" }; //EarlySite.Cache.Session.Current.Set("test", "1111"); }
public static Session Deployment() { lock (g_pLook) { WorkThreadDictionary work = WorkThreadDictionary.Get(); Session session = work.Get <Session>(WORK_KEY_NAME); if (session == null) { session = new Session(); work.Set(WORK_KEY_NAME, session); } return(session); } }
public static MySql.Data.MySqlClient.MySqlConnection DeployInThread() { WorkThreadDictionary work = WorkThreadDictionary.Get(); MySql.Data.MySqlClient.MySqlConnection conn = null; if (work != null) { conn = work.Get <MySql.Data.MySqlClient.MySqlConnection>(WORK_KEY_NAME); } if (conn == null) { conn = new MySql.Data.MySqlClient.MySqlConnection(); if (work != null) { work.Set(WORK_KEY_NAME, conn); } conn.Disposed += Connection_Disposed; } if (conn.State != ConnectionState.Open) { conn.ConnectionString = mysqlConnStr; } return(conn); }