private async Task UpdateVersions()
        {
            var branch = (OfficeBranch)UpdateBranch.SelectedItem;

            if (branch == null)
            {
                return;
            }

            UpdateTargetVersion.ItemsSource = branch.Versions;
            UpdateTargetVersion.SetValue(TextBoxHelper.WatermarkProperty, branch.CurrentVersion);

            var officeEdition = OfficeEdition.Office32Bit;

            var configXml = GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml;

            if (configXml.Add != null)
            {
                if (configXml.Add.OfficeClientEdition == OfficeClientEdition.Office64Bit)
                {
                    officeEdition = OfficeEdition.Office64Bit;
                }
            }

            if (UpdateUpdatePath.Text.Length > 0)
            {
                var otherFolder = GlobalObjects.SetBranchFolderPath(branch.Branch.ToString(), UpdateUpdatePath.Text);
                if (await GlobalObjects.DirectoryExists(otherFolder))
                {
                    if (!string.IsNullOrEmpty(UpdateUpdatePath.Text))
                    {
                        UpdateUpdatePath.Text = GlobalObjects.SetBranchFolderPath(branch.Branch.ToString(),
                                                                                  UpdateUpdatePath.Text);
                    }
                }
            }

            await GetBranchVersion(branch, officeEdition);
        }
        private async Task DownloadOfficeFiles()
        {
            try
            {
                SetTabStatus(false);
                GlobalObjects.ViewModel.BlockNavigation = true;
                _tokenSource = new CancellationTokenSource();

                UpdateXml();

                ProductUpdateSource.IsReadOnly = true;
                UpdatePath.IsEnabled           = false;

                DownloadProgressBar.Maximum = 100;
                DownloadPercent.Content     = "";

                var configXml = GlobalObjects.ViewModel.ConfigXmlParser.ConfigurationXml;
                var startPath = ProductUpdateSource.Text.Trim();

                if (!string.IsNullOrEmpty(startPath))
                {
                    GlobalObjects.ViewModel.DownloadFolderPath = startPath;
                }

                var channelItems = (List <Channel>)lvUsers.ItemsSource;

                var taskList = new List <Task>();
                _lastUpdated = DateTime.Now.AddDays(-10);
                var startTime = DateTime.Now;

                foreach (var channelItem in channelItems)
                {
                    if (!channelItem.Selected)
                    {
                        continue;
                    }
                    var branch = channelItem.ChannelName;

                    var task = Task.Run(async() =>
                    {
                        try
                        {
                            var proPlusDownloader = new ProPlusDownloader();
                            proPlusDownloader.DownloadFileProgress += (senderfp, progress) =>
                            {
                                if (!_tokenSource.Token.IsCancellationRequested)
                                {
                                    DownloadFileProgress(progress, channelItems, channelItem);
                                }
                            };

                            proPlusDownloader.VersionDetected += (sender, version) =>
                            {
                                UpdateVersion(channelItems, channelItem, version.Version);
                            };

                            if (string.IsNullOrEmpty(startPath))
                            {
                                return;
                            }

                            var languages =
                                (from product in configXml.Add.Products
                                 from language in product.Languages
                                 select language.ID.ToLower()).Distinct().ToList();

                            var officeEdition = GetSelectedEdition();

                            var buildPath = GlobalObjects.SetBranchFolderPath(branch, startPath);

                            Directory.CreateDirectory(buildPath);

                            var setVersion = channelItem.DisplayVersion;

                            await proPlusDownloader.DownloadBranch(new DownloadBranchProperties()
                            {
                                BranchName      = branch,
                                OfficeEdition   = officeEdition,
                                TargetDirectory = buildPath,
                                Languages       = languages,
                                Version         = setVersion
                            }, _tokenSource.Token);

                            if (!_tokenSource.Token.IsCancellationRequested)
                            {
                                UpdatePercentage(channelItems, channelItem.Name);
                            }

                            LogAnaylytics("/ProductView", "Download." + branch);
                        }
                        catch (Exception ex)
                        {
                            if (!ex.Message.ToLower().Contains("aborted"))
                            {
                                ex.LogException(false);
                                UpdateError(channelItems, channelItem.Name, "ERROR: " + ex.Message);
                            }
                        }
                    });

                    if (!GlobalObjects.ViewModel.AllowMultipleDownloads)
                    {
                        await task;
                    }

                    if (_tokenSource.Token.IsCancellationRequested)
                    {
                        break;
                    }

                    var timeTaken = DateTime.Now - startTime;

                    taskList.Add(task);
                    await Task.Delay(new TimeSpan(0, 0, 5));
                }

                await Task.Delay(new TimeSpan(0, 0, 1));

                foreach (var task in taskList)
                {
                    if (task.Exception != null)
                    {
                    }
                    await task;
                }

                //MessageBox.Show("Download Complete");
            }
            finally
            {
                SetTabStatus(true);
                GlobalObjects.ViewModel.BlockNavigation = false;
                ProductUpdateSource.IsReadOnly          = false;
                UpdatePath.IsEnabled      = true;
                DownloadProgressBar.Value = 0;
                DownloadPercent.Content   = "";

                DownloadButton.Content = "Download";
                _tokenSource           = new CancellationTokenSource();
            }
        }