コード例 #1
0
        /// <summary>
        /// This method will execute a Method returning a result. 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public MethodResult ExecuteMethod(MethodInput input)
        {
            MethodResult methodResult;

            // 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 Method"))
            {
                //Construct a new instance of the method handler 
                //passing along the current instance of the data access object
                MethodHandler methodHandler = new MethodHandler(_dataAccess);

                try
                {
                    //Use the name stored in the method 
                    //input to determine the correct method to execute
                    switch (input.Name.ToLower())
                    {
                        case "getobjectdefinition":
                            methodResult = methodHandler.GetObjectDefinition(input);
                            break;
                        case "createorupdateobjectforreplication":
                            methodResult = methodHandler.CreateOrUpdateObjectForReplication(input);
                            break;
                        case "getlastreplicationsyncdate":
                            methodResult = methodHandler.GetLastReplicationSyncDate(input);
                            break;
                        default:
                            string message = string.Format(ErrorCodes.UnknownMethod.Description, input.Name);
                            throw new InvalidExecuteMethodException(ErrorCodes.UnknownMethod.Number, message);
                    }

                    LogMethodResult(methodResult);
                }
                //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 during method execution 
                    //and store them in the MethodResult.ErrorInfo
                    methodResult = new MethodResult {Success = false};
                    
                    //Create the error info using the exception message
                    methodResult.ErrorInfo = new ErrorResult
                    {
                        Description = exception.Message,
                        Detail = exception.StackTrace,
                        Number = ErrorCodes.MethodError.Number
                    };

                    LogMethodResult(methodResult);
                }


            }
            return methodResult;
        }
コード例 #2
0
        /// <summary>
        /// This method will execute a Method returning a result. 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public MethodResult ExecuteMethod(MethodInput input)
        {
            MethodResult methodResult;

            // 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 Method"))
            {
                //Construct a new instance of the method handler
                //passing along the current instance of the data access object
                MethodHandler methodHandler = new MethodHandler(_dataAccess);

                try
                {
                    //Use the name stored in the method
                    //input to determine the correct method to execute
                    switch (input.Name.ToLower())
                    {
                        case "getobjectdefinition":
                            methodResult = methodHandler.GetObjectDefinition(input);
                            break;
                        case "createorupdateobjectforreplication":
                            methodResult = methodHandler.CreateOrUpdateObjectForReplication(input);
                            break;
                        case "getlastreplicationsyncdate":
                            methodResult = methodHandler.GetLastReplicationSyncDate(input);
                            break;
                        default:
                            string message = string.Format(ErrorCodes.UnknownMethod.Description, input.Name);
                            throw new InvalidExecuteMethodException(ErrorCodes.UnknownMethod.Number, message);
                    }

                    LogMethodResult(methodResult);
                }
                //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 during method execution
                    //and store them in the MethodResult.ErrorInfo
                    methodResult = new MethodResult {Success = false};

                    //Create the error info using the exception message
                    methodResult.ErrorInfo = new ErrorResult
                    {
                        Description = exception.Message,
                        Detail = exception.StackTrace,
                        Number = ErrorCodes.MethodError.Number
                    };

                    LogMethodResult(methodResult);
                }

            }
            return methodResult;
        }