Esempio n. 1
0
 void AppManagerCallback(int code, AppCommon.MODULES module, DateTime dtime, string msg)
 {
     lock (this)
     {
         switch (code)
         {
         case 100:
         {
             if (m_appConfig.logOnScreen == false)
             {
                 return;
             }
             if (dataGridView1.InvokeRequired)
             {
                 dataGridView1.BeginInvoke((MethodInvoker) delegate()
                     {
                         InsertToDataGrid(module, dtime, msg);
                     });
             }
             else
             {
                 InsertToDataGrid(module, dtime, msg);
             }
         }
         break;
         }
     }
 }
Esempio n. 2
0
        public void Write(AppCommon.MODULES module, string str)
        {
            if (m_enable == false)
            {
                return;
            }

            lock (this)
            {
                DateTime d     = DateTime.Now;
                string   dname = "Logs\\" + d.Year + "_" + d.Month + "_" + d.Day;
                if (dname != m_dateName)
                {
                    m_dateName        = dname;
                    m_fullLogPathName = dname + "_" + m_logFileName;
                }

                using (FileStream fs = new FileStream(m_fullLogPathName, FileMode.Append, FileAccess.Write))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.WriteLine("{0}, {1} , {2}", module.ToString(), d, str);
                    }
                if (pMsgCallback != null)
                {
                    pMsgCallback(100, module, d, str);
                }
            }
        }
Esempio n. 3
0
        void InsertToDataGrid(AppCommon.MODULES module, DateTime dtime, string msg)
        {
            dataGridView1.Rows.Add();
            int index = dataGridView1.RowCount - 1;

            dataGridView1.Rows[index].Cells[0].Value = module.ToString();
            dataGridView1.Rows[index].Cells[1].Value = dtime.ToString();
            dataGridView1.Rows[index].Cells[2].Value = msg;
        }