//protected override string ChangedDbConn(string newDbName)
        //{
        //    string dbName = Path.GetFileNameWithoutExtension(DbFilePath);
        //    string newDbPath = DbFilePath.Replace(dbName, newDbName);
        //    if (File.Exists(newDbPath))
        //    {
        //        filePath = string.Empty;
        //        return base.conn.Replace(dbName, newDbName);
        //    }
        //    return conn;
        //}
        private Assembly GetAssembly()
        {
            object ass = _Cache.Get("SQLite_Assembly");

            if (ass == null)
            {
                try
                {
                    ass = Assembly.Load(providerName);
                    _Cache.Add("SQLite_Assembly", ass, null, 10080, System.Web.Caching.CacheItemPriority.High);
                }
                catch (Exception err)
                {
                    string errMsg = err.Message;
                    if (!System.IO.File.Exists(AppConst.RunFolderPath + "System.Data.SQLite.DLL"))
                    {
                        errMsg = "Can't find the System.Data.SQLite.dll more info : " + errMsg;
                    }
                    else
                    {
                        errMsg = "You need to choose the right version : x86 or x64. more info : \r\n" + errMsg;
                    }
                    Error.Throw(errMsg);
                }
            }
            return(ass as Assembly);
        }
 /// <summary>
 /// 将文档缓存到全局Cache中
 /// </summary>
 /// <param name="key">缓存的Key名称</param>
 /// <param name="isClone">是否克隆副本存档</param>
 /// <param name="cacheTimeMinutes">存档的分钟数</param>
 public void SaveToCache(string key, bool isClone, double cacheTimeMinutes)
 {
     if (_XmlDocument != null)
     {
         if (!isClone)
         {
             theCache.Add(key, _XmlDocument, _FileName, cacheTimeMinutes);//添加Cache缓存
         }
         else
         {
             theCache.Add(key, GetCloneFrom(_XmlDocument), _FileName, cacheTimeMinutes);//添加Cache缓存Clone
         }
     }
 }
Exemple #3
0
        private IAop GetFromConfig()
        {
            IAop aop = null;

            string aopApp = AppConfig.Aop;

            if (!string.IsNullOrEmpty(aopApp))
            {
                if (_Cache.Contains("Aop_Instance"))
                {
                    aop = _Cache.Get("Aop_Instance") as IAop;
                }
                else
                {
                    #region AOP加载

                    string[] aopItem = aopApp.Split(',');
                    if (aopItem.Length == 2)//完整类名,程序集(dll)名称
                    {
                        try
                        {
                            System.Reflection.Assembly ass = System.Reflection.Assembly.Load(aopItem[1]);
                            if (ass != null)
                            {
                                object instance = ass.CreateInstance(aopItem[0]);
                                if (instance != null)
                                {
                                    _Cache.Add("Aop_Instance", instance, AppConst.RunFolderPath + aopItem[1].Replace(".dll", "") + ".dll", 1440);
                                    aop = instance as IAop;
                                    if (!_CallOnLoad)
                                    {
                                        lock (lockObj)
                                        {
                                            if (!_CallOnLoad)
                                            {
                                                _CallOnLoad = true;
                                                aop.OnLoad();
                                            }
                                        }
                                    }
                                    return(aop);
                                }
                            }
                        }
                        catch (Exception err)
                        {
                            string errMsg = err.Message + "--Web.config need add a config item,for example:<add key=\"Aop\" value=\"Web.Aop.AopAction,Aop\" />(value format:namespace.Classname,Assembly name) ";
                            Error.Throw(errMsg);
                        }
                    }
                    #endregion
                }
            }
            if (aop != null)
            {
                return(aop.Clone());
            }
            return(null);
        }
        /// <summary>
        /// 缓存
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public IList <tb_config_model> GetCacheList(DbConn conn, string key)
        {
            IList <tb_config_model> cacheList = CacheManage.Retrieve(key) as List <tb_config_model>;

            if (cacheList != null && cacheList.Count > 0)
            {
                return(cacheList);
            }
            IList <tb_config_model> list = this.GetList(conn);

            CacheManage.Add(key, list);
            return(list);
        }
Exemple #5
0
        protected override DbProviderFactory GetFactory(string providerName)
        {
            object factory = _Cache.Get("MySqlClient_Factory");

            if (factory == null)
            {
                Assembly ass = GetAssembly();
                factory = ass.CreateInstance("MySql.Data.MySqlClient.MySqlClientFactory");
                if (factory == null)
                {
                    throw new System.Exception("Can't Create  MySqlClientFactory in MySql.Data.dll");
                }
                else
                {
                    _Cache.Add("MySqlClient_Factory", factory, null, 10080, System.Web.Caching.CacheItemPriority.High);
                }
            }
            return(factory as DbProviderFactory);
        }
Exemple #6
0
        /// <summary>
        /// 新增用户缓存数据 有个更新 没有就新增
        /// </summary>
        /// <param name="KeyNum">键</param>
        /// <param name="Info">值</param>
        /// <returns></returns>
        public static bool UpdateCache(string KeyNum, object Info)
        {
            if (Info == null)
            {
                return(false);
            }
            try
            {
                var _KeyNum = string.Concat(KeyNum, GetIdentityKey);

                CacheManage cache = CacheManage.LocalInstance;
                cache.Add(_KeyNum, Info, 15);
                return(true);
            }
            catch (Exception ex)
            {
                Log.WriteLogToTxt(string.Format("更新用户缓存信息[UpdateUserInfoCache]:{0}", ex.Message));
                return(false);
            }
        }