コード例 #1
0
        protected void ExecuteWithException(T connection, DatabaseCommand cmd)
        {
            Tuple <bool, string> t = ExecuteCommand(connection, cmd);

            if (!t.Item1)
            {
                throw new DatabaseCommandException(t.Item2, cmd);
            }
        }
コード例 #2
0
        public Tuple <bool, string> ExecuteCommand(T connection, DatabaseCommand cmd)
        {
            if (cmd.Version != 0 && cmd.Revision != 0 && AllVersions.ContainsKey(cmd.Version.ToString()) &&
                AllVersions[cmd.Version.ToString()].ContainsKey(cmd.Revision.ToString()))
            {
                return(new Tuple <bool, string>(true, null));
            }

            Tuple <bool, string> ret;

            string message = cmd.CommandName;

            if (message.Length > 42)
            {
                message = message.Substring(0, 42) + "...";
            }
            message = ServerState.Instance.CurrentSetupStatus =
                Commons.Properties.Resources.Database_ApplySchema + cmd.Version + "." + cmd.Revision +
                " - " + message;
            ServerState.Instance.CurrentSetupStatus = message;

            switch (cmd.Type)
            {
            case DatabaseCommandType.CodedCommand:
                ret = cmd.UpdateCommand(connection);
                break;

            case DatabaseCommandType.PostDatabaseFix:
                try
                {
                    AddFix(cmd);
                    ret = new Tuple <bool, string>(true, null);
                }
                catch (Exception e)
                {
                    ret = new Tuple <bool, string>(false, e.ToString());
                }
                break;

            default:
                ret = ExecuteCommand(connection, cmd.Command);
                break;
            }
            if (cmd.Version != 0 && ret.Item1 && cmd.Type != DatabaseCommandType.PostDatabaseFix)
            {
                AddVersion(cmd.Version.ToString(), cmd.Revision.ToString(), cmd.CommandName);
            }

            return(ret);
        }
コード例 #3
0
        public Tuple <bool, string> ExecuteCommand(T connection, DatabaseCommand cmd)
        {
            if (cmd.Version != 0 && cmd.Revision != 0)
            {
                if (AllVersions.ContainsKey(cmd.Version.ToString()) &&
                    AllVersions[cmd.Version.ToString()].ContainsKey(cmd.Revision.ToString()))
                {
                    return(new Tuple <bool, string>(true, null));
                }
            }
            Tuple <bool, string> ret;

            switch (cmd.Type)
            {
            case DatabaseCommandType.CodedCommand:
                ret = cmd.UpdateCommand(connection);
                break;

            case DatabaseCommandType.PostDatabaseFix:
                try
                {
                    AddFix(cmd);
                    ret = new Tuple <bool, string>(true, null);
                }
                catch (Exception e)
                {
                    ret = new Tuple <bool, string>(false, e.ToString());
                }
                break;

            default:
                ret = ExecuteCommand(connection, cmd.Command);
                break;
            }
            if (cmd.Version != 0 && ret.Item1 && cmd.Type != DatabaseCommandType.PostDatabaseFix)
            {
                AddVersion(cmd.Version.ToString(), cmd.Revision.ToString(), cmd.CommandName);
            }
            return(ret);
        }
コード例 #4
0
 public void AddFix(DatabaseCommand cmd)
 {
     Fixes.Add(cmd);
 }
コード例 #5
0
 public DatabaseCommandException(string message, DatabaseCommand cmd) : base(message)
 {
     DatabaseCommand = cmd;
 }