コード例 #1
0
        public Comparator()
        {
            //vytvorim vsetky tie listy;
            tablesMissingInDb1 = new List<Tablee>();
            proceduresMissingInDb1 = new List<SProcedure>();
            functionsMissingInDb1 = new List<SFunction>();
            typesMissingInDb1 = new List<Typ>();
            usersMissingInDb1 = new List<User>();

            tablesMissingInDb2 = new List<Tablee>();
            proceduresMissingInDb2 = new List<SProcedure>();
            functionsMissingInDb2 = new List<SFunction>();
            typesMissingInDb2 = new List<Typ>();
            usersMissingInDb2 = new List<User>();

            differentFunctions = new List<DbSyncFunctionDiff>();
            differentProcedures = new List<DbSyncStoredProcedureDiff>();
            differentTables = new List<DbSyncTableDiff>();
            differentTypes = new List<DbSyncTypeDiff>();
            differentUsers = new List<DbSyncUserDiff>();
            //listy vytvorene

            db1 = new DataBasee();
            db2 = new DataBasee();

            //priradim eventhandlery
            db1.DatabaseChanged += new EventHandler(Akt_Vypis);
            db2.DatabaseChanged += new EventHandler(Akt_Vypis);
        }
コード例 #2
0
 public FrmSqlShow(List<string> sqlText, DataBasee dat)
 {
     InitializeComponent();
     this.datab = dat;
     this.sqlCommands = sqlText;
     if (dat != null && sqlText != null)
     {
         foreach (string s in sqlText)
         {
             this.richTextBox1.AppendText(s);
             this.richTextBox1.AppendText(Environment.NewLine + " GO " + Environment.NewLine);
         }
     }
 }
コード例 #3
0
 public FrmSqlShow(List <string> sqlText, DataBasee dat)
 {
     InitializeComponent();
     this.datab       = dat;
     this.sqlCommands = sqlText;
     if (dat != null && sqlText != null)
     {
         foreach (string s in sqlText)
         {
             this.richTextBox1.AppendText(s);
             this.richTextBox1.AppendText(Environment.NewLine + " GO " + Environment.NewLine);
         }
     }
 }
コード例 #4
0
        public DbSyncDataBaseDiff(DataBasee db1, DataBasee db2)
        {
            this.dataBaseA = db1;
            this.dataBaseB = db2;

            if (dataBaseA != null) DatabaseNameA = dataBaseA.getNameOfDAtabase();
            if (dataBaseB != null) DatabaseNameB = dataBaseB.getNameOfDAtabase();

            //vytvorim listy
            diffFunctions = new List<DbSyncFunctionDiff>();
            diffStoredProcedures = new List<DbSyncStoredProcedureDiff>();
            difftables = new List<DbSyncTableDiff>();
            diffTypes = new List<DbSyncTypeDiff>();
            diffUsers = new List<DbSyncUserDiff>();

            //vytvorim objekty tabuliek
            foreach (Tablee tabA in dataBaseA.Tabulky)
            {
                //zistim ci je tabulka s rovnakym nazovm v databaseB
                bool found = false;
                foreach (Tablee tabB in dataBaseB.Tabulky)
                {

                    if (tabA.NazovTabulky == tabB.NazovTabulky)
                    {
                        difftables.Add(new DbSyncTableDiff(tabA,tabB));
                        found = true;
                    }
                }
                if (!found) difftables.Add(new DbSyncTableDiff(tabA, null));
            }
            //este zistim ci nahodou nejaka tabulka v DatabaseB nieje naviac
            foreach (Tablee tabB in dataBaseB.Tabulky)
            {
                bool found = false;
                foreach (DbSyncTableDiff diff in difftables)
                {
                    if (diff.getTableName() == tabB.NazovTabulky) found = true;
                }
                if (!found) difftables.Add(new DbSyncTableDiff(null, tabB));
            }
            // tabulky vytvorene

            //vytvorim objekty Stored procedur
            foreach (SProcedure spA in dataBaseA.Procedury)
            {
                //zistim ci je procedura s rovnakym nazovm v databaseB
                bool found = false;
                foreach (SProcedure spB in dataBaseB.Procedury)
                {

                    if (spA.NazovProcedury == spB.NazovProcedury)
                    {
                        diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(spA, spB));
                        found = true;
                    }
                }
                if (!found) diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(spA, null));
            }
            //este zistim ci nahodou nejaka procedura v DatabaseB nieje naviac
            foreach (SProcedure spB in dataBaseB.Procedury)
            {
                bool found = false;
                foreach (DbSyncStoredProcedureDiff diff in diffStoredProcedures)
                {
                    if (diff.getName() == spB.NazovProcedury) found = true;
                }
                if (!found) diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(null, spB));
            }
            // Procedury vytvorene

            //vytvorim objekty funkcii
            foreach (SFunction sfA in dataBaseA.Funkcie)
            {

                bool found = false;
                foreach (SFunction sfB in dataBaseB.Funkcie)
                {

                    if (sfA.NazovFunkcie == sfB.NazovFunkcie)
                    {
                        diffFunctions.Add(new DbSyncFunctionDiff(sfA, sfB));
                        found = true;
                    }
                }
                if (!found) diffFunctions.Add(new DbSyncFunctionDiff(sfA, null));
            }

            foreach (SFunction sfB in dataBaseB.Funkcie)
            {
                bool found = false;
                foreach (DbSyncFunctionDiff diff in diffFunctions)
                {
                    if (diff.getName() == sfB.NazovFunkcie) found = true;
                }
                if (!found) diffFunctions.Add(new DbSyncFunctionDiff(null, sfB));
            }
            // funkcie vytvorene

            //vytvorim objekty typov
            foreach (Typ typA in dataBaseA.Typy)
            {

                bool found = false;
                foreach (Typ typB in dataBaseB.Typy)
                {

                    if (typA.Nazov == typB.Nazov)
                    {
                        diffTypes.Add(new DbSyncTypeDiff(typA, typB));
                        found = true;
                    }
                }
                if (!found) diffTypes.Add(new DbSyncTypeDiff(typA, null));
            }

            foreach (Typ typB in dataBaseB.Typy)
            {
                bool found = false;
                foreach (DbSyncTypeDiff diff in diffTypes)
                {
                    if (diff.getName() == typB.Nazov) found = true;
                }
                if (!found) diffTypes.Add(new DbSyncTypeDiff(null, typB));
            }
            // typy vytvorene

            //vytvorim objekty userov
            foreach (User usrA in dataBaseA.Usery)
            {

                bool found = false;
                foreach (User usrB in dataBaseB.Usery)
                {

                    if (usrA.UserName == usrB.UserName)
                    {
                        diffUsers.Add(new DbSyncUserDiff(usrA, usrB));
                        found = true;
                    }
                }
                if (!found) diffUsers.Add(new DbSyncUserDiff(usrA, null));
            }

            foreach (User usrB in dataBaseB.Usery)
            {
                bool found = false;
                foreach (DbSyncUserDiff diff in diffUsers)
                {
                    if (diff.getName() == usrB.UserName) found = true;
                }
                if (!found) diffUsers.Add(new DbSyncUserDiff(null, usrB));
            }
            // usery vytvoreny

            foreach (DbSyncTableDiff tab in difftables)
            {
                if (tab.isDifferent()) areDiffTables = true;
            }

            foreach (DbSyncFunctionDiff funct in diffFunctions)
            {
                if (funct.isDifferent()) areDiffFunctions = true;
            }

            foreach (DbSyncStoredProcedureDiff proc in diffStoredProcedures)
            {
                if (proc.isDifferent()) areDiffStoredProcedures = true;
            }

            foreach (DbSyncTypeDiff typee in diffTypes)
            {
                if (typee.isDifferent()) areDiffTypes = true;
            }

            foreach (DbSyncUserDiff usr in diffUsers)
            {
                if (usr.isDifferent()) areDiffUsers = true;
            }
        }
コード例 #5
0
        public DbSyncDataBaseDiff(DataBasee db1, DataBasee db2)
        {
            this.dataBaseA = db1;
            this.dataBaseB = db2;

            if (dataBaseA != null)
            {
                DatabaseNameA = dataBaseA.getNameOfDAtabase();
            }
            if (dataBaseB != null)
            {
                DatabaseNameB = dataBaseB.getNameOfDAtabase();
            }


            //vytvorim listy
            diffFunctions        = new List <DbSyncFunctionDiff>();
            diffStoredProcedures = new List <DbSyncStoredProcedureDiff>();
            difftables           = new List <DbSyncTableDiff>();
            diffTypes            = new List <DbSyncTypeDiff>();
            diffUsers            = new List <DbSyncUserDiff>();

            //vytvorim objekty tabuliek
            foreach (Tablee tabA in dataBaseA.Tabulky)
            {
                //zistim ci je tabulka s rovnakym nazovm v databaseB
                bool found = false;
                foreach (Tablee tabB in dataBaseB.Tabulky)
                {
                    if (tabA.NazovTabulky == tabB.NazovTabulky)
                    {
                        difftables.Add(new DbSyncTableDiff(tabA, tabB));
                        found = true;
                    }
                }
                if (!found)
                {
                    difftables.Add(new DbSyncTableDiff(tabA, null));
                }
            }
            //este zistim ci nahodou nejaka tabulka v DatabaseB nieje naviac
            foreach (Tablee tabB in dataBaseB.Tabulky)
            {
                bool found = false;
                foreach (DbSyncTableDiff diff in difftables)
                {
                    if (diff.getTableName() == tabB.NazovTabulky)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    difftables.Add(new DbSyncTableDiff(null, tabB));
                }
            }
            // tabulky vytvorene

            //vytvorim objekty Stored procedur
            foreach (SProcedure spA in dataBaseA.Procedury)
            {
                //zistim ci je procedura s rovnakym nazovm v databaseB
                bool found = false;
                foreach (SProcedure spB in dataBaseB.Procedury)
                {
                    if (spA.NazovProcedury == spB.NazovProcedury)
                    {
                        diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(spA, spB));
                        found = true;
                    }
                }
                if (!found)
                {
                    diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(spA, null));
                }
            }
            //este zistim ci nahodou nejaka procedura v DatabaseB nieje naviac
            foreach (SProcedure spB in dataBaseB.Procedury)
            {
                bool found = false;
                foreach (DbSyncStoredProcedureDiff diff in diffStoredProcedures)
                {
                    if (diff.getName() == spB.NazovProcedury)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    diffStoredProcedures.Add(new DbSyncStoredProcedureDiff(null, spB));
                }
            }
            // Procedury vytvorene

            //vytvorim objekty funkcii
            foreach (SFunction sfA in dataBaseA.Funkcie)
            {
                bool found = false;
                foreach (SFunction sfB in dataBaseB.Funkcie)
                {
                    if (sfA.NazovFunkcie == sfB.NazovFunkcie)
                    {
                        diffFunctions.Add(new DbSyncFunctionDiff(sfA, sfB));
                        found = true;
                    }
                }
                if (!found)
                {
                    diffFunctions.Add(new DbSyncFunctionDiff(sfA, null));
                }
            }

            foreach (SFunction sfB in dataBaseB.Funkcie)
            {
                bool found = false;
                foreach (DbSyncFunctionDiff diff in diffFunctions)
                {
                    if (diff.getName() == sfB.NazovFunkcie)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    diffFunctions.Add(new DbSyncFunctionDiff(null, sfB));
                }
            }
            // funkcie vytvorene

            //vytvorim objekty typov
            foreach (Typ typA in dataBaseA.Typy)
            {
                bool found = false;
                foreach (Typ typB in dataBaseB.Typy)
                {
                    if (typA.Nazov == typB.Nazov)
                    {
                        diffTypes.Add(new DbSyncTypeDiff(typA, typB));
                        found = true;
                    }
                }
                if (!found)
                {
                    diffTypes.Add(new DbSyncTypeDiff(typA, null));
                }
            }

            foreach (Typ typB in dataBaseB.Typy)
            {
                bool found = false;
                foreach (DbSyncTypeDiff diff in diffTypes)
                {
                    if (diff.getName() == typB.Nazov)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    diffTypes.Add(new DbSyncTypeDiff(null, typB));
                }
            }
            // typy vytvorene

            //vytvorim objekty userov
            foreach (User usrA in dataBaseA.Usery)
            {
                bool found = false;
                foreach (User usrB in dataBaseB.Usery)
                {
                    if (usrA.UserName == usrB.UserName)
                    {
                        diffUsers.Add(new DbSyncUserDiff(usrA, usrB));
                        found = true;
                    }
                }
                if (!found)
                {
                    diffUsers.Add(new DbSyncUserDiff(usrA, null));
                }
            }

            foreach (User usrB in dataBaseB.Usery)
            {
                bool found = false;
                foreach (DbSyncUserDiff diff in diffUsers)
                {
                    if (diff.getName() == usrB.UserName)
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    diffUsers.Add(new DbSyncUserDiff(null, usrB));
                }
            }
            // usery vytvoreny

            foreach (DbSyncTableDiff tab in difftables)
            {
                if (tab.isDifferent())
                {
                    areDiffTables = true;
                }
            }

            foreach (DbSyncFunctionDiff funct in diffFunctions)
            {
                if (funct.isDifferent())
                {
                    areDiffFunctions = true;
                }
            }

            foreach (DbSyncStoredProcedureDiff proc in diffStoredProcedures)
            {
                if (proc.isDifferent())
                {
                    areDiffStoredProcedures = true;
                }
            }

            foreach (DbSyncTypeDiff typee in diffTypes)
            {
                if (typee.isDifferent())
                {
                    areDiffTypes = true;
                }
            }

            foreach (DbSyncUserDiff usr in diffUsers)
            {
                if (usr.isDifferent())
                {
                    areDiffUsers = true;
                }
            }
        }