public ResponseBase SetClientMinerProfileProperty(SetClientMinerProfilePropertyRequest request)
 {
     if (request == null)
     {
         return(LoadClientResponse.InvalidInput(Guid.Empty, "参数错误"));
     }
     try {
         if (string.IsNullOrEmpty(request.LoginName))
         {
             return(ResponseBase.InvalidInput(request.MessageId, "登录名不能为空"));
         }
         if (!HostRoot.Current.UserSet.TryGetKey(request.LoginName, out IUser key))
         {
             return(ResponseBase.Forbidden(request.MessageId));
         }
         if (!request.Timestamp.IsInTime())
         {
             return(ResponseBase.Expired(request.MessageId));
         }
         throw new NotImplementedException();
     }
     catch (Exception e) {
         Global.Logger.ErrorDebugLine(e.Message, e);
         return(ResponseBase.ServerError(request.MessageId, e.Message));
     }
 }
 public ResponseBase SetMinerProfileProperty(string clientIp, SetClientMinerProfilePropertyRequest request)
 {
     using (HttpClient client = new HttpClient()) {
         client.Timeout = TimeSpan.FromMilliseconds(3000);
         Task <HttpResponseMessage> message = client.PostAsJsonAsync($"http://{clientIp}:{WebApiConst.MinerClientPort}/api/{s_controllerName}/{nameof(IMinerClientController.SetMinerProfileProperty)}", request);
         ResponseBase response = message.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
 public ResponseBase SetMinerProfileProperty(string clientIp, SetClientMinerProfilePropertyRequest request)
 {
     using (HttpClient client = RpcRoot.Create()) {
         client.Timeout = TimeSpan.FromSeconds(3);
         Task <HttpResponseMessage> getHttpResponse = client.PostAsJsonAsync($"http://{clientIp}:{NTKeyword.MinerClientPort.ToString()}/api/{s_controllerName}/{nameof(IMinerClientController.SetMinerProfileProperty)}", request);
         ResponseBase response = getHttpResponse.Result.Content.ReadAsAsync <ResponseBase>().Result;
         return(response);
     }
 }
 public void SetMinerProfilePropertyAsync(string clientIp, SetClientMinerProfilePropertyRequest request, Action <ResponseBase, Exception> callback)
 {
     Task.Factory.StartNew(() => {
         try {
             var response = SetMinerProfileProperty(clientIp, request);
             callback?.Invoke(response, null);
         }
         catch (Exception e) {
             callback?.Invoke(null, e);
         }
     });
 }
Exemple #5
0
            public void SetClientMinerProfilePropertyAsync(IMinerData client, string propertyName, object value, Action <ResponseBase, Exception> callback)
            {
                SetClientMinerProfilePropertyRequest innerRequest = new SetClientMinerProfilePropertyRequest {
                    PropertyName = propertyName,
                    Value        = value
                };
                WrapperRequest <SetClientMinerProfilePropertyRequest> request = new WrapperRequest <SetClientMinerProfilePropertyRequest> {
                    ObjectId     = client.Id,
                    ClientId     = client.ClientId,
                    ClientIp     = client.MinerIp,
                    InnerRequest = innerRequest
                };

                PostAsync(SControllerName, nameof(IWrapperMinerClientController.SetClientMinerProfileProperty), request.ToQuery(SingleUser.LoginName, SingleUser.PasswordSha1), request, callback);
            }
            public void SetClientMinerProfilePropertyAsync(IClientData client, string propertyName, object value, Action <ResponseBase, Exception> callback)
            {
                SetClientMinerProfilePropertyRequest innerRequest = new SetClientMinerProfilePropertyRequest {
                    LoginName    = SingleUser.LoginName,
                    PropertyName = propertyName,
                    Value        = value
                };

                innerRequest.SignIt(SingleUser.GetRemotePassword(client.ClientId));
                WrapperRequest <SetClientMinerProfilePropertyRequest> request = new WrapperRequest <SetClientMinerProfilePropertyRequest> {
                    ObjectId     = client.GetId(),
                    ClientId     = client.ClientId,
                    LoginName    = SingleUser.LoginName,
                    ClientIp     = client.MinerIp,
                    InnerRequest = innerRequest
                };

                request.SignIt(SingleUser.PasswordSha1);
                PostAsync(SControllerName, nameof(IWrapperMinerClientController.SetClientMinerProfileProperty), null, request, callback);
            }