1
This commit is contained in:
@@ -5,6 +5,7 @@ namespace BLL
|
|||||||
using Quartz;
|
using Quartz;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -22,13 +23,13 @@ namespace BLL
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 维护一个DB集合
|
/// 维护一个DB集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static Dictionary<int, Model.SGGLDB> dataBaseLinkList = new System.Collections.Generic.Dictionary<int, Model.SGGLDB>();
|
private static ConcurrentDictionary<int, Model.SGGLDB> dataBaseLinkList = new ConcurrentDictionary<int, Model.SGGLDB>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 维护一个DB集合
|
/// 维护一个DB集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static System.Collections.Generic.Dictionary<int, Model.SGGLDB> DBList
|
public static ConcurrentDictionary<int, Model.SGGLDB> DBList
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -148,7 +149,7 @@ namespace BLL
|
|||||||
{
|
{
|
||||||
if (!DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
if (!DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
||||||
{
|
{
|
||||||
DBList.Add(System.Threading.Thread.CurrentThread.ManagedThreadId, new SGGLDB(connString));
|
DBList.TryAdd(System.Threading.Thread.CurrentThread.ManagedThreadId, new Model.SGGLDB(connString));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].CommandTimeout = 1200;
|
// DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].CommandTimeout = 1200;
|
||||||
|
|||||||
@@ -106,14 +106,15 @@ namespace WebAPI.Filter
|
|||||||
}
|
}
|
||||||
if (!isOk)
|
if (!isOk)
|
||||||
{
|
{
|
||||||
if (BLL.Funs.DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
|
||||||
{
|
|
||||||
BLL.Funs.DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].Dispose();
|
|
||||||
BLL.Funs.DBList.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnActionExecuted(actionExecutedContext);
|
base.OnActionExecuted(actionExecutedContext);
|
||||||
}
|
}
|
||||||
|
if (BLL.Funs.DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
||||||
|
{
|
||||||
|
Model.SGGLDB db;
|
||||||
|
BLL.Funs.DBList.TryRemove(System.Threading.Thread.CurrentThread.ManagedThreadId,out db );
|
||||||
|
db.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user