private void AppendUsageData(UsageMessage message) { message.AppData = new System.Collections.Generic.List <UsageApplicationData>(); if (_uptime != null) { message.AppData.Add(new UsageApplicationData() { Key = "UPTIME", Value = _uptime.Value.TotalHours.ToString(CultureInfo.InvariantCulture.NumberFormat), }); } }
private void OnStartup() { try { UsageMessage theMessage = CreateUsageMessage(UsageType.Startup); UsageUtilities.Register(theMessage, UsageTrackingThread.Background); } catch (Exception ex) { //catch everything or the shred host will crash Platform.Log(LogLevel.Error, ex, "Error occurred when trying to send usage tracking data"); } }
public UsageTrackingForm() { InitializeComponent(); UsageUtilities.MessageEvent += DisplayMessage; _message = UsageUtilities.GetUsageMessage(); textBoxVersion.Text = _message.Version; textBoxProduct.Text = _message.Product; textBoxOS.Text = _message.OS; textBoxRegion.Text = _message.Region; textBoxLicense.Text = _message.LicenseString; textBoxComponent.Text = _message.Component; textBoxMachineIdentifier.Text = _message.MachineIdentifier; textBoxEdition.Text = _message.Edition; }
private void OnShutdown() { try { _uptime = DateTime.Now - _startTimestamp; UsageMessage theMessage = CreateUsageMessage(UsageType.Shutdown); UsageUtilities.Register(theMessage, UsageTrackingThread.Current /* send in current thread */); } catch (Exception ex) { //catch everything or the shred host will crash Platform.Log(LogLevel.Error, ex, "Error occurred when trying to send usage tracking data"); } }
private void OnTimer(object nothing) { try { _uptime = DateTime.Now - _startTimestamp; UsageMessage theMessage = CreateUsageMessage(UsageType.Other); AppendUsageData(theMessage); UsageUtilities.Register(theMessage, UsageTrackingThread.Background); } catch (Exception ex) { //catch everything or the shred host will crash Platform.Log(LogLevel.Error, ex, "Error occurred when trying to send usage tracking data"); } }
/// <summary> /// Distributes the message via SignalR /// </summary> /// <param name="usage">The usage stats to send</param> private void BroadcastUsage(UsageMessage usage) { _clients.All.updateUsage(usage); _output.Tell(new SimpleMessage($"UsageDispatchActor created new broadcast with Cpu={usage.CpuPercent} and Memory={usage.BytesUsed}")); }