コード例 #1
0
        /// <summary>
        /// 插入操作日志
        /// </summary>
        /// <param name="opLog"></param>
        /// <returns></returns>

        public bool InsertOprLog(OprLog opLog)
        {
            List <string> strSqlList = new List <string>();
            string        strSql     = string.Format("insert into oprlog values('{0}',{1},{2},datetime('now'),'{3}','{4}');", opLog.Sn, opLog.Type, opLog.Source, opLog.Content, opLog.Condition);

            strSqlList.Add(strSql);
            return(_idbWrite.ExecuteNonQueryTrans(strSqlList));
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: hardborn/MonitorManager
 private void WriteLog()
 {
     OprLog opLog = new OprLog();
     for (int i = 0; i < comboBox.SelectedIndex + 1; i++)
     {
         opLog.Sn = "sn_" + i;
         opLog.Type = i;
         opLog.Source = i + 2;
         opLog.Updatetime = DateTime.UtcNow.AddHours(i);
         opLog.Content = "content" + i;
         opLog.Condition = "condition" + i;
         if (!_accessor.InsertOprLog(opLog))
         {
             toolStripStatusLabel1.Text = "填写日志失败";
             return;
         }
     }
     toolStripStatusLabel1.Text = "填写日志成功";
 }
コード例 #3
0
 /// <summary>
 /// 插入操作日志
 /// </summary>
 /// <param name="opLog"></param>
 /// <returns></returns>
 public bool InsertOprLog(OprLog opLog)
 {
     List<string> strSqlList = new List<string>();
     string strSql = string.Format("insert into oprlog values('{0}',{1},{2},datetime('now'),'{3}','{4}');", opLog.Sn, opLog.Type, opLog.Source, opLog.Content, opLog.Condition);
     strSqlList.Add(strSql);
     return _idbWrite.ExecuteNonQueryTrans(strSqlList);
 }
コード例 #4
0
 /// <summary>
 /// 查询操作日志
 /// </summary>
 /// <param name="ledSN">显示屏SN号,空串代表不限制</param>
 /// <param name="type">操作类型,<0代表不限制</param>
 /// <param name="source">操作源,<0代表不限制</param>
 /// <param name="minDT">时段起始时间</param>
 /// <param name="maxDT">时段结束时间</param>
 /// <returns></returns>
 public List<OprLog> GetOprLog(string ledSN, int type, int source, long minDT, long maxDT)
 {
     List<OprLog> oprList = new List<OprLog>();
     string strTmp = "select sn,type,source,updatetime,content,condition from oprlog where";
     string strSql = "select sn,type,source,updatetime,content,condition from oprlog where";
     if (ledSN != string.Empty) strSql += " sn=" + "'" + ledSN + "'";
     if (type >= 0)
     {
         if (strTmp == strSql) strSql += " type=" + type;
         else strSql += " and type=" + type;
     }
     if (source >= 0)
     {
         if (strTmp == strSql) strSql += " source=" + source;
         else strSql += " and source=" + source;
     }
     if (strTmp == strSql) strSql += " updatetime between " + minDT + " and " + maxDT;
     else strSql += " and updatetime between " + minDT + " and " + maxDT;
     strSql += ";";
     DataTable dt = _idbRead.ExecuteDataTable(strSql);
     if (dt == null || dt.Rows.Count == 0) return oprList;
     OprLog opLog;
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         opLog = new OprLog();
         opLog.Sn = (string)dt.Rows[i][0];
         opLog.Type = (int)dt.Rows[i][1];
         opLog.Source = (int)dt.Rows[i][2];
         opLog.Updatetime = SystemHelper.GetTimeByUtcTicks((long)dt.Rows[i][3]);
         opLog.Content = (string)dt.Rows[i][4];
         opLog.Condition = (string)dt.Rows[i][5];
         oprList.Add(opLog);
     }
     return oprList;
 }
コード例 #5
0
        /// <summary>
        /// 查询操作日志
        /// </summary>
        /// <param name="ledSN">显示屏SN号,空串代表不限制</param>
        /// <param name="type">操作类型,<0代表不限制</param>
        /// <param name="source">操作源,<0代表不限制</param>
        /// <param name="minDT">时段起始时间</param>
        /// <param name="maxDT">时段结束时间</param>
        /// <returns></returns>
        public List <OprLog> GetOprLog(string ledSN, int type, int source, long minDT, long maxDT)
        {
            List <OprLog> oprList = new List <OprLog>();
            string        strTmp  = "select sn,type,source,updatetime,content,condition from oprlog where";
            string        strSql  = "select sn,type,source,updatetime,content,condition from oprlog where";

            if (ledSN != string.Empty)
            {
                strSql += " sn=" + "'" + ledSN + "'";
            }
            if (type >= 0)
            {
                if (strTmp == strSql)
                {
                    strSql += " type=" + type;
                }
                else
                {
                    strSql += " and type=" + type;
                }
            }
            if (source >= 0)
            {
                if (strTmp == strSql)
                {
                    strSql += " source=" + source;
                }
                else
                {
                    strSql += " and source=" + source;
                }
            }
            if (strTmp == strSql)
            {
                strSql += " updatetime between " + minDT + " and " + maxDT;
            }
            else
            {
                strSql += " and updatetime between " + minDT + " and " + maxDT;
            }
            strSql += ";";
            DataTable dt = _idbRead.ExecuteDataTable(strSql);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(oprList);
            }
            OprLog opLog;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                opLog            = new OprLog();
                opLog.Sn         = (string)dt.Rows[i][0];
                opLog.Type       = (int)dt.Rows[i][1];
                opLog.Source     = (int)dt.Rows[i][2];
                opLog.Updatetime = SystemHelper.GetTimeByUtcTicks((long)dt.Rows[i][3]);
                opLog.Content    = (string)dt.Rows[i][4];
                opLog.Condition  = (string)dt.Rows[i][5];
                oprList.Add(opLog);
            }
            return(oprList);
        }