Ejemplo n.º 1
0
 public ReportResponse ReportSpeed([FromBody] SpeedData speedData)
 {
     try {
         if (speedData == null)
         {
             return(ResponseBase.InvalidInput <ReportResponse>());
         }
         WebApiRoot.ClientDataSet.ReportSpeed(speedData, MinerIp, isFromWsServerNode: false);
         if (Version.TryParse(speedData.Version, out Version version))
         {
             string jsonVersionKey = HomePath.GetServerJsonVersion(version);
             var    response       = ReportResponse.Ok(WebApiRoot.GetServerStateResponse(jsonVersionKey));
             if (speedData.LocalServerMessageTimestamp.AddSeconds(1) < WebApiRoot.ServerMessageTimestamp)
             {
                 var list = WebApiRoot.ServerMessageSet.GetServerMessages(speedData.LocalServerMessageTimestamp);
                 // 如果服务器新消息少于10条直接在上报算力时的响应消息中携带上,如果较多就算了推迟到用户切换到消息界面查看时再获取
                 if (list.Count < 10)
                 {
                     response.NewServerMessages.AddRange(list);
                 }
             }
             return(response);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     return(ResponseBase.InvalidInput <ReportResponse>());
 }
Ejemplo n.º 2
0
 internal static ReportResponse DoReportSpeed(SpeedDto speedDto, string minerIp)
 {
     try {
         if (speedDto == null)
         {
             return(ResponseBase.InvalidInput <ReportResponse>());
         }
         AppRoot.ClientDataSet.ReportSpeed(speedDto, minerIp, isFromWsServerNode: false);
         if (Version.TryParse(speedDto.Version, out Version version))
         {
             string jsonVersionKey = HomePath.GetServerJsonVersion(version);
             var    response       = ReportResponse.Ok(AppRoot.GetServerStateResponse(jsonVersionKey));
             if (speedDto.LocalServerMessageTimestamp.AddDays(1) > DateTime.Now && // 为了排除Timestamp.UnixBaseTime
                 speedDto.LocalServerMessageTimestamp.AddSeconds(1) < AppRoot.ServerMessageTimestamp)
             {
                 var list = AppRoot.ServerMessageSet.GetServerMessages(speedDto.LocalServerMessageTimestamp);
                 // 如果服务器新消息少于10条直接在上报算力时的响应消息中携带上,如果较多就算了推迟到用户切换到消息界面查看时再获取
                 if (list.Count < 10)
                 {
                     response.NewServerMessages.AddRange(list);
                 }
             }
             return(response);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     return(ResponseBase.InvalidInput <ReportResponse>());
 }