Ejemplo n.º 1
0
        public static void BackupInstance(InstallWizardArgs args)
        {
            var id = MainWindowHelper.GetListItemID(args.Instance.ID);

            Assert.IsTrue(id >= 0, "id ({0}) should be >= 0".FormatWith(id));
            WizardPipelineManager.Start("backup", args.WizardWindow, new BackupArgs(args.Instance, ProfileManager.GetConnectionString(), null, true, true), null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new BackupSettingsWizardArgs(args.Instance));
        }
        public static void BackupInstance(InstallWizardArgs args)
        {
            int id = MainWindowHelper.GetListItemID(args.Instance.ID);

            Assert.IsTrue(id >= 0, "id ({0}) should be >= 0".FormatWith(id));
            WizardPipelineManager.Start("backup", args.WizardWindow, new BackupArgs(args.Instance, null, true, true), null, () => MainWindowHelper.MakeInstanceSelected(id), args.Instance);
        }
Ejemplo n.º 3
0
        private static bool InitializePipelines()
        {
            using (new ProfileSection("Re-initializing pipelines"))
            {
                try
                {
                    var pipelinesConfig = XmlDocumentEx.LoadXml(PipelinesConfig.Contents);

                    var wizardPipelinesConfig = XmlDocumentEx.LoadXml(WizardPipelinesConfig.Contents);
                    var pipelinesNode         = wizardPipelinesConfig.SelectSingleNode("/configuration/pipelines") as XmlElement;
                    if (pipelinesNode != null)
                    {
                        pipelinesConfig.Merge(XmlDocumentEx.LoadXml(pipelinesNode.OuterXml));
                    }

                    var resultPipelinesNode = pipelinesConfig.SelectSingleNode("/pipelines") as XmlElement;
                    Assert.IsNotNull(resultPipelinesNode, "Can't find pipelines configuration node");

                    PipelineManager.Initialize(resultPipelinesNode);

                    WizardPipelineManager.Initialize(wizardPipelinesConfig.DocumentElement);

                    return(true);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Error during initializing pipelines", true, ex);

                    return(false);
                }
            }
        }
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (FileSystem.FileSystem.Local.Directory.Exists(ProfileManager.Profile.LocalRepository))
     {
         WizardPipelineManager.Start("download8", mainWindow, null, null, ignore => MainWindowHelper.RefreshInstaller(), () => new DownloadWizardArgs(WindowsSettings.AppDownloaderSdnUserName.Value, WindowsSettings.AppDownloaderSdnPassword.Value));
     }
 }
Ejemplo n.º 5
0
        public override IEnumerable <FinishAction> GetFinishActions(WizardArgs wizardArgs)
        {
            InstallModulesWizardArgs installModulesWizardArgs = (InstallModulesWizardArgs)wizardArgs;
            List <Product>           modules = installModulesWizardArgs._Modules;

            foreach (var module in modules)
            {
                XmlDocument manifest = module.Manifest;
                if (manifest != null && manifest != Product.EmptyManifest)
                {
                    XmlElement finish = (XmlElement)manifest.SelectSingleNode("manifest/*/finish");
                    if (finish == null)
                    {
                        continue;
                    }

                    foreach (FinishAction action in WizardPipelineManager.GetFinishActions(finish, WizardArgumentsType))
                    {
                        yield return(new FinishAction(action.Text, action.Method));
                    }
                }
            }

            wizardArgs.HasInstallationBeenCompleted = true;
        }
Ejemplo n.º 6
0
        private static bool InitializeProfileManager(Window mainWindow)
        {
            using (new ProfileSection("Initialize profile manager"))
            {
                ProfileSection.Argument("mainWindow", mainWindow);

                try
                {
                    ProfileManager.Initialize();
                    if (ProfileManager.IsValid)
                    {
                        return(ProfileSection.Result(true));
                    }

                    // if current profile is not valid then we will show the legacy profile if it exists, or at least use invalid one
                    WizardPipelineManager.Start("setup", mainWindow, null, false, null, ProfileManager.Profile ?? DetectProfile());
                    if (ProfileManager.IsValid)
                    {
                        return(ProfileSection.Result(true));
                    }
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Profile manager failed during initialization. " + AppLogsMessage, true, ex);
                }

                return(ProfileSection.Result(false));
            }
        }
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var id = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("backup", mainWindow, new BackupArgs(instance), null, () => MainWindowHelper.MakeInstanceSelected(id), instance);
     }
 }
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var id = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("installmodules", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new InstallModulesWizardArgs(instance));
     }
 }
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var id = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("backup", mainWindow, new BackupArgs(instance, ProfileManager.GetConnectionString()), null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new BackupSettingsWizardArgs(instance));
     }
 }
Ejemplo n.º 10
0
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var id = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("export", mainWindow, new ExportArgs(instance, false, true, true, true, false, false, false, false, false), null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new ExportWizardArgs(instance, string.Empty));
     }
 }
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var args = new RestoreArgs(instance, new SqlConnectionStringBuilder(Profile.Read(new RealFileSystem()).ConnectionString));
         var id   = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("restore", mainWindow, args, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new RestoreWizardArgs(instance));
     }
 }
Ejemplo n.º 12
0
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var args = new RestoreArgs(instance);
         var id   = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("restore", mainWindow, args, null, () => MainWindowHelper.MakeInstanceSelected(id), instance);
     }
 }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("Download");

            if (FileSystem.FileSystem.Local.Directory.Exists(ProfileManager.Profile.LocalRepository))
            {
                WizardPipelineManager.Start("download", mainWindow, null, null, MainWindowHelper.RefreshInstaller, WindowsSettings.AppDownloaderSdnUserName.Value, WindowsSettings.AppDownloaderSdnPassword.Value);
            }
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("Export");

            if (instance != null)
            {
                var id = MainWindowHelper.GetListItemID(instance.ID);
                WizardPipelineManager.Start("export", mainWindow, new ExportArgs(instance, false, true, true, true, false, false, false, false, false), null, () => MainWindowHelper.MakeInstanceSelected(id), instance, string.Empty);
            }
        }
Ejemplo n.º 15
0
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("Backup");

            if (instance != null)
            {
                var id = MainWindowHelper.GetListItemID(instance.ID);
                WizardPipelineManager.Start("backup", mainWindow, new BackupArgs(instance), null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new BackupSettingsWizardArgs(instance));
            }
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("InstallModules");

            if (instance != null)
            {
                var id = MainWindowHelper.GetListItemID(instance.ID);
                WizardPipelineManager.Start("installmodules", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), instance);
            }
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Assert.ArgumentNotNull(mainWindow, nameof(mainWindow));

            Analytics.TrackEvent("Import");

            var fileDialog = new OpenFileDialog
            {
                Title       = "Select zip file of exported solution",
                Multiselect = false,
                DefaultExt  = ".zip"
            };

            fileDialog.ShowDialog();
            var filePath = fileDialog.FileName;

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

            Log.Info($"Importing solution from {filePath}");
            var fileSystem = new RealFileSystem();
            var file       = fileSystem.ParseFile(filePath);

            using (var zipFile = new RealZipFile(fileSystem.ParseFile(file.FullName)))
            {
                const string AppPoolFileName = "AppPoolSettings.xml";
                var          appPool         = zipFile.Entries.Contains(AppPoolFileName);
                if (!appPool)
                {
                    WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(AppPoolFileName));
                    return;
                }

                const string WebsiteSettingsFileName = "WebsiteSettings.xml";
                var          websiteSettings         = zipFile.Entries.Contains(WebsiteSettingsFileName);
                if (!websiteSettings)
                {
                    WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(WebsiteSettingsFileName));

                    return;
                }

                const string WebConfigFileName = @"Website/Web.config";
                if (!zipFile.Entries.Contains(WebConfigFileName))
                {
                    WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(WebConfigFileName));

                    return;
                }
            }

            WizardPipelineManager.Start("import", mainWindow, null, null, ignore => MainWindowHelper.SoftlyRefreshInstances(), () => new ImportWizardArgs(file.FullName));
        }
        public static void ReinstallInstance([NotNull] Instance instance, Window owner, [NotNull] string license, [NotNull] SqlConnectionStringBuilder connectionString)
        {
            Assert.ArgumentNotNull(instance, nameof(instance));
            Assert.ArgumentNotNull(license, nameof(license));
            Assert.ArgumentNotNull(connectionString, nameof(connectionString));

            if (instance.IsSitecore)
            {
                Product product = instance.Product;
                if (string.IsNullOrEmpty(product.PackagePath))
                {
                    if (WindowHelper.ShowMessage("The {0} product isn't presented in your local repository. Would you like to choose the zip installation package?".FormatWith(instance.ProductFullName), MessageBoxButton.YesNo, MessageBoxImage.Stop) == MessageBoxResult.Yes)
                    {
                        var            patt = instance.ProductFullName + ".zip";
                        OpenFileDialog fileBrowserDialog = new OpenFileDialog
                        {
                            Title           = @"Choose installation package",
                            Multiselect     = false,
                            CheckFileExists = true,
                            Filter          = patt + '|' + patt
                        };

                        if (fileBrowserDialog.ShowDialog() == DialogResult.OK)
                        {
                            product = Product.Parse(fileBrowserDialog.FileName);
                            if (string.IsNullOrEmpty(product.PackagePath))
                            {
                                WindowHelper.HandleError("SIM can't parse the {0} package".FormatWith(instance.ProductFullName), true, null);
                                return;
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(product.PackagePath))
                {
                    return;
                }

                ReinstallArgs args;
                try
                {
                    args = new ReinstallArgs(instance, connectionString, license, SIM.Pipelines.Install.Settings.CoreInstallWebServerIdentity.Value, Settings.CoreInstallNotFoundTransfer.Value);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError(ex.Message, false, ex);
                    return;
                }

                var name = instance.Name;
                WizardPipelineManager.Start("reinstall", owner, args, null, ignore => MainWindowHelper.MakeInstanceSelected(name));
            }
        }
Ejemplo n.º 19
0
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var connectionString = ProfileManager.GetConnectionString();
         var args             = new DeleteArgs(instance, connectionString);
         args.OnCompleted += () => mainWindow.Dispatcher.Invoke(() => OnPipelineCompleted(args.RootPath));
         var index = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("delete", mainWindow, args, null, (ignore) => OnWizardCompleted(index), () => null);
     }
 }
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("Restore");

            if (instance != null)
            {
                var args = new RestoreArgs(instance);
                var id   = MainWindowHelper.GetListItemID(instance.ID);
                WizardPipelineManager.Start("restore", mainWindow, args, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new RestoreWizardArgs(instance));
            }
        }
Ejemplo n.º 21
0
        public static void Reinstall9Instance([NotNull] Instance instance, Window owner, [NotNull] string license, [NotNull] SqlConnectionStringBuilder connectionString)
        {
            Assert.ArgumentNotNull(instance, nameof(instance));
            Assert.ArgumentNotNull(license, nameof(license));
            Assert.ArgumentNotNull(connectionString, nameof(connectionString));

            if (instance.IsSitecore || instance.IsSitecoreEnvironmentMember)
            {
                var name = instance.Name;
                WizardPipelineManager.Start("reinstall9", owner, null, null, ignore => MakeInstanceSelected(name), () => new ReinstallWizardArgs(instance, connectionString, license));
            }
        }
Ejemplo n.º 22
0
        public void OnClick(Window mainWindow, Instance instance)
        {
            Assert.ArgumentNotNull(mainWindow, "mainWindow");

            Analytics.TrackEvent("Import");

            var fileDialog = new OpenFileDialog
            {
                Title       = "Select zip file of exported solution",
                Multiselect = false,
                DefaultExt  = ".zip"
            };

            fileDialog.ShowDialog();
            var filePath = fileDialog.FileName;

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

            const string AppPoolFileName = "AppPoolSettings.xml";
            var          appPool         = FileSystem.Local.Zip.ZipContainsFile(filePath, AppPoolFileName);

            if (!appPool)
            {
                WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(AppPoolFileName));
                return;
            }

            const string WebsiteSettingsFileName = "WebsiteSettings.xml";
            var          websiteSettings         = FileSystem.Local.Zip.ZipContainsFile(filePath, WebsiteSettingsFileName);

            if (!websiteSettings)
            {
                WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(WebsiteSettingsFileName));

                return;
            }

            const string WebConfigFileName = @"Website/Web.config";

            if (!FileSystem.Local.Zip.ZipContainsFile(filePath, WebConfigFileName))
            {
                WindowHelper.ShowMessage("Wrong package for import. The package does not contain the {0} file.".FormatWith(WebConfigFileName));

                return;
            }

            WizardPipelineManager.Start("import", mainWindow, null, null, MainWindowHelper.SoftlyRefreshInstances, filePath);
        }
Ejemplo n.º 23
0
        private void FinishUnsafe([NotNull] string message, bool allDone)
        {
            Assert.ArgumentNotNull(message, "message");

            using (new ProfileSection("Finish wizard (unsafe)", this))
            {
                ProfileSection.Argument("message", message);
                ProfileSection.Argument("allDone", allDone);

                if (allDone)
                {
                    this.AddFinishActions(this.wizardPipeline.FinishActions);

                    if (this.wizardPipeline.FinishActionHives != null)
                    {
                        foreach (FinishActionHive hive in this.wizardPipeline.FinishActionHives.NotNull())
                        {
                            this.AddFinishActions(hive.GetFinishActions(this.ProcessorArgs));
                        }
                    }

                    foreach (var plugin in PluginManager.GetEnabledPlugins())
                    {
                        var actionElements = plugin.PluginXmlDocument.SelectNodes("/plugin/wizards/" + this.wizardPipeline.Name + "/finish/action");
                        foreach (var actionElement in actionElements.OfType <XmlElement>())
                        {
                            var finishAction = WizardPipelineManager.ParseFinishAction(this.ProcessorArgs.GetType(), actionElement);
                            this.AddFinishAction(finishAction);
                        }
                    }

                    this.FinishTextBlock.Text          = this.wizardPipeline.FinishText;
                    this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
                    this.Progress = 0;
                    this.NextButton.Visibility = Visibility.Hidden;
                    this.CancelButton.Content  = "Finish";
                    this.CancelButton.Focus();
                    this.PageNumber++;
                    this.HeaderDetails.Text = "Completed";
                }
                else
                {
                    this.SetStatusUnsafe("Some steps require your attention");
                    this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error;
                    this.progressBar1.Foreground       = Brushes.Red;
                    this.NextButton.IsEnabled          = true;
                }
            }
        }
Ejemplo n.º 24
0
        public static void ReinstallInstance([NotNull] Instance instance, Window owner, [NotNull] string license, [NotNull] SqlConnectionStringBuilder connectionString)
        {
            Assert.ArgumentNotNull(instance, nameof(instance));
            Assert.ArgumentNotNull(license, nameof(license));
            Assert.ArgumentNotNull(connectionString, nameof(connectionString));

            if (instance.IsSitecore || instance.IsSitecoreEnvironmentMember)
            {
                if (int.Parse(instance.Product.ShortVersion) < 90)
                {
                    Product product = instance.Product;
                    if (string.IsNullOrEmpty(product.PackagePath))
                    {
                        if (WindowHelper.ShowMessage("The {0} product isn't presented in your local repository. Would you like to choose the zip installation package?".FormatWith(instance.ProductFullName), MessageBoxButton.YesNo, MessageBoxImage.Stop) == MessageBoxResult.Yes)
                        {
                            var            patt = instance.ProductFullName + ".zip";
                            OpenFileDialog fileBrowserDialog = new OpenFileDialog
                            {
                                Title           = @"Choose installation package",
                                Multiselect     = false,
                                CheckFileExists = true,
                                Filter          = patt + '|' + patt
                            };

                            if (fileBrowserDialog.ShowDialog() == DialogResult.OK)
                            {
                                product = Product.Parse(fileBrowserDialog.FileName);
                                if (string.IsNullOrEmpty(product.PackagePath))
                                {
                                    WindowHelper.HandleError("SIM can't parse the {0} package".FormatWith(instance.ProductFullName), true, null);
                                    return;
                                }
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(product.PackagePath))
                    {
                        return;
                    }
                }

                var name = instance.Name;
                WizardPipelineManager.Start("reinstall", owner, null, null, ignore => MakeInstanceSelected(name), () => new ReinstallWizardArgs(instance, connectionString, license));
            }
        }
        public void OnClick([NotNull] Window mainWindow, [CanBeNull] Instance instance)
        {
            WizardPipelineManager.Start("install9", mainWindow, null, null, (args) =>
            {
                if (args == null)
                {
                    return;
                }

                var install = (InstallWizardArgs)args;
                var product = install.Product;

                if (install.HasInstallationBeenCompleted)
                {
                    MainWindowHelper.SoftlyRefreshInstances();
                }
            }, () => new Install9WizardArgs());
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            if (instance != null)
            {
                var connectionString = ProfileManager.GetConnectionString();
                var args             = new DeleteArgs(instance, connectionString);
                args.OnCompleted += () => mainWindow.Dispatcher.Invoke(() => OnPipelineCompleted(args));
                var index = MainWindowHelper.GetListItemID(instance.ID);
                int version;
                if (int.TryParse(instance.Product.ShortVersion, out version) && version < 90)
                {
                    WizardPipelineManager.Start("delete", mainWindow, args, null, (ignore) => OnWizardCompleted(index, args.HasInstallationBeenCompleted), () => null);
                }
                else
                {
                    string uninstallPath    = string.Empty;
                    SitecoreEnvironment env = SitecoreEnvironmentHelper.GetExistingSitecoreEnvironment(instance.Name);
                    if (!string.IsNullOrEmpty(env?.UnInstallDataPath))
                    {
                        uninstallPath = env.UnInstallDataPath;
                    }
                    else
                    {
                        foreach (string installName in Directory.GetDirectories(ApplicationManager.UnInstallParamsFolder).OrderByDescending(s => s.Length))
                        {
                            if (instance.Name.StartsWith(Path.GetFileName(installName)))
                            {
                                uninstallPath = installName;
                                break;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(uninstallPath))
                    {
                        WindowHelper.ShowMessage("UnInstall files not found.");
                        return;
                    }

                    Delete9WizardArgs delete9WizardArgsargs = new Delete9WizardArgs(instance, connectionString, uninstallPath);
                    WizardPipelineManager.Start("delete9", mainWindow, null, null, (ignore) => OnWizardCompleted(index, delete9WizardArgsargs.HasInstallationBeenCompleted), () => delete9WizardArgsargs);
                }
            }
        }
Ejemplo n.º 27
0
        public void OnClick(Window mainWindow, Instance instance)
        {
            Assert.IsTrue(ProfileManager.IsValid, "Some of configuration settings are invalid - please fix them in Settings dialog and try again", false);
            Assert.IsTrue(ProductManager.StandaloneProducts.Any(),
                          @"You don't have any standalone product package in your repository. Options to solve:

1. (recommended) Use Ribbon -> Home -> Bundled Tools -> Download Sitecores button to download them.

2. If you already have them then you can either: 

* change the local repository folder (Ribbon -> Home -> Settings button) to the one that contains the files 

* put the files into the current local repository folder: 
" + ProfileManager.Profile.LocalRepository, false);

            if (EnvironmentHelper.CheckSqlServer())
            {
                WizardPipelineManager.Start("install", mainWindow, null, null, MainWindowHelper.SoftlyRefreshInstances);
            }
        }
Ejemplo n.º 28
0
        public void OnClick(Window mainWindow, Instance instance)
        {
            Analytics.TrackEvent("Install");

            Assert.IsTrue(ProfileManager.IsValid, "Some of configuration settings are invalid - please fix them in Settings dialog and try again");
            Assert.IsTrue(ProductManager.StandaloneProducts.Any(),
                          $@"You don't have any standalone product package in your repository. Options to solve:

1. (recommended) Use Ribbon -> Home -> Bundled Tools -> Download Sitecores button to download them.

2. If you already have them then you can either: 

* change the local repository folder (Ribbon -> Home -> Settings button) to the one that contains the files 

* put the files into the current local repository folder: 
{ProfileManager.Profile.LocalRepository}");

            if (EnvironmentHelper.CheckSqlServer())
            {
                WizardPipelineManager.Start("install", mainWindow, null, null, (args) =>
                {
                    MainWindowHelper.SoftlyRefreshInstances();

                    if (args == null)
                    {
                        return;
                    }

                    var install = (InstallWizardArgs)args;
                    var product = install.Product;
                    if (product == null)
                    {
                        return;
                    }

                    Analytics.TrackEvent($"install-{product.Version}");
                }, () => new InstallWizardArgs());
            }
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            var fileDialog = new OpenFileDialog
            {
                Title       = "Select zip file of exported solution",
                Multiselect = false,
                DefaultExt  = ".zip"
            };

            fileDialog.ShowDialog();
            string filePath = fileDialog.FileName;

            if (!string.IsNullOrEmpty(filePath))
            {
                if (FileSystem.FileSystem.Local.Zip.ZipContainsFile(filePath, "AppPoolSettings.xml") && FileSystem.FileSystem.Local.Zip.ZipContainsFile(filePath, "WebsiteSettings.xml") && FileSystem.FileSystem.Local.Zip.ZipContainsFile(filePath, @"Website/Web.config"))
                {
                    WizardPipelineManager.Start("import", mainWindow, null, null, MainWindowHelper.SoftlyRefreshInstances, filePath);
                }
                else
                {
                    WindowHelper.ShowMessage("Wrong package for import.");
                }
            }
        }
Ejemplo n.º 30
0
        protected override void OnStartup([CanBeNull] StartupEventArgs e)
        {
            base.OnStartup(e);

            if (!App.EnsureSingleProcess(e.Args))
            {
                Environment.Exit(0);

                return;
            }

            if (CoreApp.HasBeenUpdated)
            {
                var ver = ApplicationManager.AppVersion;
                if (!string.IsNullOrEmpty(ver))
                {
                    var exists = false;
                    var wc     = new WebClient();
                    var url    = "https://github.com/Sitecore/Sitecore-Instance-Manager/releases/tag/" + ver;
                    try
                    {
                        wc.DownloadString(url);
                        exists = true;
                    }
                    catch
                    {
                        Log.Warn("Tag was not found: {0}", url);
                    }

                    if (exists)
                    {
                        WindowHelper.OpenInBrowser(url, true);
                    }
                }
            }

            if (CoreApp.IsFirstRun || CoreApp.HasBeenUpdated)
            {
                CacheManager.ClearAll();
                foreach (var dir in Directory.GetDirectories(ApplicationManager.TempFolder))
                {
                    Directory.Delete(dir, true);
                }

                var ext = ".deploy.txt";
                foreach (var filePath in Directory.GetFiles(".", "*" + ext, SearchOption.AllDirectories))
                {
                    if (filePath == null)
                    {
                        continue;
                    }

                    var newFilePath = filePath.Substring(0, filePath.Length - ext.Length);
                    if (File.Exists(newFilePath))
                    {
                        File.Delete(newFilePath);
                    }

                    File.Move(filePath, newFilePath);
                }
            }

            if (!App.CheckPermissions())
            {
                Environment.Exit(0);

                return;
            }

            CoreApp.InitializeLogging();

            CoreApp.LogMainInfo();

            if (!App.CheckIIS())
            {
                WindowHelper.ShowMessage("Cannot connect to IIS. Make sure it is installed and running.", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                Environment.Exit(0);

                return;
            }

            // Initializing pipelines from Pipelines.config and WizardPipelines.config files
            if (!App.InitializePipelines())
            {
                Environment.Exit(0);

                return;
            }

            // Application is closing when it doesn't have any window instance therefore it's
            // required to create MainWindow before creating the initial configuration dialog
            var main = App.CreateMainWindow();

            if (main == null)
            {
                Environment.Exit(0);

                return;
            }

            // Initialize Profile Manager
            if (!App.InitializeProfileManager(main))
            {
                Log.Info("Application closes due to invalid configuration");

                // Since the main window instance was already created we need to "dispose" it by showing and closing.
                main.Width  = 0;
                main.Height = 0;
                main.Show();
                main.Close();

                Environment.Exit(0);

                return;
            }

            // Check if user accepted agreement
            var agreementAcceptedFilePath = Path.Combine(ApplicationManager.TempFolder, "agreement-accepted.txt");

            if (!File.Exists(agreementAcceptedFilePath))
            {
                WizardPipelineManager.Start("agreement", main, new ProcessorArgs(), false);
                if (!File.Exists(agreementAcceptedFilePath))
                {
                    Environment.Exit(0);

                    return;
                }
            }

            // Clean up garbage
            CoreApp.DeleteTempFolders();

            Analytics.Start();

            // Show main window
            try
            {
                main.Initialize();
                WindowHelper.ShowDialog(main, null);
            }
            catch (Exception ex)
            {
                WindowHelper.HandleError("Main window caused unhandled exception", true, ex);
            }

            CoreApp.Exit();

            Analytics.Flush();

            Environment.Exit(0);
        }