Ejemplo n.º 1
0
        public AuditTrail(Exception ex, TextFormat textFormat = TextFormat.Txt)
        {
            TimeStamp = DateTime.Now;

            Level = ErrorLevel.Critical;
            Tag   = "Exception";

            if (ex != null)
            {
                Message = ex.Message;

                switch (textFormat)
                {
                default:
                case TextFormat.Txt:
                    DataOutType = "TXT";
                    DataOut     = ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + Environment.NewLine + ex.Source;
                    break;

                case TextFormat.TxtEx:
                    DataOutType = "TXTEx";

                    DataOut = "!" + ex.Message + Environment.NewLine
                              + Environment.NewLine
                              + "#StackTrace" + Environment.NewLine
                              + ex.StackTrace + Environment.NewLine
                              + Environment.NewLine
                              + "#Source" + Environment.NewLine
                              + ex.Source;
                    break;

                case TextFormat.HTML:
                    DataOutType = "HTML";

                    TStrings html = new TStrings();

                    html.Add("<p style='font-family: Consolas,monospace; bgcolor=transparent;'>");
                    html.Add(string.Format("{0}</br>", "Message"));
                    html.Add(string.Format("<b>{0}</b></br></br>", ex.Message));

                    html.Add(string.Format("{0}</br>", "StackTrace"));
                    html.Add(string.Format("<b>{0}</b></br></br>", ex.StackTrace));

                    html.Add(string.Format("{0}</br>", "Source"));
                    html.Add(string.Format("<b>{0}</b></br></br>", ex.Source));
                    html.Add("</p>");

                    DataOut = html.Text;
                    break;
                }
                ;
            }
            ;
        }
Ejemplo n.º 2
0
        /*
         *    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         *    // ---------- Vergleich beenden
         *    // Wenn aus irgendeinem Grund nicht mehr weiter syncronisier werden kann, dann schließt
         *    // diese Methode den Dateivergleich ab: Alle Zeilen nach 'sync' werden als abweichend
         *    // markiert.
         *
         *    static void Beenden()
         *    {
         *       int p;
         *
         *       if( !EoF( Datei[ 1 ] ) ) ReadLines( 1, 30000 );
         *       if( !EoF( Datei[ 2 ] ) ) ReadLines( 2, 30000 );
         *
         *       for( int p = sync+1; GAIS <= Grid.RowCount; p++ )
         *       {
         *          Grid.Cells[ 0, p ] = DiffSign + Copy( Grid.Cells[ 0, p ], 2, 20 );
         *       };
         *    }
         */
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Solange Zeilenweise mit der Marke 'LastEqualLine' weiterlaufen, bis eine Abweichung entdeckt
        // wird. 'LastEqualLine' wird dann auf die letzte übereinstimmende Zeile gesetzt.
        // Falls ein Syncronisieren der Dateien sicher nicht möglich ist (weil mindestens
        // eine der Dateien endet), dann wird 'false' sonst 'true' zurückgegeben.

        static bool ReadUntilDiff()
        {
            bool Result = false;

            if ((LastEqualLine < File1.Count) && ((LastEqualLine < File2.Count)))
            {
                do
                {
                    Lines.Add("=");
                    LastEqualLine += 1;
                }while (
                    (LastEqualLine < File1.Count) &&
                    (LastEqualLine < File2.Count) &&
                    (GetCell(1, LastEqualLine) == GetCell(2, LastEqualLine))
                    );

                // Jetzt gibt's zwei Möglichkeiten
                //   1) Es wurde eine Abweichung gefunden und es sind noch Zeilen in den Dateien, so das ein
                //      Versuch zum Syncronisieren gestartet werden kann.
                //   2) Die Schleife wurde beendet, aber weil in einer Datei keine Zeilen mehr sind.

                if ((LastEqualLine >= File1.Count) || (LastEqualLine >= File2.Count))
                {
                    if (GetCell(1, LastEqualLine) != GetCell(2, LastEqualLine))
                    {
                        LastEqualLine -= 1;
                    }
                    ;
                }
                else
                {
                    LastEqualLine -= 1;
                    Result         = true;
                };
            }

            return(Result);
        }
Ejemplo n.º 3
0
        private void saveChangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TStrings File =

            if (File1Modified)
            {
                TStrings File = new TStrings();

                for (int i = 0; i < File1.Count; i++)
                {
                    if (File1.GetObject(i) != null)
                    {
                        File.Add(File1[i]);
                    }
                    ;
                }
                ;

                File.SaveToFile(FileName1, System.Text.Encoding.Unicode);
                File1Modified = false;
            }
            ;

            if (File2Modified)
            {
                TStrings File = new TStrings();

                for (int i = 0; i < File2.Count; i++)
                {
                    if (File2.GetObject(i) != null)
                    {
                        File.Add(File2[i]);
                    }
                    ;
                }
                ;

                File.SaveToFile(FileName2, System.Text.Encoding.Unicode);
                File2Modified = false;
            }
            ;
        }
Ejemplo n.º 4
0
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        static public void Exec(TStrings _Lines, TStrings Text1, TStrings Text2)
        {
            bool Continue;

            Lines = _Lines;
            File1 = Text1;
            File2 = Text2;

            //ToDo: //ToDo: Basics.ShowWaitCursor(true);

            try
            {
                //
                // - - -  - - -

                //Last[ 1 ]      = 0;
                //Last[ 2 ]      = 0;
                LastEqualLine = 0;
                Nr            = 0;

                Continue = true;

                while (Continue)
                {
                    Continue = ReadUntilDiff();

                    if (Continue)
                    {
                        Continue = ReSync();
                    }
                }

                //if( !Continue ) Beenden();
            }
            finally
            {
            }

            while (Lines.Count < File1.Count)
            {
                Lines.Add("=");
            }
            ;

            while (Lines.Count < File2.Count)
            {
                Lines.Add("=");
            }
            ;

            for (int i = 0; i < Lines.Count; i++)
            {
                try
                {
                    if ((Lines[i] == "#") && (File1.GetObject(i) == null))
                    {
                        Lines[i] = ">";
                    }
                }
                catch
                {
                    Lines[i] = ">";
                };

                try
                {
                    if ((Lines[i] == "#") && (File2.GetObject(i) == null))
                    {
                        Lines[i] = "<";
                    }
                }
                catch
                {
                    Lines[i] = "<";
                };
            }
            ;

            //ToDo: Basics.ShowWaitCursor(false);
        }