/// <summary>
 /// 按钮“停止服务”按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsmiStopService_Click(object sender, EventArgs e)
 {
     try
     {
         selfHost.Close();
         ShowMsgControlText("服务停止。");
         SaveTextLog.WriteOperateLog("服务停止。");
     }
     catch (Exception ex)
     {
         ShowMsgControlText(ex.Message);
         selfHost.Abort();
         SaveTextLog.WriteErrorLog(ex.ToString());
     }
 }
 /// <summary>
 /// 按钮“启动服务”按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tsmiStartService_Click(object sender, EventArgs e)
 {
     try
     {
         if (selfHost.State == CommunicationState.Created)
         {
             selfHost.Open();
         }
         else
         {
             selfHost = new ServiceHost(typeof(DataRcvService));
             selfHost.Open();
         }
         ShowMsgControlText("服务启动成功。");
         SaveTextLog.WriteOperateLog("服务启动成功。");
     }
     catch (Exception ex)
     {
         ShowMsgControlText(ex.Message);
         selfHost.Abort();
         SaveTextLog.WriteErrorLog(ex.ToString());
     }
 }