Added code to Track DB Usage. Uses the StackTrace to find which object and method are being used when the database is being used.
Added Profile debug
This commit is contained in:
parent
29ffd0329c
commit
25719bf869
@ -19,6 +19,7 @@ using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Volian.Base.Library;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@ -71,13 +72,41 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return Database._ConnectionName; }
|
||||
set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ }
|
||||
}
|
||||
private static bool _TrackDBUsage = false;
|
||||
public static bool TrackDBUsage
|
||||
{
|
||||
get { return _TrackDBUsage; }
|
||||
set { _TrackDBUsage = value; }
|
||||
}
|
||||
private static Dictionary<string, int> _Methods = new Dictionary<string, int>();
|
||||
public static void ShowDBTracking(string fileName)
|
||||
{
|
||||
DebugDBTrack.Open(VlnSettings.TemporaryFolder + "\\" + fileName);
|
||||
ShowDictionary();
|
||||
DebugDBTrack.Show();
|
||||
}
|
||||
private static string _VEPROMS_Connection;
|
||||
public static string VEPROMS_Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TrackDBUsage)
|
||||
{
|
||||
string str = Volian.Base.Library.vlnStackTrace.CalledFromCSLA;
|
||||
//if (str.Contains("ItemAndChildren"))
|
||||
//{
|
||||
// ShowDictionary(Methods);
|
||||
// Methods = new Dictionary<string, int>();
|
||||
//}
|
||||
if (!_Methods.ContainsKey(str))
|
||||
_Methods.Add(str, 1);
|
||||
else
|
||||
_Methods[str]++;
|
||||
}
|
||||
if (_VEPROMS_Connection != null ) // Use Lazy Load
|
||||
{
|
||||
return _VEPROMS_Connection;
|
||||
}
|
||||
DateTime.Today.ToLongDateString();
|
||||
// If DBConnection.XML exists, use the connection string from DBConnection.XML
|
||||
string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML";
|
||||
@ -118,6 +147,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
set { _VEPROMS_Connection = value; }
|
||||
}
|
||||
private static void ShowDictionary()
|
||||
{
|
||||
DebugDBTrack.WriteLine("\"Module\"\t\"Count\"");
|
||||
foreach (string key in _Methods.Keys)
|
||||
{
|
||||
DebugDBTrack.WriteLine("\"{0}\"\t{1}", key, _Methods[key]);
|
||||
}
|
||||
}
|
||||
private static string FixServer(string connectionString)
|
||||
{
|
||||
string serverName = Volian.Base.Library.VlnSettings.GetCommand("Server",null);
|
||||
|
@ -17,6 +17,7 @@ using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using Volian.Base.Library;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public delegate void ItemInfoEvent(object sender);
|
||||
@ -313,11 +314,13 @@ namespace VEPROMS.CSLA.Library
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
//int profileDepth = ProfileTimer.Push(">>>> ItemParts");
|
||||
CanReadProperty("ItemParts", true);
|
||||
if (_ItemPartCount < 0 || (_ItemPartCount > 0 && _ItemParts == null))
|
||||
_ItemParts = PartInfoList.GetByItemID(_ItemID);
|
||||
if (_ItemPartCount < 0)
|
||||
_ItemPartCount = _ItemParts.Count;
|
||||
//ProfileTimer.Pop(profileDepth);
|
||||
return _ItemParts;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user