Пример #1
0
        /// <summary>
        /// 保存日志到数据库
        /// </summary>
        private void SaveLogToDB()
        {
            while (true)
            {
                Thread.Sleep(500);
                if (_logList.Count > 0)
                {
                    lock (logB)
                    {
                        string conStr = LogSQL.GetConnectString();
                        using (SQLiteConnection conn = new SQLiteConnection(conStr))
                        {
                            conn.Open();

                            using (SQLiteCommand cmd = conn.CreateCommand())
                            {
                                foreach (LogData data in _logList)
                                {
                                    if (LogSQL.ExecuteNonQuery(cmd, LOGTABLE.GetTableInsertSQL(data)) == -1)
                                    {
                                        _errorList.Add(data);
                                    }
                                }
                                _logList.Clear();
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// 初始化日志服务:没有密码,默认数据文件名
 /// </summary>
 public static void Init()
 {
     if (!_init)
     {
         LogSQL.InitSQLiteDB();
         LOG = new LogHelper();
     }
 }
Пример #3
0
 /// <summary>
 /// 带有数据库密码,和文件明的初始化
 /// </summary>
 /// <param name="passwd"></param>
 /// <param name="dbName"></param>
 public static void InitParam(String passwd, String dbName)
 {
     if (!_init)
     {
         LogSQL.SetDbFileName(dbName);
         LogSQL.SetDbPaswd(passwd);
         LogSQL.InitSQLiteDB();
         LOG = new LogHelper();
     }
 }
Пример #4
0
 /// <summary>
 /// 设置日志文件打开密码,默认没有密码
 /// </summary>
 public static void SetDbPwd(String passworkd)
 {
     LogSQL.SetDbPaswd(passworkd);
 }