Exemplo n.º 1
0
        static internal void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
        {
            try
            {
                if (Globals.Status == Globals.UpgradeStatus.None)
                {
                    LogInfo objEventLogInfo = new LogInfo();
                    switch (removedReason)
                    {
                    case CacheItemRemovedReason.Removed:
                        objEventLogInfo.LogTypeKey = EventLogController.EventLogType.CACHE_REMOVED.ToString();
                        break;

                    case CacheItemRemovedReason.Expired:
                        objEventLogInfo.LogTypeKey = EventLogController.EventLogType.CACHE_EXPIRED.ToString();
                        break;

                    case CacheItemRemovedReason.Underused:
                        objEventLogInfo.LogTypeKey = EventLogController.EventLogType.CACHE_UNDERUSED.ToString();
                        break;

                    case CacheItemRemovedReason.DependencyChanged:
                        objEventLogInfo.LogTypeKey = EventLogController.EventLogType.CACHE_DEPENDENCYCHANGED.ToString();
                        break;
                    }
                    objEventLogInfo.LogProperties.Add(new LogDetailInfo(key, removedReason.ToString()));
                    EventLogController objEventLog = new EventLogController();
                    objEventLog.AddLog(objEventLogInfo);
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void Signal(string key, object value, CacheItemRemovedReason reason)
        {
            var virtualPath = Convert.ToString(value);
            Logger.Debug("Virtual path changed ({1}) '{0}'", virtualPath, reason.ToString());

            var token = DetachToken(virtualPath);
            if (token != null)
                token.IsCurrent = false;
        }
Exemplo n.º 3
0
 public void Refresh(string key, object expiredValue, CacheItemRemovedReason removalReason)
 {
     lock (this)
     {
         expiredKeys    += key;
         expiredValues  += expiredValue;
         removalReasons += removalReason.ToString();
     }
 }
Exemplo n.º 4
0
 //此方法在值失效之前调用,可以用于在失效之前更新数据库,或从数据库重新获取数据
 private static void onRemove(string strIdentify, object talkInfo, CacheItemRemovedReason reason)
 {
     if (reason.ToString() == "Expired")
     {
         ServiceCommon sc            = new ServiceCommon();
         string        strSerializer = XmlSerializerHelper.XmlSerializer(talkInfo);
         sc.ExecuteSql("insert into OrderMessage(OrderNumber,TalkContent,ModifyDate,BelongFactory)values('" + strIdentify.Split('|')[1] + "','" + strSerializer + "',getdate(),'" + strIdentify.Split('|')[0] + "')");
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Called when the root cache item has been removed from the cache
        /// </summary>
        /// <param name="key">the key of the cache item that wwas removed</param>
        /// <param name="value">the value of the cache item that was removed</param>
        /// <param name="reason">The <see cref="CacheItemRemovedReason"/> for the removal of the
        ///     item from the cache</param>
        /// <remarks>
        ///     <para>Since all cache items are dependent on the root cache item, if this method is called,
        ///     all the cache items for this region have also been removed</para>
        /// </remarks>
        private void RootCacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Cache items for region '{0}' have been removed from the cache for the following reason : {1}",
                                _name, reason.ToString("g"));
            }

            //lets us know that we need to reestablish the root cache item for this region
            _isRootItemCached = false;
        }
        private void Signal(object value, CacheItemRemovedReason reason)
        {
            var virtualPath = Convert.ToString(value);

            Logger.Debug("虚拟路径发生了变更 ({1}) '{0}'", virtualPath, reason.ToString());

            var token = DetachToken(virtualPath);

            if (token != null)
            {
                token.IsCurrent = false;
            }
        }
 internal void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
 {
     try
     {
         if (Globals.Status == Globals.UpgradeStatus.None)
         {
             // track data removed from cache to synchonize UrlRule cache
             string[] CacheKeys = UrlRuleConfiguration.GetCacheKeys();
             if (CacheKeys != null)
             {
                 foreach (string CacheKey in CacheKeys)
                 {
                     if (key.Contains(CacheKey))
                     {
                         if (DotNetNuke.Entities.Portals.PortalSettings.Current != null)
                         {
                             int PortalId = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
                             Remove(GetCacheKey("UrlRuleConfig" + PortalId));
                             DnnLog.Trace("Clear cache " + key + " portal "+ PortalId + " raison "+ removedReason.ToString());
                         }
                         else
                         {
                            // DnnLog.Trace("Clear cache not executed " + key + " raison " + removedReason.ToString());
                         }
                     }
                 }
             }
             if (key.StartsWith("UrlRuleConfig"))
             {
                 DnnLog.Trace("cache " + key + "claired : " + removedReason.ToString());
             }
         }
     }
     catch (Exception exc)
     {
         //Swallow exception
         DnnLog.Error(exc);
     }
 }
Exemplo n.º 8
0
        public void Signal(string key, object value, CacheItemRemovedReason reason)
        {
            var virtualPath = Convert.ToString(value);

            Logger.DebugFormat("Virtual path changed ({1}) '{0}'", virtualPath, reason.ToString());

            var token = DetachToken(virtualPath);

            if (token != null)
            {
                token.IsCurrent = false;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 缓存失效回调
 /// </summary>
 /// <param name="cacheKey">缓存key值</param>
 /// <param name="cacheValue">缓存的对象</param>
 /// <param name="reasonToRemove">缓存移出原因</param>
 public static void CacheItemRemovedCallback(string cacheKey, object cacheValue, CacheItemRemovedReason reasonToRemove)
 {
     if (BaseSystemInfo.LogCache)
     {
         var sb = Pool.StringBuilder.Get();
         sb.Append(
             string.Format("Cache Key: {0} invalid at {1} with reason {2}",
                           new object[]
         {
             cacheKey, DateTime.Now.ToString(BaseSystemInfo.DateTimeLongFormat),
             reasonToRemove.ToString()
         }));
         LogUtil.WriteLog(sb.Put(), "Cache", null, "Cache");
     }
 }
Exemplo n.º 10
0
 public static void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
 {
     Logger.Info($"CacheItemRemovedCallback({reason.ToString()}): [{typeof(Provider).FullName}]({key})");
     if (reason == CacheItemRemovedReason.Expired)
     {
         Provider provider = value as Provider;
         if (provider != null)
         {
             new GetProvider()
             {
                 Id = provider.Id
             }.ExecuteItem(false);
         }
     }
 }
Exemplo n.º 11
0
 //移除缓存项的按钮单击事件。
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (Cache["Products"] != null)
     {
         //调用Cache.Remove方法移除缓存项
         Cache.Remove("Products");
     }
     //当缓存移除后,通过判断属性来更新label控件
     if (itemRemoved)
     {
         Label1.Text += "RemovedCallback事件触发";
         Label1.Text += "<BR>";
         Label1.Text += "原因是: <B>" + reason.ToString() + "</B>";
     }
     else
     {
         Label1.Text += "缓存键值是: <B>" + Server.HtmlEncode(Cache["Products"] as string) + "</B>";
     }
 }
Exemplo n.º 12
0
 internal void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
 {
     try
     {
         if (Globals.Status == Globals.UpgradeStatus.None)
         {
             // track data removed from cache to synchonize UrlRule cache
             string[] CacheKeys = UrlRuleConfiguration.GetCacheKeys();
             if (CacheKeys != null)
             {
                 foreach (string CacheKey in CacheKeys)
                 {
                     if (key.Contains(CacheKey))
                     {
                         if (DotNetNuke.Entities.Portals.PortalSettings.Current != null)
                         {
                             int PortalId = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
                             Remove(GetCacheKey("UrlRuleConfig" + PortalId));
                             Logger.Trace("Clear cache " + key + " portal " + PortalId + " raison " + removedReason.ToString());
                         }
                         else
                         {
                             // Logger.Trace("Clear cache not executed " + key + " raison " + removedReason.ToString());
                         }
                     }
                 }
             }
             if (key.StartsWith("UrlRuleConfig"))
             {
                 Logger.Trace("cache " + key + "claired : " + removedReason.ToString());
             }
         }
     }
     catch (Exception exc)
     {
         //Swallow exception
         Logger.Error(exc);
     }
 }
Exemplo n.º 13
0
        internal static void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
        {
            // if the item was removed from the cache, log the key and reason to the event log
            try
            {
                if (Globals.Status == Globals.UpgradeStatus.None)
                {
                    var log = new LogInfo();
                    switch (removedReason)
                    {
                    case CacheItemRemovedReason.Removed:
                        log.LogTypeKey = EventLogController.EventLogType.CACHE_REMOVED.ToString();
                        break;

                    case CacheItemRemovedReason.Expired:
                        log.LogTypeKey = EventLogController.EventLogType.CACHE_EXPIRED.ToString();
                        break;

                    case CacheItemRemovedReason.Underused:
                        log.LogTypeKey = EventLogController.EventLogType.CACHE_UNDERUSED.ToString();
                        break;

                    case CacheItemRemovedReason.DependencyChanged:
                        log.LogTypeKey = EventLogController.EventLogType.CACHE_DEPENDENCYCHANGED.ToString();
                        break;
                    }

                    log.LogProperties.Add(new LogDetailInfo(key, removedReason.ToString()));
                    LogController.Instance.AddLog(log);
                }
            }
            catch (Exception exc)
            {
                // Swallow exception
                Logger.Error(exc);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 缓存失效回调委托的一个实例,以后增加日志记录
 /// </summary>
 /// <param name="key"></param>
 /// <param name="val"></param>
 /// <param name="reason"></param>
 public void CacheOnRemove(string Key, object Val, CacheItemRemovedReason Reason)
 {
     //switch (Reason)
     //{
     //    case CacheItemRemovedReason.DependencyChanged:
     //        break;
     //    case CacheItemRemovedReason.Expired:
     //        {
     //            break;
     //        }
     //    case CacheItemRemovedReason.Removed:
     //        {
     //            break;
     //        }
     //    case CacheItemRemovedReason.Underused:
     //        {
     //            break;
     //        }
     //    default: break;
     //}
     //如需要使用缓存日志,则需要使用下面代码
     //myLogVisitor.WriteLog(this,key,val,reason);
     if (this._IsWriteLogs)
     {
         string logfilepath = Common.Utils.GetMapPath(string.Format("~\\LiteCMSLogs\\{0}.txt", DateTime.Now.ToString("yyMMdd")));
         Val = Val == null ? "" : Val.ToString();
         string message = string.Format("Key:{0},Value:{1},Reason:{2}", Key, Val, Reason.ToString());
         Logs.TinyLogs.InsertLog(logfilepath, DateTime.Now, "Cache_Removed", message);
     }
 }
 /// <summary>
 /// Construct cache expire event argument.
 /// </summary>
 /// <param name="cacheKey">caching key</param>
 /// <param name="cacheValue">caching value</param>
 /// <param name="reason">cached object removed reason</param>
 internal CacheExpiredEventArgs(object cacheKey, object cacheValue, CacheItemRemovedReason reason)
 {
     this.Key = cacheKey;
     this.Value = cacheKey;
     this.Reason = (CacheRemovedReason)Enum.Parse(typeof(CacheRemovedReason), reason.ToString());
 }
Exemplo n.º 16
0
 /// <summary>
 /// 缓存依赖的回调函数(缓存被清除的时候调用此方法)
 /// </summary>
 /// <param name="key">缓存的键</param>
 /// <param name="value">缓存的值</param>
 /// <param name="reason">缓存被移除的原因</param>
 void CacheCallBack(string key, object value, CacheItemRemovedReason reason)
 {
     //是用logHelper对象来记录日记
     sqllitehelper _sh = new sqllitehelper();
     int           db  = _sh.InsertData("在Home控制器下的Index方法中,Cache[" + key + "]=" + value.ToString() + "因为" + reason.ToString() + "被删除了");
 }
Exemplo n.º 17
0
 protected static void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
 {
     CacheHelper.Log($"CacheItemRemovedCallback({reason.ToString()}): [{typeof(Provider).FullName}]({key})[{value}]");
 }
Exemplo n.º 18
0
 private void RemovedCallBack(string k, object v, CacheItemRemovedReason r)
 {
     Logger.Info(k + " : " + r.ToString() + "/" + Environment.StackTrace);
 }
 /// <summary>
 /// Invoked when the system removes an execution chain from cache
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="reason">The reason.</param>
 public void CacheItemRemoved(string key, Object value, CacheItemRemovedReason reason)
 {
     WSApplication.Application.Report(Messages.ChainRemoved, key, reason.ToString());
 }
Exemplo n.º 20
0
 private void CachedItemRemovedCallback(string key, Object val,
     CacheItemRemovedReason reason)
 {
     //
     if (reason == CacheItemRemovedReason.DependencyChanged)
     {
         // Log the cache key name, reason and time details
         // when the cached object was removed from the cache
     }
     Logger.Debug("Removed item from cache - " + key + " at " + DateTime.Now.ToString() + ". Reason - " + reason.ToString());
 }
Exemplo n.º 21
0
        // This method gets invoked automatically, whenever the cached item is removed from cache
        public void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason)
        {
            // Retrieve the key and reason for removal
            string dataToStore = "Cache item with key = \"" + key + "\" is no longer present. Reason = " + reason.ToString();

            // Cache the message
            Cache["CacheStatus"] = dataToStore;

            // ADO.NET code to store the message in database
            // string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            // SqlConnection con = new SqlConnection(cs);
            // SqlCommand cmd = new SqlCommand("insert into tblAuditLog values('" + dataToStore + "')", con);
            // con.Open();
            // cmd.ExecuteNonQuery();
            // con.Close();

            // Reload data into cache
            // DataSet ds = new DataSet();
            // ds.ReadXml(Server.MapPath("~/Data/Countries.xml"));

            // CacheItemRemovedCallback onCacheItemRemoved = new CacheItemRemovedCallback(CacheItemRemovedCallbackMethod);
            // Cache.Insert("CountriesData", ds, new CacheDependency(Server.MapPath("~/Data/Countries.xml")), DateTime.Now.AddSeconds(60),
            //    System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.Default, onCacheItemRemoved);
        }
Exemplo n.º 22
0
 public static void LogRemovedItemToConsole(String key, Object o, CacheItemRemovedReason r)
 {
     Console.WriteLine("info: " + key + " " + r.ToString());
 }
 public void RemovedCallback(String k, Object v, CacheItemRemovedReason r)
 {
     string reason = r.ToString();
 }
Exemplo n.º 24
0
        public void RemovedPageIndexCallBack(string k, object v, CacheItemRemovedReason r)
        {
            cacheItemRemovedReason = r;
#if (DEBUG)
            if (LogRemovedReason)
            {
                var elc = new EventLogController();
                var logValue = new LogInfo { LogTypeKey = "HOST_ALERT" };

                string itemName;
                string count;
                List<string> portalCounts = null;
                switch (k)
                {
                    case "DNN_" + PageIndexKey:
                        itemName = "Page Index";
                        //user profile actions
                        try
                        {
                            DataCache.RemoveCache(UserProfileActionsKey);
                        }
                        catch (ConfigurationErrorsException)
                        {
                            //do nothing, this means the web.config file was overwritten, and thus the cache
                            //was cleared.
                        }
                        if (v != null && v.GetType() == typeof(SharedDictionary<string, string>))
                        {
                            count = "Item Count: " + ((SharedDictionary<string, string>)v).Values.Count.ToString();
                        }
                        else
                        {
                            count = "N/a";
                        }

                        break;
                    case "DNN_"  + UrlDictKey:
                        itemName = "Friendly Url List";
                        if (v != null &&
                            v.GetType() == typeof(SharedDictionary<int, SharedDictionary<string, string>>))
                        {
                            var friendlyUrls = (SharedDictionary<int, SharedDictionary<string, string>>)v;
                            portalCounts = new List<string>();
                            using (friendlyUrls.GetReadLock())
                            {
                                count = "Portal Count: " + friendlyUrls.Count.ToString();
                                foreach (int key in friendlyUrls.Keys)
                                {
                                    SharedDictionary<string, string> portalUrls = friendlyUrls[key];
                                    using (portalUrls.GetReadLock())
                                    {
                                        portalCounts.Add("Portal " + key.ToString() + " Item Count :" + portalUrls.Count.ToString());
                                    }
                                }
                            }
                        }
                        else
                        {
                            count = "N/a";
                        }
                        break;
                    default:
                        itemName = "Url Rewriter Cache Item";
                        count = "";
                        break;
                }
                //add log values
                logValue.AddProperty("Url Rewriting Caching Message", itemName + " Cache item Removed.");
                logValue.AddProperty("Reason", cacheItemRemovedReason.ToString());
                logValue.AddProperty("Cache Item Key", k);
                logValue.AddProperty("Item Count", count);
                if (portalCounts != null)
                {
                    int i = 0;
                    foreach (string item in portalCounts)
                    {
                        logValue.AddProperty("Item " + i.ToString(), item);
                        i++;
                    }
                }
                //System.Diagnostics.Trace.Assert(k != null, "k == " + k);
                elc.AddLog(logValue);
            }
#endif
        }
Exemplo n.º 25
0
 /// <summary>
 /// ����ʧЧ�ص�ί�е�һ��ʵ��,�Ժ�������־��¼
 /// </summary>
 /// <param name="key"></param>
 /// <param name="val"></param>
 /// <param name="reason"></param>
 public void CacheOnRemove(string Key, object Val, CacheItemRemovedReason Reason)
 {
     //switch (Reason)
     //{
     //    case CacheItemRemovedReason.DependencyChanged:
     //        break;
     //    case CacheItemRemovedReason.Expired:
     //        {
     //            break;
     //        }
     //    case CacheItemRemovedReason.Removed:
     //        {
     //            break;
     //        }
     //    case CacheItemRemovedReason.Underused:
     //        {
     //            break;
     //        }
     //    default: break;
     //}
     //����Ҫʹ�û�����־,����Ҫʹ���������
     //myLogVisitor.WriteLog(this,key,val,reason);
     if (this._IsWriteLogs)
     {
         string logfilepath = Common.Utils.GetMapPath(string.Format("~\\LiteCMSLogs\\{0}.txt", DateTime.Now.ToString("yyMMdd")));
         Val = Val == null ? "" : Val.ToString();
         string message = string.Format("Key:{0},Value:{1},Reason:{2}", Key, Val, Reason.ToString());
         Logs.TinyLogs.InsertLog(logfilepath, DateTime.Now, "Cache_Removed", message);
     }
 }
        private void Signal(object value, CacheItemRemovedReason reason)
        {
            var virtualPath = Convert.ToString(value);
            Logger.Debug("虚拟路径发生了变更 ({1}) '{0}'", virtualPath, reason.ToString());

            var token = DetachToken(virtualPath);
            if (token != null)
                token.IsCurrent = false;
        }
Exemplo n.º 27
0
 /// <summary>
 /// Called when [remove].
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="cacheItem">The cache item.</param>
 /// <param name="reason">The reason.</param>
 public static void OnRemove(string key, object cacheItem, CacheItemRemovedReason reason)
 {
     ErrorHandler.Publish(LogLevel.Info,
                          "The cached value with key '" + key + "' was removed from the cache.  Reason: " +
                          reason.ToString());
 }
Exemplo n.º 28
0
 public static void RemovedCallback(string k, object v, CacheItemRemovedReason r)
 {
     Log.TraceLog("★★★★★★Cache中的数据库对象被移除!★★★★★★");
     Log.TraceLog("移除的原因为:" + r.ToString());
     try
     {
         if (v != null)
         {
             if (v is IDbConnection)
             {
                 IDbConnection connection = v as IDbConnection;
                 if (connection != null)
                 {
                     connection.Close();
                     connection = null;
                     Log.TraceLog("★★★★★★数据库正常关闭!!!★★★★★★");
                 }
                 else
                 {
                     Log.TraceLog("★★★★★★数据库已经关闭!!!★★★★★★");
                 }
             }
             else
             {
                 Log.TraceLog("★★★★★★数据库已经关闭!!!★★★★★★");
             }
         }
         else
         {
             Log.TraceLog("★★★★★★不是数据库对象,无法关闭★★★★★★");
         }
     }
     catch (Exception exception)
     {
         Log.ErrorLog("★★★★★★数据库关闭发生错误!!!★★★★★★");
         Log.ErrorLog(exception.Message);
     }
 }
 private void RemovedCallBack(string k, object v, CacheItemRemovedReason r)
 {
     Logger.Info(k + " : " + r.ToString() + "/" + Environment.StackTrace);
 }
Exemplo n.º 30
0
 public static void LogRemovedItemToAzure(String key, Object o, CacheItemRemovedReason r)
 {
     GenUtils.LogMsg("status", "LogRemovedItemToAzure: " + key, r.ToString());
 }
Exemplo n.º 31
0
 public void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
 {
     HitPage();
     WriteToLog(" Cache item callback, Reason: " + reason.ToString());
     DoWork();
 }
Exemplo n.º 32
0
 public static void LogRemovedItemToConsole(String key, Object o, CacheItemRemovedReason r)
 {
     Console.WriteLine("info: " + key + " " + r.ToString());
 }
Exemplo n.º 33
0
        /// <summary>
        /// Called when the root cache item has been removed from the cache
        /// </summary>
        /// <param name="key">the key of the cache item that wwas removed</param>
        /// <param name="value">the value of the cache item that was removed</param>
        /// <param name="reason">The <see cref="CacheItemRemovedReason"/> for the removal of the 
        ///     item from the cache</param>
        /// <remarks>
        ///     <para>Since all cache items are dependent on the root cache item, if this method is called, 
        ///     all the cache items for this region have also been removed</para>
        /// </remarks>
        private void RootCacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Cache items for region '{0}' have been removed from the cache for the following reason : {1}",
                                 _name, reason.ToString("g"));
            }

            //lets us know that we need to reestablish the root cache item for this region
            _isRootItemCached = false;
        }
 public void Refresh(string key, object expiredValue, CacheItemRemovedReason removalReason)
 {
     expiredKeys += key;
     expiredValues += expiredValue;
     removalReasons += removalReason.ToString();
 }
Exemplo n.º 35
0
 public void SearchCacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
 {
     LogManager.CurrentLog.AddEntry("Item removed from web cache:\r\n KEY: {0}\r\nREASON: {1}", LogEventType.Information, key, reason.ToString());
 }
Exemplo n.º 36
0
        public void RemovedPageIndexCallBack(string k, object v, CacheItemRemovedReason r)
        {
            cacheItemRemovedReason = r;
#if (DEBUG)
            if (LogRemovedReason)
            {
                var log = new LogInfo {
                    LogTypeKey = "HOST_ALERT"
                };

                string        itemName;
                string        count;
                List <string> portalCounts = null;
                switch (k)
                {
                case "DNN_" + PageIndexKey:
                    itemName = "Page Index";
                    //user profile actions
                    try
                    {
                        DataCache.RemoveCache(UserProfileActionsKey);
                    }
                    catch (ConfigurationErrorsException)
                    {
                        //do nothing, this means the web.config file was overwritten, and thus the cache
                        //was cleared.
                    }
                    if (v != null && v.GetType() == typeof(SharedDictionary <string, string>))
                    {
                        count = "Item Count: " + ((SharedDictionary <string, string>)v).Values.Count.ToString();
                    }
                    else
                    {
                        count = "N/a";
                    }

                    break;

                case "DNN_" + UrlDictKey:
                    itemName = "Friendly Url List";
                    if (v != null &&
                        v.GetType() == typeof(SharedDictionary <int, SharedDictionary <string, string> >))
                    {
                        var friendlyUrls = (SharedDictionary <int, SharedDictionary <string, string> >)v;
                        portalCounts = new List <string>();
                        using (friendlyUrls.GetReadLock())
                        {
                            count = "Portal Count: " + friendlyUrls.Count.ToString();
                            foreach (int key in friendlyUrls.Keys)
                            {
                                SharedDictionary <string, string> portalUrls = friendlyUrls[key];
                                using (portalUrls.GetReadLock())
                                {
                                    portalCounts.Add("Portal " + key.ToString() + " Item Count :" + portalUrls.Count.ToString());
                                }
                            }
                        }
                    }
                    else
                    {
                        count = "N/a";
                    }
                    break;

                default:
                    itemName = "Url Rewriter Cache Item";
                    count    = "";
                    break;
                }
                //add log values
                log.AddProperty("Url Rewriting Caching Message", itemName + " Cache item Removed.");
                log.AddProperty("Reason", cacheItemRemovedReason.ToString());
                log.AddProperty("Cache Item Key", k);
                log.AddProperty("Item Count", count);
                if (portalCounts != null)
                {
                    int i = 0;
                    foreach (string item in portalCounts)
                    {
                        log.AddProperty("Item " + i.ToString(), item);
                        i++;
                    }
                }
                //System.Diagnostics.Trace.Assert(k != null, "k == " + k);
                LogController.Instance.AddLog(log);
            }
#endif
        }
 public void SearchCacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
 {
     LogManager.CurrentLog.AddEntry("Item removed from web cache:\r\n KEY: {0}\r\nREASON: {1}", LogEventType.Information, key, reason.ToString());
 }
Exemplo n.º 38
0
 public static void LogRemovedItemToAzure(String key, Object o, CacheItemRemovedReason r)
 {
     GenUtils.LogMsg("info", "LogRemovedItemToAzure: " + key, r.ToString());
 }