private void buttonSend_Click(object sender, EventArgs e)
        {
            _message.Version           = textBoxVersion.Text;
            _message.Product           = textBoxProduct.Text;
            _message.OS                = textBoxOS.Text;
            _message.Region            = textBoxRegion.Text;
            _message.LicenseString     = textBoxLicense.Text;
            _message.Component         = textBoxComponent.Text;
            _message.MachineIdentifier = textBoxMachineIdentifier.Text;
            _message.Edition           = textBoxEdition.Text;
            _message.MessageType       = UsageType.Other;

            if (!string.IsNullOrEmpty(textBoxAppKey.Text) &&
                !string.IsNullOrEmpty(textBoxAppValue.Text))
            {
                UsageApplicationData d = new UsageApplicationData
                {
                    Key   = textBoxAppKey.Text,
                    Value = textBoxAppValue.Text
                };
                _message.AppData = new List <UsageApplicationData>
                {
                    d
                };
            }

            UsageUtilities.Register(_message, UsageTrackingThread.Background);
        }
Пример #2
0
        private static UsageMessage CreateUsageMessage(UsageType type)
        {
            var msg = UsageUtilities.GetUsageMessage();

            msg.Certified   = ManifestVerification.Valid;
            msg.MessageType = type;
            return(msg);
        }
Пример #3
0
        private UsageMessage CreateUsageMessage(UsageType type)
        {
            UsageMessage theMessage = UsageUtilities.GetUsageMessage();

            theMessage.MessageType = type;
            theMessage.Certified   = ManifestVerification.Valid;

            AppendUsageData(theMessage);
            return(theMessage);
        }
Пример #4
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");
            }
        }
        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;
        }
Пример #6
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");
            }
        }
Пример #7
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");
            }
        }
Пример #8
0
        /// <summary>
        /// Start up the phone home service.
        /// </summary>
        internal static void Startup()
        {
            lock (_sync)
            {
                OnStartUp();

                _phoneHomeTimer = new Timer(ignore =>
                {
                    var type    = _sentStartUpMessage ? UsageType.Other : UsageType.Startup;
                    var msg     = CreateUsageMessage(type);
                    msg.AppData = new List <UsageApplicationData>();
                    msg.AppData.AddRange(UsageUtilities.GetApplicationData(type));
                    UsageUtilities.Register(msg, UsageTrackingThread.Background);

                    _sentStartUpMessage = true;
                },
                                            null,
                                            _startupCallDelay,
                                            _periodicCallInterval);
            }
        }
Пример #9
0
        private static void SendShutdownMessage()
        {
            const string keyProcessUptime = "PROCESSUPTIME";

            try
            {
                TimeSpan uptime = DateTime.Now - _startTimestamp;

                var msg = CreateUsageMessage(UsageType.Shutdown);
                msg.AppData = new List <UsageApplicationData>();
                msg.AppData.AddRange(UsageUtilities.GetApplicationData(UsageType.Shutdown));
                msg.AppData.Add(new UsageApplicationData {
                    Key = keyProcessUptime, Value = String.Format(CultureInfo.InvariantCulture, "{0}", uptime.TotalHours)
                });

                // Message must be sent using the current thread instead of threadpool when the app is being shut down
                UsageUtilities.Register(msg, UsageTrackingThread.Current);
            }
            catch (Exception ex)
            {
                // Requirement says log must be in debug
                Platform.Log(LogLevel.Debug, ex, "Error occurred when shutting down phone home service");
            }
        }