Skip to content

Commit 09b1eb0

Browse files
committed
* Added error logs
* Fixed possible crashes when retrieving properties * Code refactoring * Fixed an issue with sorting the process details
1 parent d749101 commit 09b1eb0

26 files changed

+174
-96
lines changed

MemPlus/Business/GUI/GuiManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal static void ChangeLanguage(LogController logController)
7676
catch (Exception ex)
7777
{
7878
langUri = new Uri("..\\Resources\\Languages\\en.xaml", UriKind.Relative);
79-
logController.AddLog(new ApplicationLog(ex.Message));
79+
logController.AddLog(new ErrorLog(ex.Message));
8080
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
8181
}
8282

MemPlus/Business/PROCESS/ProcessDetail.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ internal class ProcessDetail
2222
/// The current memory usage of the Process in MB
2323
/// </summary>
2424
public string MemoryUsage { get; set; }
25+
/// <summary>
26+
/// The current memory usage of the Process
27+
/// </summary>
28+
// ReSharper disable once UnusedAutoPropertyAccessor.Global
29+
public long MemoryUsageLong { get; set; }
2530
}
2631
}

MemPlus/Business/RAM/RamController.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
44
using System.Timers;
5-
using System.Windows;
65
using MemPlus.Business.LOG;
76
using Microsoft.VisualBasic.Devices;
87
// ReSharper disable PossibleNullReferenceException
@@ -82,19 +81,19 @@ internal sealed class RamController : IDisposable
8281
/// <summary>
8382
/// Property displaying whether the standby cache should be cleared or not during memory optimization
8483
/// </summary>
85-
internal bool ClearStandbyCache { get; set; }
84+
internal bool ClearStandbyCache { private get; set; }
8685
/// <summary>
8786
/// Property displaying whether automatic RAM optimization should occur after a certain RAM usage percentage was reached
8887
/// </summary>
89-
internal bool AutoOptimizePercentage { get; set; }
88+
internal bool AutoOptimizePercentage { private get; set; }
9089
/// <summary>
9190
/// Property displaying whether the clipboard should be cleared during memory cleaning
9291
/// </summary>
9392
internal bool ClearClipboard { get; set; }
9493
/// <summary>
9594
/// Property displaying whether the .NET garbage collector should be invoked or not
9695
/// </summary>
97-
internal bool InvokeGarbageCollector { get; set; }
96+
internal bool InvokeGarbageCollector { private get; set; }
9897
#endregion
9998

10099
#region Delegates

MemPlus/Business/RAM/RamData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ internal sealed class RamData
88
/// <summary>
99
/// A key value
1010
/// </summary>
11-
public string Key { get; set; }
11+
public string Key { get; }
1212
/// <summary>
1313
/// The value that is linked to the specific key
1414
/// </summary>
15-
public string Value { get; set; }
15+
public string Value { get; }
1616

1717
/// <summary>
1818
/// Initialize a new RamData object

MemPlus/Business/RAM/RamOptimizer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ internal void EmptyWorkingSetFunction(List<string> processExceptions)
131131
}
132132
catch (Exception ex)
133133
{
134-
_logController.AddLog(new RamLog("Could not empty working set for process " + process.ProcessName + ": " + ex.Message));
134+
_logController.AddLog(new ErrorLog("Could not empty working set for process " + process.ProcessName + ": " + ex.Message));
135135
}
136136
}
137137

@@ -159,7 +159,7 @@ internal void ClearClipboard()
159159
}
160160
catch (Exception ex)
161161
{
162-
_logController.AddLog(new RamLog(ex.ToString()));
162+
_logController.AddLog(new ErrorLog(ex.ToString()));
163163
}
164164
}
165165

@@ -252,7 +252,7 @@ internal void ClearFileSystemCache(bool clearStandbyCache)
252252
}
253253
catch (Exception ex)
254254
{
255-
_logController.AddLog(new RamLog(ex.ToString()));
255+
_logController.AddLog(new ErrorLog(ex.ToString()));
256256
}
257257
}
258258

MemPlus/Business/UTILS/GridViewSort.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static void ColumnHeader_Click(object sender, RoutedEventArgs e)
117117
/// <typeparam name="T">DependencyObject</typeparam>
118118
/// <param name="reference">A DependencyObject</param>
119119
/// <returns>The parent of a DependencyObject</returns>
120-
internal static T GetAncestor<T>(DependencyObject reference) where T : DependencyObject
120+
private static T GetAncestor<T>(DependencyObject reference) where T : DependencyObject
121121
{
122122
DependencyObject parent = VisualTreeHelper.GetParent(reference);
123123
while (!(parent is T))
@@ -132,7 +132,7 @@ internal static T GetAncestor<T>(DependencyObject reference) where T : Dependenc
132132
/// </summary>
133133
/// <param name="view">The ICollectionView</param>
134134
/// <param name="propertyName">The name of the property</param>
135-
internal static void ApplySort(ICollectionView view, string propertyName)
135+
private static void ApplySort(ICollectionView view, string propertyName)
136136
{
137137
ListSortDirection direction = ListSortDirection.Ascending;
138138
if (view.SortDescriptions.Count > 0)

MemPlus/Business/UTILS/Utils.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal static void RunAsAdministrator(LogController logController)
6060
}
6161
catch (Exception ex)
6262
{
63-
logController.AddLog(new ApplicationLog(ex.Message));
63+
logController.AddLog(new ErrorLog(ex.Message));
6464
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
6565
}
6666
}
@@ -139,7 +139,7 @@ internal static bool ExportRamSticks(LogController logController)
139139
}
140140
catch (Exception ex)
141141
{
142-
logController.AddLog(new ApplicationLog(ex.Message));
142+
logController.AddLog(new ErrorLog(ex.Message));
143143
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
144144
}
145145

@@ -189,7 +189,7 @@ internal static bool ExportLogs(LogType? logType, LogController logController)
189189
}
190190
catch (Exception ex)
191191
{
192-
logController.AddLog(new ApplicationLog(ex.Message));
192+
logController.AddLog(new ErrorLog(ex.Message));
193193
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
194194
}
195195
return false;
@@ -231,7 +231,7 @@ internal static async Task<bool> ExportProcessDetails(LogController logControlle
231231
}
232232
catch (Exception ex)
233233
{
234-
logController.AddLog(new ApplicationLog(ex.Message));
234+
logController.AddLog(new ErrorLog(ex.Message));
235235
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
236236
}
237237

@@ -259,13 +259,14 @@ await Task.Run(() =>
259259
ProcessId = p.Id,
260260
ProcessName = p.ProcessName,
261261
ProcessLocation = p.MainModule.FileName,
262-
MemoryUsage = (p.WorkingSet64 / (1024 * 1024)).ToString("F2") + " MB"
262+
MemoryUsage = (p.WorkingSet64 / (1024 * 1024)).ToString("F2") + " MB",
263+
MemoryUsageLong = p.WorkingSet64
263264
};
264265
processDetailsList.Add(pd);
265266
}
266267
catch (Exception ex)
267268
{
268-
logController.AddLog(new ProcessLog(p.ProcessName + ": " + ex.Message));
269+
logController.AddLog(new ErrorLog(p.ProcessName + ": " + ex.Message));
269270
}
270271
}
271272
});

MemPlus/MemPlus.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<SubType>Designer</SubType>
106106
</ApplicationDefinition>
107107
<Compile Include="Business\EXPORT\ExportTypes.cs" />
108+
<Compile Include="Business\LOG\ErrorLog.cs" />
108109
<Compile Include="Business\LOG\LogType.cs" />
109110
<Compile Include="Business\LOG\ProcessLog.cs" />
110111
<Compile Include="Business\PROCESS\ProcessDetail.cs" />

MemPlus/Resources/Languages/ar_SA.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<system:String x:Key="Logs">سجلات</system:String>
2222
<system:String x:Key="AllLogs">كل السجلات</system:String>
2323
<system:String x:Key="RamLogs">سجلات الرام</system:String>
24+
<system:String x:Key="ErrorLogs">سجلات الأخطاء</system:String>
2425
<system:String x:Key="ProcessLogs">سجلات العمليات</system:String>
2526
<system:String x:Key="ApplicationLogs">سجلات البرنامج</system:String>
2627
<system:String x:Key="RamAnalyzerData">بيانات محلل الرام</system:String>

MemPlus/Resources/Languages/de_DE.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<system:String x:Key="Logs">Protokolle</system:String>
2222
<system:String x:Key="AllLogs">Alle Protokolle</system:String>
2323
<system:String x:Key="RamLogs">RAM Protokolle</system:String>
24+
<system:String x:Key="ErrorLogs">Fehlerprotokolle</system:String>
2425
<system:String x:Key="ProcessLogs">Prozess Protokolle</system:String>
2526
<system:String x:Key="ApplicationLogs">Bewerbungsprotokolle</system:String>
2627
<system:String x:Key="RamAnalyzerData">RAM Analysierungsdaten</system:String>

0 commit comments

Comments
 (0)