/// <summary> /// Helper private method to add additional common properties to all telemetry events via ref param /// </summary> /// <param name="properties">original properties to add to</param> private static void AddCommonProperties(ref IDictionary <string, string> properties) { // add common properties as long as they don't already exist in the original properties passed in if (!properties.ContainsKey("Custom_AppVersion")) { properties.Add("Custom_AppVersion", EnvironmentSettings.GetAppVersion()); } if (!properties.ContainsKey("Custom_OSVersion")) { properties.Add("Custom_OSVersion", EnvironmentSettings.GetOSVersion()); } #if MS_INTERNAL_ONLY // Do not send this app insights telemetry data for external customers. Microsoft only. if (!properties.ContainsKey("userAlias")) { properties.Add("userAlias", App.Controller.XmlSettings.MicrosoftAlias); } if (!properties.ContainsKey("Custom_DeviceName")) { properties.Add("Custom_DeviceName", EnvironmentSettings.GetDeviceName()); } if (!properties.ContainsKey("Custom_IPAddress")) { properties.Add("Custom_IPAddress", EnvironmentSettings.GetIPAddress()); } #endif }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { // Initialize AI telemetry in the app. WindowsAppInitializer.InitializeAsync(); // Timer uploading hearbeat telemetry event HeartbeatTimer = new DispatcherTimer(); HeartbeatTimer.Tick += HeartbeatTimer_Tick; HeartbeatTimer.Interval = new TimeSpan(0, heartbeatInterval, 0); // tick every heartbeatInterval HeartbeatTimer.Start(); // Retrieve and set environment settings OSVersion = EnvironmentSettings.GetOSVersion(); appVersion = EnvironmentSettings.GetAppVersion(); deviceName = EnvironmentSettings.GetDeviceName(); ipAddress = EnvironmentSettings.GetIPAddress(); this.InitializeComponent(); this.Suspending += OnSuspending; this.Resuming += OnResuming; Controller = new AppController(); }
/// <summary> /// Generates the html for the home page (status page) /// </summary> /// <returns></returns> public async Task <string> GenerateStatusPage() { string html = "<table>"; // Device Name html += "<tr><td><b>Device Name:</b></td><td> " + EnvironmentSettings.GetDeviceName() + "</td></tr>"; // IP Address html += "<tr><td><b>IP Address:</b></td><td> " + EnvironmentSettings.GetIPAddress() + "</td></tr>"; // App Version html += "<tr><td><b>App Version:</b></td><td> " + EnvironmentSettings.GetAppVersion() + "</td></tr>"; // OS Version html += "<tr><td><b>OS Version:</b></td><td> " + EnvironmentSettings.GetOSVersion() + "</td></tr>"; html += "<tr><td> </td></tr>"; // Show controller status html += "<tr><td><b>Status:</b></td><td> " + ((App.Controller.IsInitialized) ? "<span style='color:Green'>Running" : "<span style='color:Red'>Not Running") + "</span></td></tr>"; // Show free space var freeSpaceProperty = "System.FreeSpace"; var capacityProperty = "System.Capacity"; var picLib = KnownFolders.PicturesLibrary; var properties = await picLib.GetBasicPropertiesAsync(); var result = await properties.RetrievePropertiesAsync(new string[] { freeSpaceProperty, capacityProperty }); double freeSpaceInGb = Convert.ToDouble(result[freeSpaceProperty]) / 1000000000.0; double capacityInGb = Convert.ToDouble(result[capacityProperty]) / 1000000000.0; html += "<tr><td><b>Space:</b></td><td> " + freeSpaceInGb.ToString("#.##") + " GB free of " + capacityInGb.ToString("#.##") + " GB</td></tr>"; // Show up time html += "<tr><td><b>Up Time:</b></td><td> " + App.GlobalStopwatch.Elapsed.ToString() + "</td></tr>"; // Show OneDrive status if the Storage Provider selected is OneDrive if (App.Controller.Storage.GetType() == typeof(OneDrive)) { var oneDrive = App.Controller.Storage as OneDrive; html += "<tr><td><b>OneDrive Status:</b></td><td> " + (oneDrive.IsLoggedIn() ? "<span style='color:Green'>Logged In" : "<span style='color:Red'>Not Logged In") + "</span></td></tr>"; } html += "<tr><td> </td></tr>"; // Show camera type on status page html += "<tr><td><b>Camera Type:</b></td><td> " + App.Controller.Camera.GetType().Name + "</td></tr>"; // Show storage type on status page html += "<tr><td><b>Storage Type:</b></td><td> " + App.Controller.Storage.GetType().Name + "</td></tr>"; return(GeneratePage("Security System", "Home", html)); }
public MainPage() { string ipAddress = ""; string instructions = ""; this.InitializeComponent(); // get device environment info and display it in UI deviceNameValueTextBlock.Text = EnvironmentSettings.GetDeviceName(); ipAddress = EnvironmentSettings.GetIPAddress(); ipAddressValueTextBlock.Text = ipAddress; appVersionValueTextBlock.Text = EnvironmentSettings.GetAppVersion(); OSVersionValueTextBlock.Text = EnvironmentSettings.GetOSVersion(); // instructions text with ip address instructions = "Setup Instructions: To configure this security system please go to URL http://" + ipAddress + ":8000 on a browser."; instructionsTextBlock.Text = instructions; }
/// <summary> /// Get dynamic network information about the device and display it /// </summary> private void UpdateNetworkInfo() { string ipAddress = EnvironmentSettings.GetIPAddress(); string instructions = ""; // check if ip address is valid if (ipAddress == "0.0.0.0") { ipAddress = "Invalid IP Address: 0.0.0.0"; instructions = "Setup Instructions: Please ensure your device has a valid ip address first."; } else { instructions = "Setup Instructions: To configure this security system please go to URL http://" + ipAddress + ":8000 on a browser."; } // update UI deviceNameValueTextBlock.Text = EnvironmentSettings.GetDeviceName(); ipAddressValueTextBlock.Text = ipAddress; instructionsTextBlock.Text = instructions; }