Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        private static void RaiseExecutionAction(Action <VfpCommandExecutionDetails> action, VfpCommandExecutionDetails executionEventArgs)
        {
            if (action == null)
            {
                return;
            }

            action(executionEventArgs);
        }
Ejemplo n.º 3
0
 internal void RaiseFailed(VfpCommandExecutionDetails executionEventArgs)
 {
     RaiseExecutionAction(CommandFailed, executionEventArgs);
 }