public void RefreshAuthType(string key, AuthTypeEnum authType) { if (key == null) { throw new ArgumentNullException("key"); } this.dict.Remove(key); AuthTypeCacheItem item = new AuthTypeCacheItem(); item.AuthTypeEnum = authType; item.ExpireDateTime = DateTime.Now.AddMinutes(basicExipreMinutes + rd.Next(-5, 5)); this.dict.Add(key, item); }
//session type(web only), 1:session, 2:redis, 3:custom(config must set SessionService field, use Activator) //public static int SessionServiceType = 1; #endregion /* * //constructor * static _Fun() * { * } */ /// <summary> /// initial db environment for Ap with db function !! /// </summary> public static void Init(IServiceProvider di, DbTypeEnum dbType = DbTypeEnum.MSSql, AuthTypeEnum authType = AuthTypeEnum.None, bool dynamicLocale = false) { //set instance variables _di = di; _dbType = dbType; _authType = authType; _dynamicLocale = dynamicLocale; #region set smtp var smtp = Config.Smtp; if (smtp != "") { try { var cols = smtp.Split(','); Smtp = new SmtpDto() { Host = cols[0], Port = int.Parse(cols[1]), Ssl = bool.Parse(cols[2]), Id = cols[3], Pwd = cols[4], FromEmail = cols[5], FromName = cols[6] }; } catch { _Log.Error("config Smtp is wrong(7 cols): Host,Port,Ssl,Id,Pwd,FromEmail,FromName"); } } #endregion #region set DB variables //0:select, 1:order by, 2:start row(base 0), 3:rows count switch (_dbType) { case DbTypeEnum.MSSql: DbDtFormat = "yyyy-MM-dd HH:mm:ss"; //JsDtFormat = "yyyy/M/d HH:mm:ss"; //for sql 2012, more easy //note: offset/fetch not sql argument ReadPageSql = @" select {0} {1} offset {2} rows fetch next {3} rows only "; DeleteRowsSql = "delete {0} where {1} in ({2})"; break; case DbTypeEnum.MySql: DbDtFormat = "YYYY-MM-DD HH:mm:SS"; ReadPageSql = @" select {0} {1} limit {2},{3} "; //TODO: set delete sql for MySql //DeleteRowsSql = break; case DbTypeEnum.Oracle: DbDtFormat = "YYYY/MM/DD HH24:MI:SS"; //for Oracle 12c after(same as mssql) ReadPageSql = @" Select {0} {1} Offset {2} Rows Fetch Next {3} Rows Only "; //TODO: set delete sql for Oracle //DeleteRowsSql = break; } #endregion }