private void AddSolr_Click(object sender, RoutedEventArgs e)
        {
            SolrDefinition solr = WindowHelper.ShowDialog <AddSolrDialog>(ProfileManager.Profile.Solrs, this.owner) as SolrDefinition;

            if (solr != null)
            {
                ProfileManager.Profile.Solrs.Add(solr);
                ProfileManager.SaveChanges(ProfileManager.Profile);
                this.Solrs.SelectedItem = solr;
            }
        }
 private void RefreshSolrText()
 {
     if (this.Profile.Solrs.Count > 1)
     {
         this.SolrsText.Text = "multiple instances";
     }
     else
     {
         SolrDefinition solr = this.Profile.Solrs.FirstOrDefault();
         if (solr != null)
         {
             this.SolrsText.Text = string.Join(";", solr.Name, solr.Url, solr.Root, solr.Service);
         }
         else
         {
             this.SolrsText.Text = "No solrs configured. Click '...' to add one.";
         }
     }
 }
示例#3
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            SolrDefinition solr = new SolrDefinition();

            solr.Name    = this.NameText.Text;
            solr.Root    = this.RootText.Text;
            solr.Url     = this.UrlText.Text;
            solr.Service = this.ServiceText.Text;
            string error = solr.ValidateAndGetError();

            if (!string.IsNullOrEmpty(error))
            {
                MessageBox.Show(error);
                return;
            }

            this.DataContext  = solr;
            this.DialogResult = true;
            this.Close();
        }
        public bool OnMovingNext(WizardArgs wizardArgs)
        {
            var productRevision = ProductRevision;

            Assert.IsNotNull(productRevision, nameof(productRevision));

            Product product = productRevision.SelectedValue as Product;

            Assert.IsNotNull(product, nameof(product));


            var name = GetValidWebsiteName();

            if (name == null)
            {
                return(false);
            }

            var connectionString = ProfileManager.GetConnectionString();

            SqlServerManager.Instance.ValidateConnectionString(connectionString);

            var licensePath = ProfileManager.Profile.License;

            Assert.IsNotNull(licensePath, @"The license file isn't set in the Settings window");
            FileSystem.FileSystem.Local.File.AssertExists(licensePath, "The {0} file is missing".FormatWith(licensePath));


            var args = (Install9WizardArgs)wizardArgs;

            args.Validate                 = this.runValidation.IsChecked.Value;
            args.InstanceName             = name;
            args.InstanceProduct          = product;
            args.InstanceConnectionString = connectionString;
            args.LicenseFileInfo          = new FileInfo(licensePath);
            args.Product = product;

            SolrDefinition solr = this.Solrs.SelectedItem as SolrDefinition;

            if (solr == null)
            {
                WindowHelper.ShowMessage("Please provide solr.");
                return(false);
            }

            args.SolrUrl    = solr.Url;  //this.solrUrl.Text;
            args.SorlRoot   = solr.Root; //this.solrRoot.Text;
            args.ScriptRoot = System.IO.Path.Combine(Directory.GetParent(args.Product.PackagePath).FullName, System.IO.Path.GetFileNameWithoutExtension(args.Product.PackagePath));

            if (!this.IsFilePathLengthValidInPackage(args.Product.PackagePath, args.ScriptRoot))
            {
                return(false);
            }

            if (!Directory.Exists(args.ScriptRoot))
            {
                Directory.CreateDirectory(args.ScriptRoot);
                WindowHelper.LongRunningTask(() => this.UnpackInstallationFiles(args), "Unpacking unstallation files.", wizardArgs.WizardWindow);
                WindowHelper.LongRunningTask(() => InstallTasksHelper.CopyCustomSifConfig(args), "Copying custom SIF configuration files to the install folder.", wizardArgs.WizardWindow);
                WindowHelper.LongRunningTask(() => InstallTasksHelper.AddUninstallTasks(args), "Add Uninstall tasks to the OOB config files.", wizardArgs.WizardWindow);
            }
            else
            {
                if (MessageBox.Show(string.Format("Path '{0}' already exists. Do you want to overwrite it?", args.ScriptRoot), "Overwrite?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Directory.Delete(args.ScriptRoot, true);
                    Directory.CreateDirectory(args.ScriptRoot);
                    WindowHelper.LongRunningTask(() => this.UnpackInstallationFiles(args), "Unpacking installation files.", wizardArgs.WizardWindow);
                    WindowHelper.LongRunningTask(() => InstallTasksHelper.CopyCustomSifConfig(args), "Copying custom SIF configuration files to the install folder.", wizardArgs.WizardWindow);
                    WindowHelper.LongRunningTask(() => InstallTasksHelper.AddUninstallTasks(args), "Add Uninstall tasks to the OOB config files.", wizardArgs.WizardWindow);
                }
            }

            string rootPath = this.LocationText.Text;

            if (!args.ScriptsOnly)
            {
                if (string.IsNullOrWhiteSpace(rootPath))
                {
                    WindowHelper.ShowMessage("Please specify location.");
                    return(false);
                }

                if (SIM.FileSystem.FileSystem.Local.Directory.Exists(rootPath))
                {
                    if (Directory.EnumerateFileSystemEntries(rootPath).Any())
                    {
                        if (WindowHelper.ShowMessage("The folder with the same name already exists and is not empty. Would you like to delete it?", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.OK) == MessageBoxResult.OK)
                        {
                            SIM.FileSystem.FileSystem.Local.Directory.DeleteIfExists(rootPath, null);
                            SIM.FileSystem.FileSystem.Local.Directory.CreateDirectory(rootPath);
                        }
                    }
                }
                else
                {
                    SIM.FileSystem.FileSystem.Local.Directory.CreateDirectory(rootPath);
                }
            }

            Tasker       tasker    = new Tasker(args.ScriptRoot, Path.GetFileNameWithoutExtension(args.Product.PackagePath), rootPath);
            InstallParam sqlServer = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlServer");

            if (sqlServer != null)
            {
                sqlServer.Value = args.InstanceConnectionString.DataSource;
            }

            InstallParam sqlAdminUser = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminUser");

            if (sqlAdminUser != null)
            {
                sqlAdminUser.Value = args.InstanceConnectionString.UserID;
            }

            InstallParam sqlAdminPass = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminPassword");

            if (sqlAdminPass != null)
            {
                sqlAdminPass.Value = args.InstanceConnectionString.Password;
            }

            InstallParam sqlDbPrefix = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlDbPrefix");

            if (sqlDbPrefix != null)
            {
                sqlDbPrefix.Value = args.InstanceName;
            }

            InstallParam licenseFile = tasker.GlobalParams.FirstOrDefault(p => p.Name == "LicenseFile");

            if (licenseFile != null)
            {
                licenseFile.Value = args.LicenseFileInfo.FullName;
            }

            InstallParam solrRoot = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SolrRoot");

            if (solrRoot != null)
            {
                solrRoot.Value = args.SorlRoot;
            }

            InstallParam solrService = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SolrService");

            if (solrService != null && !string.IsNullOrEmpty(solr.Service))
            {
                solrService.Value = solr.Service; // this.SolrService.Text;
            }

            InstallParam solrUrl = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SolrUrl");

            if (solrUrl != null)
            {
                solrUrl.Value = args.SolrUrl;
            }

            args.ScriptsOnly = this.scriptsOnly.IsChecked ?? false;
            args.Tasker      = tasker;

            VersionToSolr vts = ProfileManager.Profile.VersionToSolrMap.FirstOrDefault(s => s.Vesrion == product.ShortVersion);

            if (vts == null)
            {
                vts         = new VersionToSolr();
                vts.Vesrion = product.ShortVersion;
                ProfileManager.Profile.VersionToSolrMap.Add(vts);
            }

            vts.Solr = solr.Name;
            ProfileManager.SaveChanges(ProfileManager.Profile);

            return(true);
        }