示例#1
0
        public void RunInstaller()
        {
            if (!VerifyLocalUpdateExists())
                return;
            if (!RecreateFilesDir (filesDir))
                return;

            UpdateExtractor extractor = new UpdateExtractor (updateCacheDir);
            extractor.ProgressChanged += (s, e) =>
            {
                if (e.TotalBytesToTransfer != 0)
                {
                    progressForm.SetProgress ((e.BytesTransferred / e.TotalBytesToTransfer) * 100);
                    progressForm.SetInstruction ("Unzipping " + e.CurrentEntry.FileName);
                }
            };
            extractor.Finished += (s, e) =>
            {
                logger.DebugFormat ("Finished extracting files to {0}", filesDir);
                progressForm.SetInstruction ("Installing files from " + filesDir + " to " + flashDevelopDir);
                Installer installer = new Installer ();

                installer.FileInstalled += (o, ev) => {
                    LogMessage ("File installed: " + ev.FileInstalled.FullName);
                };
                installer.FinishedInstalling += (o, ev) => {
                    Invoke (new Action (FinishedInstalling));
                };
                installer.InstallFailed += (o, ev) => {
                    invokeMessageBox ("Install failed, rolling back...");
                };
                installer.RollingBackFinished += (o, ev) => {
                    invokeMessageBox ("Finished rolling back, exiting.");
                    Application.Exit ();
                };

                installer.Start (
                    new DirectoryInfo (updateCacheDir),
                    new FileInfo (flashDevelopAssemblyPath));
            };
            extractor.Unzip (versionToInstall);

            progressForm.SetInstruction ("Extracting files files from " + versionToInstall + ".zip");
            progressForm.ShowDialog (this);
        }