public LndGrpcService(IConfiguration config)
        {
            /*
             * var certLoc = config.GetValue<string>("cert");
             * var macLoc = config.GetValue<string>("mac");
             * ;
             *
             * var directory = Path.GetFullPath(certLoc);
             * Console.WriteLine(rpc + " stuff " + directory);*/
            var directory = Environment.CurrentDirectory;
            var tls       = File.ReadAllText(directory + "./../lnd-test-cluster/docker/temp/lnd-alice/tls.cert");
            var hexMac    = Util.ToHex(File.ReadAllBytes(directory + "./../lnd-test-cluster/docker/temp/lnd-alice/data/chain/bitcoin/regtest/admin.macaroon"));
            var rpc       = config.GetValue <string>("rpc");

            feePercentage    = config.GetValue <uint>("fee");
            maxSatPerPayment = config.GetValue <uint>("max_sat");
            maxVouchers      = config.GetValue <uint>("max_voucher");
            var macaroonCallCredentials = new MacaroonCallCredentials(hexMac);
            var channelCreds            = ChannelCredentials.Create(new SslCredentials(tls), macaroonCallCredentials.credentials);
            var lndChannel = new Grpc.Core.Channel(rpc, channelCreds);

            client  = new Lightning.LightningClient(lndChannel);
            getInfo = client.GetInfo(new GetInfoRequest());
            Console.WriteLine(getInfo.ToString());
        }
        public void CancellationTokenMultipleRequestsCancel_test()
        {
            var cancelToken = new CancellationTokenSource();

            var client = TestUtil.GetClient(cancelToken.Token);

            Task <GetInfoResponse>[] tasks    = new Task <GetInfoResponse> [4];
            GetInfoResponse          response = null;

            try
            {
                for (int i = 0; i < tasks.Length; i++)
                {
                    tasks[i] = client.Info.GetInfo();
                    if (i == 0)
                    {
                        response = tasks[0].Result;
                        cancelToken.Cancel();
                    }
                }
                Assert.IsNotNull(response);
                Task.WaitAll(tasks);
                Assert.Fail("Expected OperationCanceledException but no exception was thrown");
            }
            catch (AggregateException aex)
            {
                foreach (var ex in aex.Flatten().InnerExceptions)
                {
                    if (!(ex is OperationCanceledException))
                    {
                        Assert.Fail(string.Format("Expected OperationCanceledException but got {0}", ex.ToString()));
                    }
                }
            }
        }
Beispiel #3
0
        public GetInfoResponse GetInfo(GetInfoRequest request)
        {
            var respone = new GetInfoResponse()
            {
                ErrorCode = "00", IsSuccess = "0", Message = "成功"
            };
            var info = curdData.GetInfo(request.Id);

            if (info == null)
            {
                respone.ErrorCode = "失败";
            }
            else
            {
                respone.UserInfo = new UserInfo()
                {
                    Name   = info.Name,
                    Id     = info.Id,
                    Gender = info.Gender,
                    Age    = info.Age
                };
                respone.IsSuccess = "1";
            }

            return(respone);
        }
Beispiel #4
0
        public ActionResult FilterByTaskName(string taskName)
        {
            _schedulerManager.SetWPIntService(getCurrentService());
            GetInfoResponse infoResponse = _schedulerManager.GetTaskList();

            infoResponse.TasksInfos = TaskListSort.SortByName(infoResponse.TasksInfos);
            if (taskName != null && taskName != "")
            {
                List <TaskHandlerInfo> taskHandlerInfos = new List <TaskHandlerInfo>();
                foreach (TaskHandlerInfo taskHandlerInfo in infoResponse.TasksInfos)
                {
                    TaskHandlerInfo newTaskHandlerInfo = new TaskHandlerInfo();
                    newTaskHandlerInfo.Name = taskHandlerInfo.Name;
                    newTaskHandlerInfo.NearTaskScheduledTime = taskHandlerInfo.NearTaskScheduledTime;
                    newTaskHandlerInfo.Type = taskHandlerInfo.Type;
                    foreach (TaskInfo taskInfo in taskHandlerInfo.TaskInfos)
                    {
                        if (taskInfo.Name.Contains(taskName))
                        {
                            newTaskHandlerInfo.TaskInfos.Add(taskInfo);
                        }
                    }
                    if (newTaskHandlerInfo.TaskInfos.Count > 0)
                    {
                        taskHandlerInfos.Add(newTaskHandlerInfo);
                    }
                }
                infoResponse.TasksInfos = taskHandlerInfos;
            }
            return(PartialView("TableView", infoResponse));
        }
Beispiel #5
0
        private void GetLogsUsingDoppler(CloudFoundryClient client, Guid?appGuid, GetInfoResponse detailedInfo)
        {
            using (var doppler = new Doppler.Client.DopplerLog(new Uri(detailedInfo.DopplerLoggingEndpoint), string.Format(CultureInfo.InvariantCulture, "bearer {0}", client.AuthorizationToken), null, this.CFSkipSslValidation))
            {
                doppler.ErrorReceived += (sender, error) =>
                {
                    Logger.LogErrorFromException(error.Error);
                };

                doppler.StreamOpened += (sender, args) =>
                {
                    Logger.LogMessage("Log stream opened.");
                };

                doppler.StreamClosed += (sender, args) =>
                {
                    Logger.LogMessage("Log stream closed.");
                };

                doppler.MessageReceived += (sender, message) =>
                {
                    long timeInMilliSeconds = message.LogMessage.timestamp / 1000 / 1000;
                    var  logTimeStamp       = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(timeInMilliSeconds);

                    Logger.LogMessage("[{0}] - {1}: {2}", message.LogMessage.logMessage.source_type.ToString(), logTimeStamp.ToString(CultureInfo.InvariantCulture), Encoding.UTF8.GetString(message.LogMessage.logMessage.message));
                };

                doppler.Tail(appGuid.Value.ToString());

                this.MonitorApp(client, appGuid);

                doppler.StopLogStream();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Gets a country code for a router within the tor network. This method will not work unless a <c>geoip</c> and/or <c>geoip6</c> file has been supplied.
        /// </summary>
        /// <param name="router">The router to retrieve the country code for.</param>
        /// <returns>A <see cref="System.String"/> containing the country code; otherwise, <c>null</c> if the country code could not be resolved.</returns>
        public string GetCountryCode(Router router)
        {
            if (router == null)
            {
                throw new ArgumentNullException("router");
            }

            string address = router.IPAddress.ToString();

            GetInfoCommand  command  = new GetInfoCommand(string.Format("ip-to-country/{0}", address));
            GetInfoResponse response = command.Dispatch(client);

            if (response.Success)
            {
                string[] values = response.Values[0].Split(new[] { '=' }, 2);

                if (values.Length == 2)
                {
                    return(values[1].Trim());
                }

                return(values[0].Trim().ToUpper());
            }

            return(null);
        }
Beispiel #7
0
        /// <summary>
        /// Gets the version of the running tor application.
        /// </summary>
        /// <returns>A <see cref="Version"/> object instance containing the version.</returns>
        private Version PropertyGetVersion()
        {
            GetInfoCommand  command  = new GetInfoCommand("version");
            GetInfoResponse response = command.Dispatch(client);

            if (!response.Success)
            {
                return(new Version());
            }

            Regex pattern = new Regex(@"(?<major>\d{1,})\.(?<minor>\d{1,})\.(?<build>\d{1,})\.(?<revision>\d{1,})(?:$|\s)");
            Match match   = pattern.Match(response.Values[0]);

            if (match.Success)
            {
                return(new Version(
                           Convert.ToInt32(match.Groups["major"].Value),
                           Convert.ToInt32(match.Groups["minor"].Value),
                           Convert.ToInt32(match.Groups["build"].Value),
                           Convert.ToInt32(match.Groups["revision"].Value)
                           ));
            }

            return(new Version());
        }
Beispiel #8
0
        public override bool Execute()
        {
            this.CFOrganization = this.CFOrganization.Trim();
            this.CFSpace        = this.CFSpace.Trim();

            this.Logger = new TaskLogger(this);
            var app = LoadAppFromManifest();

            try
            {
                CloudFoundryClient client = InitClient();

                Guid?spaceGuid = null;

                if ((!string.IsNullOrWhiteSpace(this.CFSpace)) && (!string.IsNullOrWhiteSpace(this.CFOrganization)))
                {
                    spaceGuid = Utils.GetSpaceGuid(client, this.Logger, this.CFOrganization, this.CFSpace);

                    if (spaceGuid == null)
                    {
                        return(false);
                    }
                }

                var appGuid = Utils.GetAppGuid(client, app.Name, spaceGuid.Value);

                if (appGuid.HasValue == false)
                {
                    Logger.LogError("Application {0} not found", app.Name);
                    return(false);
                }

                Logger.LogMessage("Restarting application {0}", app.Name);

                // ======= HOOKUP LOGGING =======
                GetInfoResponse detailedInfo = client.Info.GetInfo().Result;

                if (string.IsNullOrWhiteSpace(detailedInfo.DopplerLoggingEndpoint) == false)
                {
                    this.GetLogsUsingDoppler(client, appGuid, detailedInfo);
                }
                else
                if (string.IsNullOrWhiteSpace(detailedInfo.LoggingEndpoint) == false)
                {
                    this.GetLogsUsingLoggregator(client, appGuid, detailedInfo);
                }
                else
                {
                    this.Logger.LogError("Could not retrieve application logs");
                }
            }
            catch (Exception exception)
            {
                this.Logger.LogError("Restart App failed", exception);
                return(false);
            }

            return(true);
        }
        public ActionResult UnprotectedLanding()
        {
            logger.Debug("UnprotectedLanding");
            GetInfoResponse getInfoResponse = new GetInfoResponse();

            TempData["oktaOrg"] = primaryOrgUrl;
            return(View(getInfoResponse));
        }
        public ActionResult AuthCodeLanding(string relayState)
        {
            logger.Debug("Post AuthCodeLanding");
            GetInfoResponse rspData = new GetInfoResponse();

            TempData["oktaOrg"] = apiUrl;
            return(View("AuthCodeLanding", rspData));
        }
Beispiel #11
0
        public ActionResult AuthCodeLanding()
        {
            logger.Debug("AuthCodeLanding");
            GetInfoResponse getInfoResponse = new GetInfoResponse();

            TempData["oktaOrg"] = MvcApplication.apiUrl;
            return(View(getInfoResponse));
        }
Beispiel #12
0
    public www.mnb.hu.webservices.GetInfoResponseBody GetInfo(www.mnb.hu.webservices.GetInfoRequestBody GetInfo1)
    {
        GetInfoRequest inValue = new GetInfoRequest();

        inValue.GetInfo = GetInfo1;
        GetInfoResponse retVal = ((MNBArfolyamServiceSoap)(this)).GetInfo(inValue);

        return(retVal.GetInfoResponse1);
    }
Beispiel #13
0
        public ActionResult UnprotectedLanding()
        {
            logger.Debug("UnprotectedLanding");
            GetInfoResponse getInfoResponse = new GetInfoResponse();

            TempData["oktaOrg"] = MvcApplication.apiUrl;
            //TempData["token"] = MvcApplication.apiToken;
            return(View(getInfoResponse));
        }
Beispiel #14
0
        public ActionResult Pause(SchedulerInfo taskData)
        {
            _schedulerManager.SetWPIntService(getCurrentService());
            _schedulerManager.SuspendTask(taskData.TaskName, taskData.SchedulerName);
            GetInfoResponse infoResponse = _schedulerManager.GetTaskList();

            infoResponse.TasksInfos = TaskListSort.SortByName(infoResponse.TasksInfos);
            return(PartialView("TableView", infoResponse));
        }
Beispiel #15
0
        public void GetInfoTest()
        {
            // Arrange
            LndClient lndClient = new LndClient();

            // Act
            GetInfoResponse response = lndClient.GetInfo();

            Assert.AreEqual("0.5.0-beta commit=3b2c807288b1b7f40d609533c1e96a510ac5fa6d", response.Version);
        }
Beispiel #16
0
        public async Task <string> CreateTransaction(Transaction trx)
        {
            if (EosConfig.SignProvider == null)
            {
                throw new ArgumentNullException("SignProvider");
            }

            GetInfoResponse getInfoResult = null;
            string          chainId       = EosConfig.ChainId;

            if (string.IsNullOrWhiteSpace(chainId))
            {
                getInfoResult = await Api.GetInfo();

                chainId = getInfoResult.ChainId;
            }

            if (trx.Expiration == DateTime.MinValue ||
                trx.RefBlockNum == 0 ||
                trx.RefBlockPrefix == 0)
            {
                if (getInfoResult == null)
                {
                    getInfoResult = await Api.GetInfo();
                }

                var getBlockResult = await Api.GetBlock(new GetBlockRequest()
                {
                    BlockNumOrId = getInfoResult.LastIrreversibleBlockNum.GetValueOrDefault().ToString()
                });

                trx.Expiration     = getInfoResult.HeadBlockTime.Value.AddSeconds(EosConfig.ExpireSeconds);
                trx.RefBlockNum    = (UInt16)(getInfoResult.LastIrreversibleBlockNum.Value & 0xFFFF);
                trx.RefBlockPrefix = getBlockResult.RefBlockPrefix;
            }

            var packedTrx = await AbiSerializer.SerializePackedTransaction(trx);

            var availableKeys = await EosConfig.SignProvider.GetAvailableKeys();

            var requiredKeys = await GetRequiredKeys(availableKeys.ToList(), trx);

            var signatures = await EosConfig.SignProvider.Sign(chainId, requiredKeys, packedTrx);

            var result = await Api.PushTransaction(new PushTransactionRequest()
            {
                Signatures            = signatures.ToArray(),
                Compression           = 0,
                PackedContextFreeData = "",
                PackedTrx             = SerializationHelper.ByteArrayToHexString(packedTrx)
            });

            return(result.TransactionId);
        }
Beispiel #17
0
        /// <summary>	Handles the bitshares desposits. </summary>
        ///
        /// <remarks>	Paul, 16/12/2014. </remarks>
        ///
        /// <exception cref="UnsupportedTransactionException">	Thrown when an Unsupported Transaction
        ///                                                     error condition occurs. </exception>
        protected virtual Dictionary <string, BitsharesLedgerEntry> HandleBitsharesDesposits()
        {
            Dictionary <string, BitsharesLedgerEntry> results = new Dictionary <string, BitsharesLedgerEntry>();

            // which block do we start from
            uint lastBlockBitshares = GetLastBitsharesBlock();

            // which block do we end on
            GetInfoResponse info = m_bitshares.GetInfo();

            if (lastBlockBitshares == 0)
            {
                // default to current block
                lastBlockBitshares = info.blockchain_head_block_num;
            }

            // get all relevant bitshares deposits
            List <BitsharesWalletTransaction> assetTransactions = m_bitshares.WalletAccountTransactionHistory(m_bitsharesAccount,
                                                                                                              null,
                                                                                                              0,
                                                                                                              lastBlockBitshares,
                                                                                                              info.blockchain_head_block_num);

            IEnumerable <BitsharesWalletTransaction> assetDeposits = assetTransactions.Where(t => t.is_confirmed &&
                                                                                             t.ledger_entries.Any(l => l.to_account == m_bitsharesAccount &&
                                                                                                                  l.from_account != l.to_account &&
                                                                                                                  l.memo != kFundingMemo &&
                                                                                                                  l.from_account != BitsharesWallet.kNetworkAccount));

            foreach (BitsharesWalletTransaction t in assetDeposits)
            {
                // make sure we didn't already send bitcoins for this deposit
                if (!HasDepositBeenCredited(t.trx_id) && !IsTransactionIgnored(t.trx_id))
                {
                    IEnumerable <BitsharesLedgerEntry> deposits = t.ledger_entries.Where(l => l.to_account == m_bitsharesAccount);

                    if (deposits.Count() == 1)
                    {
                        BitsharesLedgerEntry l = deposits.First();
                        results[t.trx_id] = l;
                    }
                    else
                    {
                        // fail with unhandled case
                        throw new UnsupportedTransactionException(t.trx_id);
                    }
                }
            }

            UpdateBitsharesBlock(info.blockchain_head_block_num);

            return(results);
        }
Beispiel #18
0
        public ActionResult Index()
        {
            ViewBag.Services = _wpIntServiceManager.GetServices().Keys.ToList();
            _schedulerManager.SetWPIntService(getCurrentService());
            ViewBag.CurrentService = _wpIntServiceManager.GetServiceName(_schedulerManager.GetWPIntService());
            GetInfoResponse infoResponse = _schedulerManager.GetTaskList();

            if (infoResponse == null)
            {
                return(View("Error"));
            }
            infoResponse.TasksInfos = TaskListSort.SortByName(infoResponse.TasksInfos);
            return(View("Index", infoResponse));
        }
Beispiel #19
0
 public void Init()
 {
     _testScheduler    = new TestScheduler();
     _handler          = new VanillaMessageObserver(Substitute.For <ILogger>());
     _fakeContext      = Substitute.For <IChannelHandlerContext>();
     _responseMessages = Enumerable.Range(0, 10).Select(i =>
     {
         var message = new GetInfoResponse {
             Query = i.ToString()
         };
         return(message.ToProtocolMessage(
                    PeerIdHelper.GetPeerId(i.ToString()),
                    CorrelationId.GenerateCorrelationId()));
     }).ToArray();
 }
Beispiel #20
0
        public ActionResult ChangeWPIntService(string name)
        {
            ViewBag.Services = _wpIntServiceManager.GetServices().Keys.ToList();
            HttpContext.Response.Cookies["service"].Value = name;
            _schedulerManager.SetWPIntService(_wpIntServiceManager.GetService(name));
            GetInfoResponse infoResponse = _schedulerManager.GetTaskList();

            ViewBag.CurrentService = name;
            if (infoResponse == null)
            {
                return(View("Error"));
            }
            infoResponse.TasksInfos = TaskListSort.SortByName(infoResponse.TasksInfos);
            return(Redirect("/"));
        }
        public void TestGetInfoResponse()
        {
            string json = @"{""name"":""vcap"",""build"":""2222"",""support"":""http://support.cloudfoundry.com"",""version"":2,""description"":""Cloud Foundry sponsored by Pivotal"",""authorization_endpoint"":""http://localhost:8080/uaa"",""token_endpoint"":""http://localhost:8080/uaa"",""api_version"":""2.19.0"",""logging_endpoint"":""ws://loggregator.vcap.me:80""}";

            GetInfoResponse obj = Utilities.DeserializeJson <GetInfoResponse>(json);

            Assert.AreEqual("vcap", TestUtil.ToTestableString(obj.Name), true);
            Assert.AreEqual("2222", TestUtil.ToTestableString(obj.Build), true);
            Assert.AreEqual("http://support.cloudfoundry.com", TestUtil.ToTestableString(obj.Support), true);
            Assert.AreEqual("2", TestUtil.ToTestableString(obj.Version), true);
            Assert.AreEqual("Cloud Foundry sponsored by Pivotal", TestUtil.ToTestableString(obj.Description), true);
            Assert.AreEqual("http://localhost:8080/uaa", TestUtil.ToTestableString(obj.AuthorizationEndpoint), true);
            Assert.AreEqual("http://localhost:8080/uaa", TestUtil.ToTestableString(obj.TokenEndpoint), true);
            Assert.AreEqual("2.19.0", TestUtil.ToTestableString(obj.ApiVersion), true);
            Assert.AreEqual("ws://loggregator.vcap.me:80", TestUtil.ToTestableString(obj.LoggingEndpoint), true);
        }
Beispiel #22
0
        public async Task Test(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network)
        {
            if (!_ExplorerClientProvider.IsAvailable(network))
            {
                throw new Exception($"Full node not available");
            }

            var             explorerClient = _ExplorerClientProvider.GetExplorerClient(network);
            var             cts            = new CancellationTokenSource(5000);
            var             client         = GetClient(supportedPaymentMethod, network);
            var             status         = explorerClient.GetStatusAsync();
            GetInfoResponse info           = null;

            try
            {
                info = await client.GetInfoAsync(cts.Token);
            }
            catch (Exception ex)
            {
                throw new Exception($"Error while connecting to the lightning charge {client.Uri} ({ex.Message})");
            }
            var address = info.Address.Select(a => a.Address).FirstOrDefault();
            var port    = info.Port;

            address = address ?? client.Uri.DnsSafeHost;

            if (info.Network != network.CLightningNetworkName)
            {
                throw new Exception($"Lightning node network {info.Network}, but expected is {network.CLightningNetworkName}");
            }

            var blocksGap = Math.Abs(info.BlockHeight - (await status).ChainHeight);

            if (blocksGap > 10)
            {
                throw new Exception($"The lightning is not synched ({blocksGap} blocks)");
            }

            try
            {
                await TestConnection(address, port, cts.Token);
            }
            catch (Exception ex)
            {
                throw new Exception($"Error while connecting to the lightning node via {address}:{port} ({ex.Message})");
            }
        }
        public void GetInfoResponse_Can_Get_Output()
        {
            //Arrange
            var getInfoResponse = new GetInfoResponse {
                Query = "Test"
            };
            var commandContext = TestCommandHelpers.GenerateCliResponseCommandContext(_testScheduler);
            var getInfoCommand = new GetInfoCommand(commandContext, Substitute.For <ILogger>());

            //Act
            TestCommandHelpers.GenerateResponse(commandContext, getInfoResponse);

            _testScheduler.Start();

            //Assert
            commandContext.UserOutput.Received(1).WriteLine(getInfoResponse.ToJsonString());
        }
Beispiel #24
0
        public async Task <GetInfoResponse> GetInfo(string id)
        {
            Account acc = await userManager.FindByIdAsync(id);

            if (acc != null)
            {
                var resp = new GetInfoResponse()
                {
                    Sent_today      = acc.Sent_today,
                    Sent_total      = acc.Sent_total,
                    Left_today      = acc.Left_today,
                    Delivered_today = acc.Delivered_today,
                    Delivered_total = acc.Delivered_total
                };
                return(resp);
            }
            return(null);
        }
        public List <SymbolPairsInfo> GetListSymbols()
        {
            List <SymbolPairsInfo> result = new List <SymbolPairsInfo>();

            GetInfoResponse info = yobitClient.Info();

            foreach (var pair in info.pairs)
            {
                string   pairName = pair.Key;
                PairInfo pairInfo = pair.Value;

                result.Add(new SymbolPairsInfo {
                    Name = pairName, LimitNumberDecimalPlaces = pairInfo.decimal_places
                });
            }

            return(result);
        }
Beispiel #26
0
        public override Task <GetInfoResponse> GetInfo(GetInfoRequest request, ServerCallContext context)
        {
            var resp = new GetInfoResponse();

            var data = ComponentApi.GetAuthorizerInfo(_componentAccessToken, _componentAppId, request.AppId);

            if (data.ErrCode == 0)
            {
                _redis.StringSet(CacheKey.UserRefreshTokenPrefix + data.AuthorizationInfo.AuthorizerAppId, data.AuthorizationInfo.AuthorizerRefreshToken);
                if (data.AuthorizerInfo.MiniProgramInfo != null)
                {
                    _redis.StringSet(CacheKey.UserIsWxAppPrefix + data.AuthorizationInfo.AuthorizerAppId, 1);
                    resp.Type = "WxApp";
                }
                else
                {
                    _redis.KeyDelete(CacheKey.UserIsWxAppPrefix + data.AuthorizationInfo.AuthorizerAppId);
                    resp.Type = "WxWeb";
                }
                resp.HeadImg         = data.AuthorizerInfo.HeadImg;
                resp.NickName        = data.AuthorizerInfo.NickName;
                resp.PrincipalName   = data.AuthorizerInfo.PrincipalName;
                resp.UserName        = data.AuthorizerInfo.UserName;
                resp.Alias           = data.AuthorizerInfo.Alias;
                resp.AppId           = data.AuthorizationInfo.AuthorizerAppId;
                resp.QrcodeUrl       = data.AuthorizerInfo.QrcodeUrl;
                resp.ServiceTypeInfo = data.AuthorizerInfo.ServiceTypeInfo.Id;
                resp.VerifyTypeInfo  = data.AuthorizerInfo.VerifyTypeInfo.Id;
                foreach (var item in data.AuthorizationInfo.FuncInfos)
                {
                    resp.Permissions.Add(item.Category.Id);
                }
            }
            else
            {
                resp.Error = new Error
                {
                    ErrMsg  = data.ErrMsg,
                    ErrCode = data.ErrCode
                };
            }
            return(Task.FromResult(resp));
        }
Beispiel #27
0
        /// <summary>
        /// Gets a value indicating whether the tor software service is dormant.
        /// </summary>
        /// <returns><c>true</c> if the tor software service is dormant; otherwise, <c>false</c>.</returns>
        private bool PropertyGetIsDormant()
        {
            GetInfoCommand  command  = new GetInfoCommand("dormant");
            GetInfoResponse response = command.Dispatch(client);

            if (!response.Success)
            {
                return(false);
            }

            int value;

            if (!int.TryParse(response.Values[0], out value))
            {
                return(false);
            }

            return(value != 0);
        }
Beispiel #28
0
        /// <summary>
        /// Gets an approximation of the total bytes uploaded by the tor software.
        /// </summary>
        /// <returns>A <see cref="Bytes"/> object instance containing the estimated number of bytes.</returns>
        private Bytes PropertyGetTotalBytesUploaded()
        {
            GetInfoCommand  command  = new GetInfoCommand("traffic/written");
            GetInfoResponse response = command.Dispatch(client);

            if (!response.Success)
            {
                return(Bytes.Empty);
            }

            double value;

            if (!double.TryParse(response.Values[0], out value))
            {
                return(Bytes.Empty);
            }

            return(new Bytes(value).Normalize());
        }
Beispiel #29
0
        public ActionResult SortTaskList(string typeSort)
        {
            _schedulerManager.SetWPIntService(getCurrentService());
            GetInfoResponse infoResponse = _schedulerManager.GetTaskList();

            switch (typeSort)
            {
            case "byName":
                infoResponse.TasksInfos = TaskListSort.SortByName(infoResponse.TasksInfos);
                return(PartialView("TableView", infoResponse));

            case "byTime":
                infoResponse.TasksInfos = TaskListSort.SortByTime(infoResponse.TasksInfos);
                return(PartialView("TableView", infoResponse));

            default:
                return(PartialView("TableView", infoResponse));
            }
        }
        public FrameInfo <SbModule>?GetInfo(FrameInfoFlags fields)
        {
            var request = new GetInfoRequest()
            {
                Frame  = grpcSbFrame,
                Fields = (uint)fields
            };
            GetInfoResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.GetInfo(request);
            }))
            {
                if (response.Info != null)
                {
                    return(FrameInfoUtils.CreateFrameInfo(response.Info, moduleFactory, connection));
                }
            }
            return(null);
        }
 /// <summary>
 /// Get a summary of a service identity
 /// </summary>
 /// <returns> GetInfoResponse object</returns>
 /// <param name="request"> GetInfoRequest object</param>
 /// <param name='jsonRpcCallId'>
 /// The json rpc call identifier. This is a string generated by the client, which can be used to correlate the response to the request. Max length is 256 characters. A JSON-RPC id must be generated on a per call invocation basis. The Rogerthat platform uses the id of the call to store the call result for a certain amount of time so that if something fails during the communication, the same call (having the same JSON-RPC id) can be resent to the Rogerthat service, allowing to fetch the result, without actually executing the call again. This avoids annoying problems such as duplicate delivery of messages.
 /// 
 /// You should use a different JSON-RPC id for every call you make.
 /// 
 /// In case of an intermittent failure such as a network connectivity problem, you can retry the same call using the same JSON-RPC id, without running the risk of duplicate execution of your call (e.g. duplicate message delivery).
 /// </param>
 public GetInfoResponse GetInfo(GetInfoRequest request, string jsonRpcCallId)
 {
     GetInfoResponse result = new GetInfoResponse();
     WireRequest(0, jsonRpcCallId, "system.get_info", (writer) =>
         {
             request.Write(writer, false);
         }, (reader) =>
         {
             result.Read(reader);
         }
     );
     return result;
 }