Exemplo n.º 1
0
 public ResponseBase RemoveNTMinerFile(RemoveNTMinerFileRequest 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));
         }
         if (request.GetSign(key.Password) != request.Sign)
         {
             return(ResponseBase.Forbidden(request.MessageId, "签名验证未通过"));
         }
         HostRoot.Current.NTMinerFileSet.Remove(request.NTMinerId);
         return(ResponseBase.Ok(request.MessageId));
     }
     catch (Exception e) {
         Global.Logger.Error(e.Message, e);
         return(ResponseBase.ServerError(request.MessageId, e.Message));
     }
 }
 public ResponseBase SetCoinKernelProfileProperty(SetCoinKernelProfilePropertyRequest 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));
         }
         if (!HostRoot.Current.MineWorkSet.Contains(request.WorkId))
         {
             return(ResponseBase.InvalidInput(request.MessageId, "给定的workId不存在"));
         }
         if (request.Sign != request.GetSign(key.Password))
         {
             return(ResponseBase.Forbidden(request.MessageId, "签名验证未通过"));
         }
         HostRoot.Current.MineProfileManager.SetCoinKernelProfileProperty(request.WorkId, request.CoinKernelId, request.PropertyName, request.Value);
         return(ResponseBase.Ok(request.MessageId));
     }
     catch (Exception e) {
         Global.Logger.ErrorDebugLine(e.Message, e);
         return(ResponseBase.ServerError(request.MessageId, e.Message));
     }
 }
 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 LoadClientResponse LoadClient(LoadClientRequest request)
 {
     if (request == null)
     {
         return(LoadClientResponse.InvalidInput(Guid.Empty, "参数错误"));
     }
     try {
         if (string.IsNullOrEmpty(request.LoginName))
         {
             return(LoadClientResponse.InvalidInput(request.MessageId, "登录名不能为空"));
         }
         if (!HostRoot.Current.UserSet.TryGetKey(request.LoginName, out IUser key))
         {
             return(LoadClientResponse.Forbidden(request.MessageId));
         }
         if (!request.Timestamp.IsInTime())
         {
             return(LoadClientResponse.Expired(request.MessageId));
         }
         if (request.ClientId == Guid.Empty)
         {
             return(LoadClientResponse.InvalidInput(request.MessageId, "clientId为空"));
         }
         if (request.Sign != request.GetSign(key.Password))
         {
             return(LoadClientResponse.Forbidden(request.MessageId, "签名验证未通过"));
         }
         var data = HostRoot.Current.ClientSet.LoadClient(request.MessageId);
         return(new LoadClientResponse {
             Data = data
         });
     }
     catch (Exception e) {
         Global.Logger.ErrorDebugLine(e.Message, e);
         return(LoadClientResponse.ServerError(request.MessageId, e.Message));
     }
 }