private static T ExecuteWithTracing <T>(VfpCommand vfpCommand, VfpCommandMethod method, Func <T> executeFunc) { var executionEventArgs = new VfpCommandExecutionDetails(vfpCommand, method); executionEventArgs.Status = VfpCommandExecutionStatus.Executing; vfpCommand.Connection.RaiseExecuting(executionEventArgs); var sw = new Stopwatch(); try { try { sw.Start(); var result = executeFunc(); sw.Stop(); executionEventArgs.Result = result; executionEventArgs.Duration = sw.Elapsed; executionEventArgs.Status = VfpCommandExecutionStatus.Finished; vfpCommand.Connection.RaiseFinished(executionEventArgs); return(result); } catch (OleDbException oleDbException) { throw new VfpException(oleDbException.Message, oleDbException); } } catch (Exception ex) { executionEventArgs.Result = ex; executionEventArgs.Status = VfpCommandExecutionStatus.Failed; vfpCommand.Connection.RaiseFailed(executionEventArgs); throw; } }
internal static T Execute <T>(VfpCommand vfpCommand, VfpCommandMethod method, Func <T> executeFunc) { if (VfpClientTracing.Tracer.HasSourceLevel(SourceLevels.Information)) { return(ExecuteWithTracing(vfpCommand, method, executeFunc)); } return(ExecuteWithoutTracing(executeFunc)); }
private T Execute <T>(Func <VfpCommand, T> executeFunc, VfpCommandMethod method) { var vfpCommand = GetCommand(); if (VfpClientTracing.Tracer.HasSourceLevel(SourceLevels.Information)) { return(ExecuteWithTracing(vfpCommand, method, () => executeFunc(vfpCommand))); } return(ExecuteWithoutTracing(() => executeFunc(vfpCommand))); }
internal VfpCommandExecutionDetails(VfpCommand command, VfpCommandMethod method) { CommandId = command.CommandId; Command = command; Method = method; }