Merge branch 'feat/uptime-utils' of Common/Utils into ConnectPro_v1.4

This commit is contained in:
Chris Cameron
2019-09-03 14:02:26 +00:00
committed by Gogs
4 changed files with 28 additions and 6 deletions

View File

@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Added
- Added Public API Properties to get the program install date based on the creation date of core dll file for NetStandard and SimplSharp
- Implemented processor utils for NetStandard to get the system uptime and the program uptime
### Changed ### Changed
- Fixed a bug where ANSI color encoded strings with percentages were being scrambled - Fixed a bug where ANSI color encoded strings with percentages were being scrambled

View File

@@ -142,8 +142,7 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static TimeSpan GetSystemUptime() public static TimeSpan GetSystemUptime()
{ {
// TODO return TimeSpan.FromMilliseconds(Environment.TickCount);
return default(TimeSpan);
} }
/// <summary> /// <summary>
@@ -153,8 +152,8 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static TimeSpan GetProgramUptime() public static TimeSpan GetProgramUptime()
{ {
// TODO var current = System.Diagnostics.Process.GetCurrentProcess();
return default(TimeSpan); return IcdEnvironment.GetLocalTime() - current.StartTime;
} }
#endregion #endregion

View File

@@ -1,4 +1,5 @@
using ICD.Common.Utils.Services; using ICD.Common.Utils.IO;
using ICD.Common.Utils.Services;
using ICD.Common.Utils.Services.Logging; using ICD.Common.Utils.Services.Logging;
#if SIMPLSHARP #if SIMPLSHARP
using Crestron.SimplSharp; using Crestron.SimplSharp;
@@ -86,6 +87,16 @@ namespace ICD.Common.Utils
} }
} }
/// <summary>
/// Returns the date and time the program was installed.
/// </summary>
/// <returns></returns>
[PublicAPI]
public static DateTime ProgramInstallDate
{
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
}
/// <summary> /// <summary>
/// Parses the prog comments and pulls program information. /// Parses the prog comments and pulls program information.
/// </summary> /// </summary>

View File

@@ -55,6 +55,15 @@ namespace ICD.Common.Utils
return Assembly.GetEntryAssembly().GetName().Name; return Assembly.GetEntryAssembly().GetName().Name;
} }
} }
}
/// <summary>
/// Gets the date and time the program was installed.
/// </summary>
[PublicAPI]
public static DateTime ProgramInstallDate
{
get { return IcdFile.GetCreationTime(PathUtils.Join(PathUtils.ProgramPath, ProgramFile)); }
}
}
} }
#endif #endif