Skip to content

Commit

Permalink
Catch-up and fix issues #21 #17 #19 #20
Browse files Browse the repository at this point in the history
  • Loading branch information
Smurf-IV committed Oct 1, 2018
1 parent a2fa021 commit 7304737
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 70 deletions.
22 changes: 20 additions & 2 deletions Elucidate/Elucidate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,41 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|x64.ActiveCfg = Debug|x64
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|x64.Build.0 = Debug|x64
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|x86.ActiveCfg = Debug|x86
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Debug|x86.Build.0 = Debug|x86
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|Any CPU.Build.0 = Release|Any CPU
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|x64.ActiveCfg = Release|x64
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|x64.Build.0 = Release|x64
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|x86.ActiveCfg = Release|x86
{C45A0899-34D4-4CB0-B5FF-9DFADBC5E70E}.Release|x86.Build.0 = Release|x86
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Debug|Any CPU.ActiveCfg = Debug|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Debug|x64.ActiveCfg = Debug|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Debug|x64.Build.0 = Debug|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Debug|x86.ActiveCfg = Debug|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Release|Any CPU.ActiveCfg = Release|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Release|Any CPU.Build.0 = Release|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Release|x64.ActiveCfg = Release|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Release|x64.Build.0 = Release|x64
{EA76FDE5-C6AE-46B7-ADA4-F3DC9DCCC9FB}.Release|x86.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
BuildVersion_UseGlobalSettings = False
BuildVersion_StartDate = 2000/1/1
SolutionGuid = {39E6A612-AC12-4D63-BE2A-60EA16940A8A}
BuildVersion_StartDate = 2000/1/1
BuildVersion_UseGlobalSettings = False
EndGlobalSection
EndGlobal
20 changes: 14 additions & 6 deletions Elucidate/Elucidate/ConfigFileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@
using System.IO;
using System.Linq;
using System.Text;

using Elucidate.HelperClasses;
using Elucidate.Logging;
using Elucidate.Objects;

using MoreLinq.Extensions;

namespace Elucidate
{
public class ConfigFileHelper
{
public bool IsValid => !ConfigErrors.Any();
public bool IsValid => (ConfigFileExists && !ConfigErrors.Any());

public bool IsErrors => ConfigErrors.Any();

Expand Down Expand Up @@ -319,14 +321,20 @@ private static bool IsRulePassDevicesMustNotRepeat(List<string> paths)

internal static bool IsRulePassDevicesMustNotRepeat(List<string> paths, string current)
{
if (paths == null || string.IsNullOrEmpty(current))
try
{
return true;
}
if (paths == null || string.IsNullOrEmpty(current)) return true;

int count = paths.Where(s => !string.IsNullOrEmpty(s)).Count(temp => StorageUtil.GetPathRoot(temp).Equals(StorageUtil.GetPathRoot(current)));
var count = paths.Where(s => !string.IsNullOrEmpty(s)).Count(temp => StorageUtil.GetPathRoot(temp).Equals(StorageUtil.GetPathRoot(current)));

return count <= 1;
return count <= 1;
}
catch
{
// ignored
}

return true;
}

public static bool IsRulePassPreviousCannotBeEmpty(string previous, string current)
Expand Down
4 changes: 2 additions & 2 deletions Elucidate/Elucidate/Controls/LiveRunLogControl.Designer.cs

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

5 changes: 3 additions & 2 deletions Elucidate/Elucidate/Controls/LogsViewerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public LogsViewerControl()
private void LogFileWatcher_OnChanged(object sender, FileSystemEventArgs e)
{
// let's keep the file selected by the user as selected after the refresh
//UpdateLogFileList();
listBoxViewLogFiles.BeginInvoke((MethodInvoker)delegate { UpdateLogFileList(); });
}

Expand Down Expand Up @@ -104,6 +103,7 @@ private void UpdateLogFileList(string selectedDirectoryTitle = null)
warningSearchTerm = _snapraidWarningSearchTerm;
LexerToUse = LexerNameEnum.ScanRaid;
_logSourcePath = $@"{Path.GetDirectoryName(Properties.Settings.Default.ConfigFileLocation)}\{Properties.Settings.Default.LogFileDirectory}\";
if (!Directory.Exists(_logSourcePath)) return;
_logFileWatcher.Path = $@"{Path.GetDirectoryName(Properties.Settings.Default.ConfigFileLocation)}\{Properties.Settings.Default.LogFileDirectory}\";
_logFileWatcher.Filter = "*.log";
_logFileWatcher.EnableRaisingEvents = true;
Expand All @@ -114,6 +114,7 @@ private void UpdateLogFileList(string selectedDirectoryTitle = null)
warningSearchTerm = _elucidateWarningSearchTerm;
LexerToUse = LexerNameEnum.NLog;
_logSourcePath = LogFileLocation.GetActiveLogFileLocation();
if (!Directory.Exists(_logSourcePath)) return;
_logFileWatcher.Path = LogFileLocation.GetActiveLogFileLocation();
_logFileWatcher.Filter = "*.log";
_logFileWatcher.EnableRaisingEvents = true;
Expand Down Expand Up @@ -163,7 +164,7 @@ where fileText.Contains(warningSearchTerm)
listBoxViewLogFiles.Items.Add(log.Name);
}

// restore user selection, if it stil lexists
// restore user selection, if it still exists
if (selectedIndex >= 0 && !string.IsNullOrEmpty(selectedIndexValue))
{
int indexFound = -1;
Expand Down
127 changes: 71 additions & 56 deletions Elucidate/Elucidate/HelperClasses/StorageUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,67 +123,82 @@ public static List<StorageDevice> GetStorageDevices(bool isIncludeNonMountedStor
{
List<StorageDevice> storageDevices = new List<StorageDevice>();

ManagementObjectSearcher mgmtObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Volume");

ManagementObjectCollection colDisks = mgmtObjSearcher.Get();

foreach (ManagementBaseObject colDisk in colDisks)
using (ManagementObjectSearcher mgmtObjSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Volume"))
{
ManagementObject objDisk = (ManagementObject)colDisk;

try
using (var managementQuery = mgmtObjSearcher.Get())
{
// ReSharper disable once UnusedVariable
bool success = GetDiskFreeSpaceEx(
(string)objDisk["DeviceID"],
out ulong freeBytesAvailable,
out ulong totalNumberOfBytes,
out ulong totalNumberOfFreeBytes);

StorageDevice device = new StorageDevice
{
Caption = (string)objDisk["Caption"],
Name = (string)objDisk["Name"],
DeviceID = (string)objDisk["DeviceID"],
DriveLetter = (string)objDisk["DriveLetter"],
FileSystem = (string)objDisk["FileSystem"],
Capacity = (uint)totalNumberOfBytes,
FreeSpace = (uint)freeBytesAvailable
};

switch ((uint)objDisk["DriveType"])
{
case (uint)DriveType.Removable:
device.DriveType = DriveType.Removable;
break;

case (uint)DriveType.Fixed:
device.DriveType = DriveType.Fixed;
break;

case (uint)DriveType.Network:
device.DriveType = DriveType.Network;
break;

case (uint)DriveType.CDRom:
device.DriveType = DriveType.CDRom;
break;

default:
device.DriveType = DriveType.Unknown;
break;
}

if (!string.IsNullOrEmpty(device.Caption) && (!device.Caption.StartsWith(@"\\?\") || isIncludeNonMountedStorage))
// convert to LINQ to Objects query
var query =
from ManagementObject mo in managementQuery
orderby Convert.ToString(mo["DriveLetter"])
select new
{
Caption = Convert.ToString(mo["Caption"]),
Name = Convert.ToString(mo["Name"]),
DeviceID = Convert.ToString(mo["DeviceID"]),
DriveType = Convert.ToUInt32(mo["DriveType"]),
DriveLetter = Convert.ToString(mo["DriveLetter"]),
FileSystem = Convert.ToString(mo["FileSystem"])
};

// grab the fields
foreach (var item in query)
{
storageDevices.Add(device);
try
{
// ReSharper disable once UnusedVariable
bool success = GetDiskFreeSpaceEx(
item.DeviceID,
out var freeBytesAvailable,
out var totalNumberOfBytes,
out var totalNumberOfFreeBytes);

StorageDevice device = new StorageDevice
{
Caption = item.Caption,
Name = item.Name,
DeviceID = item.DeviceID,
DriveLetter = item.DriveLetter,
FileSystem = item.FileSystem,
Capacity = (uint)totalNumberOfBytes,
FreeSpace = (uint)freeBytesAvailable
};

switch (item.DriveType)
{
case (uint)DriveType.Removable:
device.DriveType = DriveType.Removable;
break;

case (uint)DriveType.Fixed:
device.DriveType = DriveType.Fixed;
break;

case (uint)DriveType.Network:
device.DriveType = DriveType.Network;
break;

case (uint)DriveType.CDRom:
device.DriveType = DriveType.CDRom;
break;

default:
device.DriveType = DriveType.Unknown;
break;
}

if (!string.IsNullOrEmpty(device.Caption) && (!device.Caption.StartsWith(@"\\?\") || isIncludeNonMountedStorage))
{
storageDevices.Add(device);
}
}
catch (Exception ex)
{
Log.Instance.Warn("A storage device failed to enumerate.");
Log.Instance.Warn(ex);
}
}
}
catch (Exception ex)
{
Log.Instance.Warn("A storage device failed to enumerate.");
Log.Instance.Warn(ex);
}
}

return storageDevices;
Expand Down
4 changes: 2 additions & 2 deletions Elucidate/Elucidate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
// Build Number - Increment
// Revision - Day
//
[assembly: AssemblyVersion("2018.9.607.30")]
[assembly: AssemblyFileVersion("18.9.607.30")]
[assembly: AssemblyVersion("2018.10.608.1")]
[assembly: AssemblyFileVersion("18.10.608.1")]

0 comments on commit 7304737

Please sign in to comment.