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; } }
private static void RaiseExecutionAction(Action <VfpCommandExecutionDetails> action, VfpCommandExecutionDetails executionEventArgs) { if (action == null) { return; } action(executionEventArgs); }
internal void RaiseFailed(VfpCommandExecutionDetails executionEventArgs) { RaiseExecutionAction(CommandFailed, executionEventArgs); }