Esempio n. 1
0
        /// <summary>
        /// Runs the specified database adapter.
        /// </summary>
        /// <param name="databaseAdapter">The database adapter.</param>
        /// <returns></returns>
        public ErrorCode Run(Strategies.DatabaseAdapter databaseAdapter)
        {
            log.InfoFormat(CultureInfo.InvariantCulture, "{0} : running...", this);

            var errorCode = ErrorCode.Ok;

            if (!databaseAdapter.Connect(ConnectionString))
            {
                log.Error("Failed to connect to the database");
                errorCode = ErrorCode.DatabaseAdapterFailureAtConnect;
            }

            if (errorCode == ErrorCode.Ok)
            {
                errorCode = RunImplementation(databaseAdapter);
                databaseAdapter.Disconnect();
            }

            if (errorCode == ErrorCode.Ok)
            {
                log.InfoFormat(CultureInfo.InvariantCulture, "{0} : succeeded", this);
            }
            else
            {
                log.ErrorFormat(CultureInfo.InvariantCulture, "{0} : FAILED.", this);
            }

            return errorCode;
        }