Exemplo n.º 1
0
 public void AppendText(string command)
 {
     this.Invoke((MethodInvoker) delegate
     {
         tb.SuspendLayout();
         if (tb.Lines.Count >= QueueLimit)
         {
             tb.Lines.RemoveAt(0);
         }
         tb.AppendText(command);
         if (!command.Trim().EndsWith(";"))
         {
             tb.AppendText(";");
         }
         tb.AppendText("\n");
         tb.GoEnd();
         tb.ResumeLayout();
     });
 }
Exemplo n.º 2
0
        private void TestTableFK(ItemDataClass itm1, ItemDataClass itm2, string db1, string db2, FastColoredTextBox fct)
        {
            var tc1 = (TableClass)itm1.Object;
            var tc2 = (TableClass)itm2.Object;

            if ((tc1.ForeignKeys != null) && (tc2.ForeignKeys != null))
            {
                if (tc1.ForeignKeys.Count != tc2.ForeignKeys.Count)
                {
                    fct.AppendText($"{"FAILURE",-12}object {itm1.Text} foreign keys length {tc1.ForeignKeys.Count} is not equal {itm2.Text} {tc2.ForeignKeys.Count}{Environment.NewLine}");
                }
            }
            else if (tc1.ForeignKeys != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} foreign keys length {tc1.ForeignKeys.Count} is not equal {itm2.Text} 0{Environment.NewLine}");
            }
            else if (tc2.ForeignKeys != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} foreign keys length 0 is not equal {itm2.Text} {tc2.ForeignKeys.Count}{Environment.NewLine}");
            }
        }
Exemplo n.º 3
0
        private void TestTableDepent(ItemDataClass itm1, ItemDataClass itm2, string db1, string db2, FastColoredTextBox fct)
        {
            var tc1 = (TableClass)itm1.Object;
            var tc2 = (TableClass)itm2.Object;

            if ((tc1.DependenciesTO_Views != null) && (tc2.DependenciesTO_Views != null))
            {
                if (tc1.DependenciesTO_Views.Values.Count != tc2.DependenciesTO_Views.Values.Count)
                {
                    fct.AppendText($"{"FAILURE",-12}object {itm1.Text} dependencies length {tc1.DependenciesTO_Views.Values.Count} is not equal {itm2.Text} {tc2.DependenciesTO_Views.Values.Count}{Environment.NewLine}");
                }
            }
            else if (tc1.DependenciesTO_Views != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} dependencies length {tc1.DependenciesTO_Views.Values.Count} is not equal {itm2.Text} 0{Environment.NewLine}");
            }
            else if (tc2.DependenciesTO_Views != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} dependencies length 0 is not equal {itm2.Text} {tc2.DependenciesTO_Views.Values.Count}{Environment.NewLine}");
            }
        }
Exemplo n.º 4
0
        public void DelegateFastColoredTextBoxAppendText(FastColoredTextBox control, string text)
        {
            if (control.InvokeRequired)
            {
                DelegateFastColoredTextBoxAppendTextCallback d = DelegateFastColoredTextBoxAppendText;
                this.Invoke(d, control, text);
            }
            else
            {
                control.AppendText(text + Environment.NewLine);


                if (control.Lines.Count >= 10)
                {
                    control.Navigate(control.Lines.Count - 10);
                }
            }
        }
Exemplo n.º 5
0
        private void PrintCommand(string method, string output)
        {
            if (printMethod)
            {
                txt.AppendText(method);
            }

            if (output != null && output != "")
            {
                string[] lines = output.Split('\n');
                foreach (string line in lines)
                {
                    txt.AppendText('\n' + line);
                }
            }

            txt.AppendText("\n");
            txt.AppendText("> ");
            txt.GoEnd();
        }
Exemplo n.º 6
0
 public override void Write(string message)
 {
     _textbox.AppendText(message);
 }
Exemplo n.º 7
0
 private bool _ProcessDiff(DiffMergeStuffs.Lines lines, FastColoredTextBox fctb1, FastColoredTextBox fctb2)
 {
     bool match = true;
     foreach (var line in lines)
     {
         switch (line.state)
         {
             case DiffMergeStuffs.DiffType.None:
                 fctb1.AppendText(line.line + Environment.NewLine);
                 fctb2.AppendText(line.line + Environment.NewLine);
                 break;
             case DiffMergeStuffs.DiffType.Deleted:
                 fctb1.AppendText(line.line + Environment.NewLine, HighlightSyntax.RedLineStyle);
                 fctb2.AppendText(Environment.NewLine);
                 match = false;
                 break;
             case DiffMergeStuffs.DiffType.Inserted:
                 fctb1.AppendText(Environment.NewLine);
                 fctb2.AppendText(line.line + Environment.NewLine, HighlightSyntax.GreenLineStyle);
                 match = false;
                 break;
         }
         if (line.subLines != null)
         {
             bool res = _ProcessDiff(line.subLines, fctb1, fctb2);
             match = match && res;
         }
     }
     return match;
 }
 private void Log(string msg)
 {
     _editor.AppendText(msg);
 }
Exemplo n.º 9
0
        private void TestFunctions(ItemDataClass itm1, ItemDataClass itm2, string db1, string db2, bool second, FastColoredTextBox fct)
        {
            string str = (second) ? "<<--<<--<<--<<--<<" : ">>-->>-->>-->>-->>";

            fct.AppendText($"{str} Testing DB {db1} function {itm1.Text} -> {db2}{Environment.NewLine}{Environment.NewLine}");
            if (itm2 != null)
            {
                var tcf1 = (FunctionClass)itm1.Object;
                var tcf2 = (FunctionClass)itm2.Object;

                if (tcf1.Name == tcf2.Name)
                {
                    string txt1 = tcf1.GetSourceText();
                    string txt2 = tcf2.GetSourceText();
                    if (txt1 == txt2)
                    {
                        if (!cbOnlyFailures.Checked)
                        {
                            fct.AppendText($"{"OK",-8}function {tcf1.Name} exists and source is equal{Environment.NewLine}");
                        }
                    }
                    else
                    {
                        fct.AppendText($"{"FAILURE",-8}function {tcf1.Name} exists but source is not equal{Environment.NewLine}");
                        fct.AppendText($"----------------- Source {db1}->{tcf1.Name} Length:{txt1.Length} -----------{Environment.NewLine}{Environment.NewLine}");
                        fct.AppendText(txt1);
                        fct.AppendText($"{Environment.NewLine}{Environment.NewLine}");
                        fct.AppendText($"----------------- Source {db2}->{tcf2.Name} Length:{txt2.Length} -----------{Environment.NewLine}{Environment.NewLine}");
                        fct.AppendText(txt2);
                    }
                }
                else
                {
                    fct.AppendText($"{"FAILURE",-8}function {tcf1.Name} not exists in {db2}{Environment.NewLine}");
                }
            }
            else
            {
                var tcf1 = (FunctionClass)itm1.Object;
                fct.AppendText($"{"FAILURE",-8}DB {db1}->has no function {tcf1} in DB {db2}{Environment.NewLine}");
            }
            fct.AppendText(Environment.NewLine);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        private void TestTablePK(ItemDataClass itm1, ItemDataClass itm2, string db1, string db2, FastColoredTextBox fct)
        {
            var tc1 = (TableClass)itm1.Object;
            var tc2 = (TableClass)itm2.Object;

            if ((tc1.primary_constraint != null) && (tc2.primary_constraint != null))
            {
            }
            else if (tc1.primary_constraint != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} primary keys length 1 is not equal {itm2.Text} 0{Environment.NewLine}");
            }
            else if (tc2.primary_constraint != null)
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} primary keys length 0 is not equal {itm2.Text} 1{Environment.NewLine}");
            }

            string pk1 = string.Empty;
            string pk2 = string.Empty;

            if (tc1.Indices != null)
            {
                foreach (IndexClass fld in tc1.Indices.Values)
                {
                    if (fld.HasPrimaryConstraint)
                    {
                        foreach (FieldClass fc in fld.RelationFields.Values)
                        {
                            pk1 = (string.IsNullOrEmpty(pk1)) ? pk1 + fc.Name : "|" + pk1 + fc.Name;
                        }
                    }
                }
            }
            if (tc2.Indices != null)
            {
                foreach (IndexClass fld in tc2.Indices.Values)
                {
                    if (fld.HasPrimaryConstraint)
                    {
                        foreach (FieldClass fc in fld.RelationFields.Values)
                        {
                            pk2 = (string.IsNullOrEmpty(pk2)) ? pk2 + fc.Name : "|" + pk2 + fc.Name;
                        }
                    }
                }
            }

            /*
             * foreach (TableFieldClass fld in tc2.Fields.Values)
             * {
             *  if (fld.IsPrimary) pk2 = fld.Name;
             * }
             */
            if (pk1 == pk2)
            {
                if (string.IsNullOrEmpty(pk1))
                {
                    fct.AppendText($"{"WARNING",-12}both objects {itm1.Text} and {itm2.Text} has no primary key.{Environment.NewLine}");
                }
            }
            else if (string.IsNullOrEmpty(pk1))
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} has no primary key, and {itm2.Text} primary key is {pk2}{Environment.NewLine}");
            }
            else if (string.IsNullOrEmpty(pk2))
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} primary key is {pk2}, and {itm2.Text} has no primary key.{Environment.NewLine}");
            }
            else
            {
                fct.AppendText($"{"FAILURE",-12}object {itm1.Text} primary key {pk1}  and {itm2.Text} primary key {pk2} are not equal.{Environment.NewLine}");
            }
        }
Exemplo n.º 12
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            if (_richTextBox == null)
            {
                if (string.IsNullOrEmpty(FormName) ||
                    string.IsNullOrEmpty(TextBoxName))
                {
                    return;
                }

                Form form = Application.OpenForms[FormName];
                if (form == null)
                {
                    return;
                }

                _richTextBox = FindControlRecursive(form, TextBoxName) as FastColoredTextBox;
                if (_richTextBox == null)
                {
                    return;
                }

                form.FormClosing += (s, e) => _richTextBox = null;
            }

            lock (_richTextBox)
            {
                // This check is required a second time because this class
                // is executing on multiple threads.
                if (_richTextBox == null)
                {
                    return;
                }

                // Because the logging is running on a different thread than
                // the GUI, the control's "BeginInvoke" method has to be
                // leveraged in order to append the message. Otherwise, a
                // threading exception will be thrown.
                Action <FastColoredTextBox, string> del = new Action <FastColoredTextBox, string>((_richTextBox, s) =>
                {
                    //some stuffs for best performance
                    _richTextBox.BeginUpdate();
                    _richTextBox.Selection.BeginUpdate();
                    //remember user selection
                    Range userSelection = _richTextBox.Selection.Clone();
                    //add text with predefined style
                    _richTextBox.TextSource.CurrentTB = _richTextBox;
                    _richTextBox.AppendText("=======================================================\n", styles[loggingEvent.Level.Name]);
                    _richTextBox.AppendText(s, styles[loggingEvent.Level.Name]);
                    _richTextBox.AppendText("=======================================================\n", styles[loggingEvent.Level.Name]);
                    //restore user selection
                    if (!userSelection.IsEmpty || userSelection.Start.iLine < _richTextBox.LinesCount - 2)
                    {
                        _richTextBox.Selection.Start = userSelection.Start;
                        _richTextBox.Selection.End   = userSelection.End;
                    }
                    else
                    {
                        _richTextBox.GoEnd();    //scroll to end of the text
                    }
                    //
                    _richTextBox.Selection.EndUpdate();
                    _richTextBox.EndUpdate();
                }
                                                                                                  );
                _richTextBox.BeginInvoke(del, _richTextBox, loggingEvent.RenderedMessage + Environment.NewLine);
            }
        }