public DBsyncTvTableType(Tablee tab)
 {
     this.tab        = tab;
     this.Text       = tab.NazovTabulky;
     this.typeOfIcon = TableIcon;
     this.Name       = this.Text;
 }
Ejemplo n.º 2
0
 public abstract List <string> removeKey(Tablee tabIn, Key keyIn);
Ejemplo n.º 3
0
 public abstract List <string> alterKey(Tablee tabIn, Key keyIn);
Ejemplo n.º 4
0
 public abstract List <string> removeColumn(Tablee tabIn, Columnn colIn);
Ejemplo n.º 5
0
 public abstract List <string> alterColumn(Tablee tabIn, Columnn colIn);
Ejemplo n.º 6
0
 public abstract List <string> alterTrigger(Tablee tabIn, Trigger trigIn);
Ejemplo n.º 7
0
 public abstract List <string> alterIndex(Tablee tabIn, Index indexIn);
Ejemplo n.º 8
0
 public override List <string> removeTrigger(Tablee tabIn, Trigger trigIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public override List <string> removeIndex(Tablee tabIn, Index indexIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 public override List <string> removeKey(Tablee tabIn, Key keyIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
 public override List <string> removeConstraint(Tablee tabIn, Constraintt constIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
 public override List <string> alterColumn(Tablee tabIn, Columnn colIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public override List <string> removeFKonTab(Tablee tab)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public override List <string> createTable(Tablee tabIn)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 public abstract List <string> alterConstraint(Tablee tabIn, Constraintt constIn);
Ejemplo n.º 16
0
 public abstract List <string> createTable(Tablee tabIn);
Ejemplo n.º 17
0
 public abstract List <string> removeConstraint(Tablee tabIn, Constraintt constIn);
Ejemplo n.º 18
0
 public abstract List <string> removeTable(Tablee tabIn);
Ejemplo n.º 19
0
 public abstract List <string> removeTrigger(Tablee tabIn, Trigger trigIn);
Ejemplo n.º 20
0
 public abstract List <string> removeFKonTab(Tablee tab);
Ejemplo n.º 21
0
 public abstract List <string> removeIndex(Tablee tabIn, Index indexIn);
Ejemplo n.º 22
0
        public DbSyncTableDiff(Tablee tabAin, Tablee tabBin)
        {
            columnsDifList    = new List <DbSyncColumnDiff>();
            constraintDifList = new List <DbSyncConstraintDiff>();
            triggerDifList    = new List <DbSyncTriggerDiff>();
            privilegeDifList  = new List <DbSyncPrivilegeDiff>();
            indexesDifList    = new List <DbSyncIndexDiff>();
            keysDifList       = new List <DbSyncKeyDiff>();

            columnsMissingDb1     = new List <Columnn>();
            columnsMissingDb2     = new List <Columnn>();
            columnsDifferent      = new List <DbSyncColumnDiff>();
            keysMissingDb1        = new List <Key>();
            keysMissingDb2        = new List <Key>();
            keysDifferent         = new List <DbSyncKeyDiff>();
            constraintsMissingDb1 = new List <Constraintt>();
            constraintsMissingDb2 = new List <Constraintt>();
            constraintsDifferent  = new List <DbSyncConstraintDiff>();
            triggersMissingDb1    = new List <Trigger>();
            triggersMissingDb2    = new List <Trigger>();
            triggersDifferent     = new List <DbSyncTriggerDiff>();
            grantsMissingDb1      = new List <Privilege>();
            grantsMissingDb2      = new List <Privilege>();
            grantsDifferent       = new List <DbSyncPrivilegeDiff>();
            indexesMissingDb1     = new List <Index>();
            indexesMissingDb2     = new List <Index>();
            indexesDifferent      = new List <DbSyncIndexDiff>();



            this.tabA = tabAin;
            this.tabB = tabBin;
            if (tabA != null)
            {
                TableName = tabA.NazovTabulky;
            }
            else if (tabB != null)
            {
                TableName = tabB.NazovTabulky;
            }
            else
            {
                TableName = "UNDEFINED";
            }

            if (tabA != null && tabB != null)
            {
                if (tabA.NazovTabulky == tabB.NazovTabulky)
                {
                    diffTableName = false;
                    if (!compareKeys(tabA.Keys, tabB.Keys))
                    {
                        diffKeys = true;
                    }
                    if (!compareCoulumns(tabA.Stlpce, tabB.Stlpce))
                    {
                        diffCoulumns = true;
                    }
                    if (!CompareIndexes(tabA.Indexy, tabB.Indexy))
                    {
                        diffIndexes = true;
                    }
                    if (!CompareConstraints(tabA.Constrainty, tabB.Constrainty))
                    {
                        diffConstraints = true;
                    }
                    if (!CompareTriggers(tabA.Trigre, tabB.Trigre))
                    {
                        diffTriggers = true;
                    }
                    if (!ComparePrivileges(tabA.Privileges, tabB.Privileges))
                    {
                        diffPrivileges = true;
                    }
                }
                else
                {
                    diffTableName = true;
                }

                if (diffTableName || diffCoulumns || diffIndexes || diffConstraints || diffTriggers || diffPrivileges || diffKeys)
                {
                    different = true;
                }
                else
                {
                    different = false;
                }
            }
            else
            {
                different = true;
            }

            //to by sme mali vytvorenie samotnej tabulky, treba este vytvorit jej stlpce, procedury atd atd...

            //vytvorenie stlpcov
            if (tabA != null && tabB != null)
            {
                foreach (Columnn colA in tabA.Stlpce)
                {
                    bool found = false;
                    foreach (Columnn colB in tabB.Stlpce)
                    {
                        if (colA.COULUMN_NAME1 == colB.COULUMN_NAME1)
                        {
                            found = true;
                            this.columnsDifList.Add(new DbSyncColumnDiff(colA, colB));
                        }
                    }
                    if (!found)
                    {
                        this.columnsDifList.Add(new DbSyncColumnDiff(colA, null));
                    }
                }
                foreach (Columnn colB in tabB.Stlpce)
                {
                    bool found = false;
                    foreach (DbSyncColumnDiff col in columnsDifList)
                    {
                        if (colB.COULUMN_NAME1 == col.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.columnsDifList.Add(new DbSyncColumnDiff(null, colB));
                    }
                }
                //stlpce hotove

                //vytvorim indexy
                foreach (Index indA in tabA.Indexy)
                {
                    bool found = false;
                    foreach (Index indB in tabB.Indexy)
                    {
                        if (indA.Name == indB.Name)
                        {
                            found = true;
                            this.indexesDifList.Add(new DbSyncIndexDiff(indA, indB));
                        }
                    }
                    if (!found)
                    {
                        this.indexesDifList.Add(new DbSyncIndexDiff(indA, null));
                    }
                }
                foreach (Index indB in tabB.Indexy)
                {
                    bool found = false;
                    foreach (DbSyncIndexDiff ind in indexesDifList)
                    {
                        if (indB.Name == ind.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.indexesDifList.Add(new DbSyncIndexDiff(null, indB));
                    }
                }

                //vytvorim constrainty
                foreach (Constraintt conA in tabA.Constrainty)
                {
                    bool found = false;
                    foreach (Constraintt conB in tabB.Constrainty)
                    {
                        if (conA.Constraint_nam == conB.Constraint_nam)
                        {
                            found = true;
                            this.constraintDifList.Add(new DbSyncConstraintDiff(conA, conB));
                        }
                    }
                    if (!found)
                    {
                        this.constraintDifList.Add(new DbSyncConstraintDiff(conA, null));
                    }
                }
                foreach (Constraintt conB in tabB.Constrainty)
                {
                    bool found = false;
                    foreach (DbSyncConstraintDiff con in constraintDifList)
                    {
                        if (conB.Constraint_nam == con.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.constraintDifList.Add(new DbSyncConstraintDiff(null, conB));
                    }
                }

                //vytvorim trigre
                foreach (Trigger trigA in tabA.Trigre)
                {
                    bool found = false;
                    foreach (Trigger trigB in tabB.Trigre)
                    {
                        if (trigA.Trigger_name == trigB.Trigger_name)
                        {
                            found = true;
                            this.triggerDifList.Add(new DbSyncTriggerDiff(trigA, trigB));
                        }
                    }
                    if (!found)
                    {
                        this.triggerDifList.Add(new DbSyncTriggerDiff(trigA, null));
                    }
                }
                foreach (Trigger trigB in tabB.Trigre)
                {
                    bool found = false;
                    foreach (DbSyncTriggerDiff trig in triggerDifList)
                    {
                        if (trigB.Trigger_name == trig.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.triggerDifList.Add(new DbSyncTriggerDiff(null, trigB));
                    }
                }


                //vytvorim kluce
                foreach (Key keyA in tabA.Keys)
                {
                    bool found = false;
                    foreach (Key keyB in tabB.Keys)
                    {
                        if (keyA.NameOfKey == keyB.NameOfKey)
                        {
                            found = true;
                            this.keysDifList.Add(new DbSyncKeyDiff(keyA, keyB));
                        }
                    }
                    if (!found)
                    {
                        this.keysDifList.Add(new DbSyncKeyDiff(keyA, null));
                    }
                }
                foreach (Key keyB in tabB.Keys)
                {
                    bool found = false;
                    foreach (DbSyncKeyDiff k in keysDifList)
                    {
                        if (keyB.NameOfKey == k.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.keysDifList.Add(new DbSyncKeyDiff(null, keyB));
                    }
                }

                //vytvorim privileges
                foreach (Privilege privA in tabA.Privileges)
                {
                    bool found = false;
                    foreach (Privilege privB in tabB.Privileges)
                    {
                        if (privA.DBSyncCompareTO(privB))
                        {
                            found = true;
                            this.privilegeDifList.Add(new DbSyncPrivilegeDiff(privA, privB));
                        }
                    }
                    if (!found)
                    {
                        this.privilegeDifList.Add(new DbSyncPrivilegeDiff(privA, null));
                    }
                }
                foreach (Privilege privB in tabB.Privileges)
                {
                    bool found = false;
                    foreach (DbSyncPrivilegeDiff priv in privilegeDifList)
                    {
                        if (privB.getName() == priv.getName())
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        this.privilegeDifList.Add(new DbSyncPrivilegeDiff(null, privB));
                    }
                }
            }

            if (tabA == null)
            {
                foreach (Columnn colB in tabB.Stlpce)
                {
                    this.columnsDifList.Add(new DbSyncColumnDiff(null, colB));
                }

                foreach (Index indB in tabB.Indexy)
                {
                    this.indexesDifList.Add(new DbSyncIndexDiff(null, indB));
                }

                foreach (Constraintt conB in tabB.Constrainty)
                {
                    this.constraintDifList.Add(new DbSyncConstraintDiff(null, conB));
                }

                foreach (Trigger trigB in tabB.Trigre)
                {
                    this.triggerDifList.Add(new DbSyncTriggerDiff(null, trigB));
                }
                //vytvorim kluce
                foreach (Key keyB in tabB.Keys)
                {
                    this.keysDifList.Add(new DbSyncKeyDiff(null, keyB));
                }

                //vytvorim privileges
                foreach (Privilege privB in tabB.Privileges)
                {
                    this.privilegeDifList.Add(new DbSyncPrivilegeDiff(null, privB));
                }
            }

            if (tabB == null)
            {
                foreach (Columnn colA in tabA.Stlpce)
                {
                    this.columnsDifList.Add(new DbSyncColumnDiff(colA, null));
                }

                foreach (Index indA in tabA.Indexy)
                {
                    this.indexesDifList.Add(new DbSyncIndexDiff(indA, null));
                }

                foreach (Constraintt conA in tabA.Constrainty)
                {
                    this.constraintDifList.Add(new DbSyncConstraintDiff(conA, null));
                }

                foreach (Trigger trigA in tabA.Trigre)
                {
                    this.triggerDifList.Add(new DbSyncTriggerDiff(trigA, null));
                }
                //vytvorim kluce
                foreach (Key keyA in tabA.Keys)
                {
                    this.keysDifList.Add(new DbSyncKeyDiff(keyA, null));
                }

                //vytvorim privileges
                foreach (Privilege privA in tabA.Privileges)
                {
                    this.privilegeDifList.Add(new DbSyncPrivilegeDiff(privA, null));
                }
            }
            fulfillLists();
        }