public void SetReportMsgIdState(string msgid, string state) { try { if (msgid.Equals(SaveReportMsgId)) { SaveReportState = state; } if (ReportMsgIdLst != null) { foreach (ReportMsgidStatus rms in ReportMsgIdLst) { if (rms.Msgid.Equals(msgid)) { rms.ReportState = state; break; } } } } catch (Exception ex) { SMSLog.Error("SmsModel=>SetReportMsgIdState Exception:" + ex.Message); } }
public void Del(object key) { try { //lock (_cachedic) // { if (_cachedic.ContainsKey(key)) { object obj; _cachedic.TryRemove(key, out obj); } // } } catch (Exception ex) { SMSLog.Error("TimeoutCache:Add=>添加缓存数据异常:" + ex.Message); } }
public void Add(object key, object obj) { try { //lock (_cachedic) // { if (!_cachedic.ContainsKey(key)) { TimeoutCacheObject tco = new TimeoutCacheObject(obj, DateTime.Now); _cachedic.TryAdd(key, tco); } // } } catch (Exception ex) { SMSLog.Error("TimeoutCache:Add=>添加缓存数据异常:" + ex.Message); } }
private void TCallback2(object obj) { SMSLog.Debug("TimeoutCache=====TCallback2======>开始清除缓存数据:" + DateTime.Now); try { int c = _cachedic.Keys.Count; object[] keys = new object[c]; object[] vals = new object[c]; _cachedic.Keys.CopyTo(keys, 0); _cachedic.Values.CopyTo(vals, 0); for (int i = 0; i < vals.Length; i++) { try { TimeoutCacheObject tco = vals[i] as TimeoutCacheObject; if (tco != null) { TimeSpan ts = DateTime.Now - tco.Timestamp; if (ts.TotalSeconds > _totalSeconds) { if (_cachedic.ContainsKey(keys[i])) { object movobj = null; _cachedic.TryRemove(keys[i], out movobj); } } } } catch (Exception ex) { SMSLog.Error("TimeoutCache=TCallback2=>删除缓存数据异常:" + ex.Message); } } } catch (Exception e) { SMSLog.Error("TimeoutCache=TCallback2=>删除缓存数据异常:" + e.Message); } SMSLog.Debug("TimeoutCache=====TCallback2======>结束清除缓存数据:" + DateTime.Now); }
private void TCallback(object obj) { try { SMSLog.Debug("TimeoutCache===========>开始清除缓存数据:" + DateTime.Now); IDictionary <object, object> tcachedic = new Dictionary <object, object>(); tcachedic = _cachedic; if (tcachedic != null) { foreach (object key in tcachedic.Keys) { try { TimeoutCacheObject tco = (TimeoutCacheObject)tcachedic[key]; TimeSpan ts = DateTime.Now - tco.Timestamp; if (ts.TotalSeconds > _totalSeconds) { if (_cachedic.ContainsKey(key)) { object movobj = null; _cachedic.TryRemove(key, out movobj); } } } catch (Exception ex) { SMSLog.Error("TimeoutCache==>删除缓存数据异常:" + ex.Message); } } tcachedic.Clear(); } SMSLog.Debug("TimeoutCache===========>结束清除缓存数据:" + DateTime.Now); } catch (Exception ex) { SMSLog.Error("TimeoutCache==>清除缓存数据异常:" + ex.Message); } }