private void ExecTask(TaskInfo taskInfo) { ITask taskObject = this.GetTaskObject(taskInfo); LogicSession logicSession = new LogicSession(taskInfo.UserId, LogicSessionType.S); logicSession.DbId = taskInfo.DbId; LogicContext current = LogicContext.Current; current.SetLogicSession(logicSession); current.UserId = taskInfo.UserId; current.SetDatabase(taskInfo.DbId); current.AmId = taskObject.MdId; current.MdId = taskObject.MdId; current.ComId = taskObject.ComId; try { taskObject.Execute(); } catch (Exception ex_7D) { } finally { } }
internal static bool SelectAuthToSession(string sessionId, LogicSession lgcSession) { Auth auth = AuthUtils.SelectAuth(sessionId); bool flag = auth == null; bool result; if (flag) { result = false; } else { lgcSession.UserId = auth.UserId; lgcSession.UserName = auth.UserName; lgcSession.LoginTime = auth.LoginTime; lgcSession.LoginType = auth.LoginType; lgcSession.ClientIp = auth.ClientIp; lgcSession.ClientName = auth.ClientName; lgcSession.DbId = auth.DbId; lgcSession.LastRefreshTime = auth.LastRefresh; lgcSession.LastRequestTime = auth.LastRequest; lgcSession.UpdateTime = auth.UpdateTime; lgcSession.ExInfo = auth.ExInfo; lgcSession.AuthSession = auth; result = true; } return(result); }
internal static void RemoveSession(string sessionId) { LogicSession logicSession = null; try { while (!Monitor.TryEnter(logicSession)) { Thread.Sleep(0); } bool flag = !AuthUtils.GlobalLogicSession.TryGetValue(sessionId, out logicSession); if (!flag) { object lockObj = AuthUtils._lockObj; lock (lockObj) { AuthUtils.GlobalLogicSession.Remove(sessionId); } } } finally { Monitor.Exit(logicSession); } }
public static void RunTask(ITask task, string userId, string dbId) { LogicSession logicSession = new LogicSession(userId, LogicSessionType.S); User user = UserUtils.GetUser(userId); bool flag = user != null; if (flag) { logicSession.UserName = user.UserName; } logicSession.DbId = dbId; LogicContext current = LogicContext.Current; current.SetLogicSession(logicSession); current.UserId = userId; current.SetDatabase(dbId); current.AmId = task.MdId; current.MdId = task.MdId; current.ComId = task.ComId; try { task.Execute(); } finally { } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; this.m_context = context; this.m_request = this.m_context.Request; this.m_response = this.m_context.Response; this.m_lgc = LogicContext.Current; this.m_pageParam = new PageParameter(); this.m_pageParam.ReadPageParameter(this.m_request.QueryString); this.m_session = LogicContext.GetLogicSession(); context.Server.ScriptTimeout = 3600; string codeId = this.m_pageParam.GetString("CODEID"); string ctrlId = this.m_pageParam.GetString("CTRLID"); string ctrlValue = this.m_pageParam.GetString("CTRLVALUE"); CodeHelper codeHelper = CodeHelperUtils.GetCodeHelper(codeId); bool flag = codeHelper != null; if (flag) { int mdId = codeHelper.MdId; bool flag2 = mdId > 0; if (flag2) { context.Response.Write(string.Concat(new object[] { "ActiveModule.aspx?AMID=", mdId, "&", this.m_request.QueryString })); } } }
internal static void LogicSessionUpdateFromMemorySessionTask() { object lockObj = AuthUtils._lockObj; Dictionary <string, LogicSession> dictionary; lock (lockObj) { try { dictionary = new Dictionary <string, LogicSession>(AuthUtils.GlobalLogicSession); } catch { return; } } DateTime dateTime = AppRuntime.ServerDateTime.AddMinutes(-480.0); DateTime dateTime2 = AppRuntime.ServerDateTime.AddMinutes(-5.0); foreach (KeyValuePair <string, LogicSession> keyValuePair in dictionary) { LogicSession logicSession = keyValuePair.Value; bool ignore = logicSession.Ignore; if (ignore) { LogicSession obj = logicSession; lock (obj) { bool flag3 = logicSession.LastRequestTime < dateTime2; if (flag3) { AuthUtils.RemoveSession(logicSession.SessionId); } } } else { LogicSession obj2 = logicSession; lock (obj2) { bool flag5 = logicSession.LastRequestTime < dateTime; if (flag5) { AuthUtils.RemoveSession(logicSession.SessionId); } } } } }
public static bool Login(string userId, string password, string clientIp) { bool flag = string.IsNullOrEmpty(userId); bool result; if (flag) { result = false; } else { userId = userId.ToUpper(); User user = UserUtils.GetUser(userId); bool flag2 = user == null; if (flag2) { throw new Exception("用户名或密码错误!"); } bool disabled = user.Disabled; if (disabled) { throw new Exception("当前用户名已被停用!"); } bool flag3 = user.Password != PasswordSec.Encode(userId, password); if (flag3) { throw new Exception("用户名或密码错误!"); } LogicSession logicSession = AuthUtils.SignIn(userId, clientIp); bool flag4 = logicSession != null; if (flag4) { logicSession.UserName = user.UserName; LogicContext current = LogicContext.Current; bool flag5 = current != null; if (flag5) { current.SetLogicSession(logicSession); } } result = true; } return(result); }
internal static LogicSession SignIn(string userId, string clientIp) { HttpContext current = HttpContext.Current; LogicSession logicSession = new LogicSession(userId, LogicSessionType.C); logicSession.DbId = AppConfig.DefaultDbId; logicSession.ClientIp = clientIp; object lockObj = AuthUtils._lockObj; lock (lockObj) { bool flag2 = AuthUtils.GlobalLogicSession.ContainsKey(logicSession.SessionId); if (flag2) { logicSession = null; } else { AuthUtils.GlobalLogicSession.Add(logicSession.SessionId, logicSession); AuthUtils.InsertAuth(new Auth { SessionId = logicSession.SessionId, UserId = logicSession.UserId, LoginTime = logicSession.LastRequestTime, LoginType = logicSession.LoginType, ClientIp = logicSession.ClientIp, ClientName = logicSession.ClientIp, DbId = logicSession.DbId, LastRefresh = logicSession.LastRefreshTime, LastRequest = logicSession.LastRequestTime, UpdateTime = logicSession.UpdateTime, ExInfo = logicSession.ExInfo }); current.Response.SetCookie(new HttpCookie("USERID", logicSession.UserId) { HttpOnly = false, Path = AppRuntime.AppVirtualPath }); } } return(logicSession); }
internal static void SignOut() { LogicContext current = LogicContext.Current; bool flag = current == null; if (!flag) { LogicSession userSession = current.UserSession; bool flag2 = userSession != null; if (flag2) { object lockObj = AuthUtils._lockObj; lock (lockObj) { AuthUtils.GlobalLogicSession.Remove(userSession.SessionId); userSession.Ignore = true; AuthUtils.DeleteAuth(userSession.SessionId); } } } }
public void ProcessRequest(HttpContext context) { this.m_server = context.Server; this.m_context = context; this.m_request = this.m_context.Request; this.m_response = this.m_context.Response; this.m_lgcContext = LogicContext.Current; this.m_lgcSession = LogicContext.GetLogicSession(); this.m_pageParam = new PageParameter(); this.m_pageParam.ReadPageParameter(this.Request.QueryString); context.Server.ScriptTimeout = 3600; this.ParsePageParam(); try { this.PrepareData(); } catch (Exception ex) { this.m_promptMessage = ex.Message; } this.SendHeader(); this.SendData(); this.ClearData(); }
public static LogicSession GetLogicSession(CookieMemory cookie) { string sessionId = cookie.SessionId; DateTime updateTime = cookie.UpdateTime; LogicSession logicSession = null; LogicSession lgcSession = null; object lockObj = AuthUtils._lockObj; LogicSession result; lock (lockObj) { bool local_5_; do { bool flag2 = !AuthUtils.GlobalLogicSession.TryGetValue(sessionId, out lgcSession); if (flag2) { lgcSession = new LogicSession(sessionId); AuthUtils.GlobalLogicSession[sessionId] = lgcSession; } local_5_ = Monitor.TryEnter(lgcSession); bool flag3 = !local_5_; if (flag3) { Thread.Sleep(0); } }while (!local_5_); try { DateTime local_6 = AppRuntime.ServerDateTime; bool flag4 = lgcSession.LoginType == LogicSessionType.N && !AuthUtils.SelectAuthToSession(sessionId, lgcSession); if (flag4) { lgcSession.Ignore = true; result = null; return(result); } bool flag5 = lgcSession.LastRequestTime < AppRuntime.ServerDateTime.AddMinutes(-480.0) && !AuthUtils.UpdateAuthLastRequest(sessionId, local_6); if (flag5) { lgcSession.Ignore = true; result = null; return(result); } bool flag6 = updateTime > lgcSession.UpdateTime && !AuthUtils.SelectAuthToSession(sessionId, lgcSession); if (flag6) { lgcSession.Ignore = true; result = null; return(result); } lgcSession.LastRequestTime = local_6; logicSession = lgcSession; } finally { Monitor.Exit(lgcSession); } } result = logicSession; return(result); }