Пример #1
0
 /// <summary>
 /// 发送下载完成消息
 /// </summary>
 /// <param name="version">下载完成的(最大)版本号</param>
 private void SendDownloadCompletedMessage(object version)
 {
     try
     {
         DownloadCompletedMessage dcMsg = new DownloadCompletedMessage();
         dcMsg.messageType = "downloadCompleted";
         dcMsg.account     = _ipAddress;
         dcMsg.diskCode    = _diskcode;
         dcMsg.version     = version.ToString();
         dcMsg.time        = DateTime.Now.ToString("yyyyMMddHHmmss");
         //向服务端发送消息
         Send(dcMsg);
         //接收服务端回应的消息(如果服务端未收到消息,尝试再次发送,最多尝试3次)
         string content = Receive();
         if (string.IsNullOrEmpty(content) ||
             !string.IsNullOrEmpty(content) && !content.Contains("receiveOk"))
         {
             int time = 3;
             while (time > 0 && string.IsNullOrEmpty(content))
             {
                 Send(dcMsg);
                 content = Receive();
                 time--;
             }
         }
     }
     catch (Exception ex)
     {
         _loger.Error("SendDownloadCompletedMessage(object)方法:" + ex.Message);
         throw ex;
     }
 }
Пример #2
0
 /// <summary>
 /// 发送下载完成消息
 /// </summary>
 /// <param name="version">下载完成的(最大)版本号</param>
 private void SendDownloadCompletedMessage(object version)
 {
     try
     {
         DownloadCompletedMessage dcMsg = new DownloadCompletedMessage();
         dcMsg.messageType = "downloadCompleted";
         dcMsg.account = _ipAddress;
         dcMsg.diskCode = _diskcode;
         dcMsg.version = version.ToString();
         dcMsg.time = DateTime.Now.ToString("yyyyMMddHHmmss");
         //向服务端发送消息
         Send(dcMsg);
         //接收服务端回应的消息(如果服务端未收到消息,尝试再次发送,最多尝试3次)
         string content = Receive();
         if (string.IsNullOrEmpty(content) ||
             !string.IsNullOrEmpty(content) && !content.Contains("receiveOk"))
         {
             int time = 3;
             while (time > 0 && string.IsNullOrEmpty(content))
             {
                 Send(dcMsg);
                 content = Receive();
                 time--;
             }
         }
     }
     catch (Exception ex)
     {
         _loger.Error("SendDownloadCompletedMessage(object)方法:" + ex.Message);
         throw ex;
     }
 }