Exemplo n.º 1
0
        public void WriteLog(string logSrc, string category, string level, string content)
        {
            if (this.richTextBoxLog.InvokeRequired)
            {
                DelegateDispLog delegateLog = new DelegateDispLog(WriteLog);
                this.Invoke(delegateLog, new object[4] {
                    logSrc, category, level, content
                });
            }
            else
            {
                richTextBoxLog.AppendText(string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1},{2},{3}", DateTime.Now.ToString(), logSrc, category, content) + Environment.NewLine);

                string[] newlines = new string[richTextBoxLog.Lines.Length];
                Array.Copy(richTextBoxLog.Lines, richTextBoxLog.Lines.Length - newlines.Count(), newlines, 0, newlines.Count());
                richTextBoxLog.Lines = newlines;
                richTextBoxLog.Select(richTextBoxLog.Text.Length, 0);
                richTextBoxLog.ScrollToCaret();

                if (this.richTextBoxLog.Lines.Length > 600)//600行数据
                {
                    this.richTextBoxLog.Clear();
                }
                SysLogModel logModel = new SysLogModel();
                logModel.SysLog_ID      = Guid.NewGuid().ToString();
                logModel.SysLog_Level   = level;
                logModel.SysLog_Content = content;
                logModel.SysLog_Source  = logSrc;
                logModel.SysLog_Time    = DateTime.Now;
                this.mainPresenter.AddDBLog(logModel);
            }
        }
Exemplo n.º 2
0
        private delegate void DelegateDispLog(LogModel log);//委托,显示日志

        public void DispLog(LogModel log)
        {
            if (this.richTextBoxLog.InvokeRequired)
            {
                DelegateDispLog delegateLog = new DelegateDispLog(DispLog);
                this.Invoke(delegateLog, new object[] { log });
            }
            else
            {
                richTextBoxLog.AppendText(string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1},{2}", log.LogTime, log.LogSource, log.LogContent) + Environment.NewLine);
                if (richTextBoxLog.Lines.Length > 600)
                {
                    string[] newlines = new string[600];
                    Array.Copy(richTextBoxLog.Lines, richTextBoxLog.Lines.Length - 600, newlines, 0, 600);
                    richTextBoxLog.Lines = newlines;
                    richTextBoxLog.Select(richTextBoxLog.Text.Length, 0);
                    richTextBoxLog.ScrollToCaret();
                }
                //if (this.richTextBoxLog.Text.Count() > 10000)
                //{
                //    this.richTextBoxLog.Text = "";
                //}
                //this.richTextBoxLog.Text += (string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1},{2}", log.LogTime, log.LogSource,log.LogContent) + "\r\n");
            }
        }
Exemplo n.º 3
0
        private delegate void DelegateDispLog(LogModel log);//委托,显示日志

        public void DispLog(LogModel log)
        {
            if (this.richTextBoxLog.InvokeRequired)
            {
                DelegateDispLog delegateLog = new DelegateDispLog(DispLog);
                this.Invoke(delegateLog, new object[] { log });
            }
            else
            {
                this.richTextBoxLog.Text += (string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1},{2}", log.LogTime, log.LogSource, log.LogContent) + "\r\n");
            }
        }
Exemplo n.º 4
0
 private void RefreshLogdt(DataTable dt, string timeCost, int curPage)
 {
     if (this.dataGridView1.InvokeRequired)
     {
         DelegateDispLog logDelegate = new DelegateDispLog(RefreshLogdt);
         this.Invoke(logDelegate, new object[] { dt, timeCost, curPage });
     }
     else
     {
         this.toolStripLabelTimecost.Text = timeCost;
         //  this.bindingSource1.DataSource = dt;
         //this.bindingNavigator1.BindingSource = this.bindingSource1;
         this.dataGridView1.DataSource       = dt;// this.bindingSource1;
         this.dataGridView1.Columns[0].Width = 100;
         this.dataGridView1.Columns[2].Width = 100;
         this.dataGridView1.Columns[3].Width = 100;
         this.dataGridView1.Columns[4].Width = 200;
         this.dataGridView1.Columns[4].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
         this.dataGridView1.Columns[1].AutoSizeMode            = DataGridViewAutoSizeColumnMode.Fill;
         this.toolTextBoxCurpage.Text = curPage.ToString();
     }
 }
Exemplo n.º 5
0
        private delegate void DelegateDispLog(LogModel log);//委托,显示日志
        public void DispLog(LogModel log)
        {
            if(this.richTextBoxLog.InvokeRequired)
            {
                DelegateDispLog delegateLog = new DelegateDispLog(DispLog);
                this.Invoke(delegateLog, new object[] {log });
            }
            else
            {
                if (this.richTextBoxLog.Text.Count() > 10000)
                {
                    this.richTextBoxLog.Text = "";
                }

                this.richTextBoxLog.Text += (string.Format("[{0:yyyy-MM-dd HH:mm:ss.fff}]{1},{2}", log.LogTime, log.LogSource,log.LogContent) + "\r\n");
                //this.richTextBoxLog.Focus();
                //this.richTextBoxLog.Select(this.richTextBoxLog.TextLength, 0); 

                //this.richTextBoxLog.ScrollToCaret(); 
            }
            
        }