diff --git a/Logic/Support/Formatting.cs b/Logic/Support/Formatting.cs index c41c7fbc..a419a9d6 100644 --- a/Logic/Support/Formatting.cs +++ b/Logic/Support/Formatting.cs @@ -14,6 +14,7 @@ namespace Swarmops.Logic.Support public static class Formatting { private static string _swarmopsVersion; + private static DateTime? _swarmopsBuildDateTime = null; public static string SwarmopsVersion { @@ -73,6 +74,62 @@ namespace Swarmops.Logic.Support } } + public static DateTime SwarmopsBuildTime + { + get + { + if (_swarmopsBuildDateTime != null) + { + return (DateTime) _swarmopsBuildDateTime; + } + + if (System.Diagnostics.Debugger.IsAttached) + { + _swarmopsBuildDateTime = DateTime.Now; + GuidCache.Set("_swarmopsBuildDateTime", _swarmopsBuildDateTime); + return (DateTime) _swarmopsBuildDateTime; + } + + // if we still don't have it, check the cache and possibly return + + _swarmopsBuildDateTime = (DateTime?) GuidCache.Get("_swarmopsBuildDateTime"); + + if (_swarmopsBuildDateTime != null) + { + return (DateTime) _swarmopsBuildDateTime; + } + + try + { + if (HttpContext.Current != null) // frontend: use friendly format + { + using ( + StreamReader reader = + File.OpenText(HttpContext.Current.Request.MapPath("~/BuildDateTime.txt"))) + { + _swarmopsBuildDateTime = DateTime.Parse(reader.ReadLine()); + } + } + else // backend: use build ID only + { + using ( + StreamReader reader = + File.OpenText("/usr/share/swarmops/backend/BuildDateTime.txt")) + { + _swarmopsBuildDateTime = DateTime.Parse(reader.ReadLine()); + } + } + } + catch (Exception) + { + _swarmopsBuildDateTime = DateTime.Now; + } + + GuidCache.Set("_swarmopsBuildDateTime", _swarmopsBuildDateTime); + return (DateTime) _swarmopsBuildDateTime; + } + } + public static string CleanNumber (string input) { return LogicServices.CleanNumber (input); diff --git a/Site/App_GlobalResources/Menu5.designer.cs b/Site/App_GlobalResources/Menu5.designer.cs index 50639333..fb7cbc8b 100644 --- a/Site/App_GlobalResources/Menu5.designer.cs +++ b/Site/App_GlobalResources/Menu5.designer.cs @@ -19,7 +19,7 @@ namespace Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option or rebuild the Visual Studio project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "11.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "14.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Menu5 { @@ -132,6 +132,33 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Built on {0:MMM d, yyyy}. + /// + internal static string Menu5_Beta_BuildTime { + get { + return ResourceManager.GetString("Menu5_Beta_BuildTime", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0:N0} lines of code. + /// + internal static string Menu5_Beta_LinesOfCode { + get { + return ResourceManager.GetString("Menu5_Beta_LinesOfCode", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Report a Swarmops Bug (on Github). + /// + internal static string Menu5_Beta_ReportBug { + get { + return ResourceManager.GetString("Menu5_Beta_ReportBug", resourceCulture); + } + } + /// /// Looks up a localized string similar to Communications. /// diff --git a/Site/App_GlobalResources/Menu5.resx b/Site/App_GlobalResources/Menu5.resx index 12dffe04..90cc8dd9 100644 --- a/Site/App_GlobalResources/Menu5.resx +++ b/Site/App_GlobalResources/Menu5.resx @@ -423,4 +423,14 @@ Bitcoin Hotwallet + + Built on {0:MMM d, yyyy} + Change date format as appropriate for language (here it's "Jan 21, 1972") + + + {0:N0} lines of code + + + Report a Swarmops Bug (on Github) + \ No newline at end of file diff --git a/Site/Controls/v5/Base/MainMenu.ascx.cs b/Site/Controls/v5/Base/MainMenu.ascx.cs index 70113126..0a47e7ac 100644 --- a/Site/Controls/v5/Base/MainMenu.ascx.cs +++ b/Site/Controls/v5/Base/MainMenu.ascx.cs @@ -6,6 +6,7 @@ using System.Web.UI; using System.Xml.Serialization; using Swarmops.Frontend; using Swarmops.Interface.Objects; +using Swarmops.Logic.Support; using Swarmops.Logic.Swarm; @@ -52,7 +53,20 @@ namespace Swarmops.Controls.Base protected override void Render (HtmlTextWriter output) { output.Write ("