示例#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)
            {
                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);
        }
 public DatabaseCommandException(string message, DatabaseCommand cmd) : base(message)
 {
     DatabaseCommand = cmd;
 }
示例#4
0
 public void AddFix(DatabaseCommand cmd)
 {
     Fixes.Add(cmd);
 }
 public DatabaseCommandException(string message, DatabaseCommand cmd)
     : base(message)
 {
     DatabaseCommand = cmd;
 }