-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagnosticMode.cs
108 lines (96 loc) · 4.1 KB
/
DiagnosticMode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Linq;
using Windows.Networking.Connectivity;
using Windows.Storage;
using Windows.System.Profile;
using Windows.UI.Xaml.Controls;
using System.IO;
namespace PassDefend
{
class DiagnosticMode
{
//byte converter
static double convertBytesToMegabytes(long bytes)
{
return (bytes / 1024f) / 1024f;
}
//diagnostic mode displays information about the program and the system the program is running on for development and support purposes.
public static async void openDiagnostics()
{
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
string hashPresent = "";
string corePresent = "";
string savedGenSettingsPresent = "";
string activeColorScheme = "";
var hostNames = NetworkInformation.GetHostNames();
var localName = hostNames.FirstOrDefault(name => name.DisplayName.Contains(".local"));
var computerName = localName.DisplayName.Replace(".local", "");
string deviceFamilyVersion = AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
ulong version = ulong.Parse(deviceFamilyVersion);
ulong major = (version & 0xFFFF000000000000L) >> 48;
ulong minor = (version & 0x0000FFFF00000000L) >> 32;
ulong build = (version & 0x00000000FFFF0000L) >> 16;
ulong revision = (version & 0x000000000000FFFFL);
var osVersion = $"{major}.{minor}.{build}.{revision}";
if (await localFolder.TryGetItemAsync("hash") != null)
{
hashPresent = "Yes";
}
else
{
hashPresent = "No";
}
if (await localFolder.TryGetItemAsync("core") != null)
{
corePresent = "Yes";
}
else
{
corePresent = "No";
}
if (await localFolder.TryGetItemAsync("genSettings") != null)
{
savedGenSettingsPresent = "Stored";
}
else
{
savedGenSettingsPresent = "Not stored";
}
if (await localFolder.TryGetItemAsync("colorScheme") != null)
{
StorageFile colorschemefile = await localFolder.GetFileAsync("colorScheme");
string fileContent = await FileIO.ReadTextAsync(colorschemefile);
if (fileContent == "green")
{
activeColorScheme = "Yes (Green)";
}
else if (fileContent == "red")
{
activeColorScheme = "Yes (Red)";
}
else if (fileContent == "purple")
{
activeColorScheme = "Yes (Purple)";
}
else if (fileContent == "black")
{
activeColorScheme = "Yes (Black)";
}
}
else
{
activeColorScheme = "Default";
}
string dbpath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "core");
long bytes = new System.IO.FileInfo(dbpath).Length;
double dbfilesize = convertBytesToMegabytes(bytes);
ContentDialog diagnosticsDialog = new ContentDialog
{
Title = "PassDefend v" + MainPage.GetAppVersion() + " diagnostics",
Content = "Diagnostics generated: " + DateTime.Now + "\r\nUsing: DiagnosticEngine1 on PassDefend v" + MainPage.GetAppVersion() + "\r\n\r\nMachine name: " + computerName + "\r\nWindows version: " + osVersion + "\r\n\r\nHash present: " + hashPresent + "\r\nCore present: " + corePresent + "\r\nGeneration settings: " + savedGenSettingsPresent + "\r\nActive color scheme: " + activeColorScheme + "\r\n\r\nCurrent database size: " + dbfilesize.ToString("0.0000") + " MB (" + bytes + " bytes)",
PrimaryButtonText = "Okay",
};
ContentDialogResult result = await diagnosticsDialog.ShowAsync();
}
}
}