Example #1
0
 public ReportResponse ReportSpeed([FromBody] SpeedData speedData)
 {
     try {
         if (speedData == null)
         {
             return(ResponseBase.InvalidInput <ReportResponse>());
         }
         ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId);
         if (clientData == null)
         {
             clientData = ClientData.Create(speedData, ClientIp);
             HostRoot.Instance.ClientSet.Add(clientData);
         }
         else
         {
             clientData.Update(speedData, ClientIp);
         }
         if (Version.TryParse(speedData.Version, out Version version))
         {
             string jsonVersionKey = EntryAssemblyInfo.GetServerJsonVersion(version);
             var    response       = ReportResponse.Ok(HostRoot.GetServerState(jsonVersionKey));
             if (speedData.LocalServerMessageTimestamp.AddSeconds(1) < HostRoot.Instance.ServerMessageTimestamp)
             {
                 var list = HostRoot.Instance.ServerMessageSet.GetServerMessages(speedData.LocalServerMessageTimestamp);
                 if (list.Count < 10)
                 {
                     response.NewServerMessages.AddRange(list);
                 }
             }
             return(response);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     return(ResponseBase.InvalidInput <ReportResponse>());
 }
Example #2
0
        public ReportResponse ReportSpeed([FromBody] SpeedData speedData)
        {
            ReportResponse response;

            try {
                if (speedData == null)
                {
                    response             = ResponseBase.InvalidInput <ReportResponse>();
                    response.ServerState = ServerState.Empty;
                    return(response);
                }
                ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId);
                if (clientData == null)
                {
                    clientData = ClientData.Create(speedData, ClientIp);
                    HostRoot.Instance.ClientSet.Add(clientData);
                }
                else
                {
                    clientData.Update(speedData, ClientIp);
                }
                if (Version.TryParse(speedData.Version, out Version version))
                {
                    string jsonVersionKey = MainAssemblyInfo.GetServerJsonVersion(version);
                    response             = ResponseBase.Ok <ReportResponse>();
                    response.ServerState = HostRoot.GetServerState(jsonVersionKey);
                    return(response);
                }
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
            response             = ResponseBase.InvalidInput <ReportResponse>();
            response.ServerState = ServerState.Empty;
            return(response);
        }
Example #3
0
        public string GetJsonFileVersion(AppSettingRequest request)
        {
            ServerState serverState = HostRoot.GetServerState(request.Key);

            return($"{serverState.JsonFileVersion}|{serverState.MinerClientVersion}|{serverState.Time.ToString()}|{serverState.MessageTimestamp.ToString()}|{serverState.OutputKeywordTimestamp.ToString()}");
        }