Ejemplo n.º 1
0
        private static void OnCheckDynamicTable(string key, object value, CacheRemovedReason reason)
        {
            try
            {
                DateTime date = DateTime.Now;
                int      logPriorBuildMonth = GetEntitySection().LogPriorBuildMonth;
                var      tableTypes         = _dynamicTables.ToList();
                foreach (var schema in tableTypes)
                {
                    DbBaseProvider dbprovider = DbConnectionProvider.CreateDbProvider(schema);
                    if (dbprovider == null)
                    {
                        continue;
                    }
                    string tableName = "";
                    int    count     = logPriorBuildMonth > 1 ? logPriorBuildMonth : 2;
                    for (int i = 0; i < count; i++)
                    {
                        tableName = schema.GetTableName(date, i);

                        DbColumn[] columns;
                        if (!dbprovider.CheckTable(tableName, out columns))
                        {
                            CreateTableSchema(schema, dbprovider, tableName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnCheckLogTable error:{0}", ex);
            }
        }
Ejemplo n.º 2
0
 private void OnRemoveCallback(string key, object value, CacheRemovedReason reason)
 {
     try
     {
         if (key == _cacheKey)
         {
             if (_listenerHandle != null)
             {
                 _listenerHandle(key, value, reason);
             }
             if (value != null && value.ToBool())
             {
                 Start();
             }
             else
             {
                 TraceLog.ReleaseWrite("Cache listener expire key:\"{0}\",reason:{1} is stoped.", key, reason);
             }
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("Cache listener expire key:\"{0}\",reason:{1},error:{2}", key, reason, ex);
     }
 }
Ejemplo n.º 3
0
        private void OnCacheEntryRemoved(CacheEntryRemovedArguments arg)
        {
            string             key    = arg.CacheItem.Key;
            CacheRemovedReason reason = CacheRemovedReason.None;

            switch (arg.RemovedReason)
            {
            case CacheEntryRemovedReason.Removed:
                reason = CacheRemovedReason.Removed;
                break;

            case CacheEntryRemovedReason.Expired:
                reason = CacheRemovedReason.Expired;
                break;

            case CacheEntryRemovedReason.ChangeMonitorChanged:
                reason = CacheRemovedReason.Changed;
                break;

            case CacheEntryRemovedReason.Evicted:
            case CacheEntryRemovedReason.CacheSpecificEviction:
                break;

            default:
                break;
            }
            this._callback.BeginInvoke(key, arg.CacheItem.Value, reason, EndCallback, null);
        }
Ejemplo n.º 4
0
 private static void DoCacheDispose(string key, object value, CacheRemovedReason reason)
 {
     if (reason == CacheRemovedReason.Expired)
     {
         _contextSet.Foreach((ckey, context) =>
         {
             if (context != null && MathUtils.DiffDate(context.ExpireDate).TotalSeconds > 3600)
             {
                 _contextSet.Remove(ckey);
             }
             return(true);
         });
     }
 }
Ejemplo n.º 5
0
        private static void OnCheckLogTable(string key, object value, CacheRemovedReason reason)
        {
            try
            {
                var tableTypes = _logTables.ToList();
                foreach (var type in tableTypes)
                {
                    SchemaTable schema;
                    if (!SchemaSet.TryGetValue(type, out schema))
                    {
                        continue;
                    }
                    DbBaseProvider dbprovider = DbConnectionProvider.CreateDbProvider(schema);
                    if (dbprovider == null)
                    {
                        continue;
                    }
                    string tableName = "";
                    string format    = "";
                    for (int i = 0; i < LogPriorBuildMonth; i++)
                    {
                        int month = i;
                        format    = LogTableNameFormat.Replace("$date", DateTime.Now.AddMonths(month).ToString("yyyyMM"));
                        tableName = string.Format(format, schema.SpecialName);

                        DbColumn[] columns;
                        if (!dbprovider.CheckTable(tableName, out columns))
                        {
                            CreateTableSchema(schema, dbprovider, tableName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnCheckLogTable error:{0}", ex);
            }
        }
Ejemplo n.º 6
0
 private void OnRemoveCallback(string key, object value, CacheRemovedReason reason)
 {
     try
     {
         if (key == _cacheKey)
         {
             if (_listenerHandle != null)
             {
                 _listenerHandle(key, value, reason);
             }
             if (value != null && value.ToBool())
             {
                 Start();
             }
             else
             {
                 TraceLog.ReleaseWrite("Cache listener expire key:\"{0}\",reason:{1} is stoped.", key, reason);
             }
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("Cache listener expire key:\"{0}\",reason:{1},error:{2}", key, reason, ex);
     }
 }