maintenance expiration vs build date checking code
This commit is contained in:
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Biz;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
@@ -481,7 +482,7 @@ namespace AyaNova.Util
|
||||
AttachToAType = attachToObject.AType,
|
||||
LastModified = lastModified,
|
||||
Size = FileSize,
|
||||
AttachedByUserId=attachedByUserId
|
||||
AttachedByUserId = attachedByUserId
|
||||
|
||||
};
|
||||
|
||||
@@ -828,7 +829,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
//Linux ~ home folder special handling here
|
||||
if (path.Contains('~'))
|
||||
{
|
||||
@@ -841,6 +842,34 @@ namespace AyaNova.Util
|
||||
}
|
||||
#endregion general utilities
|
||||
|
||||
|
||||
#region licensing related utility to qualify upgradability
|
||||
//https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm
|
||||
public static DateTime GetLinkerTimestampUtc(Assembly assembly)
|
||||
{
|
||||
var location = assembly.Location;
|
||||
return GetLinkerTimestampUtc(location);
|
||||
}
|
||||
|
||||
public static DateTime GetLinkerTimestampUtc(string filePath)
|
||||
{
|
||||
const int peHeaderOffset = 60;
|
||||
const int linkerTimestampOffset = 8;
|
||||
var bytes = new byte[2048];
|
||||
|
||||
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
file.Read(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
|
||||
var secondsSince1970 = BitConverter.ToInt32(bytes, headerPos + linkerTimestampOffset);
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return dt.AddSeconds(secondsSince1970);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
Reference in New Issue
Block a user