/// <summary>
 /// 保存所有的全局变量
 /// </summary>
 /// <param name="globalVariableList">所有的全局变量列表</param>
 public void SaveAllGlobalVariable(List <GlobalVariable> globalVariableList)
 {
     CheckSaveAllGlobalVariable(globalVariableList);
     lock (GlobalVariableCache)
     {
         using (TransactionScope tx = new TransactionScope())
         {
             Repository.DeleteAll();
             int sortIndex = 0;
             foreach (GlobalVariable globalVariable in globalVariableList)
             {
                 globalVariable.Id           = NextId();
                 globalVariable.VarSortIndex = sortIndex;
                 sortIndex++;
             }
             Repository.Insert(globalVariableList);
             tx.Complete();
         }
         GlobalVariableCache.Clear();
         GlobalVariableCache.AddRange(globalVariableList);
         GlobalVariableMapCache.Clear();
         foreach (GlobalVariable globalVariable in globalVariableList)
         {
             GlobalVariableMapCache.Add(globalVariable.VarName, globalVariable.VarValue);
         }
     }
 }
 void LoadGlobalVariableFromDb()
 {
     if (GlobalVariableCache.Count == 0)
     {
         lock (GlobalVariableCache)
         {
             if (GlobalVariableCache.Count == 0)
             {
                 List <GlobalVariable> globalVariableList = Repository.FindAllList();
                 globalVariableList.Sort((a, b) => (int)(a.VarSortIndex - b.VarSortIndex));
                 GlobalVariableCache.AddRange(globalVariableList);
                 foreach (GlobalVariable globalVariable in globalVariableList)
                 {
                     GlobalVariableMapCache.Add(globalVariable.VarName, globalVariable.VarValue);
                 }
             }
         }
     }
 }