//copy scarti_load file into _sharedOutputFolder private void CopyInSharedFolder(string pathFileName, string fileName) { //check if the machine contains the shared folder is reachable //var hostPath = _sharedOutputFolder.Split("\\"); var machinePingable = PingTest.PingHost(_hostPath, _logger, _timeout); var pathReportFile = new StringBuilder(_configuration["PathReportFile"]).Append(@"\").Append(@"\"); pathReportFile.Append(Path.GetFileName(fileName)).Append("-SCARTI_LOAD_").Append(Guid.NewGuid()).Append(".TXT"); if (machinePingable) { if (Directory.Exists(@"\\" + _sharedOutputFolder)) { _logger.LogInformation("copy " + fileName + $" file into {_sharedOutputFolder}"); System.IO.File.Copy(pathFileName, Path.Combine(@"\\" + _sharedOutputFolder, _lostFolder) + @"\\" + fileName); } else { _logger.LogError("Remote folder: " + @"\\" + _sharedOutputFolder + " not found"); } } else { _logger.LogError("copy " + fileName + $" file into {_sharedOutputFolder} failed! Remote computer: " + _hostPath + " not found"); } }
public Task PingAsync() { var pingtime = PingTest.ComplexPing(); ReplyAsync("pong! " + pingtime + "ms"); return(null); }
private void CopyLogErrorFile2SharedFolder(string nomefileErr) { //copy log_error file into _sharedOutputFolder if (String.IsNullOrEmpty(nomefileErr)) { return; } var machinePingable = PingTest.PingHost(_hostPath, _logger, _timeout); if (machinePingable) { if (Directory.Exists(@"\\" + _sharedOutputFolder)) { if (Directory.Exists(Path.Combine(@"\\" + _sharedOutputFolder, _lostFolder))) { _logger.LogInformation($"copy {nomefileErr} file into {_sharedOutputFolder}"); System.IO.File.Copy(nomefileErr, @"\\" + _sharedOutputFolder + @"\" + nomefileErr); } } else { _logger.LogError("Remote folder: " + @"\\" + _sharedOutputFolder + " not found"); } } else { _logger.LogError($"copy {nomefileErr} file into {_sharedOutputFolder} failed! Remote computer: {_hostPath} not found"); } }
private void CopyOutcomesFile2SharedFolder(string outcomesFilename, string outputFileName) { //copy scarti_update file into _sharedOutputFolder var machinePingable = PingTest.PingHost(_hostPath, _logger, _timeout); if (machinePingable) { if (Directory.Exists(@"\\" + _sharedOutputFolder)) { if (Directory.Exists(Path.Combine(@"\\" + _sharedOutputFolder, _lostFolder))) { _logger.LogInformation($"copy {outputFileName} file into {_sharedOutputFolder}"); System.IO.File.Copy(outcomesFilename, Path.Combine(@"\\" + _sharedOutputFolder, _lostFolder) + @"\" + outputFileName); } } else { _logger.LogError("Remote folder: " + @"\\" + _sharedOutputFolder + " not found"); } } else { _logger.LogError($"copy {outputFileName} file into {_sharedOutputFolder} failed! Remote computer: {_hostPath} not found"); } }
public MainWindowViewModel() { StartTest = new Command(RunTest); _test = PingTest.getInstace(); PrepareUI(); RefreshUI(); ProgressMax = _test.Duration * _test.ProgressTicksInSec; ButtonContent = $"Wysyłaj zapytania PING przez {_test.Duration} sek."; }
public bool Ping(string host, int port) { var ping = new PingTest() { Address = $"{host}:{port}", Date = DateTime.Now, Success = TcpUtil.PingHost(host, port) }; if (!Pings.ContainsKey(ping.Date)) { Pings.Add(ping.Date, ping); } return(ping.Success); }
//private async Task<bool> Login() //{ // Console.Write("Username: "******"Password: "******"network")); uris = await proxyListLoader.LoadAsync(_ctx); } catch (Exception e) { throw new Exception("Could not get the server network", e); } var sb = new StringBuilder(); sb.AppendLine("Available server:"); foreach (var i in uris) { sb.AppendLine($"- {i}"); } Logger.Info(sb.ToString()); try { var fastest = await PingTest.GetBestPing(uris); Logger.Info($"Fastest server: {fastest.Item1} -> {(int)fastest.Item2.TotalMilliseconds} ms"); return(fastest); } catch (Exception e) { throw new Exception("Error while doing the ping speed test", e); } } catch (Exception e) { throw new Exception("Could not determine the fastest proxy", e); } }
/// <summary> /// Return list of Sport folders /// currently only NHL and MLB are supported /// </summary> /// <returns></returns> private Task <ChannelItemResult> GetSportFolders() { _logger.Debug("[GetSportFolders] Get Sport Folders"); var pingTestDomains = new[] { "mf.svc.nhl.com", "mlb-ws-mf.media.mlb.com", "playback.svcs.mlb.com" }; var info = pingTestDomains.Where(domain => !PingTest.IsMatch(domain, _logger)) .Select(domain => new ChannelItemInfo { Id = $"{domain}", Name = $"{domain} IP ERROR", Type = ChannelItemType.Folder }) .ToList(); info.Add(new ChannelItemInfo { Id = "nhl", Name = "NHL", Type = ChannelItemType.Folder }); info.Add(new ChannelItemInfo { Id = "MLB", Name = "MLB", Type = ChannelItemType.Folder }); return(Task.FromResult(new ChannelItemResult { Items = info, TotalRecordCount = info.Count })); }