Interaction logic for UpdateItem.xaml
상속: System.Windows.Controls.UserControl
예제 #1
0
        private void GetInstalledApplications()
        {
            var appNames = Registry_Functions.GetKeyNames();
            if (appNames != null)
            {
                foreach (var appName in appNames)
                {
                    var valueNames = Registry_Functions.GetValueNames(appName);

                    var item = new UpdateItem();
                    item.ApplyClicked += Apply;
                    item.CheckForUpdatesClicked += Check;

                    item.ApplicationName = appName;
                    item.ApplicationTitle = GetValueData(valueNames.ToList().Find(x => x == "title"), appName);
                    item.ApplicationSubtitle = GetValueData(valueNames.ToList().Find(x => x == "subtitle"), appName);

                    string lastUpdated = GetValueData(valueNames.ToList().Find(x => x == "update_last_checked"), appName);
                    string lastInstalled = GetValueData(valueNames.ToList().Find(x => x == "update_last_installed"), appName);

                    if (!String.IsNullOrEmpty(lastUpdated)) item.UpdateLastChecked = lastUpdated;
                    if (!String.IsNullOrEmpty(lastInstalled)) item.UpdateLastInstalled = lastInstalled;

                    CheckForDownloadedUpdates(item);

                    // Make sure that TrakHound Client/Bundle is first
                    if (appName == ApplicationNames.TRAKHOUND_BUNDLE) UpdateItems.Insert(0, item);
                    else UpdateItems.Add(item);
                }
            }
        }
예제 #2
0
        private void CheckTimestamps(UpdateItem item)
        {
            string appName = item.ApplicationName;

            var valueNames = Registry_Functions.GetValueNames(appName);
            if (valueNames != null)
            {
                string lastUpdated = GetValueData(valueNames.ToList().Find(x => x == "update_last_checked"), appName);
                string lastInstalled = GetValueData(valueNames.ToList().Find(x => x == "update_last_installed"), appName);

                if (!String.IsNullOrEmpty(lastUpdated)) item.UpdateLastChecked = lastUpdated;
                if (!String.IsNullOrEmpty(lastInstalled)) item.UpdateLastInstalled = lastInstalled;
            }
        }
예제 #3
0
        private void Check(UpdateItem item)
        {
            item.Loading = true;
            item.UpdateAvailable = false;
            item.ProgressValue = 0;

            if (CheckUpdaterIsRunning())
            {
                item.Error = false;
                item.Status = "Retrieving Update Information..";

                var message = new WCF_Functions.MessageData("check");
                message.Data01 = item.ApplicationName;
                SendMessage(message);
            }
            else
            {
                item.Loading = false;
                item.Error = true;
                item.Status = "Updater Service Not Running";
            }
        }
예제 #4
0
        private void CheckForDownloadedUpdates(UpdateItem item)
        {
            string appName = item.ApplicationName;

            var valueNames = Registry_Functions.GetValueNames(appName);
            if (valueNames != null)
            {
                var updatePath = valueNames.ToList().Exists(x => x == "update_path");
                if (updatePath)
                {
                    string version = GetValueData(valueNames.ToList().Find(x => x == "update_version"), appName);

                    item.Loading = false;
                    item.UpdateAvailable = true;
                    item.Status = version + " Update Ready";
                }
            }
        }
예제 #5
0
        private void Apply(UpdateItem item)
        {
            item.Error = false;
            item.Loading = false;
            item.UpdateAvailable = false;

            if (CheckUpdaterIsRunning())
            {
                item.Status = "Restart TrakHound to Apply Update";

                var message = new WCF_Functions.MessageData("apply");
                message.Data01 = item.ApplicationName;
                SendMessage(message);
            }
            else
            {
                item.Error = true;
                item.Status = "Updater Service Not Running";
            }
        }