public void CreateStoredProcedure(ProcedureFile procedure)
 {
     CreateStoredProcedure(procedure.GetTable(), procedure.GetOperation(), procedure.GetVersion());
 }
 public void DowngradeStoredProcedure(ProcedureFile procedure)
 {
     DowngradeStoredProcedure(procedure.GetTable(), procedure.GetOperation(), procedure.GetVersion(), procedure.GetRevision());
 }
        private void ReadProceduresDirectory(string dir)
        {
            //Console.WriteLine("ReadProceduresDirectory: " + dir);
            if (Directory.Exists(dir))
            {
                //Console.WriteLine("Found " + dir + " directory");
                string[] files = Directory.GetFiles(dir);
                foreach (string f in files)
                {
                    var revisions  = new List <int>();
                    var versions   = new Hashtable();
                    var operations = new Hashtable();

                    try {
                        //Console.WriteLine("Found file: " + f);
                        ProcedureFile pf = new ProcedureFile(f);
                        //Console.WriteLine("Table: " + pf.GetTable() + ", Operation: " + pf.GetOperation() +
                        //    ", Version: " + pf.GetVersion() + ", Revision: " + pf.GetRevision());

                        string table     = pf.GetTable();
                        string operation = pf.GetOperation();
                        int    version   = pf.GetVersion();
                        int    revision  = pf.GetRevision();
                        if (!tables.ContainsKey(table))
                        {
                            revisions.Add(revision);
                            versions.Add(version, revisions);
                            operations.Add(operation, versions);
                            tables.Add(table, operations);
                        }

                        operations = (Hashtable)tables[table];
                        if (!operations.ContainsKey(operation))
                        {
                            revisions.Add(revision);
                            versions.Add(version, revisions);
                            operations.Add(operation, versions);
                        }

                        versions = (Hashtable)operations[operation];
                        if (!versions.ContainsKey(version))
                        {
                            revisions.Add(revision);
                            versions.Add(version, revisions);
                        }

                        revisions = (List <int>)versions[version];
                        if (!revisions.Contains(revision))
                        {
                            revisions.Add(revision);
                            revisions.Sort();
                        }
                    }
                    catch (Exception) {
                        // Just in case we see a file that doesn't fit the naming convention
                    }
                }
                foreach (string t in tables.Keys)
                {
                    //Console.WriteLine("Table: " + t);
                    Hashtable op = (Hashtable)tables[t];
                    foreach (string o in op.Keys)
                    {
                        //Console.WriteLine("  Operation: " + o);
                        Hashtable ver = (Hashtable)op[o];
                        foreach (int v in ver.Keys)
                        {
                            //Console.WriteLine("    Version: " + v);
                            List <int> revs = (List <int>)ver[v];
                            foreach (int r in revs)
                            {
                                //Console.WriteLine("      Revision: " + r);
                            }
                        }
                    }
                }
            }
        }
 public void DropStoredProcedure(ProcedureFile procedure)
 {
     DropStoredProcedure(procedure.GetTable(), procedure.GetOperation(), procedure.GetVersion());
 }