コード例 #1
0
        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),
                });
            }
        }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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");
            }
        }
コード例 #5
0
        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");
            }
        }
コード例 #6
0
 /// <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}"));
 }