Esempio n. 1
0
        public static void WriteLog(string file, LogEntry e)
        {
            try
            {
                using (TextDb textDb = new TextDb('\t'))
                {
                    textDb.OpenOrCreate(file);
                    string text = "";
                    if (e.Text != null)
                    {
                        text = e.Text.Replace("\r", "");
                        if (text.EndsWith("\n"))
                        {
                            text = text.Substring(0, text.Length - 1);
                        }
                    }
                    string msgType = "";
                    if (e.EntryType == LogEntryType.INFO)
                    {
                        msgType = "INFO";
                    }
                    else if (e.EntryType == LogEntryType.RECV)
                    {
                        msgType = "RECV";
                    }
                    else if (e.EntryType == LogEntryType.SEND)
                    {
                        msgType = "SEND";
                    }
                    if (e.Exception != null)
                    {
                        text += "\n" + Error.GetExceptionMessage(e.Exception);
                    }
                    string[] array = text.Split(new char[]
                    {
                        '\n'
                    });

                    for (int i = 0; i < array.Length; i++)
                    {
                        string line = array[i];
                        textDb.Append(new string[]
                        {
                            e.ID,
                            DateTime.Now.ToString("yyyyMMddHHmmss"),
                            (e.RemoteEndPoint != null) ? e.RemoteEndPoint.ToString() : "",
                            (e.UserIdentity != null) ? e.UserIdentity.Name : "",
                            msgType,
                            line
                        });
                    }
                }
            }
            catch (Exception x)
            {
                Error.DumpError(x);
            }
        }
Esempio n. 2
0
 public void OpenRead(string file)
 {
     if (!File.Exists(file))
     {
         throw new Exception("Specified database file doesn't exist !");
     }
     this.m_pDatabaseStream = TextDb.OpenOrCreateDb(file);
     this.m_pReader         = new StreamLineReader(new BufferedStream(this.m_pDatabaseStream));
     this.m_Open            = true;
 }
Esempio n. 3
0
 public void OpenOrCreate(string file)
 {
     this.m_pDatabaseStream = TextDb.OpenOrCreateDb(file);
     this.m_pReader         = new StreamLineReader(this.m_pDatabaseStream);
     this.m_Open            = true;
 }