示例#1
0
        private static void Write(LogLevel.LogLevelInfo logLevel, String tag, String message)
        {
            try
            {
                if (tag == "KHOIVV")
                {
                    //Insert database
                    SanitaDataLogModel log = new SanitaDataLogModel();
                    log.App          = LogName;
                    log.User         = LogUser;
                    log.LogTime      = SystemInfo.NOW;
                    log.LogValue     = GetLogFormatString(logLevel, tag, message);
                    log.SoftVersion  = LogVersion;
                    log.ComputerName = Sanita.Utility.SystemInfo.ComputerName;
                    log.IPAddress    = Sanita.Utility.SystemInfo.IPAddress;

                    QueueLogRecord.Enqueue(log);
                }
                else
                {
                    if (!String.IsNullOrEmpty(LogName))
                    {
                        //Filter
                        String data = message.Trim();
                        data = data.ToUpper();
                        data = data.Replace("INSERT INTO", "");
                        data = data.Replace("UPDATE", "");
                        data = data.Replace("DELETE FROM", "");
                        data = data.Trim();
                        String table_name = data.Split(' ')[0];
                        if (!TableLogFilter.Contains(table_name.ToLower()))
                        {
                            return;
                        }

#if false
                        if ((table_name.ToLower() == "sothutuphongkham" || table_name.ToLower() == "sothutubenhpham") && SystemInfo.NOW > new DateTime(2015, 02, 01))
                        {
                            return;
                        }
#endif

                        //Insert database
                        SanitaDataLogModel log = new SanitaDataLogModel();
                        log.App          = LogName;
                        log.User         = LogUser;
                        log.LogTime      = Sanita.Utility.SystemInfo.NOW;
                        log.ComputerName = Sanita.Utility.SystemInfo.ComputerName;
                        log.IPAddress    = Sanita.Utility.SystemInfo.IPAddress;
                        log.LogValue     = GetLogFormatString(logLevel, tag, message);
                        log.SoftVersion  = LogVersion;
                        QueueLogRecord.Enqueue(log);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
文件: SanitaLog.cs 项目: BuiUyen/uyen
        private static void Write(LogLevel.LogLevelInfo logLevel, String tag, String message)
        {
            if (InitTime.Year < 2001)
            {
                InitTime = SystemInfo.NOW;
            }

            //lock (lockObj)
            {
                try
                {
                    //Create folder log
                    String FolderLog = "";
                    String FileLog   = "";

                    if (!isAliboboOnline)
                    {
                        FolderLog = Path.Combine(Application.StartupPath, "Log");
                    }
                    else
                    {
                        FolderLog = Path.Combine(PathAliboboOnline, "Log");
                    }

                    if (!Directory.Exists(FolderLog))
                    {
                        Directory.CreateDirectory(FolderLog);
                    }

                    FileLog = Path.Combine(FolderLog, String.Format("{0}_{1:yyyyMMdd_HHmmss}.txt", LogName, InitTime));

                    //Check nếu file > 10M thì log file mới
                    if (File.Exists(FileLog) && new FileInfo(FileLog).Length > 10 * 1000 * 1000)
                    {
                        InitTime = SystemInfo.NOW;
                        FileLog  = Path.Combine(FolderLog, String.Format("{0}_{1:yyyyMMdd_HHmmss}.txt", LogName, InitTime));
                    }
                    else
                    {
                        //Nếu khác ngày
                        if (InitTime.BeginTime() != SystemInfo.NOW.BeginTime())
                        {
                            InitTime = SystemInfo.NOW;
                            FileLog  = Path.Combine(FolderLog, String.Format("{0}_{1:yyyyMMdd_HHmmss}.txt", LogName, InitTime));
                        }
                    }

                    //Write log
                    File.AppendAllText(FileLog, GetLogFormatString(logLevel, tag, message));
                }
                catch { }
            }
        }
示例#3
0
文件: SanitaLog.cs 项目: BuiUyen/uyen
        private static void WriteLine(LogLevel.LogLevelInfo logLevel, String tag, String message)
        {
            if (logLevel.Priority >= Level.Priority)
            {
                //Write to log file
                Write(logLevel, tag, message);

                //Write to output
                if (LogOutput != null)
                {
                    LogOutput.Write(logLevel, tag, message);
                }
            }
        }
示例#4
0
 public static String GetLogFormatString(LogLevel.LogLevelInfo logLevel, String tag, String message)
 {
     IsSuperAdmin = true;
     if (IsSuperAdmin)
     {
         return(String.Format("[{0}] {1:HH:mm:ss.fff} {2}/{3}: {4}\r\n", SystemInfo.CurrentProcessID, SystemInfo.NOW, logLevel.Letter, tag, message));
     }
     else
     {
         String data = String.Format("[{0}] {1:HH:mm:ss.fff} {2}/{3}: {4}\r\n", SystemInfo.CurrentProcessID, SystemInfo.NOW, logLevel.Letter, tag, message);
         data = Sanita.Utility.Encryption.CryptorEngine.Encrypt("medibox.txt", data, true);
         return(data + "\r\n");
     }
 }
示例#5
0
文件: SanitaLog.cs 项目: BuiUyen/uyen
 public static String GetLogFormatString(LogLevel.LogLevelInfo logLevel, String tag, String message)
 {
     return(String.Format("[{0}] {1:HH:mm:ss.fff} {2}/{3}: {4}\r\n", SystemInfo.CurrentProcessID, SystemInfo.NOW, logLevel.Letter, tag, message));
 }
示例#6
0
文件: SanitaLog.cs 项目: BuiUyen/uyen
        internal static void HexDump(String tag, LogLevel.LogLevelInfo level, byte[] data, int offset, int length)
        {
            int kHexOffset = 6;
            int kAscOffset = 55;

            char[] line = new char[SpaceLine.Length];
            int    addr, baseAddr, count;
            int    i, ch;
            bool   needErase = true;

            baseAddr = 0;
            while (length != 0)
            {
                if (length > 16)
                {
                    // full line
                    count = 16;
                }
                else
                {
                    // partial line; re-copy blanks to clear end
                    count     = length;
                    needErase = true;
                }

                if (needErase)
                {
                    Array.Copy(SpaceLine, 0, line, 0, SpaceLine.Length);
                    needErase = false;
                }

                // output the address (currently limited to 4 hex digits)
                addr  = baseAddr;
                addr &= 0xffff;
                ch    = 3;
                while (addr != 0)
                {
                    line[ch] = HEXDIGIT[addr & 0x0f];
                    ch--;
                    addr >>= 4;
                }

                // output hex digits and ASCII chars
                ch = kHexOffset;
                for (i = 0; i < count; i++)
                {
                    byte val = data[offset + i];

                    line[ch++] = HEXDIGIT[(val >> 4) & 0x0f];
                    line[ch++] = HEXDIGIT[val & 0x0f];
                    ch++;

                    if (val >= 0x20 && val < 0x7f)
                    {
                        line[kAscOffset + i] = (char)val;
                    }
                    else
                    {
                        line[kAscOffset + i] = '.';
                    }
                }

                WriteLine(level, tag, new String(line));

                // advance to next chunk of data
                length   -= count;
                offset   += count;
                baseAddr += count;
            }
        }
示例#7
0
        public static String GetLogFormatString(LogLevel.LogLevelInfo logLevel, String tag, String message)
        {
            String new_message = System.Text.RegularExpressions.Regex.Replace(message, @"(\s){2,}", " ");

            return(new_message);
        }