public EmailSenderService( ILogger <IMailService> logger, IIpAddressService ipAddressService, IConfiguration configuration) { _logger = logger; _ipAddressService = ipAddressService; _configuration = configuration; }
public NmapDeviceScanner(IMessageQueue messageQueue, IIpAddressService ipAddressService) { _messageQueue = messageQueue; _ipAddressService = ipAddressService; _nmapLocation = ConfigurationManager.AppSettings["nmap.location"]; if (string.IsNullOrEmpty(_nmapLocation) || !File.Exists(_nmapLocation)) { messageQueue.Publish(new NotifyUserMessage("Add nmap configuration to config file.")); } }
public ServerChatService(IIpAddressService ipAddressService) { _ipAddressService = ipAddressService; // Hash table with the max users Users = new Hashtable(ServerChatServiceConstants.MAX_USERS); // Has table with the max connections Connections = new Hashtable(ServerChatServiceConstants.MAX_USERS); // Get local IP var getIpAddress = _ipAddressService.GetLocalIp(); // If GetLocalIp was not sucessfully, set the IP manually IpAddressNumber = getIpAddress.Success ? getIpAddress.IpAddress : ServerChatServiceConstants.MANUAL_IP; IpAddress = IPAddress.Parse(IpAddressNumber); }
public ProvisioningService(ISqlDbContext sqlDbContext, IProvisioningClient provisioningClient, IFulfillmentClient fulfillmentclient, IIpAddressService ipAddressService, ISubscriptionParameterService subscriptionParameterService, IArmTemplateParameterService armTemplateParameterService, IWebhookParameterService webhookParameterService, IStorageUtility storageUtility, ILogger <ProvisioningService> logger) { _context = sqlDbContext ?? throw new ArgumentNullException(nameof(sqlDbContext)); _provisioningClient = provisioningClient ?? throw new ArgumentNullException(nameof(provisioningClient)); _fulfillmentClient = fulfillmentclient ?? throw new ArgumentNullException(nameof(fulfillmentclient)); _ipAddressService = ipAddressService ?? throw new ArgumentNullException(nameof(ipAddressService)); _subscriptionParameterService = subscriptionParameterService ?? throw new ArgumentNullException(nameof(subscriptionParameterService)); _armTemplateParameterService = armTemplateParameterService ?? throw new ArgumentNullException(nameof(armTemplateParameterService)); _webhookParameterService = webhookParameterService ?? throw new ArgumentNullException(nameof(webhookParameterService)); _storageUtility = storageUtility ?? throw new ArgumentNullException(nameof(storageUtility)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); //TODO: add the app settings. _maxRetry = 3; }
public MainWindowViewmodel(IPingTimer pingTimer, IPingService pingService, IPingCollectionVectorFactory pingCollectionVectorFactory, IPingVectorFactory pingVectorFactory, IVectorComparer vectorComparer, IIpAddressService ipAddressService, IDispatcherAccessor dispatcherAccessor, PingStatsUtil pingStatsUtil, IPingResponseUtil pingResponseUtil) { _pingTimer = pingTimer; _pingService = pingService; _pingCollectionVectorFactory = pingCollectionVectorFactory; _pingVectorFactory = pingVectorFactory; _vectorComparer = vectorComparer; _pingStatsUtil = pingStatsUtil; _pingResponseUtil = pingResponseUtil; IObservable <long> pingTimerObservable = _pingTimer.Start(() => false); IDisposable pingResponseSubscription = null; _targetDatamodels = new ConcurrentDictionary <IPAddress, PingState>(); _stats = new ConcurrentDictionary <IPAddress, PingStats>(); System.Windows.Threading.Dispatcher d = dispatcherAccessor.GetDispatcher(); Subject <int> resortSubject = new Subject <int>(); ResortObservable = resortSubject; ipAddressService.IpAddressObservable.Subscribe(ipAddresses => { pingResponseSubscription?.Dispose(); IObservable <IEnumerable <Task <IPingResponse> > > pingResponseObservable = pingTimerObservable.Select(l => _pingService.Ping(ipAddresses)); pingResponseSubscription = pingResponseObservable.Subscribe(async pingResponseTasks => { IPingResponse[] responses = await Task.WhenAll(pingResponseTasks); IVector[] vectors = responses.Select(pingResponse => { IPingStats stats = GetUpdatedStats(pingResponse); IVector pingVector = _pingVectorFactory.GetVector(pingResponse, stats); if (_targetDatamodels.TryGetValue(pingResponse.TargetIpAddress, out PingState pingState)) { TargetDatamodel targetDatamodelX = pingState.TargetDatamodel; targetDatamodelX.RoundTripTime = pingResponse.RoundTripTime; targetDatamodelX.StatusSuccess = GetStatusSuccess(pingResponse.Status); IVector boring = _pingVectorFactory.GetVector(new PingResponse(IPAddress.Loopback, TimeSpan.Zero, IPStatus.DestinationHostUnreachable, IPAddress.Loopback), new PingStats(DateTime.Now.AddDays(-1), DateTime.Now) { Average25 = 0, Average25Count = 25, StatusHistory = new bool[PingStatsUtil.MaxHistoryCount] }); double change = _vectorComparer.Compare(boring, pingVector); targetDatamodelX.Change = change; if (targetDatamodelX.Change > 0.008) { targetDatamodelX.ShowUntil = DateTime.Now.Add(TimeToShowOddTargets); } if (targetDatamodelX.ShowUntil <= DateTime.Now) { targetDatamodelX.ShowUntil = null; } pingState.Previous = pingVector; } else { TargetDatamodel targetDatamodel = new TargetDatamodel(address: pingResponse.TargetIpAddress, statusSuccess: GetStatusSuccess(pingResponse.Status), roundTripTime: pingResponse.RoundTripTime); _targetDatamodels.Add(pingResponse.TargetIpAddress, new PingState { TargetDatamodel = targetDatamodel, Previous = pingVector }); d.Invoke(() => TargetDatamodels.Add(targetDatamodel)); } return(pingVector); }).ToArray(); resortSubject.OnNext(0); }); }); TargetDatamodels = new ObservableCollection <TargetDatamodel>(); }
public void Setup() { _accessorMock = new Mock <IHttpContextAccessor>(MockBehavior.Default); _service = new IpAddressService(_accessorMock.Object); }