Ejemplo n.º 1
0
 internal static void PreLoadAllDBSchemeToCache()
 {
     if (!isFirstLoad)
     {
         isFirstLoad = true;
         lock (obj)
         {
             if (isFirstLoad)
             {
                 //DealUpdateSql();
                 //处理单表
                 foreach (ConnectionStringSettings item in ConfigurationManager.ConnectionStrings)
                 {
                     string name = item.Name.ToLower();
                     if (!string.IsNullOrEmpty(name) && name.EndsWith("conn"))
                     {
                         try
                         {
                             CacheManage.PreLoadDBSchemaToCache(name, true);
                         }
                         catch
                         {
                         }
                     }
                 }
                 ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(LoadViewSchema));
                 //处理视图文件
                 fyw.EnableRaisingEvents = true;
                 fyw.Changed            += fyw_Changed;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static void ClearCache(object threadid)
 {
     try
     {
         while (true)
         {
             Thread.Sleep(5);
             if (!KeyTable.HasAutoCacheTable && KeyTable.CheckSysAutoCacheTable())            //检测并创建表,放在循环中,是因为可能在代码中延后会AppConifg.Cache.AutoCacheConn赋值;
             {
                 ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCacheKeyTask)); //将数据库检测独立一个线程,不影响此内存操作。
             }
             if (removeList.Count > 0)
             {
                 string baseKey = removeList.Dequeue();
                 if (!string.IsNullOrEmpty(baseKey))
                 {
                     RemoveCache(baseKey);
                     if (KeyTable.HasAutoCacheTable)//检测是否开启AutoCacheConn数据库链接
                     {
                         removeListForKeyTask.Enqueue(baseKey);
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
        static ConfigurationManager()
        {
            AppConfig.IsAspNetCore = true;
            ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(RegGB2312));
            string filePath = AppConfig.RunPath + "appsettings.json";

            appSettingJson = JsonHelper.ReadJson(filePath);
            InitAddtionalConfigFiles();//加载额外的附加配置。
        }
Ejemplo n.º 4
0
        static ConfigurationManager()
        {
            AppConfig.IsAspNetCore = true;
            ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(RegGB2312));
            string filePath = AppConfig.RunPath + "appsettings.json";

            ReInitConfig(filePath);
            IOWatch.On(filePath, delegate(FileSystemEventArgs e)
            {
                Thread.Sleep(500);
                ReInitConfig(e.FullPath);
            });
        }
Ejemplo n.º 5
0
 internal LocalCache()
 {
     try
     {
         ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(ClearState));
         if (AppConfig.Cache.IsAutoCache)
         {
             ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCache.ClearCache));
         }
     }
     catch (Exception err)
     {
         errorCount++;
         Log.WriteLogToTxt(err);
     }
 }
Ejemplo n.º 6
0
 internal LocalCache()
 {
     try
     {
         theCache = H.Cache;//如果配置文件错误会引发此异常。
         ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(ClearState));
         if (AppConfig.Cache.IsAutoCache)
         {
             ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCache.ClearCache));
         }
     }
     catch (Exception err)
     {
         Log.WriteLogToTxt(err);
     }
 }
Ejemplo n.º 7
0
 internal LocalCache()
 {
     try
     {
         ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(ClearState));
         ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(ConnObject.CheckConnIsOk));//主从链接的检测机制。
         //if (AppConfig.Cache.IsAutoCache) // 机制变更为Aop也可控制,所以这个参数还决定不了
         //{
         ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(AutoCache.ClearCache));
         //}
     }
     catch (Exception err)
     {
         errorCount++;
         Log.Write(err, LogType.Cache);
     }
 }
Ejemplo n.º 8
0
        static ConfigurationManager()
        {
            AppConfig.IsAspNetCore = true;
            ThreadBreak.AddGlobalThread(new ParameterizedThreadStart(RegGB2312));
            string filePath = AppConfig.RunPath + "appsettings.json";

            if (System.IO.File.Exists(filePath))
            {
                appSettingJson = IOHelper.ReadAllText(filePath);
                if (!string.IsNullOrEmpty(appSettingJson))
                {
                    int index = appSettingJson.LastIndexOf("/*");
                    if (index > -1)//去掉注释
                    {
                        appSettingJson = Regex.Replace(appSettingJson, @"/\*[.\s\S]*?\*/", string.Empty, RegexOptions.IgnoreCase);
                    }
                    char splitChar = '\n';
                    if (appSettingJson.IndexOf(splitChar) > -1)
                    {
                        string[]      items = appSettingJson.Split(splitChar);
                        StringBuilder sb    = new StringBuilder();
                        foreach (string item in items)
                        {
                            if (!item.TrimStart(' ', '\r').StartsWith("//"))
                            {
                                sb.Append(item.Trim(' ', '\r'));
                            }
                        }
                        appSettingJson = sb.ToString();
                    }
                    if (appSettingJson.IndexOf("\\\\") > -1)
                    {
                        appSettingJson = appSettingJson.Replace("\\\\", "\\");
                    }
                }
            }
        }