コード例 #1
0
        public HttpResponseMessage QueryClientsForWs([FromBody] QueryClientsForWsRequest request)
        {
            QueryClientsResponse response;

            if (request == null)
            {
                response = ResponseBase.InvalidInput <QueryClientsResponse>("参数错误");
            }
            else
            {
                request.PagingTrim();
                try {
                    var user = WebApiRoot.UserSet.GetUser(UserId.CreateLoginNameUserId(request.LoginName));
                    if (user == null)
                    {
                        response = ResponseBase.InvalidInput <QueryClientsResponse>("用户不存在");
                    }
                    else
                    {
                        var data = WebApiRoot.ClientDataSet.QueryClients(
                            user,
                            request,
                            out int total,
                            out CoinSnapshotData[] latestSnapshots,
                            out int totalOnlineCount,
                            out int totalMiningCount) ?? new List <ClientData>();
                        response = QueryClientsResponse.Ok(data, total, latestSnapshots, totalMiningCount, totalOnlineCount);
                    }
                }
                catch (Exception e) {
                    Logger.ErrorDebugLine(e);
                    response = ResponseBase.ServerError <QueryClientsResponse>(e.Message);
                }
            }
            var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(VirtualRoot.BinarySerializer.Serialize(response))
            };

            httpResponseMessage.Content.Headers.ContentType = WebApiRoot.BinaryContentType;
            return(httpResponseMessage);
        }
コード例 #2
0
        public static QueryClientsResponse QueryClientsForWs(QueryClientsForWsRequest request)
        {
            QueryClientsResponse response;

            if (request == null)
            {
                response = ResponseBase.InvalidInput <QueryClientsResponse>("参数错误");
            }
            else
            {
                request.PagingTrim();
                try {
                    var user = UserSet.GetUser(UserId.CreateLoginNameUserId(request.LoginName));
                    if (user == null)
                    {
                        response = ResponseBase.InvalidInput <QueryClientsResponse>("用户不存在");
                    }
                    else
                    {
                        var data = ClientDataSet.QueryClients(
                            user,
                            request,
                            out int total,
                            out CoinSnapshotData[] latestSnapshots,
                            out int totalOnlineCount,
                            out int totalMiningCount) ?? new List <ClientData>();
                        response = QueryClientsResponse.Ok(data, total, latestSnapshots, totalMiningCount, totalOnlineCount);
                    }
                }
                catch (Exception e) {
                    Logger.ErrorDebugLine(e);
                    response = ResponseBase.ServerError <QueryClientsResponse>(e.Message);
                }
            }
            return(response);
        }