public static int GetTmpVID() { LogicContext current = LogicContext.Current; bool flag = current == null; if (flag) { throw new Exception("内部错误:当前线程未设置上下文环境!"); } return(current.TmpID); }
public static LogicSession GetServiceLogicSession() { LogicSession logicSession = new LogicSession(AppConfig.Default_Service_UserId, LogicSessionType.S); logicSession.DbId = AppConfig.DefaultDbId; LogicContext current = LogicContext.Current; current.SetLogicSession(logicSession); current.UserId = AppConfig.Default_Service_UserId; current.SetDatabase(AppConfig.DefaultDbId); return(logicSession); }
public static LogicSession GetLogicSession() { LogicSession logicSession = null; LogicContext current = LogicContext.Current; bool flag = current != null; if (flag) { logicSession = current.UserSession; } return(logicSession); }
private void application_BeginRequest(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; HttpRequest request = context.Request; string filePath = request.FilePath; string executionFilePath = request.AppRelativeCurrentExecutionFilePath; GlobalCulture.SetContextCulture(); LogicContext current = LogicContext.Current; current.SetDatabase(AppConfig.DefaultDbId); current.Source = filePath; HttpCookie cookie = request.Cookies[CookieMemory.FormsCookieName]; bool flag = cookie != null; if (flag) { CookieMemory cookie2 = new CookieMemory(cookie); LogicSession logicSession = AuthUtils.GetLogicSession(cookie2); bool flag2 = logicSession != null && logicSession.UserId == cookie2.UserId; if (!flag2) { AppEventLog.Debug("无法恢复"); return; } current.CookieUpdateTime = cookie2.UpdateTime; logicSession.LastRequestTime = AppRuntime.ServerDateTime; current.SetLogicSession(logicSession); current.UserAuthCookies = cookie; } bool flag3 = filePath == null; if (!flag3) { string s = StringHelper.RightSubstring(filePath, 5); bool flag4 = (!StringHelper.EqualsIgnoreCase(s, ".aspx") && !StringHelper.EqualsIgnoreCase(s, ".asmx") && !StringHelper.EqualsIgnoreCase(s, ".ashx")) || context.Request.Url.ToString().IndexOf("ActiveModule.aspx") < 0; if (!flag4) { string routeUrl = ModuleUtils.GetRouteUrl(request.QueryString["AMID"].ToString().Trim().ToInt()); current.AmId = request.QueryString["AMID"].ToString().Trim().ToInt(); bool flag5 = routeUrl.IndexOf("?") < 0; if (flag5) { context.Response.Redirect(routeUrl + "?" + context.Request.QueryString, false); } else { context.Response.Redirect(routeUrl + "&" + context.Request.QueryString, false); } } } }
internal bool RewriteAuthSession() { DateTime dateTime = AppRuntime.ServerDateTime; bool flag = dateTime <= this.UpdateTime; if (flag) { dateTime = this.UpdateTime.AddSeconds(1.0); } bool flag2 = !(this.RewriteAuthTime < dateTime); bool result; if (flag2) { result = false; } else { Database database = LogicContext.GetDatabase(); HSQL sql = new HSQL(database); sql.Raw = true; sql.Clear(); sql.Add("update AUTH set "); sql.Add(" AUTH_USERID = :AUTH_USERID,"); sql.Add(" AUTH_LOGINTIME = :AUTH_LOGINTIME,"); sql.Add(" AUTH_LOGINTYPE = :AUTH_LOGINTYPE,"); sql.Add(" AUTH_CLIENTIP = :AUTH_CLIENTIP,"); sql.Add(" AUTH_CLIENTNAME = :AUTH_CLIENTNAME,"); sql.Add(" AUTH_DBID = :AUTH_DBID,"); sql.Add(" AUTH_LASTREFRESH = :AUTH_LASTREFRESH,"); sql.Add(" AUTH_LASTREQUEST = :AUTH_LASTREQUEST,"); sql.Add(" AUTH_UPDATETIME = :AUTH_UPDATETIME,"); sql.Add(" AUTH_EXINFO = :AUTH_EXINFO"); sql.Add("where AUTH_SESSIONID = :AUTH_SESSIONID"); sql.ParamByName("AUTH_USERID").Value = this.UserId; sql.ParamByName("AUTH_LOGINTIME").Value = this.LoginTime; sql.ParamByName("AUTH_LOGINTYPE").Value = this.LoginType.ToString(); sql.ParamByName("AUTH_CLIENTIP").Value = this.ClientIp; sql.ParamByName("AUTH_CLIENTNAME").Value = this.ClientName; sql.ParamByName("AUTH_DBID").Value = this.DbId; sql.ParamByName("AUTH_LASTREFRESH").Value = this.LastRefreshTime; sql.ParamByName("AUTH_LASTREQUEST").Value = this.LastRequestTime; sql.ParamByName("AUTH_UPDATETIME").Value = this.UpdateTime; sql.ParamByName("AUTH_EXINFO").Value = this.ExInfo; sql.ParamByName("AUTH_SESSIONID").Value = this.SessionId; database.ExecSQL(sql); this.UpdateTime = dateTime; this.RewriteAuthTime = AppRuntime.ServerDateTime.AddMinutes(5.0); result = true; } return(result); }
private void application_AuthenticateRequest(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; HttpRequest request = context.Request; LogicContext current = LogicContext.Current; bool flag = current != null && string.IsNullOrWhiteSpace(current.UserId); if (flag) { context.User = null; } bool isAuthenticated = request.IsAuthenticated; if (!isAuthenticated) { string filePath = request.FilePath; bool flag2 = !StringHelper.EqualsLastStr(filePath, ".css") && !StringHelper.EqualsLastStr(filePath, ".js") && !StringHelper.EqualsLastStr(filePath, ".htc") && !StringHelper.EqualsLastStr(filePath, ".gif") && !StringHelper.EqualsLastStr(filePath, ".jpg") && !StringHelper.EqualsLastStr(filePath, ".png") && !StringHelper.EqualsLastStr(filePath, ".ico") && !StringHelper.EqualsLastStr(filePath, "bundles/MsAjaxJs") && !StringHelper.EqualsLastStr(filePath, "bundles/WebFormsJs") && !StringHelper.EqualsLastStr(filePath, "bundles/modernizr") && !StringHelper.EqualsLastStr(filePath, "Content/css") && !StringHelper.EqualsLastStr(filePath, "Content/ligerUI/skins/Timblue/css/css") && !StringHelper.EqualsLastStr(filePath, "Content/ligerUI/skins/Gray/css/css") && !StringHelper.EqualsLastStr(filePath, "Content/ligerUI/skins/Aqua/css/css"); if (!flag2) { context.SkipAuthorization = true; } } }
private void HandlerRequest(HttpContext context) { LogicContext current = LogicContext.Current; bool flag = current == null || current.HeaderIsSend; if (!flag) { current.HeaderIsSend = true; LogicSession userSession = current.UserSession; bool flag2 = userSession == null || string.IsNullOrEmpty(userSession.UserId) || userSession.Ignore; if (flag2) { FormsAuthentication.SignOut(); } else { bool flag3 = userSession.RewriteAuthSession() && current.CookieUpdateTime < userSession.UpdateTime; if (flag3) { NameValueString nameValueString = new NameValueString(); nameValueString.Add("U", userSession.UserId); nameValueString.Add("S", userSession.SessionId); nameValueString.Add("T", userSession.UpdateTime.To16String()); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userSession.UserId, false); authCookie.Path = context.Request.ApplicationPath; FormsAuthenticationTicket authenticationTicket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(authenticationTicket.Version, authenticationTicket.Name, authenticationTicket.IssueDate, authenticationTicket.Expiration, authenticationTicket.IsPersistent, nameValueString.LineText, authenticationTicket.CookiePath); authCookie.Value = FormsAuthentication.Encrypt(ticket); context.Response.Cookies.Set(authCookie); } } bool flag4 = userSession == null || string.IsNullOrEmpty(userSession.UserId) || !userSession.Ignore; if (flag4) { } } }
internal static DateTime GetDbServerDateTime() { DateTime dateTime = DateTime.Now; try { Database database = LogicContext.GetDatabase(new DbConfig("DBCFG", AppConfig.DefaultDbDesc, AppConfig.DbMS, AppConfig.DbServer)); HSQL sql = new HSQL(database); sql.Clear(); sql.Raw = true; bool flag = database.Driver == DbProviderType.MSSQL; if (flag) { sql.Add("select getdate()"); } else { bool flag2 = database.Driver == DbProviderType.ORACLE; if (flag2) { sql.Add("select sysdate from dual"); } } object obj = database.ExecScalar(sql); bool flag3 = obj != null; if (flag3) { dateTime = (DateTime)obj; } } catch { dateTime = DateTime.Now; } return(dateTime); }
public static Database GetDatabase(string dbId) { LogicContext current = LogicContext.Current; bool flag = current == null; if (flag) { throw new Exception("内部错误:当前线程未设置上下文环境!"); } bool flag2 = current.m_databases == null; if (flag2) { current.m_databases = new ListDictionary(); } bool flag3 = current.m_databases.Contains(dbId); Database database; if (flag3) { database = (Database)current.m_databases[dbId]; } else { DbConfig dbConfig = AppDbInstance.GetDbInstance(dbId); bool flag4 = dbConfig == null; if (flag4) { DbServer dbServer = DbServerUtils.GetDbServer(dbId); bool flag5 = dbServer != null; if (flag5) { dbConfig = new DbConfig(dbServer.DbId, dbServer.Desc, dbServer.DbMS, new NameValueString { NaviteText = dbServer.Conn }.LineText); } } //database = ((dbConfig.ProviderType != DbProviderType.MSSQL) ? // ((dbConfig.ProviderType != DbProviderType.ORACLE) ? // new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString) : // new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString)) : // new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString)); if (dbConfig.ProviderType != DbProviderType.MSSQL) { if (dbConfig.ProviderType != DbProviderType.ORACLE) { database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString); } else { database = new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString); } } else { database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString); } current.m_databases.Add(dbConfig.DbId, database); } return(database); }
public static Database GetDatabase() { return(LogicContext.GetDatabase(AppConfig.DefaultDbId)); }