Beispiel #1
0
        private void RemoteUpdateDialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                var dialog     = (RemoteChannelVersionDialog)sender;
                var newVersion = new officeVersion

                {
                    Number = GlobalObjects.ViewModel.newVersion
                };

                var newChannel = new Channel
                {
                    Name = GlobalObjects.ViewModel.newChannel
                };

                if (dialog.Result == DialogResult.OK && !String.IsNullOrEmpty(newVersion.Number) && !String.IsNullOrEmpty(newChannel.Name))
                {
                    for (var i = 0; i < remoteClients.Count; i++)
                    {
                        if (remoteClients[i].include)
                        {
                            var row = (DataGridRow)RemoteMachineList.ItemContainerGenerator.ContainerFromIndex(i);

                            var channelCB = row.FindChild <System.Windows.Controls.ComboBox>("ProductChannel");
                            var versionCB = row.FindChild <System.Windows.Controls.ComboBox>("ProductVersion");

                            channelCB.SelectedValue = GlobalObjects.ViewModel.newChannel;
                            versionCB.SelectedValue = GlobalObjects.ViewModel.newVersion;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
            finally
            {
                GlobalObjects.ViewModel.newChannel = null;
                GlobalObjects.ViewModel.newVersion = null;

                ToggleControlsMulti(true);
                WaitImage.Dispatcher.Invoke(new Action(() =>
                {
                    WaitImage.Visibility = Visibility.Hidden;
                }));
                GlobalObjects.ViewModel.BlockNavigation = false;

                RemoteMachineList.Items.Refresh();
            }
        }
Beispiel #2
0
        private void ProductChannel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                var selectedBranch = (sender as System.Windows.Controls.ComboBox).SelectedValue as string;
                var newVersions    = new List <officeVersion>();
                var branches       = GlobalObjects.ViewModel.Branches;
                var row            = GetAncestorOfType <DataGridRow>(sender as System.Windows.Controls.ComboBox);
                var versionCB      = row.FindChild <System.Windows.Controls.ComboBox>("ProductVersion");


                var branch = branches.Find(a => a.NewName == GlobalObjects.ViewModel.newChannel);

                if (String.IsNullOrEmpty(GlobalObjects.ViewModel.newChannel))
                {
                    branch = branches.Find(a => a.NewName == selectedBranch);
                }


                foreach (var version in branch.Versions)
                {
                    var tempVersion = new officeVersion()
                    {
                        Number = version.Version
                    };

                    newVersions.Add(tempVersion);
                }

                if (row != null)
                {
                    var client = remoteClients[row.GetIndex()];
                    versionCB.ItemsSource = newVersions;
                    versionCB.Items.Refresh();

                    if (String.IsNullOrEmpty(GlobalObjects.ViewModel.newVersion))
                    {
                        versionCB.SelectedValue = client.Version.Number;
                    }
                }
            }
            catch (Exception ex)
            {
                LogErrorMessage(ex);
            }
        }
Beispiel #3
0
        private static List <officeVersion> GetVersions(OfficeBranch currentChannel, List <officeVersion> versions, string currentVersion)
        {
            foreach (var version in currentChannel.Versions)
            {
                if (version.Version.ToString() != currentVersion)
                {
                    var tempVersion = new officeVersion()
                    {
                        Number = version.Version.ToString()
                    };

                    versions.Add(tempVersion);
                }
            }

            var selectedVersion = new officeVersion()
            {
                Number = currentVersion
            };

            versions.Insert(0, selectedVersion);

            return(versions);
        }
Beispiel #4
0
        private async Task CollectMachineData(RemoteMachine remoteMachine)
        {
            var installGenerator = new OfficeInstallManager(remoteMachine.Machine, remoteMachine.WorkGroup, remoteMachine.UserName, remoteMachine.Password);

            try
            {
                remoteMachine.Status = "Checking...";

                RemoteMachineList.ItemsSource = null;
                RemoteMachineList.ItemsSource = remoteClients;

                await installGenerator.InitConnections();

                var officeInstall = await installGenerator.CheckForOfficeInstallAsync();

                var channels = new List <Channel>();

                var versions = new List <officeVersion>();

                if (officeInstall.Channel != null)
                {
                    var branches = GlobalObjects.ViewModel.Branches;

                    var currentChannel = new Channel()
                    {
                        Name = officeInstall.Channel.Trim()
                    };

                    var currentVersion = new officeVersion()
                    {
                        Number = officeInstall.Version.Trim()
                    };

                    versions.Add(currentVersion);
                    channels.Add(currentChannel);

                    foreach (var branch in branches)
                    {
                        if (branch.NewName.ToString() != officeInstall.Channel)
                        {
                            var tempChannel = new Channel()
                            {
                                Name = branch.NewName.ToString()
                            };
                            channels.Add(tempChannel);
                        }
                        else
                        {
                            versions = GetVersions(branch, versions, currentVersion.Number);
                        }
                    }

                    remoteMachine.include         = false;
                    remoteMachine.Machine         = remoteMachine.Machine;
                    remoteMachine.UserName        = remoteMachine.UserName;
                    remoteMachine.Password        = remoteMachine.Password;
                    remoteMachine.WorkGroup       = remoteMachine.WorkGroup;
                    remoteMachine.Status          = "Found";
                    remoteMachine.Channels        = channels;
                    remoteMachine.Channel         = currentChannel;
                    remoteMachine.OriginalChannel = currentChannel;
                    remoteMachine.Versions        = versions;
                    remoteMachine.Version         = currentVersion;
                    remoteMachine.OriginalVersion = currentVersion;

                    RemoteMachineList.ItemsSource = null;
                    RemoteMachineList.ItemsSource = remoteClients;
                }
            }
            catch (Exception ex)
            {
                remoteMachine.Status          = ex.Message;
                RemoteMachineList.ItemsSource = null;
                RemoteMachineList.ItemsSource = remoteClients;

                LogWmiErrorMessage(ex, new RemoteComputer()
                {
                    Name     = remoteMachine.Machine,
                    Domain   = remoteMachine.WorkGroup,
                    UserName = remoteMachine.UserName,
                    Password = remoteMachine.Password
                });
            }
            if (remoteMachine.Status == "Checking...")
            {
                remoteMachine.Status = "Not Found";
            }
            RemoteMachineList.ItemsSource = null;
            RemoteMachineList.ItemsSource = remoteClients;
        }