public static DataTable getLastAWStable(string tableName, bool writeCachable = false) { lock (lockKey) { string ckey = "lastAWSiNFO#" + tableName; DataTable table = MyCacheManager.Get(ckey) as DataTable; if (table == null) { string select = string.Format(@"select * from( SELECT ROW_NUMBER() OVER(PARTITION BY obtid ORDER BY ddatetime DESC) LEV,s.* from( select * from ( select * from {0} where WD3SMAXDF>=0 ORDER BY ddatetime desc ) where ROWNUM < 5000 ) s ) WHERE LEV=1", tableName); table = OracleHelp.ExecuteDataTable(select, T_LOCALOBTDAYD.Tunnel.connString); if (writeCachable) { MyCacheManager.Insert(ckey, table, DateTime.Now.AddMinutes(1), System.Web.Caching.CacheItemPriority.High, null, (string key, object value, CacheItemRemovedReason reason) => { if (reason == CacheItemRemovedReason.Expired) { getLastAWStable(key.Split('#')[1], true); } }); } } return(table); } }
static List <AWSFieldValue> getAwsFieldValueFromDb(AWDType type, DateTime?date, OBTArea area, TimeMode timeMode, OBTField dataField, int accuracy, bool isPlaying, bool orderbyDesc) { string ckey = null; if (date != null) { ckey = "GetTempratureData" + date.Value.Ticks + area + timeMode + dataField + orderbyDesc; } else { ckey = "GetTempratureDataLastDate" + area + timeMode + dataField + orderbyDesc; } List <AWSFieldValue> result = MyCacheManager.Get(ckey) as List <AWSFieldValue>; if (result == null) { result = myQuery.GetFiledValue(type, date, area, timeMode, dataField, isPlaying, accuracy, orderbyDesc); if (result.Count > 0) { DateTime expire; if (date != null) { expire = DateTime.Now.AddMinutes(4); if (DateTime.Now - date > TimeSpan.FromMinutes(20)) { expire = DateTime.Now.AddHours(8); } } else { expire = DateTime.Now.AddMinutes(1); } MyCacheManager.Insert(ckey, result, expire); } } return(result); }
public SqlFileMessage(string filePath) { _file = new FileInfo(filePath); _sqlCache = MyCacheManager.GetCache <string, SqlDocument>(Constants.SQL_CACHE_KEY, k => SqlXmlHelper.Instance.GetDocument(k)); }
public SqlXmlHelper() { _sqlCache = MyCacheManager.GetCache <string, SqlDocument>(Constants.SQL_CACHE_KEY, k => GetDocument(k)); }