/// <summary> /// 建構子 /// </summary> /// <param name="dbtyp">資料庫類別</param> /// <param name="connstr">連線字串</param> /// <param name="cmdtimeout">逾時設定</param> public DBEntity(DBType dbtyp, string connstr, int cmdtimeout = 30) { DBConnStr = connstr; DBTimeout = cmdtimeout; DBType = dbtyp; if (connstr.ToLower().StartsWith("server=")) { db = new DB(dbtyp, connstr, cmdtimeout); } else { db = new DB(dbtyp, ConnSecure.Decrypt(connstr), cmdtimeout); } _conn = db.CreateConnection(); }
private string getRedisData(IConfigurationSection section, string rediskey) { var redisconn = GetService <DBInfo>(section.Value); CSRedis.CSRedisClient csredis; try { csredis = new CSRedis.CSRedisClient(ConnSecure.Decrypt(redisconn.RedisConnStr)); RedisHelper.Initialization(csredis); } catch (Exception err) { NCLog.ExceptionLog(err, $"getRedisData error: {err.Message}"); throw new Exception($"getRedisData error: {err.Message}"); } var tokenstr = csredis.Get(rediskey); return(tokenstr); }