public static void CanCallCancelDownloadCheck()
        {
            var selectedDrive = new USBHelper.Drive {
                Path = "TestValue866096061", Name = "TestValue539938438"
            };
            var result = SanityCheckHelper.CancelDownloadCheck(selectedDrive);

            Assert.Fail("Create or modify test");
        }
        public void SetUp()
        {
            toTest = new SModel.Ivsu
            {
                Selected = true,
                Type     = "APPS",
                Name     = "5U5T-14G381-AP",
                Version  = "3.4.19101",
                Notes    = null,
                Url      = "https://ivsubinaries.azureedge.net/swparts/5U5T-14G381-AP_1555085337000.TAR.GZ",
                Md5      = "98c289f37416a07ba274585350acaa4c",
                FileName = "5U5T-14G381-AP_1555085337000.TAR.GZ",
                Source   = null
            };

            IvsuList = new System.Collections.ObjectModel.ObservableCollection <SModel.Ivsu>()
            {
                new SModel.Ivsu
                {
                    Selected = false,
                    Type     = "GRACENOTES",
                    Name     = "4U5T-14G423-CA",
                    Version  = "1.1.1.1332",
                    Notes    = "",
                    Url      = "https://ivsubinaries.azureedge.net/swparts/4U5T-14G423-CA_123766.tar.gz",
                    Md5      = "95d8331ef437041ec4edd2163c1f2619",
                    FileName = "4U5T-14G423-CA_123766.tar.gz",
                    Source   = null
                },
                toTest,
                new SModel.Ivsu
                {
                    Selected = false,
                    Type     = "VOICE",
                    Name     = "5U5T-14G391-CL",
                    Version  = null,
                    Notes    = null,
                    Url      = "https://ivsubinaries.azureedge.net/swparts/5U5T-14G391-CL_1580862907000.TAR.GZ",
                    Md5      = "672fc1d83f6a28fb1ec5ca713d23f050",
                    FileName = "5U5T-14G391-CL_1580862907000.TAR.GZ",
                    Source   = null
                },
            };
            merica = new SModel.SRegion()
            {
                Code = "NA", Name = "United States, Canada & Mexico"
            };
            nosavedrive = new USBHelper.Drive()
            {
                Name = "Download Only (NO USB)"
            };
        }
示例#3
0
        public static async Task <bool> Download(string installMode, ObservableCollection <SModel.Ivsu> ivsuList,
                                                 SModel.SRegion selectedRegion, string selectedRelease, string selectedMapVersion, string driveLetter, USBHelper.Drive selectedDrive)
        {
            if (await SetIvsuList(installMode, ivsuList, selectedRegion, selectedRelease, selectedMapVersion, driveLetter) == false)
            {
                await Application.Current.Dispatcher.BeginInvoke(() => UIHelper.ShowErrorDialog(LM.GetValue("MessageBox.NoPackagesSelected")));

                return(false);
            }

            bool canceldownload = false;

            //Install Mode is reformat or downgrade My20 warning
            if ((installMode == "reformat" || installMode == "downgrade") && !AppMan.App.DownloadOnly && AppMan.App.Settings.My20v2 == null)
            {
                if (await Application.Current.Dispatcher.Invoke(() => UIHelper.ShowDialog(string.Format(LM.GetValue("MessageBox.My20Check")), LM.GetValue("String.Warning") + "!", LM.GetValue("String.No"),
                                                                                          LM.GetValue("String.Yes"), null, ContentDialogButton.None, Brushes.DarkRed)) == ContentDialogResult.Primary)
                {
                    await USBHelper.LogPrepareUSBAction(selectedDrive, driveLetter, "logutilitymy20");

                    return(true);
                }
            }

            //Warn is users region is different to new selection
            if (selectedRegion.Code != AppMan.App.Settings.CurrentRegion)
            {
                if (await Application.Current.Dispatcher.Invoke(() => UIHelper.ShowWarningDialog(string.Format(LM.GetValue("MessageBox.CancelRegionMismatch")), LM.GetValue("String.Warning") + "!", LM.GetValue("String.No"),
                                                                                                 LM.GetValue("String.Yes"))) != ContentDialogResult.Primary)
                {
                    canceldownload = true;
                }
            }

            //Cancel no apps package selected
            if (!AppMan.App.AppsSelected && (installMode == "reformat" || installMode == "downgrade"))
            {
                await Application.Current.Dispatcher.BeginInvoke(() => UIHelper.ShowErrorDialog(LM.GetValue("MessageBox.CancelNoApps")));

                canceldownload = true;
            }


            if (!canceldownload && (AppMan.App.DownloadOnly || !await SanityCheckHelper.CancelDownloadCheck(selectedDrive)))
            {
                if (AppMan.App.DownloadOnly)
                {
                    AppMan.Logger.Info($"Starting download only of ({selectedRelease} - {selectedRegion?.Code} - {selectedMapVersion})");
                }
                else
                {
                    AppMan.App.DriveNumber = selectedDrive.Path.Replace("Win32_DiskDrive.DeviceID=\"\\\\\\\\.\\\\PHYSICALDRIVE", "").Replace("\"", "");
                    AppMan.App.DriveLetter = driveLetter;
                    AppMan.Logger.Info($"Starting process ({selectedRelease} - {selectedRegion?.Code} - {selectedMapVersion})");
                }

                AppMan.App.IsDownloading = true;
                AppMan.App.FireDownloadsTabEvent();
                return(true);
            }

            return(false);
        }