private static void LogProgress(StorePackageUpdateStatus progress)
        {
            string packageName = progress.PackageFamilyName;

            ulong bytesDownloaded = progress.PackageBytesDownloaded;
            ulong totalBytes      = progress.PackageDownloadSizeInBytes;

            double downloadProgress        = progress.PackageDownloadProgress;
            double overallDownloadProgress = progress.TotalDownloadProgress;

            switch (progress.PackageUpdateState)
            {
            case StorePackageUpdateState.Pending:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " is pending");
                break;

            case StorePackageUpdateState.Downloading:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " is downloading");
                break;

            case StorePackageUpdateState.Completed:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " is completed");
                break;

            case StorePackageUpdateState.Canceled:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " is cancelled");
                break;

            case StorePackageUpdateState.OtherError:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " has encountered an error");
                break;

            case StorePackageUpdateState.ErrorLowBattery:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " has stopped due to low battery");
                break;

            case StorePackageUpdateState.ErrorWiFiRecommended:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " has stopped due to no Wi-Fi recommendation");
                break;

            case StorePackageUpdateState.ErrorWiFiRequired:
                System.Diagnostics.Debug.WriteLine("Package download for " + packageName + " has stopped due to Wi-Fi requirement");
                break;
            }
        }
Example #2
0
        private static void LogProgress(StorePackageUpdateStatus progress)
        {
            string packageName = progress.PackageFamilyName;

            switch (progress.PackageUpdateState)
            {
            case StorePackageUpdateState.Pending:
                App.LogService.Write("Package download for " + packageName + " is pending");
                break;

            case StorePackageUpdateState.Downloading:
                App.LogService.Write("Package download for " + packageName + " is downloading");
                break;

            case StorePackageUpdateState.Completed:
                App.LogService.Write("Package download for " + packageName + " is completed");
                break;

            case StorePackageUpdateState.Canceled:
                App.LogService.Write("Package download for " + packageName + " is cancelled");
                break;

            case StorePackageUpdateState.ErrorLowBattery:
                App.LogService.Write("Package download for " + packageName + " has stopped due to low battery");
                break;

            case StorePackageUpdateState.ErrorWiFiRecommended:
                App.LogService.Write("Package download for " + packageName + " has stopped due to no Wi-Fi recommendation");
                break;

            case StorePackageUpdateState.ErrorWiFiRequired:
                App.LogService.Write("Package download for " + packageName + " has stopped due to Wi-Fi requirement");
                break;

            case StorePackageUpdateState.OtherError:
                App.LogService.Write("Package download for " + packageName + " has encountered an error");
                break;
            }
        }
        private async void ShowProgress(StorePackageUpdate update, StorePackageUpdateStatus progressInfo)
        {
            try
            {
                string displayName             = update.Package.DisplayName;
                string packageFamilyName       = progressInfo.PackageFamilyName;
                ulong  bytesDownloaded         = progressInfo.PackageBytesDownloaded;
                ulong  totalBytes              = progressInfo.PackageDownloadSizeInBytes;
                double downloadProgress        = progressInfo.PackageDownloadProgress;
                double overallDownloadProgress = progressInfo.TotalDownloadProgress;

                PackageDeploymentControl currentPackage;
                lock (packageUpdates)
                {
                    // Get the UI Context and create one if one doesn't exist
                    if (!packageUpdates.ContainsKey(packageFamilyName))
                    {
                        PackageDeploymentControl control = new PackageDeploymentControl(update.Package);
                        packageUpdates.Add(packageFamilyName, control);
                        packageUpdatesUI.Add(control);
                    }

                    currentPackage = packageUpdates[packageFamilyName];
                }

                lock (currentPackage)
                {
                    // Possible states for each package
                    switch (progressInfo.PackageUpdateState)
                    {
                    case StorePackageUpdateState.Pending:
                        currentPackage.ProgressBar.IsIndeterminate = true;
                        break;

                    case StorePackageUpdateState.Downloading:
                        currentPackage.ProgressBar.IsIndeterminate = false;
                        currentPackage.ProgressBar.Value           = overallDownloadProgress * 100;
                        break;

                    case StorePackageUpdateState.Completed:
                        //packageUpdates.Remove(currentPackage.PackageFamilyName);
                        //packageUpdatesUI.Remove(currentPackage);
                        currentPackage.SetAsDone();
                        break;

                    case StorePackageUpdateState.Canceled:
                        packageUpdates.Remove(currentPackage.PackageFamilyName);
                        packageUpdatesUI.Remove(currentPackage);

                        break;

                    case StorePackageUpdateState.OtherError:
                        // Download and/or Install errored
                        break;

                    case StorePackageUpdateState.ErrorLowBattery:
                        // Download and/or Install stopped due to low battery
                        break;

                    case StorePackageUpdateState.ErrorWiFiRecommended:
                        // Download and/or Install stopped due to Wi-Fi recommendated
                        break;

                    case StorePackageUpdateState.ErrorWiFiRequired:
                        // Download and/or Install stopped due to Wi-Fi required
                        break;

                    default:
                        // Future proof the switch block
                        throw new InvalidOperationException();
                    }
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog("Error while showing progress during async update. {" + err(ex) + "}").ShowAsync();
            }
        }