Initial commit - Pingerino network monitoring application
هذا الالتزام موجود في:
21
Services/Interfaces/IConfigurationService.cs
Normal file
21
Services/Interfaces/IConfigurationService.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Pingerino.Services.Interfaces
|
||||
{
|
||||
public interface IConfigurationService
|
||||
{
|
||||
T GetValue<T>(string key, T defaultValue = default);
|
||||
void SetValue<T>(string key, T value);
|
||||
void Save();
|
||||
void Load();
|
||||
|
||||
// Specific application settings
|
||||
string LastUsedIpAddress { get; set; }
|
||||
int PingInterval { get; set; }
|
||||
bool AutoPingEnabled { get; set; }
|
||||
Point FormPosition { get; set; }
|
||||
string IpAddressValue { get; set; }
|
||||
string TextBoxIntervalValue { get; set; }
|
||||
}
|
||||
}
|
20
Services/Interfaces/ILoggingService.cs
Normal file
20
Services/Interfaces/ILoggingService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Pingerino.Services.Interfaces
|
||||
{
|
||||
public interface ILoggingService
|
||||
{
|
||||
void LogInformation(string message);
|
||||
void LogWarning(string message);
|
||||
void LogError(string message, Exception exception = null);
|
||||
void LogDebug(string message);
|
||||
}
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
Debug,
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
}
|
31
Services/Interfaces/INetworkService.cs
Normal file
31
Services/Interfaces/INetworkService.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pingerino.Services.Interfaces
|
||||
{
|
||||
public interface INetworkService : IDisposable
|
||||
{
|
||||
System.Threading.Tasks.Task<string> GetPublicIpAddressAsync(CancellationToken cancellationToken = default);
|
||||
System.Threading.Tasks.Task<List<NetworkAdapterInfo>> GetNetworkAdaptersAsync();
|
||||
System.Threading.Tasks.Task<bool> ResetNetworkAdapterAsync(string adapterName, IProgress<int> progress = null, CancellationToken cancellationToken = default);
|
||||
System.Threading.Tasks.Task<NetworkAdapterInfo> GetActiveEthernetAdapterAsync();
|
||||
System.Threading.Tasks.Task<bool> IsNetworkAvailableAsync();
|
||||
}
|
||||
|
||||
public class NetworkAdapterInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string PhysicalAddress { get; set; }
|
||||
public bool IsDhcpEnabled { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public string SubnetMask { get; set; }
|
||||
public string DefaultGateway { get; set; }
|
||||
public string DhcpServer { get; set; }
|
||||
public List<string> DnsServers { get; set; } = new List<string>();
|
||||
public bool IsActive { get; set; }
|
||||
public string InterfaceType { get; set; }
|
||||
}
|
||||
}
|
67
Services/Interfaces/IPingService.cs
Normal file
67
Services/Interfaces/IPingService.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pingerino.Services.Interfaces
|
||||
{
|
||||
public interface IPingService : IDisposable
|
||||
{
|
||||
event EventHandler<PingResultEventArgs> PingCompleted;
|
||||
event EventHandler<NetworkStatisticsEventArgs> StatisticsUpdated;
|
||||
|
||||
System.Threading.Tasks.Task StartPingingAsync(string ipAddress, int intervalMs, CancellationToken cancellationToken = default);
|
||||
System.Threading.Tasks.Task StopPingingAsync();
|
||||
System.Threading.Tasks.Task<PingResult> PingOnceAsync(string ipAddress, CancellationToken cancellationToken = default);
|
||||
void ClearStatistics();
|
||||
NetworkStatistics GetCurrentStatistics();
|
||||
bool IsRunning { get; }
|
||||
}
|
||||
|
||||
public class PingResultEventArgs : EventArgs
|
||||
{
|
||||
public PingResult Result { get; }
|
||||
public DateTime Timestamp { get; }
|
||||
|
||||
public PingResultEventArgs(PingResult result, DateTime timestamp)
|
||||
{
|
||||
Result = result;
|
||||
Timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
public class NetworkStatisticsEventArgs : EventArgs
|
||||
{
|
||||
public NetworkStatistics Statistics { get; }
|
||||
|
||||
public NetworkStatisticsEventArgs(NetworkStatistics statistics)
|
||||
{
|
||||
Statistics = statistics;
|
||||
}
|
||||
}
|
||||
|
||||
public class PingResult
|
||||
{
|
||||
public string IpAddress { get; set; }
|
||||
public bool IsSuccess { get; set; }
|
||||
public long RoundTripTime { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
public class NetworkStatistics
|
||||
{
|
||||
public double Jitter { get; set; }
|
||||
public double PacketLoss { get; set; }
|
||||
public long MaxPing { get; set; }
|
||||
public long MinPing { get; set; }
|
||||
public double AveragePing { get; set; }
|
||||
public double MaxJitter { get; set; }
|
||||
public double MinJitter { get; set; }
|
||||
public double AverageJitter { get; set; }
|
||||
public double MaxPacketLoss { get; set; }
|
||||
public double MinPacketLoss { get; set; }
|
||||
public double AveragePacketLoss { get; set; }
|
||||
public int TotalPings { get; set; }
|
||||
public int SuccessfulPings { get; set; }
|
||||
}
|
||||
}
|
16
Services/Interfaces/ISystemService.cs
Normal file
16
Services/Interfaces/ISystemService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pingerino.Services.Interfaces
|
||||
{
|
||||
public interface ISystemService : IDisposable
|
||||
{
|
||||
System.Threading.Tasks.Task<bool> CleanTemporaryFilesAsync(IProgress<int> progress = null, CancellationToken cancellationToken = default);
|
||||
System.Threading.Tasks.Task<bool> CreateStartupTaskAsync(string taskName, string executablePath);
|
||||
System.Threading.Tasks.Task<bool> RemoveStartupTaskAsync(string taskName);
|
||||
System.Threading.Tasks.Task<bool> IsStartupTaskExistsAsync(string taskName);
|
||||
void OpenNetworkAdaptersControl();
|
||||
System.Threading.Tasks.Task<bool> RunExternalScriptAsync(string scriptPath);
|
||||
}
|
||||
}
|
المرجع في مشكلة جديدة
حظر مستخدم