Exemplo n.º 1
0
 /// <summary>
 /// 守护线程
 /// </summary>
 private void GuardThread()
 {
     while (isStart)
     {
         try
         {
             //启动获取数据线程
             if (dataThread == null || !dataThread.IsAlive)
             {
                 dataThread = new Thread(new ThreadStart(DataThread))
                 {
                     Name         = "DataThread",
                     IsBackground = true
                 };
                 dataThread.Start();
             }
         }
         catch (ThreadAbortException)
         {
             Log4NetUtil.Info("手动停止守护线程");
             break;
         }
         catch (Exception ex)
         {
             Log4NetUtil.Error("守护线程运行错误,信息为:" + ex.Message);
         }
         finally
         {
             Thread.Sleep(50);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 数据获取线程
 /// </summary>
 private void DataThread()
 {
     while (isStart)
     {
         try
         {
             if (CacheData.GetCount() > 0)
             {
                 Command command = (Command)CacheData.GetDataFromQueue();
                 if (command != null)
                 {
                     DataForwardMethod(command);
                 }
             }
         }
         catch (ThreadAbortException)
         {
             Log4NetUtil.Info("手动停止操作线程");
             break;
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             Log4NetUtil.Error(ex.GetType().ToString() + ":" + ex.Message);
         }
         finally
         {
             Thread.Sleep(50);
         }
     }
 }
Exemplo n.º 3
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            //log4net日志配置
            Log4NetUtil.InitLog4net();
            Log4NetUtil.Info(typeof(Startup), "entConsole启动");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 批次处理通知事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BulkCopy_SqlRowsCopied_Notify(object sender, SqlRowsCopiedEventArgs e)
        {
            string      strTableName = string.Empty;
            SqlBulkCopy sqlBulkCopy  = sender as SqlBulkCopy;

            if (sqlBulkCopy != null)
            {
                strTableName = sqlBulkCopy.DestinationTableName;
            }
            Log4NetUtil.Info(this, strTableName + " 当前已复制行数:" + e.RowsCopied.ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 /// 粗粒度信息
 /// </summary>
 /// <param name="log"></param>
 /// <param name="main"></param>
 public static void Info(string log, MainWindow main)
 {
     Log4NetUtil.Info(log);
     LogBoxAppend(Colors.Black, "INFO", log, main);
 }