/// <summary>
        /// This method will execute an operation returning a result.
        /// This method is also used in bulk operations.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public OperationResult ExecuteOperation(OperationInput input)
        {
            OperationResult operationResult;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution
                       (Globals.ConnectorName, "Execute Operation"))
            {
                //Construct a new instance of the operation handler,
                //passing along the current instance of the data access object
                OperationHandler operationHandler = new OperationHandler(_dataAccess);

                try
                {
                    //Use the name stored in the operation input
                    //to determine the correct operation to execute
                    switch (input.Name.ToLower())
                    {
                    case "delete":
                        operationResult = operationHandler.DeleteOperation(input);
                        break;

                    default:
                        // Throw an exception when an opertion that does not exist is requested.
                        throw new InvalidExecuteOperationException(
                                  ErrorCodes.UnknownOperation.Number,
                                  ErrorCodes.UnknownOperation.Description);
                    }

                    LogOperationResult(operationResult);
                }
                // Throw the Fatal Error Exception which notifies
                // the upper layers that an error has occured
                // in the Connector and will be unable to recover.
                catch (FatalErrorException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    // Log any other exceptions that occur in operation execution and
                    // throw the Invalid Execute Operation Exception
                    string msg = string.Format("{0} {1}",
                                               Globals.ConnectorName, exception.Message);
                    Logger.Write(Logger.Severity.Error,
                                 Globals.ConnectorName, msg);
                    throw new InvalidExecuteOperationException(msg);
                }
            }

            return(operationResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method will execute an operation returning a result. 
        /// This method is also used in bulk operations.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public OperationResult ExecuteOperation(OperationInput input)
        {
            OperationResult operationResult;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution
                (Globals.ConnectorName, "Execute Operation"))
            {
                //Construct a new instance of the operation handler,
                //passing along the current instance of the data access object
                OperationHandler operationHandler = new OperationHandler(_dataAccess);

                try
                {
                    //Use the name stored in the operation input
                    //to determine the correct operation to execute
                    switch (input.Name.ToLower())
                    {
                        case "delete":
                            operationResult = operationHandler.DeleteOperation(input);
                            break;
                        default:
                            // Throw an exception when an opertion that does not exist is requested.
                            throw new InvalidExecuteOperationException(
                                ErrorCodes.UnknownOperation.Number,
                                ErrorCodes.UnknownOperation.Description);
                    }

                    LogOperationResult(operationResult);
                }
                // Throw the Fatal Error Exception which notifies
                // the upper layers that an error has occured
                // in the Connector and will be unable to recover.
                catch (FatalErrorException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    // Log any other exceptions that occur in operation execution and
                    // throw the Invalid Execute Operation Exception
                    string msg = string.Format("{0} {1}",
                        Globals.ConnectorName, exception.Message);
                    Logger.Write(Logger.Severity.Error,
                        Globals.ConnectorName, msg);
                    throw new InvalidExecuteOperationException(msg);
                }
            }

            return operationResult;
        }