public FrmSqlCode(SqlTextHighlited sqlTextAin, SqlTextHighlited sqlTextBin) { InitializeComponent(); if (sqlTextAin != null) sqlTextListA = sqlTextAin.Text; if (sqlTextBin != null) sqlTextListB = sqlTextBin.Text; if (sqlTextAin != null) highlitedA = sqlTextAin.Highlited; if (sqlTextBin != null) highlitedB = sqlTextBin.Highlited; sqlTextA.Clear(); if (sqlTextAin != null) { for (int i = 0; i < sqlTextListA.Count; i++) { if (highlitedA.Contains(i)) sqlTextA.SelectionColor = Color.Red; sqlTextA.AppendText(sqlTextListA[i]); } } sqlTextB.Clear(); if (sqlTextBin != null) { for (int i = 0; i < sqlTextListB.Count; i++) { if (highlitedB.Contains(i)) sqlTextB.SelectionColor = Color.Red; sqlTextB.AppendText(sqlTextListB[i]); } } }
private void button3_Click_1(object sender, EventArgs e) { List <string> test = new List <string>(); test.Add("skuska\r\n"); test.Add("skuska2\r\n"); List <int> highl = new List <int>(); highl.Add(0); SqlTextHighlited s = new SqlTextHighlited(test, highl); FrmSqlCode ff = new FrmSqlCode(s, s); ff.Show(); }
public FrmSqlCode(SqlTextHighlited sqlTextAin, SqlTextHighlited sqlTextBin) { InitializeComponent(); if (sqlTextAin != null) { sqlTextListA = sqlTextAin.Text; } if (sqlTextBin != null) { sqlTextListB = sqlTextBin.Text; } if (sqlTextAin != null) { highlitedA = sqlTextAin.Highlited; } if (sqlTextBin != null) { highlitedB = sqlTextBin.Highlited; } sqlTextA.Clear(); if (sqlTextAin != null) { for (int i = 0; i < sqlTextListA.Count; i++) { if (highlitedA.Contains(i)) { sqlTextA.SelectionColor = Color.Red; } sqlTextA.AppendText(sqlTextListA[i]); } } sqlTextB.Clear(); if (sqlTextBin != null) { for (int i = 0; i < sqlTextListB.Count; i++) { if (highlitedB.Contains(i)) { sqlTextB.SelectionColor = Color.Red; } sqlTextB.AppendText(sqlTextListB[i]); } } }
public DbSyncFunctionDiff(SFunction functionAin, SFunction functionBin) { this.functionA = functionAin; this.functionB = functionBin; functionAtributesA = new List <ObjectAtribute>(); functionAtributesB = new List <ObjectAtribute>(); privilegeDiffList = new List <DbSyncPrivilegeDiff>(); grantsMissingDb1 = new List <Privilege>(); grantsMissingDb2 = new List <Privilege>(); grantsDifferent = new List <DbSyncPrivilegeDiff>(); fulfillLists(); ComparatorOfSQL compSQL; if (functionA == null || functionB == null) { if (functionA != null) { functionName = functionA.NazovFunkcie; functionAtributesA.Add(new ObjectAtribute("Name of function ", functionName, true)); functionAtributesA.Add(new ObjectAtribute("Sql text ", "Click button", true, true)); functionAtributesA.Add(new ObjectAtribute("Return type ", functionA.ReturnType, true)); compSQL = new ComparatorOfSQL(functionA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } if (functionB != null) { functionName = functionB.NazovFunkcie; functionAtributesB.Add(new ObjectAtribute("Name of function ", functionName, true)); functionAtributesB.Add(new ObjectAtribute("Sql text ", "Click button", true, true)); functionAtributesB.Add(new ObjectAtribute("Return type ", functionB.ReturnType, true)); compSQL = new ComparatorOfSQL(null, functionB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextA; } else { functionName = "UNDEFINED"; } } if (functionA != null && functionB != null) { compSQL = new ComparatorOfSQL(functionA.SqlText, functionB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; if (functionA.NazovFunkcie != functionB.NazovFunkcie) { diffNAmeOfFunction = true; } if (functionA.ReturnType != functionB.ReturnType) { diffReturnType = true; } if (compSQL.IsDifferent) { diffSqlText = true; } if (!ComparePrivileges(functionA.Privileges, functionB.Privileges)) { diffPrivileges = true; } if (diffNAmeOfFunction || diffPrivileges || diffReturnType || diffSqlText) { different = true; } else { different = false; } //vytvorim privileges foreach (Privilege privA in functionA.Privileges) { bool found = false; foreach (Privilege privB in functionB.Privileges) { if (privA.DBSyncCompareTO(privB)) { found = true; privilegeDiffList.Add(new DbSyncPrivilegeDiff(privA, privB)); } } if (!found) { privilegeDiffList.Add(new DbSyncPrivilegeDiff(privA, null)); } } foreach (Privilege privB in functionB.Privileges) { bool found = false; foreach (DbSyncPrivilegeDiff priv in privilegeDiffList) { if (privB.getName() == priv.getName()) { found = true; } } if (!found) { this.privilegeDiffList.Add(new DbSyncPrivilegeDiff(null, privB)); } } functionName = functionA.NazovFunkcie; functionAtributesA.Add(new ObjectAtribute("Name of function ", functionName, false)); functionAtributesB.Add(new ObjectAtribute("Name of function ", functionName, false)); if (diffSqlText) { ObjectAtribute sqlA = new ObjectAtribute("Sql text ", "Click button", true, true); functionAtributesA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Sql text ", "Click button", true, true); functionAtributesB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Sql text ", "Click button", false, true); functionAtributesA.Add(sql); functionAtributesB.Add(sql); } if (diffReturnType) { ObjectAtribute sqlA = new ObjectAtribute("Return type ", functionA.ReturnType, true); functionAtributesA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Return type ", functionB.ReturnType, true); functionAtributesB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Return type ", functionA.ReturnType, false); functionAtributesA.Add(sql); functionAtributesB.Add(sql); } } else { different = true; } }
public DbSyncStoredProcedureDiff(SProcedure procAin, SProcedure procBin) { this.procA = procAin; this.procB = procBin; storedProcDiffListA = new List <ObjectAtribute>(); storedProcDiffListB = new List <ObjectAtribute>(); privilegeDifList = new List <DbSyncPrivilegeDiff>(); grantsMissingDb1 = new List <Privilege>(); grantsMissingDb2 = new List <Privilege>(); grantsDifferent = new List <DbSyncPrivilegeDiff>(); fulfillLists(); ComparatorOfSQL compSQL; if (procA == null || procB == null) { if (procA != null) { procedureName = procA.NazovProcedury; storedProcDiffListA.Add(new ObjectAtribute("Procedure name", procedureName, false)); storedProcDiffListA.Add(new ObjectAtribute("Sql text ", "Click button", false, true)); compSQL = new ComparatorOfSQL(procA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } else if (procB != null) { procedureName = procB.NazovProcedury; storedProcDiffListB.Add(new ObjectAtribute("Procedure name", procedureName, false)); storedProcDiffListB.Add(new ObjectAtribute("Sql text ", "Click button", false, true)); compSQL = new ComparatorOfSQL(null, procB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextB; } else { procedureName = "UNDEFINED"; } } if (procA != null && procB != null) { compSQL = new ComparatorOfSQL(procA.SqlText, procB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; procedureName = procB.NazovProcedury; storedProcDiffListA.Add(new ObjectAtribute("Procedure name", procedureName, false)); storedProcDiffListB.Add(new ObjectAtribute("Procedure name", procedureName, false)); if (procA.NazovProcedury != procB.NazovProcedury) { diffNameOfProcedure = true; } if (compSQL.IsDifferent) { diffSqlText = true; } if (!ComparePrivileges(procA.Privieges, procB.Privieges)) { diffPrivileges = true; } if (diffNameOfProcedure || diffPrivileges || diffSqlText) { different = true; } else { different = false; } //vytvorim privileges foreach (Privilege privA in procA.Privieges) { bool found = false; foreach (Privilege privB in procB.Privieges) { 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 procB.Privieges) { 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 (diffSqlText) { ObjectAtribute sqlA = new ObjectAtribute("Sql text ", "Click button", true, true); storedProcDiffListA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Sql text ", "Click button", true, true); storedProcDiffListB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Sql text ", "Click button", false, true); storedProcDiffListA.Add(sql); storedProcDiffListB.Add(sql); } } else { different = true; } }
public DbSyncFunctionDiff(SFunction functionAin, SFunction functionBin) { this.functionA = functionAin; this.functionB = functionBin; functionAtributesA = new List<ObjectAtribute>(); functionAtributesB = new List<ObjectAtribute>(); privilegeDiffList = new List<DbSyncPrivilegeDiff>(); grantsMissingDb1 = new List<Privilege>(); grantsMissingDb2 = new List<Privilege>(); grantsDifferent = new List<DbSyncPrivilegeDiff>(); fulfillLists(); ComparatorOfSQL compSQL; if (functionA == null || functionB == null) { if (functionA != null) { functionName = functionA.NazovFunkcie; functionAtributesA.Add(new ObjectAtribute("Name of function ",functionName, true)); functionAtributesA.Add(new ObjectAtribute("Sql text ", "Click button", true,true)); functionAtributesA.Add(new ObjectAtribute("Return type ", functionA.ReturnType, true)); compSQL = new ComparatorOfSQL(functionA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } if (functionB != null) { functionName = functionB.NazovFunkcie; functionAtributesB.Add(new ObjectAtribute("Name of function ", functionName, true)); functionAtributesB.Add(new ObjectAtribute("Sql text ", "Click button", true, true)); functionAtributesB.Add(new ObjectAtribute("Return type ", functionB.ReturnType, true)); compSQL = new ComparatorOfSQL(null, functionB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextA; } else functionName = "UNDEFINED"; } if (functionA != null && functionB != null) { compSQL = new ComparatorOfSQL(functionA.SqlText, functionB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; if (functionA.NazovFunkcie != functionB.NazovFunkcie) diffNAmeOfFunction = true; if (functionA.ReturnType != functionB.ReturnType) diffReturnType = true; if (compSQL.IsDifferent) diffSqlText = true; if (!ComparePrivileges(functionA.Privileges, functionB.Privileges)) diffPrivileges = true; if (diffNAmeOfFunction || diffPrivileges || diffReturnType || diffSqlText) different = true; else different = false; //vytvorim privileges foreach (Privilege privA in functionA.Privileges) { bool found = false; foreach (Privilege privB in functionB.Privileges) { if (privA.DBSyncCompareTO(privB)) { found = true; privilegeDiffList.Add(new DbSyncPrivilegeDiff(privA, privB)); } } if (!found) privilegeDiffList.Add(new DbSyncPrivilegeDiff(privA, null)); } foreach (Privilege privB in functionB.Privileges) { bool found = false; foreach (DbSyncPrivilegeDiff priv in privilegeDiffList) { if (privB.getName() == priv.getName()) { found = true; } } if (!found) this.privilegeDiffList.Add(new DbSyncPrivilegeDiff(null, privB)); } functionName = functionA.NazovFunkcie; functionAtributesA.Add(new ObjectAtribute("Name of function ", functionName, false)); functionAtributesB.Add(new ObjectAtribute("Name of function ", functionName, false)); if (diffSqlText) { ObjectAtribute sqlA = new ObjectAtribute("Sql text ", "Click button", true, true); functionAtributesA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Sql text ", "Click button", true, true); functionAtributesB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Sql text ", "Click button", false, true); functionAtributesA.Add(sql); functionAtributesB.Add(sql); } if (diffReturnType) { ObjectAtribute sqlA = new ObjectAtribute("Return type ", functionA.ReturnType, true); functionAtributesA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Return type ", functionB.ReturnType, true); functionAtributesB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Return type ", functionA.ReturnType, false); functionAtributesA.Add(sql); functionAtributesB.Add(sql); } } else different = true; }
public DbSyncStoredProcedureDiff(SProcedure procAin, SProcedure procBin) { this.procA = procAin; this.procB = procBin; storedProcDiffListA = new List<ObjectAtribute>(); storedProcDiffListB = new List<ObjectAtribute>(); privilegeDifList = new List<DbSyncPrivilegeDiff>(); grantsMissingDb1 = new List<Privilege>(); grantsMissingDb2 = new List<Privilege>(); grantsDifferent = new List<DbSyncPrivilegeDiff>(); fulfillLists(); ComparatorOfSQL compSQL; if (procA == null || procB == null) { if (procA != null) { procedureName = procA.NazovProcedury; storedProcDiffListA.Add(new ObjectAtribute("Procedure name", procedureName, false)); storedProcDiffListA.Add(new ObjectAtribute("Sql text ", "Click button", false, true)); compSQL = new ComparatorOfSQL(procA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } else if (procB != null) { procedureName = procB.NazovProcedury; storedProcDiffListB.Add(new ObjectAtribute("Procedure name", procedureName, false)); storedProcDiffListB.Add(new ObjectAtribute("Sql text ", "Click button", false, true)); compSQL = new ComparatorOfSQL(null, procB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextB; } else procedureName = "UNDEFINED"; } if (procA != null && procB != null) { compSQL = new ComparatorOfSQL(procA.SqlText, procB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; procedureName = procB.NazovProcedury; storedProcDiffListA.Add(new ObjectAtribute("Procedure name", procedureName,false)); storedProcDiffListB.Add(new ObjectAtribute("Procedure name", procedureName,false)); if (procA.NazovProcedury != procB.NazovProcedury) diffNameOfProcedure = true; if (compSQL.IsDifferent) diffSqlText = true; if (!ComparePrivileges(procA.Privieges, procB.Privieges)) diffPrivileges = true; if (diffNameOfProcedure || diffPrivileges || diffSqlText) different = true; else different = false; //vytvorim privileges foreach (Privilege privA in procA.Privieges) { bool found = false; foreach (Privilege privB in procB.Privieges) { 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 procB.Privieges) { 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 (diffSqlText) { ObjectAtribute sqlA = new ObjectAtribute("Sql text ", "Click button", true, true); storedProcDiffListA.Add(sqlA); ObjectAtribute sqlB = new ObjectAtribute("Sql text ", "Click button", true, true); storedProcDiffListB.Add(sqlB); } else { ObjectAtribute sql = new ObjectAtribute("Sql text ", "Click button", false, true); storedProcDiffListA.Add(sql); storedProcDiffListB.Add(sql); } } else different = true; }
private void button3_Click_1(object sender, EventArgs e) { List<string> test = new List<string>(); test.Add("skuska\r\n"); test.Add("skuska2\r\n"); List<int> highl = new List<int>(); highl.Add(0); SqlTextHighlited s = new SqlTextHighlited(test, highl); FrmSqlCode ff = new FrmSqlCode(s, s); ff.Show(); }
public ComparatorOfSQL(List <string> sqlTextAin, List <string> sqlTextBin) { //prv vytvorim objekty sqltextA = new List <string>(); sqltextB = new List <string>(); highlitedA = new List <int>(); highlitedB = new List <int>(); //najprv zistim ktory sqltext je kratsi sqltextA = sqlTextAin; sqltextB = sqlTextBin; if (sqltextA != null && sqltextB != null) { int countMin = 0; if (sqltextA.Count > sqltextB.Count) { countMin = sqltextB.Count; //isDifferent = true; } else if (sqltextB.Count > sqltextA.Count) { countMin = sqltextA.Count; //isDifferent = true; } else { countMin = sqltextA.Count; } int ia = 0; int ib = 0; for (int i = 0; i < countMin; i++) { string a = sqltextA[ia]; string b = sqltextB[ib]; a = a.Trim(); b = b.Trim(); while (a.Length == 0 && ((ia + 1) < sqltextA.Count)) { ia++; a = sqltextA[ia]; a = a.Trim(); } while (b.Length == 0 && ((ib + 1) < sqltextB.Count)) { ib++; b = sqltextB[ib]; b = b.Trim(); } if (a != b) { highlitedA.Add(ia); highlitedB.Add(ib); isDifferent = true; } if ((ia + 1) < sqltextA.Count) { ia++; } if ((ib + 1) < sqltextB.Count) { ib++; } } if (isDifferent) { if (countMin < sqltextA.Count) { for (int i = countMin; i < sqltextA.Count; i++) { highlitedA.Add(i); } } if (countMin < sqltextB.Count) { for (int i = countMin; i < sqltextB.Count; i++) { highlitedB.Add(i); } } } textA = new SqlTextHighlited(sqltextA, highlitedA); textB = new SqlTextHighlited(sqltextB, highlitedB); } else if (sqltextA != null) { textA = new SqlTextHighlited(sqltextA, highlitedA); isDifferent = true; textB = null; } else if (sqltextB != null) { textB = new SqlTextHighlited(sqltextB, highlitedB); isDifferent = true; textA = null; } }
public ComparatorOfSQL(List<string> sqlTextAin, List<string> sqlTextBin) { //prv vytvorim objekty sqltextA = new List<string>(); sqltextB = new List<string>(); highlitedA = new List<int>(); highlitedB = new List<int>(); //najprv zistim ktory sqltext je kratsi sqltextA = sqlTextAin; sqltextB = sqlTextBin; if (sqltextA != null && sqltextB != null) { int countMin = 0; if (sqltextA.Count > sqltextB.Count) { countMin = sqltextB.Count; //isDifferent = true; } else if (sqltextB.Count > sqltextA.Count) { countMin = sqltextA.Count; //isDifferent = true; } else countMin = sqltextA.Count; int ia = 0; int ib = 0; for (int i = 0; i < countMin; i++) { string a = sqltextA[ia]; string b = sqltextB[ib]; a = a.Trim(); b = b.Trim(); while (a.Length == 0 && ((ia + 1) < sqltextA.Count)) { ia++; a = sqltextA[ia]; a = a.Trim(); } while (b.Length == 0 && ((ib + 1) < sqltextB.Count)) { ib++; b = sqltextB[ib]; b = b.Trim(); } if (a != b) { highlitedA.Add(ia); highlitedB.Add(ib); isDifferent = true; } if ((ia+1) < sqltextA.Count) ia++; if ((ib + 1) < sqltextB.Count) ib++; } if (isDifferent) { if (countMin < sqltextA.Count) { for (int i = countMin; i < sqltextA.Count; i++) { highlitedA.Add(i); } } if (countMin < sqltextB.Count) { for (int i = countMin; i < sqltextB.Count; i++) { highlitedB.Add(i); } } } textA = new SqlTextHighlited(sqltextA, highlitedA); textB = new SqlTextHighlited(sqltextB, highlitedB); } else if (sqltextA != null) { textA = new SqlTextHighlited(sqltextA, highlitedA); isDifferent = true; textB = null; } else if (sqltextB != null) { textB = new SqlTextHighlited(sqltextB, highlitedB); isDifferent = true; textA = null; } }
public DbSyncTriggerDiff(Trigger trigAin, Trigger trigBin) { this.trigA = trigAin; this.trigB = trigBin; triggerAtrListA = new List <ObjectAtribute>(); triggerAtrListB = new List <ObjectAtribute>(); ComparatorOfSQL compSQL; if (trigA == null || trigB == null) { if (trigA != null) { triggerName = trigA.Trigger_name; triggerAtrListA.Add(new ObjectAtribute("Trigger name ", trigA.Trigger_name, true)); triggerAtrListA.Add(new ObjectAtribute("sql text ", "Click button", true, true)); triggerAtrListA.Add(new ObjectAtribute("Disabled ", trigA.Disabled.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("Is after ", trigA.IsAfter.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("Is instead ", trigA.IsInsteadOf.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("On action ", trigA.OnAction, true)); triggerAtrListA.Add(new ObjectAtribute("Trigger name ", trigA.Trigger_name, true)); triggerAtrListA.Add(new ObjectAtribute("Trigger owner ", trigA.Trigger_owner, true)); compSQL = new ComparatorOfSQL(trigA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } else if (trigB != null) { triggerName = trigB.Trigger_name; triggerAtrListB.Add(new ObjectAtribute("Trigger name ", trigB.Trigger_name, true)); triggerAtrListB.Add(new ObjectAtribute("sql text ", "Click button", true, true)); triggerAtrListB.Add(new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("On action ", trigB.OnAction, true)); triggerAtrListB.Add(new ObjectAtribute("Trigger name ", trigB.Trigger_name, true)); triggerAtrListB.Add(new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, true)); compSQL = new ComparatorOfSQL(null, trigB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextB; } else { triggerName = "UNDEFINED"; } } if (trigA != null && trigB != null) { compSQL = new ComparatorOfSQL(trigA.SqlText, trigB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; triggerName = trigA.Trigger_name; if (trigA.Disabled != trigB.Disabled) { diffDisabled = true; } if (trigA.IsAfter != trigB.IsAfter) { diffIsAfter = true; } if (trigA.IsInsteadOf != trigB.IsInsteadOf) { diffIsInstead = true; } if (trigA.OnAction != trigB.OnAction) { diffOnAction = true; } if (compSQL.IsDifferent) { diffsqltext = true; } if (trigA.Table_name != trigB.Table_name) { diffTableName = true; } if (trigA.Trigger_name != trigB.Trigger_name) { diffTrigName = true; } if (trigA.Trigger_owner != trigB.Trigger_owner) { diffTRigOwner = true; } if (diffDisabled || diffIsAfter || diffIsInstead || diffOnAction || diffsqltext || diffTableName || diffTrigName || diffTRigOwner) { different = true; } else { different = false; } ObjectAtribute oatriggerName = new ObjectAtribute("Trigger name ", this.triggerName, false); triggerAtrListA.Add(oatriggerName); triggerAtrListB.Add(oatriggerName); if (diffsqltext) { ObjectAtribute tSqlTextA = new ObjectAtribute("sql text ", "Click button", true, true); triggerAtrListA.Add(tSqlTextA); ObjectAtribute tSqlTextB = new ObjectAtribute("sql text ", "Click button", true, true); triggerAtrListB.Add(tSqlTextB); } else { ObjectAtribute tSqlText = new ObjectAtribute("sql text ", "Click button", false, true); triggerAtrListA.Add(tSqlText); triggerAtrListB.Add(tSqlText); } if (diffDisabled) { ObjectAtribute tDisabledA = new ObjectAtribute("Disabled ", trigA.Disabled.ToString(), true); triggerAtrListA.Add(tDisabledA); ObjectAtribute tDisabledB = new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), true); triggerAtrListB.Add(tDisabledB); } else { ObjectAtribute tDisabled = new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), false); triggerAtrListA.Add(tDisabled); triggerAtrListB.Add(tDisabled); } if (diffIsAfter) { ObjectAtribute tIsAfterA = new ObjectAtribute("Is after ", trigA.IsAfter.ToString(), true); triggerAtrListA.Add(tIsAfterA); ObjectAtribute tIsAfterB = new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), true); triggerAtrListB.Add(tIsAfterB); } else { ObjectAtribute tIsAfter = new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), false); triggerAtrListA.Add(tIsAfter); triggerAtrListB.Add(tIsAfter); } if (diffIsInstead) { ObjectAtribute tIsInsteadA = new ObjectAtribute("Is instead ", trigA.IsInsteadOf.ToString(), true); triggerAtrListA.Add(tIsInsteadA); ObjectAtribute tIsInsteadB = new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), true); triggerAtrListB.Add(tIsInsteadB); } else { ObjectAtribute tIsInstead = new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), false); triggerAtrListA.Add(tIsInstead); triggerAtrListB.Add(tIsInstead); } if (diffOnAction) { ObjectAtribute tOnActionA = new ObjectAtribute("On action ", trigA.OnAction, true); triggerAtrListA.Add(tOnActionA); ObjectAtribute tOnActionB = new ObjectAtribute("On action ", trigB.OnAction, true); triggerAtrListB.Add(tOnActionB); } else { ObjectAtribute tIsInstead = new ObjectAtribute("On action ", trigB.OnAction, false); triggerAtrListA.Add(tIsInstead); triggerAtrListB.Add(tIsInstead); } if (diffTrigName) { ObjectAtribute ttrigNameA = new ObjectAtribute("Trigger name ", trigA.Trigger_name, true); triggerAtrListA.Add(ttrigNameA); ObjectAtribute ttrigNameB = new ObjectAtribute("Trigger name ", trigB.Trigger_name, true); triggerAtrListB.Add(ttrigNameB); } else { ObjectAtribute ttrigName = new ObjectAtribute("Trigger name ", trigB.Trigger_name, false); triggerAtrListA.Add(ttrigName); triggerAtrListB.Add(ttrigName); } if (diffTRigOwner) { ObjectAtribute ttrigOwnerA = new ObjectAtribute("Trigger owner ", trigA.Trigger_owner, true); triggerAtrListA.Add(ttrigOwnerA); ObjectAtribute ttrigOwnerB = new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, true); triggerAtrListB.Add(ttrigOwnerB); } else { ObjectAtribute ttrigOwner = new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, false); triggerAtrListA.Add(ttrigOwner); triggerAtrListB.Add(ttrigOwner); } } else { different = true; } }
public DbSyncTriggerDiff(Trigger trigAin, Trigger trigBin) { this.trigA = trigAin; this.trigB = trigBin; triggerAtrListA = new List<ObjectAtribute>(); triggerAtrListB = new List<ObjectAtribute>(); ComparatorOfSQL compSQL; if (trigA == null || trigB == null) { if (trigA != null) { triggerName = trigA.Trigger_name; triggerAtrListA.Add(new ObjectAtribute("Trigger name ", trigA.Trigger_name, true)); triggerAtrListA.Add(new ObjectAtribute("sql text ", "Click button", true, true)); triggerAtrListA.Add(new ObjectAtribute("Disabled ", trigA.Disabled.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("Is after ", trigA.IsAfter.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("Is instead ", trigA.IsInsteadOf.ToString(), true)); triggerAtrListA.Add(new ObjectAtribute("On action ", trigA.OnAction, true)); triggerAtrListA.Add(new ObjectAtribute("Trigger name ", trigA.Trigger_name, true)); triggerAtrListA.Add(new ObjectAtribute("Trigger owner ", trigA.Trigger_owner, true)); compSQL = new ComparatorOfSQL(trigA.SqlText, null); sqlTextListA = compSQL.TextA; sqlTextListB = null; } else if (trigB != null) { triggerName = trigB.Trigger_name; triggerAtrListB.Add(new ObjectAtribute("Trigger name ", trigB.Trigger_name, true)); triggerAtrListB.Add(new ObjectAtribute("sql text ", "Click button", true, true)); triggerAtrListB.Add(new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), true)); triggerAtrListB.Add(new ObjectAtribute("On action ", trigB.OnAction, true)); triggerAtrListB.Add(new ObjectAtribute("Trigger name ", trigB.Trigger_name, true)); triggerAtrListB.Add(new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, true)); compSQL = new ComparatorOfSQL(null, trigB.SqlText); sqlTextListA = null; sqlTextListB = compSQL.TextB; } else triggerName = "UNDEFINED"; } if (trigA != null && trigB != null) { compSQL = new ComparatorOfSQL(trigA.SqlText, trigB.SqlText); sqlTextListA = compSQL.TextA; sqlTextListB = compSQL.TextB; triggerName = trigA.Trigger_name; if (trigA.Disabled != trigB.Disabled) diffDisabled = true; if (trigA.IsAfter != trigB.IsAfter) diffIsAfter = true; if (trigA.IsInsteadOf != trigB.IsInsteadOf) diffIsInstead = true; if (trigA.OnAction != trigB.OnAction) diffOnAction = true; if (compSQL.IsDifferent) diffsqltext = true; if (trigA.Table_name != trigB.Table_name) diffTableName = true; if (trigA.Trigger_name != trigB.Trigger_name) diffTrigName = true; if (trigA.Trigger_owner != trigB.Trigger_owner) diffTRigOwner = true; if (diffDisabled || diffIsAfter || diffIsInstead || diffOnAction || diffsqltext || diffTableName || diffTrigName || diffTRigOwner) different = true; else different = false; ObjectAtribute oatriggerName = new ObjectAtribute("Trigger name ", this.triggerName, false); triggerAtrListA.Add(oatriggerName); triggerAtrListB.Add(oatriggerName); if (diffsqltext) { ObjectAtribute tSqlTextA = new ObjectAtribute("sql text ", "Click button", true, true); triggerAtrListA.Add(tSqlTextA); ObjectAtribute tSqlTextB = new ObjectAtribute("sql text ", "Click button", true, true); triggerAtrListB.Add(tSqlTextB); } else { ObjectAtribute tSqlText = new ObjectAtribute("sql text ", "Click button", false, true); triggerAtrListA.Add(tSqlText); triggerAtrListB.Add(tSqlText); } if (diffDisabled) { ObjectAtribute tDisabledA = new ObjectAtribute("Disabled ", trigA.Disabled.ToString(), true); triggerAtrListA.Add(tDisabledA); ObjectAtribute tDisabledB = new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), true); triggerAtrListB.Add(tDisabledB); } else { ObjectAtribute tDisabled = new ObjectAtribute("Disabled ", trigB.Disabled.ToString(), false); triggerAtrListA.Add(tDisabled); triggerAtrListB.Add(tDisabled); } if (diffIsAfter) { ObjectAtribute tIsAfterA = new ObjectAtribute("Is after ", trigA.IsAfter.ToString(), true); triggerAtrListA.Add(tIsAfterA); ObjectAtribute tIsAfterB = new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), true); triggerAtrListB.Add(tIsAfterB); } else { ObjectAtribute tIsAfter = new ObjectAtribute("Is after ", trigB.IsAfter.ToString(), false); triggerAtrListA.Add(tIsAfter); triggerAtrListB.Add(tIsAfter); } if (diffIsInstead) { ObjectAtribute tIsInsteadA = new ObjectAtribute("Is instead ", trigA.IsInsteadOf.ToString(), true); triggerAtrListA.Add(tIsInsteadA); ObjectAtribute tIsInsteadB = new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), true); triggerAtrListB.Add(tIsInsteadB); } else { ObjectAtribute tIsInstead = new ObjectAtribute("Is instead ", trigB.IsInsteadOf.ToString(), false); triggerAtrListA.Add(tIsInstead); triggerAtrListB.Add(tIsInstead); } if (diffOnAction) { ObjectAtribute tOnActionA = new ObjectAtribute("On action ", trigA.OnAction, true); triggerAtrListA.Add(tOnActionA); ObjectAtribute tOnActionB = new ObjectAtribute("On action ", trigB.OnAction, true); triggerAtrListB.Add(tOnActionB); } else { ObjectAtribute tIsInstead = new ObjectAtribute("On action ", trigB.OnAction, false); triggerAtrListA.Add(tIsInstead); triggerAtrListB.Add(tIsInstead); } if (diffTrigName) { ObjectAtribute ttrigNameA = new ObjectAtribute("Trigger name ", trigA.Trigger_name, true); triggerAtrListA.Add(ttrigNameA); ObjectAtribute ttrigNameB = new ObjectAtribute("Trigger name ", trigB.Trigger_name, true); triggerAtrListB.Add(ttrigNameB); } else { ObjectAtribute ttrigName = new ObjectAtribute("Trigger name ", trigB.Trigger_name, false); triggerAtrListA.Add(ttrigName); triggerAtrListB.Add(ttrigName); } if (diffTRigOwner) { ObjectAtribute ttrigOwnerA = new ObjectAtribute("Trigger owner ", trigA.Trigger_owner, true); triggerAtrListA.Add(ttrigOwnerA); ObjectAtribute ttrigOwnerB = new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, true); triggerAtrListB.Add(ttrigOwnerB); } else { ObjectAtribute ttrigOwner = new ObjectAtribute("Trigger owner ", trigB.Trigger_owner, false); triggerAtrListA.Add(ttrigOwner); triggerAtrListB.Add(ttrigOwner); } } else different = true; }