Exemplo n.º 1
0
        //static DbSubscribeRuleConfigHelper()
        //{
        //    try
        //    {
        //        //注册缓存刷新回调和初始化缓存
        //        var data = RefreashDbPartitionConfigCache();
        //        bool r = Cache.CacheFileProvider.Register(cachekey, new Cache.CacheFileInfo { IintervalTime = 1000 * 5, CacheData = data, RefreashMethod = DbSubscribeRuleConfigHelper.RefreashDbPartitionConfigCache });
        //        if (r == false)
        //        {
        //            ErrorLog.Write("注册订阅库db分区配置缓存失败", null);
        //        }
        //    }
        //    catch (Exception exp)
        //    {
        //        ErrorLog.Write("注册订阅库db分区配置出错", exp);
        //    }
        //}

        /// <summary>
        /// 刷新数据从数据库
        /// </summary>
        /// <returns></returns>
        private static List <tb_dbsubscribe_config_model> RefreshData(DateTime lastRefeshTime)
        {
            List <tb_dbsubscribe_config_model> models = new List <tb_dbsubscribe_config_model>();

            using (var conn = Db.DbConn.CreateConn(DbType.SQLSERVER, XXF.Common.XXFConfig.ConfigConnectString))
            {
                conn.Open();
                //   int type=LibConvert.StrToInt(XXF.Common.XXFConfig.MainConnectString):
                models = new Dal.tb_dbsubscribe_config_dal().Get(conn, lastRefeshTime);
            }


            if (configData == null)
            {
                configData = new Dictionary <string, tb_dbsubscribe_config_model>();
            }
            foreach (var m in models)
            {
                string dicKey = GetDicKey(m.id.ToString());
                if (m.isDel)
                {
                    configData.Remove(dicKey);
                }
                else
                {
                    if (configData.ContainsKey(dicKey))
                    {
                        configData[dicKey] = m;
                    }
                    else
                    {
                        configData.Add(dicKey, m);
                    }
                }
            }
            List <tb_dbsubscribe_config_model> data = new List <tb_dbsubscribe_config_model>(configData.Values);

            return(data);
        }
        //static DbSubscribeRuleConfigHelper()
        //{
        //    try
        //    {
        //        //注册缓存刷新回调和初始化缓存
        //        var data = RefreashDbPartitionConfigCache();
        //        bool r = Cache.CacheFileProvider.Register(cachekey, new Cache.CacheFileInfo { IintervalTime = 1000 * 5, CacheData = data, RefreashMethod = DbSubscribeRuleConfigHelper.RefreashDbPartitionConfigCache });
        //        if (r == false)
        //        {
        //            ErrorLog.Write("注册订阅库db分区配置缓存失败", null);
        //        }
        //    }
        //    catch (Exception exp)
        //    {
        //        ErrorLog.Write("注册订阅库db分区配置出错", exp);
        //    }
        //}
        /// <summary>
        /// 刷新数据从数据库
        /// </summary>
        /// <returns></returns>
        private static List<tb_dbsubscribe_config_model> RefreshData(DateTime lastRefeshTime)
        {
            List<tb_dbsubscribe_config_model> models = new List<tb_dbsubscribe_config_model>();
            using (var conn = Db.DbConn.CreateConn(DbType.SQLSERVER, XXF.Common.XXFConfig.ConfigConnectString))
            {
                conn.Open();
                //   int type=LibConvert.StrToInt(XXF.Common.XXFConfig.MainConnectString):
                models = new Dal.tb_dbsubscribe_config_dal().Get(conn,lastRefeshTime);
            }

            if (configData == null)
            {
                configData = new Dictionary<string, tb_dbsubscribe_config_model>();
            }
            foreach (var m in models)
            {
                string dicKey = GetDicKey(m.id.ToString());
                if (m.isDel)
                {
                    configData.Remove(dicKey);
                }
                else
                {
                    if (configData.ContainsKey(dicKey))
                    {
                        configData[dicKey] = m;
                    }
                    else
                    {
                        configData.Add(dicKey, m);
                    }
                }
            }
            List<tb_dbsubscribe_config_model> data = new List<tb_dbsubscribe_config_model>(configData.Values);
            return data;
        }