private string RemoveUnneccessaryCharacters(string str1) { str1 = StringsFunctionsClass.Reduce(str1, " ,", ","); str1 = StringsFunctionsClass.Reduce(str1, " ;", ";"); str1 = str1.Replace(",", ", "); str1 = StringsFunctionsClass.Reduce(str1, " ", " "); str1 = StringsFunctionsClass.Reduce(str1, "\r\n\r\n", "\r\n"); str1 = StringsFunctionsClass.Reduce(str1, "( ", "("); while (str1.EndsWith("\n") || str1.EndsWith("\r") || str1.EndsWith(";") || str1.EndsWith(" ")) { string rm = str1.Substring(str1.Length - 1, 1); str1 = str1.Remove(str1.Length - 1, 1); } return(cbChangeToUppercase.Checked ? str1.ToUpper() : str1); }
private void TestView(ItemDataClass itm1, ItemDataClass itm2, string db1, string db2, bool second, FastColoredTextBox fct) { string str = (second) ? "<<--<<--<<--<<--<<" : ">>-->>-->>-->>-->>"; if (itm1.Object.GetType() == typeof(ViewClass)) { fct.AppendText($"{str} Testing DB {db1} view {itm1.Text} -> {db2}{Environment.NewLine}{Environment.NewLine}"); if (itm2 != null) { var tc1 = (ViewClass)itm1.Object; var tc2 = (ViewClass)itm2.Object; if (!cbOnlyFailures.Checked) { fct.AppendText($"{"OK",-8}DB {db1}->view {itm1.Text} exists in DB {itm1.Text}{db2}"); } TestViewFields(itm1, itm2, db1, db2, fct); int inx1 = tc1.CREATEINSERT_SQL.IndexOf("CREATE "); int inx2 = tc2.CREATEINSERT_SQL.IndexOf("CREATE "); //Entfernen Kommentare if (inx1 > 0) { tc1.CREATEINSERT_SQL = tc1.CREATEINSERT_SQL.Substring(inx1); } if (inx2 > 0) { tc2.CREATEINSERT_SQL = tc2.CREATEINSERT_SQL.Substring(inx1); } tc1.CREATEINSERT_SQL = $@"<START>{RemoveUnneccessaryCharacters(tc1.CREATEINSERT_SQL)}<END>"; tc2.CREATEINSERT_SQL = $@"<START>{RemoveUnneccessaryCharacters(tc2.CREATEINSERT_SQL)}<END>"; if (tc1.CREATEINSERT_SQL != tc2.CREATEINSERT_SQL) { fct.AppendText(Environment.NewLine); string str1 = tc1.CREATEINSERT_SQL.Trim().ToUpper(); string str2 = tc2.CREATEINSERT_SQL.Trim().ToUpper(); string resultstr = string.Empty; if (str1 == str2) { resultstr = "case sensitivity"; } else { str1 = str1.Replace("\r", " "); str2 = str2.Replace("\r", " "); str1 = str1.Replace("\n", " "); str2 = str2.Replace("\n", " "); if (str1 == str2) { resultstr += (resultstr.Length > 0) ? ", differences in newlines" : "differences in newlines"; } else { str1 = StringsFunctionsClass.Reduce(str1, " ", " "); str2 = StringsFunctionsClass.Reduce(str2, " ", " "); if (str1 == str2) { resultstr += (resultstr.Length > 0) ? ", differences in spaces" : "differences in spaces"; } } } int nw1 = str1.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Length; int nw2 = str2.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Length; if (resultstr.Length <= 0) { fct.AppendText($"{"FAILURE SQL differs ",-8} for {tc1.Name} words:{nw1}<->{nw2}, length:{tc1.CREATEINSERT_SQL.Length}<->{tc2.CREATEINSERT_SQL.Length}{Environment.NewLine}{Environment.NewLine}"); } else if (nw1 != nw2) { fct.AppendText($"{"FAILURE SQL differs ",-8} for {tc1.Name} in words:{nw1}<->{nw2}, length:{tc1.CREATEINSERT_SQL.Length}<->{tc2.CREATEINSERT_SQL.Length}{Environment.NewLine}{Environment.NewLine}"); } else { fct.AppendText($"{"WARNING SQL differs by",-8} ({resultstr}), may not a problem, for {tc1.Name} words:{nw1}<->{nw2}, length:{tc1.CREATEINSERT_SQL.Trim().ToUpper().Length}<->{tc2.CREATEINSERT_SQL.Trim().ToUpper().Length}{Environment.NewLine}{Environment.NewLine}"); } fct.AppendText($"{Environment.NewLine}SQL1 -------------------------------------------{Environment.NewLine}{tc1.CREATEINSERT_SQL}{Environment.NewLine}"); fct.AppendText($"{Environment.NewLine}SQL2 -------------------------------------------{Environment.NewLine}{tc2.CREATEINSERT_SQL}{Environment.NewLine}"); } } else { fct.AppendText($"{"FAILURE",-8} DB {db1}->view {itm1.Text} has no view in DB {db2}{Environment.NewLine}"); } } fct.AppendText(Environment.NewLine); }