public void HealthTest() { NodeRpcClient nodeRpcClient = new NodeRpcClient(endpoint); ResultHealth result = nodeRpcClient.Health(); Assert.NotNull(result); }
public override void OnProduceResult(IResult result, IResultControl control) { base.OnProduceResult(result, control); if (result.ClassID == (int)ENResult.Health) { ResultHealth r = result as ResultHealth; BuffInfo info = GameTable.BuffTableAsset.Lookup(BuffID); foreach (var item in info.BuffResultList) { if (item.ID == (int)ClassID) { switch ((ENType)item.ParamList[0]) { case ENType.enProduceRestore: { if ((int)item.ParamList[4] == (int)r.HealthResultType) { //改变某类型的恢复 float percent = item.ParamList[1]; if (percent != 0) { r.HealthValue *= percent; } } } break; } } } } }
public static ResultHealth Check(ConfigHealth config) { var r = new ResultHealth(); //connectivity (internet) foreach (var url in config.CheckUrls) { var request = WebRequest.Create(url); var watch = System.Diagnostics.Stopwatch.StartNew(); //TODO - this only gets running user, there may be other users on the box if (!r.LoggedOnUsers.Contains(Environment.UserName)) { r.LoggedOnUsers.Add(Environment.UserName); } try { using (var response = (HttpWebResponse)request.GetResponse()) { //log.Debug(response.StatusCode); using (var stream = response.GetResponseStream()) { using (var reader = new StreamReader(stream)) { //html = reader.ReadToEnd(); //if we wanted to read html } } } } catch (WebException e) { r.Errors.Add($"Connection error - web exception: {e.Message} to {request.RequestUri}"); } catch (Exception e) { r.Errors.Add($"Connection error - general exception: {e.Message} to {request.RequestUri}"); } watch.Stop(); r.ExecutionTime = watch.ElapsedMilliseconds; r.Internet = (r.Errors.Count == 0); r.Stats = MachineHealth.Run(); //log.Debug(r.ExecutionTime); //log.Debug(html); } // permissions // can run x return(r); }