Contains information about what to update. This is a general-purpose class which can be used to download any other type, as opposed to the FrbdkUpdaterSettings.cs class which contains information specific to updating the FRBDK.
Example #1
0
        public static Settings GetSettings(UpdaterRuntimeSettings runtimeSettings)
        {
            var toReturn = new Settings
            {
                Url           = runtimeSettings.FileToDownload,
                SaveFile      = runtimeSettings.LocationToSaveFile,
                Title         = runtimeSettings.FormTitle,
                Passive       = false,
                ForceDownload = true
            };

            toReturn.LocalFileForTimeStamp =
                UserAppPath + @"FRBDK\" +
                FileManager.RemovePath(FileManager.RemoveExtension(runtimeSettings.LocationToSaveFile))
                + @"\timestamp.txt";

            return(toReturn);
        }
Example #2
0
        public static Settings GetSettings(UpdaterRuntimeSettings runtimeSettings)
        {
            var toReturn = new Settings
                               {
                                   Url = runtimeSettings.FileToDownload,
                                   SaveFile = runtimeSettings.LocationToSaveFile,
                                   Title = runtimeSettings.FormTitle,
                                   Passive =  false,
                                   ForceDownload = true
                               };

            toReturn.LocalFileForTimeStamp =
                UserAppPath + @"FRBDK\" +
                FileManager.RemovePath(FileManager.RemoveExtension(runtimeSettings.LocationToSaveFile))
                 + @"\timestamp.txt";

            return toReturn;
        }
Example #3
0
        private void FrmMainLoad(object sender, EventArgs e)
        {
            try
            {
                var extension = FileManager.GetExtension(mFileNameToLoad);

                List <string> stringList = new List <string>();

                if (extension == UpdaterRuntimeSettings.RuntimeSettingsExtension)
                {
                    var updaterRuntimeSettings = UpdaterRuntimeSettings.FromFile(mFileNameToLoad);
                    if (string.IsNullOrEmpty(updaterRuntimeSettings.LocationToSaveFile))
                    {
                        throw new Exception("UserRuntimeSettings LocationToSaveFile is null.  Loaded settings from " + Settings.UserAppPath);
                    }

                    _settings = Settings.GetSettings(updaterRuntimeSettings);
                    Logger.Log("Loading UpdaterRuntimeSettings");

                    if (string.IsNullOrEmpty(_settings.SaveFile))
                    {
                        throw new Exception("The settings SaveFile was null when loading from UpdaterRuntimeSettings");
                    }
                }
                else
                {
                    FrbdkUpdaterSettings tempSettings;

                    if (string.IsNullOrEmpty(mFileNameToLoad))
                    {
                        throw new Exception("The command line argument must not be null");
                    }

                    tempSettings = FrbdkUpdaterSettings.LoadSettings(mFileNameToLoad);
                    stringList.Add("Selected source:" + tempSettings.SelectedSource);
                    _settings = Settings.GetSettings(tempSettings);
                    Logger.Log("Loading FrbdkUpdaterSettings");

                    if (string.IsNullOrEmpty(_settings.SaveFile))
                    {
                        throw new Exception("The settings SaveFile was null when loading from the FRBDKUpdaterSettings");
                    }
                }



                Messaging.ShowAlerts = !_settings.Passive;

                if (!String.IsNullOrEmpty(_settings.Title))
                {
                    UserMessage = _settings.Title;
                }

                var downloader = new Downloader(_settings);

                downloader.ReportProgress   += DownloaderOnReportProgress;
                downloader.ErrorOccured     += DownloaderOnErrorOccured;
                downloader.DownloadComplete += DownloaderOnDownloadComplete;



                downloader.Start();
            }
            catch (Exception outerException)
            {
                MessageBox.Show(outerException.ToString());
            }
        }
        private static bool DownloadFileSync(NewProjectViewModel viewModel, string zipToUnpack, string fileToDownoad)
        {
            EmbeddedExecutableExtractor eee = EmbeddedExecutableExtractor.Self;

            eee.ExtractFile("FlatRedBall.Tools.dll");
            eee.ExtractFile("Ionic.Zip.dll");
            eee.ExtractFile("Ionic.Zlib.dll");
            string resultingLocation = eee.ExtractFile("FRBDKUpdater.exe");


            UpdaterRuntimeSettings urs = new UpdaterRuntimeSettings();
            urs.FileToDownload = fileToDownoad;
            urs.FormTitle = "Downloading " + viewModel.ProjectType.FriendlyName;

            if (string.IsNullOrEmpty(zipToUnpack))
            {
                throw new Exception("The zipToUnpack argument is null - it shouldn't be");
            }

            urs.LocationToSaveFile = zipToUnpack;

            string whereToSaveSettings =
                FileManager.UserApplicationDataForThisApplication + "DownloadInformation." + UpdaterRuntimeSettings.RuntimeSettingsExtension;

            urs.Save(whereToSaveSettings);

            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = resultingLocation;

            // The username for the user may have a space in it
            // so we need to have quotes around the path

            psi.Arguments = "\"" + whereToSaveSettings + "\"";


            Process process = Process.Start(psi);

            while (!process.HasExited)
            {
                System.Threading.Thread.Sleep(200);
            }
            bool succeeded = process.ExitCode == 0;


            return succeeded;
        }