예제 #1
0
 public void GetGpuProfilesJsonAsync(IMinerData client)
 {
     RpcRoot.PostAsync <string>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.GetGpuProfilesJson), null, (json, e) => {
         GpuProfilesJsonDb data = VirtualRoot.JsonSerializer.Deserialize <GpuProfilesJsonDb>(json) ?? new GpuProfilesJsonDb();
         VirtualRoot.RaiseEvent(new GetGpuProfilesResponsedEvent(client.ClientId, data));
     }, timeountMilliseconds: 3000);
 }
예제 #2
0
        public void QueryClientsAsync(
            int pageIndex,
            int pageSize,
            Guid?groupId,
            Guid?workId,
            string minerIp,
            string minerName,
            MineStatus mineState,
            string coin,
            string pool,
            string wallet,
            string version,
            string kernel,
            Action <QueryClientsResponse, Exception> callback)
        {
            var request = new QueryClientsRequest {
                PageIndex = pageIndex,
                PageSize  = pageSize,
                GroupId   = groupId,
                WorkId    = workId,
                MinerIp   = minerIp,
                MinerName = minerName,
                MineState = mineState,
                Coin      = coin,
                Pool      = pool,
                Wallet    = wallet,
                Version   = version,
                Kernel    = kernel
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IClientController.QueryClients), request, request, callback);
        }
예제 #3
0
 public void GetGpuProfilesJsonAsync(string clientIp, Action <GpuProfilesJsonDb, Exception> callback)
 {
     RpcRoot.PostAsync(clientIp, NTKeyword.NTMinerDaemonPort, _controllerName, nameof(INTMinerDaemonController.GetGpuProfilesJson), null, (string json, Exception e) => {
         GpuProfilesJsonDb data = VirtualRoot.JsonSerializer.Deserialize <GpuProfilesJsonDb>(json) ?? new GpuProfilesJsonDb();
         callback?.Invoke(data, null);
     }, timeountMilliseconds: 3000);
 }
예제 #4
0
        /// <summary>
        /// 本机同步网络调用
        /// </summary>
        public void CloseNTMinerAsync(Action callback)
        {
            string location = NTMinerRegistry.GetLocation(NTMinerAppType.MinerClient);

            if (string.IsNullOrEmpty(location) || !File.Exists(location))
            {
                callback?.Invoke();
                return;
            }
            string processName = Path.GetFileNameWithoutExtension(location);

            if (Process.GetProcessesByName(processName).Length == 0)
            {
                callback?.Invoke();
                return;
            }
            RpcRoot.PostAsync(NTKeyword.Localhost, NTKeyword.MinerClientPort, _controllerName, nameof(IMinerClientController.CloseNTMiner), new SignRequest {
            }, (ResponseBase response, Exception e) => {
                if (!response.IsSuccess())
                {
                    try {
                        Windows.TaskKill.Kill(processName, waitForExit: true);
                    }
                    catch (Exception ex) {
                        Logger.ErrorDebugLine(ex);
                    }
                }
                callback?.Invoke();
            }, timeountMilliseconds: 2000);
        }
예제 #5
0
        public void GetPackageUrlAsync(string package, Action <string, Exception> callback)
        {
            PackageUrlRequest request = new PackageUrlRequest {
                Package = package
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IFileUrlController.PackageUrl), request, callback);
        }
예제 #6
0
        // ReSharper disable once InconsistentNaming
        public void UpgradeNTMinerAsync(IMinerData client, string ntminerFileName)
        {
            UpgradeNTMinerRequest request = new UpgradeNTMinerRequest {
                NTMinerFileName = ntminerFileName
            };

            RpcRoot.PostAsync <ResponseBase>(client.GetLocalIp(), NTKeyword.NTMinerDaemonPort, _daemonControllerName, nameof(INTMinerDaemonController.UpgradeNTMiner), request, null, timeountMilliseconds: 3000);
        }
예제 #7
0
        // ReSharper disable once InconsistentNaming
        public void GetNTMinerUrlAsync(string fileName, Action <string, Exception> callback)
        {
            NTMinerUrlRequest request = new NTMinerUrlRequest {
                FileName = fileName
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IFileUrlController.NTMinerUrl), request, callback);
        }
예제 #8
0
        public void RemoveMineWorkAsync(Guid id, Action <ResponseBase, Exception> callback)
        {
            DataRequest <Guid> request = new DataRequest <Guid> {
                Data = id
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IMineWorkController.RemoveMineWork), request, request, callback);
        }
예제 #9
0
        public void AddOrUpdatePoolAsync(PoolData entity, Action <ResponseBase, Exception> callback)
        {
            DataRequest <PoolData> request = new DataRequest <PoolData> {
                Data = entity
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IPoolController.AddOrUpdatePool), request, request, callback);
        }
예제 #10
0
        public void GetServerMessagesAsync(DateTime timestamp, Action <DataResponse <List <ServerMessageData> >, Exception> callback)
        {
            ServerMessagesRequest request = new ServerMessagesRequest {
                Timestamp = Timestamp.GetTimestamp(timestamp)
            };

            RpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IServerMessageController.ServerMessages), request, callback);
        }
예제 #11
0
        public void AddOrUpdateNTMinerWalletAsync(NTMinerWalletData entity, Action <ResponseBase, Exception> callback)
        {
            DataRequest <NTMinerWalletData> request = new DataRequest <NTMinerWalletData>()
            {
                Data = entity
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(INTMinerWalletController.AddOrUpdateNTMinerWallet), request, request, callback);
        }
예제 #12
0
        public void AddOrUpdateOverClockDataAsync(OverClockData entity, Action <ResponseBase, Exception> callback)
        {
            DataRequest <OverClockData> request = new DataRequest <OverClockData>()
            {
                Data = entity
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IOverClockDataController.AddOrUpdateOverClockData), request, request, callback);
        }
예제 #13
0
        public void UpdateClientsAsync(string propertyName, Dictionary <string, object> values, Action <ResponseBase, Exception> callback)
        {
            UpdateClientsRequest request = new UpdateClientsRequest {
                PropertyName = propertyName,
                Values       = values
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IClientController.UpdateClients), request, request, callback);
        }
예제 #14
0
        public void SetAppSettingsAsync(List <AppSettingData> entities, Action <ResponseBase, Exception> callback)
        {
            DataRequest <List <AppSettingData> > request = new DataRequest <List <AppSettingData> >()
            {
                Data = entities
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IAppSettingController.SetAppSettings), request, request, callback);
        }
예제 #15
0
        public void RemoveKernelOutputKeyword(Guid id, Action <ResponseBase, Exception> callback)
        {
            DataRequest <Guid> request = new DataRequest <Guid>()
            {
                Data = id
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IKernelOutputKeywordController.RemoveKernelOutputKeyword), request, request, callback);
        }
예제 #16
0
        public void AddOrUpdateKernelOutputKeywordAsync(KernelOutputKeywordData entity, Action <ResponseBase, Exception> callback)
        {
            DataRequest <KernelOutputKeywordData> request = new DataRequest <KernelOutputKeywordData>()
            {
                Data = entity
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IKernelOutputKeywordController.AddOrUpdateKernelOutputKeyword), request, request, callback);
        }
예제 #17
0
        public void MarkDeleteServerMessageAsync(Guid id, Action <ResponseBase, Exception> callback)
        {
            DataRequest <Guid> request = new DataRequest <Guid>()
            {
                Data = id
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IServerMessageController.MarkDeleteServerMessage), request, request, callback);
        }
예제 #18
0
        public void RefreshClientsAsync(List <string> objectIds, Action <DataResponse <List <ClientData> >, Exception> callback)
        {
            MinerIdsRequest request = new MinerIdsRequest()
            {
                ObjectIds = objectIds
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IClientController.RefreshClients), request, request, callback);
        }
예제 #19
0
        public void RemoveUserAsync(string loginName, Action <ResponseBase, Exception> callback)
        {
            DataRequest <String> request = new DataRequest <String>()
            {
                Data = loginName
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IUserController.RemoveUser), request, request, callback);
        }
예제 #20
0
        public void UpdateUserAsync(UserData userData, Action <ResponseBase, Exception> callback)
        {
            DataRequest <UserData> request = new DataRequest <UserData>()
            {
                Data = userData
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IUserController.UpdateUser), request, request, callback);
        }
예제 #21
0
        public void RemoveNTMinerWalletAsync(Guid id, Action <ResponseBase, Exception> callback)
        {
            DataRequest <Guid> request = new DataRequest <Guid>()
            {
                Data = id
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(INTMinerWalletController.RemoveNTMinerWallet), request, request, callback);
        }
예제 #22
0
        public void AddClientsAsync(List <string> clientIps, Action <ResponseBase, Exception> callback)
        {
            AddClientRequest request = new AddClientRequest()
            {
                ClientIps = clientIps
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IClientController.AddClients), request, request, callback);
        }
예제 #23
0
        public void AddOrUpdateMinerGroupAsync(MinerGroupData entity, Action <ResponseBase, Exception> callback)
        {
            entity.ModifiedOn = DateTime.Now;
            DataRequest <MinerGroupData> request = new DataRequest <MinerGroupData> {
                Data = entity
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IMinerGroupController.AddOrUpdateMinerGroup), request, request, callback);
        }
예제 #24
0
        public void AddOrUpdateServerMessageAsync(ServerMessageData entity, Action <ResponseBase, Exception> callback)
        {
            DataRequest <ServerMessageData> request = new DataRequest <ServerMessageData>()
            {
                Data = entity
            };

            RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IServerMessageController.AddOrUpdateServerMessage), request, request, callback);
        }
예제 #25
0
        public void GetNodeAddressAsync(Guid clientId, string outerUserId, Action <DataResponse <string>, Exception> callback)
        {
            var data = new GetNodeAddressRequest {
                ClientId = clientId,
                UserId   = outerUserId
            };

            RpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IWsServerNodeController.GetNodeAddress), data, callback, timeountMilliseconds: 8000);
        }
예제 #26
0
        public void LoginAsync(string loginName, string password, Action <ResponseBase, Exception> callback)
        {
            VirtualRoot.SetRpcUser(new User.RpcUser(loginName, password));
            SignRequest request = new SignRequest()
            {
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IControlCenterController.LoginControlCenter), request, request, callback);
        }
예제 #27
0
        public void GetLatestSnapshotsAsync(
            int limit,
            Action <GetCoinSnapshotsResponse, Exception> callback)
        {
            GetCoinSnapshotsRequest request = new GetCoinSnapshotsRequest {
                Limit = limit
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IControlCenterController.LatestSnapshots), request, request, callback);
        }
예제 #28
0
        public void ExportMineWorkAsync(Guid workId, string localJson, string serverJson, Action <ResponseBase, Exception> callback)
        {
            ExportMineWorkRequest request = new ExportMineWorkRequest {
                MineWorkId = workId,
                LocalJson  = localJson,
                ServerJson = serverJson
            };

            RpcRoot.PostAsync(NTMinerRegistry.GetControlCenterHost(), NTKeyword.ControlCenterPort, _controllerName, nameof(IMineWorkController.ExportMineWork), request, request, callback);
        }
예제 #29
0
        public void GetJsonFileVersionAsync(string key, Action <ServerStateResponse> callback)
        {
            AppSettingRequest request = new AppSettingRequest {
                Key = key
            };

            RpcRoot.PostAsync(RpcRoot.OfficialServerHost, RpcRoot.OfficialServerPort, _controllerName, nameof(IAppSettingController.GetJsonFileVersion), request, (string line, Exception e) => {
                callback?.Invoke(ServerStateResponse.FromLine(line));
            }, timeountMilliseconds: 10 * 1000);
        }
예제 #30
0
 // ReSharper disable once InconsistentNaming
 public void GetNTMinerFilesAsync(NTMinerAppType appType, Action <List <NTMinerFileData>, Exception> callback)
 {
     RpcRoot.PostAsync(_host, _port, _controllerName, nameof(IFileUrlController.NTMinerFiles), callback: (List <NTMinerFileData> data, Exception e) => {
         if (data != null)
         {
             data = data.Where(a => a.AppType == appType).ToList();
         }
         callback?.Invoke(data, e);
     });
 }