Skip to content

Commit

Permalink
assign empty process name as "System".
Browse files Browse the repository at this point in the history
fix for issue #54.
  • Loading branch information
Ashfaaq18 committed Jul 5, 2022
1 parent a9599ce commit 0ff812f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 3 additions & 1 deletion OpenNetMeter/Models/ApplicationDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public static string GetFilePath()
{
string? appName = Assembly.GetEntryAssembly()?.GetName().Name;
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
return Path.Combine(path, appName ?? "OpenNetMeter");
path = Path.Combine(path, appName ?? "OpenNetMeter");
Directory.CreateDirectory(path);
return path;
}

//
Expand Down
22 changes: 14 additions & 8 deletions OpenNetMeter/Models/NetworkProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,30 +487,36 @@ private void Recv(string name, int size)
{
CurrentSessionDownloadData += (long)size;

if (IsBufferTime)
Debug.WriteLine("Recv buffer");
//if (IsBufferTime)
// Debug.WriteLine("Recv buffer");

if (name == "")
name = "System";

MyProcesses!.TryAdd(name, new MyProcess(name, 0, 0, null));
MyProcesses[name]!.CurrentDataRecv += (long)size;
MyProcesses[name]!.CurrentDataSend += 0;

if (size == 0)
Debug.WriteLine($"but whyyy {name} | recv");
//if (size == 0)
// Debug.WriteLine($"but whyyy {name} | recv");
}

private void Send(string name, int size)
{
CurrentSessionUploadData += (long)size;

if (IsBufferTime)
Debug.WriteLine("send buffer");
//if (IsBufferTime)
// Debug.WriteLine("send buffer");

if (name == "")
name = "System";

MyProcesses!.TryAdd(name, new MyProcess(name, 0, 0, null));
MyProcesses[name]!.CurrentDataRecv += 0;
MyProcesses[name]!.CurrentDataSend += (long)size;

if (size == 0)
Debug.WriteLine($"but whyyy {name} | send");
//if (size == 0)
// Debug.WriteLine($"but whyyy {name} | send");
}

private bool IsIPv4IPv6Private(IPAddress ip)
Expand Down
2 changes: 1 addition & 1 deletion OpenNetMeter/OpenNetMeter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ApplicationIcon>Resources\AppIcon.ico</ApplicationIcon>
<Version>0.11.0</Version>
<AssemblyName>OpenNetMeter</AssemblyName>
<StartupObject></StartupObject>
<StartupObject>OpenNetMeter.App</StartupObject>
<Win32Resource />
<ApplicationManifest>app.manifest</ApplicationManifest>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
2 changes: 1 addition & 1 deletion OpenNetMeter/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions OpenNetMeter/ViewModels/DataUsageHistoryVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ private void Filter(object? obj)
{
if(!Convert.IsDBNull(dataStats[i][0]) && !Convert.IsDBNull(dataStats[i][1]) && !Convert.IsDBNull(dataStats[i][2]))
{
if ((string)dataStats[i][0] != "")
MyProcesses.Add(new MyProcess((string)dataStats[i][0], (long)dataStats[i][1], (long)dataStats[i][2], null));
else
MyProcesses.Add(new MyProcess("System", (long)dataStats[i][1], (long)dataStats[i][2], null));
MyProcesses.Add(new MyProcess((string)dataStats[i][0], (long)dataStats[i][1], (long)dataStats[i][2], null));

TotalDownloadData += (long)dataStats[i][1];
TotalUploadData += (long)dataStats[i][2];
Expand Down

0 comments on commit 0ff812f

Please sign in to comment.