Пример #1
0
        private void DoDataUpdate()
        {
            var lastUpdate = _dataUpdateService.GetLastFullUpdate();
            var shouldPerformDataUpdate = !lastUpdate.HasValue;

            if (lastUpdate.HasValue)
            {
                if (lastUpdate < DateTime.Now.AddDays(-20))
                {
                    // force an update after 20 days
                    shouldPerformDataUpdate = true;
                }
                else if (lastUpdate < DateTime.Now.AddDays(-10))
                {
                    // suggest an update after 10 days
                    var updateConfirmation = _updateConfirmationFactory();
                    var dialogResult       = updateConfirmation.ShowDialog();
                    shouldPerformDataUpdate = dialogResult == DialogResult.OK;
                }
            }

            if (shouldPerformDataUpdate)
            {
                SetStatusText("Updating catalogs...");
                _dataUpdateService.UpdateData();
            }
        }
Пример #2
0
        private void UpdateCheck_Shown(object sender, EventArgs e)
        {
            var lastDataUpdate = _dataUpdateService.GetLastFullUpdate();

            if (lastDataUpdate.HasValue)
            {
                int days = Convert.ToInt32((DateTime.Now - lastDataUpdate.Value).TotalDays);
                label1.Text = "The catalog is " + days + " days old. Update?";
            }
            else
            {
                label1.Text = "The catalog has never been updated. Update?";
            }
        }