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
        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));
        }
Ejemplo n.º 3
0
        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)));
        }
Ejemplo n.º 4
0
 internal VfpCommandExecutionDetails(VfpCommand command, VfpCommandMethod method)
 {
     CommandId = command.CommandId;
     Command   = command;
     Method    = method;
 }