public class ErrorAndComputationTimeHandler
{
public static void Invoke<TContract>(TContract proxy, Action<TContract> action, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
action(proxy);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
}
public static void Invoke<TContract, TContract2>(TContract proxy, TContract2 proxy2, Action<TContract,
TContract2> action, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
action(proxy, proxy2);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
}
public static void Invoke<TContract, TContract2, TContract3>(TContract proxy, TContract2 proxy2, TContract3 proxy3,
Action<TContract, TContract2, TContract3> action, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
action(proxy, proxy2, proxy3);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
}
public static void Invoke<TContract, TContract2, TContract3, TContract4>(TContract proxy, TContract2 proxy2,
TContract3 proxy3, TContract4 proxy4, Action<TContract, TContract2, TContract3, TContract4> action, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
action(proxy, proxy2, proxy3, proxy4);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
}
public static TReturn Invoke<TContract, TReturn>(TContract proxy, Func<TContract, TReturn> func, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
TReturn returnValue = default(TReturn);
try
{
returnValue = func(proxy);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
return returnValue;
}
public static TReturn Invoke<TContract, TContract2, TReturn>(TContract proxy, TContract2 proxy2,
Func<TContract, TContract2, TReturn> func, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
TReturn returnValue = default(TReturn);
try
{
returnValue = func(proxy, proxy2);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
return returnValue;
}
public static TReturn Invoke<TContract, TContract2, TContract3, TReturn>(TContract proxy, TContract2 proxy2,
TContract3 proxy3, Func<TContract, TContract2, TContract3, TReturn> func, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
TReturn returnValue = default(TReturn);
try
{
returnValue = func(proxy, proxy2, proxy3);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
return returnValue;
}
public static TReturn Invoke<TContract, TContract2, TContract3, TContract4, TReturn>(TContract proxy, TContract2 proxy2,
TContract3 proxy3, TContract4 proxy4, Func<TContract, TContract2, TContract3, TContract4,
TReturn> func, string MethodElapsedTimeText,string MethodErrorText)
{
Stopwatch sw = new Stopwatch();
sw.Start();
TReturn returnValue = default(TReturn);
try
{
returnValue = func(proxy, proxy2, proxy3, proxy4);
}
catch (Exception ex)
{
//Handle Exception
WebLog.SquareLog.CommonLogger.Error(MethodErrorText + ex.ToString());
}
sw.Stop();
WebLog.SquareLog.CommonLogger.Error(MethodElapsedTimeText + sw.ElapsedMilliseconds.ToString() + "毫秒");
return returnValue;
}
}