public PingView() { InitializeComponent(); PingViewModel pvm = new PingViewModel(); DataContext = pvm; }
public Task SendPingMessageAsync(PingViewModel pingViewModel) { var pingCommand = _mapper.Map <PingCommand>(pingViewModel); return(Bus.SendCommand(pingCommand)); //return _sendMessagesService.SendMessageAsync(pingCommand); }
public PingView(int tabId, Action <Tuple <int, string> > changeTabTitle) { InitializeComponent(); viewModel = new PingViewModel(tabId, changeTabTitle); DataContext = viewModel; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
public PingView(int tabId) { InitializeComponent(); viewModel = new PingViewModel(tabId); DataContext = viewModel; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
public PingView(int tabId, string host = null) { InitializeComponent(); _viewModel = new PingViewModel(DialogCoordinator.Instance, tabId, host); DataContext = _viewModel; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
public async Task <IActionResult> Post([FromBody] PingViewModel pingViewModel) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(Response(pingViewModel)); } await _pingAppService.SendPingMessageAsync(pingViewModel); return(Response(pingViewModel)); }
public object Execute(PingArgs args) { if (string.IsNullOrEmpty(args.Host)) { return(View("Default")); } var viewModel = new PingViewModel { Host = args.Host, Thread = _thread }; return(View("View", viewModel)); }
public void TestPingVehicle() { // Arrange var pingViewModel = new PingViewModel { VehicleId = "YS2R4X20005399401" }; // Act var result = _pingController.Post(pingViewModel).Result; var okResult = result as OkObjectResult; // Assert Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); }
//In Development ********************************************* private void PingButton_Click(object sender, RoutedEventArgs e) { var model = DataContext as Computer; var port = model.Ports.Single(x => x.IsConnected == true); if (port != null) { var pp = new PingViewModel(); } if (HandlerOfIPAddress.OneSubnet(model.IPv4, model.RelativeSwitch.Vlans.Single(x => x.Name == "Simple").IPv4)) { if (model.RelativeSwitch.SwitchConnectionTable.ContainsKey(model.PingIP)) { MessageBox.Show("Pinging " + model.RelativeSwitch.SwitchConnectionTable[model.PingIP]); } } }
public static void Run([TimerTrigger("*/30 * * * * *")] TimerInfo myTimer, ILogger log) { log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); var vehicleIdsList = GetVehicleIds(); var randomCount = _random.Next(vehicleIdsList.Count); var apiUrl = new Uri("https://localhost:44301"); var client = new PingReceiverService(apiUrl); for (int i = 0; i < randomCount; i++) { var randomIndex = _random.Next(vehicleIdsList.Count); var vehicleId = vehicleIdsList[randomIndex]; var pingViewModel = new PingViewModel { VehicleId = vehicleId }; client.Post("1", pingViewModel); } }
public async Task <IActionResult> StartPing(PingViewModel model) { if (!ModelState.IsValid) { return(View("Ping", model)); } List <PingDto> requestDtos; var resultModel = new PingResultViewModel(); if (model.Mode == "DB") { // unsupported by mongodb at 13.11.2019 //requestDtos = await _devices.Query() // .SelectMany(a => a.Hostnames.Select(b => new PingDto(a.Name, b))) // .ToListAsync(); try { if (!_dbStatus.Connected) { throw new TimeoutException(); } var devices = await _devices.Query().Select(a => new { a.Name, a.Hostnames }).ToListAsync(); requestDtos = new List <PingDto>(); foreach (var device in devices) { foreach (var hostname in device.Hostnames) { requestDtos.Add(new PingDto(device.Name, hostname)); } } } catch (Exception e) { if (e is TimeoutException || e is EndOfStreamException) { ModelState.AddModelError("", _lcz["DbTimeout"]); return(View("Ping", model)); } else { _logger.LogError(e, "StartPing Got Unhandeled Exception."); var err = string.Format(_lcz["DbErrorFmt"], e.Message); ModelState.AddModelError("", err); } return(View("Ping", model)); } } else if (string.IsNullOrEmpty(model.Hostnames)) { ModelState.AddModelError("", _lcz["ErrorEmptyHosts"]); return(View("Ping", model)); } else { requestDtos = model.Hostnames .Split(new string[] { "\n", "\r\n", ",", " " }, StringSplitOptions.RemoveEmptyEntries) .Distinct() .Select(a => new PingDto(a)) .ToList(); if (requestDtos.Count > MaxPingHosts) { ModelState.AddModelError("", string.Format(_lcz["ErrorTooManyHosts"], MaxPingHosts)); return(View("Ping", model)); } } resultModel.Id = _pingQueue.Add(requestDtos); resultModel.Total = requestDtos.Count; return(View("PingResult", resultModel)); }
/// <summary> /// Ping /// </summary> /// <param name='version'> /// </param> /// <param name='pingViewModel'> /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="HttpOperationException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse> PostWithHttpMessagesAsync(string version, PingViewModel pingViewModel = default(PingViewModel), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (version == null) { throw new ValidationException(ValidationRules.CannotBeNull, "version"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("pingViewModel", pingViewModel); tracingParameters.Add("version", version); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "Post", tracingParameters); } // Construct URL var _baseUrl = BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/v{version}/Ping").ToString(); _url = _url.Replace("{version}", System.Uri.EscapeDataString(version)); // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (pingViewModel != null) { _requestContent = SafeJsonConvert.SerializeObject(pingViewModel, SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json-patch+json; charset=utf-8"); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 400) { var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); if (_httpResponse.Content != null) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); } else { _responseContent = string.Empty; } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Ping /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='version'> /// </param> /// <param name='pingViewModel'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task PostAsync(this IPingReceiverService operations, string version, PingViewModel pingViewModel = default(PingViewModel), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.PostWithHttpMessagesAsync(version, pingViewModel, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Ping /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='version'> /// </param> /// <param name='pingViewModel'> /// </param> public static void Post(this IPingReceiverService operations, string version, PingViewModel pingViewModel = default(PingViewModel)) { operations.PostAsync(version, pingViewModel).GetAwaiter().GetResult(); }