private void Print(Log log) { // 保证render的时间必须短。否则界面会假死 Color color = EnvChecker.GetColor(TraceItem.ToTraceItem(log).type); string mess = log.serverName + " " + DataUtil.ToDateString(log.dateTime) + " " + log.text; this.BeginInvoke(new Action(() => { Render(color, mess); })); }
private void RenderTable(DataTable dt, int totalNum) { FormLog_SizeChanged(null, null); this.pagerControl.RecordCount = totalNum; if (dt.Rows.Count == 0) { return; } List <ListViewItem> items = new List <ListViewItem>(); foreach (DataRow dr in dt.Rows) { ListViewItem lvi = new ListViewItem(); Log log = new Log() { id = DataUtil.ToString(dr["ID"]), serverName = DataUtil.ToString(dr["系统名称"]), type = DataUtil.ToString(dr["类型"]), dateTime = DataUtil.ToString(dr["插入时间"]), text = DataUtil.ToString(dr["信息文本"]) }; // 文本绑定 lvi.Tag = log.id; lvi.Text = log.id; lvi.SubItems.Add(log.serverName); lvi.SubItems.Add(log.dateTime); lvi.SubItems.Add(log.type); lvi.SubItems.Add(log.text); // 配色 lvi.UseItemStyleForSubItems = false; TraceItem item = TraceItem.ToTraceItem(log); lvi.BackColor = EnvChecker.GetColor(TraceItem.ToTraceItem(log).type); items.Add(lvi); } this.Invoke(new Action(() => { this.listViewLog.Items.AddRange(items.ToArray()); })); }