free geoip Adding System Uptime to .Text - Jayson's Blog - jaysonKnight.com
jaysonKnight.com
Welcome to my corner of the internet

Adding System Uptime to .Text

Want to show off how long your .Text web server has been up and running (time since the last machine reboot) on your .Text header (in the blog stats section)?  Here’s how:

  • Add the following code to your [skin name]\Controls\BlogStats.ascx file: [asp:Literal ID="SystemUptime" Runat = "server" /] (use wickets instead of brackets of course).
  • To your DotText.Framework\Data\DataHelper.cs file: 

    using System.Diagnostics;

    public static BlogConfig LoadConfigData(IDataReader reader)

    {...

    PerformanceCounter pc = new PerformanceCounter("System",

                            "System Up Time");

    pc.NextValue();

  • To your Dottext.Framework\Configuration\BlogConfig.cs file:

     private TimeSpan _systemUptime;

     public TimeSpan SystemUptime

     {

           get {return this._systemUptime;}

           set {this._systemUptime = value;}

     }

  • And finally, to your DottextWeb\UI\Controls\BlogStats.cs file:

    protected System.Web.UI.WebControls.Literal SystemUptime;

    protected override void OnLoad(EventArgs e)

    {...

     

    SystemUptime.Text = string.Format("{0}d {1}h {2}m {3}s",

          config.SystemUptime.Days.ToString(),

          config.SystemUptime.Hours.ToString(),

          config.SystemUptime.Minutes.ToString(),

          config.SystemUptime.Seconds.ToString());

     

It’s that easy.  Just compile, copy over the new assemblies (and the BlogStats.ascx file) and you’re good to go.  For any rss subscribers, visit my blog to see how it looks (upper right-hand corner).


Posted Mar 26 2005, 12:34 AM by Jayson Knight

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Copyright © :: JaysonKnight.com
External Content © :: Respective Authors

Terms of Service/Privacy Policy