/// <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; case "create": operationResult = operationHandler.CreateOperation(input); break; case "update": operationResult = operationHandler.UpdateOperation(input); break; default: // Throw an exception when an operation // that does not exist is requested throw new InvalidExecuteOperationException( ErrorCodes.UnknownOperation.Number, ErrorCodes.UnknownOperation.Description); } LogOperationResult(operationResult); } //Here we throw the Fatal Error Exception which is //used to notify upper layers that an error has occured //in the Connector and will be unable to recover from it catch (FatalErrorException) { throw; } catch (Exception exception) { //Log any other exceptions that occur in method 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; }
/// <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; case "create": operationResult = operationHandler.CreateOperation(input); break; case "update": operationResult = operationHandler.UpdateOperation(input); break; default: // Throw an exception when an operation // that does not exist is requested throw new InvalidExecuteOperationException( ErrorCodes.UnknownOperation.Number, ErrorCodes.UnknownOperation.Description); } LogOperationResult(operationResult); } //Here we throw the Fatal Error Exception which is //used to notify upper layers that an error has occured //in the Connector and will be unable to recover from it catch (FatalErrorException) { throw; } catch (Exception exception) { //Log any other exceptions that occur in method 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; }