コード例 #1
0
        public static void ReinstallInstance([NotNull] Instance instance, Window owner, [NotNull] string license, [NotNull] SqlConnectionStringBuilder connectionString)
        {
            Assert.ArgumentNotNull(instance, "instance");
            Assert.ArgumentNotNull(license, "license");
            Assert.ArgumentNotNull(connectionString, "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)
                    {
                        string         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, typeof(MainWindowHelper));
                                return;
                            }
                        }
                    }
                }

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

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

                var name = instance.Name;
                WizardPipelineManager.Start("reinstall", owner, args, null, () => MainWindowHelper.MakeInstanceSelected(name));
            }
        }