void IWizardStep.InitializeStep(WizardArgs wizardArgs)
        {
            var args = (InstallModulesWizardArgs)wizardArgs;

            // create new checkbox list
            Product instanceProduct = args.Product;

            if (instanceProduct == null)
            {
                return;
            }

            var modules = ProductManager.Modules.Where(m => m.IsMatchRequirements(instanceProduct)).OrderByDescending(m => m.SortOrder);
            IEnumerable <string> moduleNames = modules.GroupBy(module => module.Name).Select(moduleGroup => moduleGroup.Key);

            ProductInCheckbox[] productCheckboxes = moduleNames.Select(moduleName => new ProductInCheckbox(moduleName, modules.Where(module => module.Name.EqualsIgnoreCase(moduleName)).OrderByDescending(m => m.VersionAndRevision).ToArray())).ToArray();

            this.productFamilies           = new ObservableCollection <ProductInCheckbox>(productCheckboxes);
            this.unfilteredProductFamilies = new ObservableCollection <ProductInCheckbox>(productCheckboxes);

            foreach (Product module in args.Modules)
            {
                Product           alreadySelectedModule = module;
                ProductInCheckbox checkBoxItem          = productCheckboxes.SingleOrDefault(cbi => cbi.Name.Equals(alreadySelectedModule.Name, StringComparison.OrdinalIgnoreCase));
                if (checkBoxItem != null)
                {
                    checkBoxItem.IsChecked = checkBoxItem.Name == module.Name || module.Name.EqualsIgnoreCase("Sitecore Analytics");
                    checkBoxItem.Value     = module;
                }
            }

            this.DoSearch(this.SearchTextBox.Text = string.Empty);
            this.sitecoreModules.ItemsSource      = this.productFamilies;
        }
Ejemplo n.º 2
0
        public void InitializeStep(WizardArgs wizardArgs)
        {
            WizardArgs = wizardArgs;
            var args = (InstallModulesWizardArgs)wizardArgs;

            _CheckBoxItems.Clear();
            foreach (var folder in EnvironmentHelper.FilePackageFolders)
            {
                Append(folder);
            }

            _UnfilteredCheckBoxItems = new ObservableCollection <ProductInCheckbox>(_CheckBoxItems);

            foreach (var module in args._Modules)
            {
                Product           alreadySelectedModule = module;
                ProductInCheckbox checkBoxItem          = _CheckBoxItems.SingleOrDefault(cbi => cbi.Value.PackagePath.Equals(alreadySelectedModule.PackagePath, StringComparison.OrdinalIgnoreCase));
                if (checkBoxItem != null)
                {
                    checkBoxItem.IsChecked = true;
                }
            }

            if (args is InstallWizardArgs)
            {
                foreach (var cbi in _CheckBoxItems.NotNull())
                {
                    if ((WindowsSettings.AppInstallDefaultCustomPackages.Value ?? string.Empty).Split('|').Any(s => cbi.Name.EqualsIgnoreCase(s)))
                    {
                        cbi.IsChecked = true;
                    }
                }
            }

            DoSearch(SearchTextBox.Text = string.Empty);
        }
 private void SelectAddedPackage(ProductInCheckbox family, Product product)
 {
     family.IsChecked = true;
     family.Value     = product;
 }
 private static Product GetProduct(ProductInCheckbox module, Product product)
 {
     return(module.Scope.FirstOrDefault(version => version.Version.Equals(product.Version, StringComparison.InvariantCultureIgnoreCase) && version.Revision.Equals(product.Revision, StringComparison.InvariantCultureIgnoreCase)));
 }
        public void CustomButtonClick()
        {
            var openDialog = new OpenFileDialog
            {
                CheckFileExists = true,
                Filter          = "Sitecore Package or ZIP Archive (*.zip)|*.zip",
                Title           = "Choose Package",
                Multiselect     = true
            };

            if (openDialog.ShowDialog(Window.GetWindow(this)) != true)
            {
                return;
            }

            foreach (var path in openDialog.FileNames)
            {
                var fileName = Path.GetFileName(path);

                if (string.IsNullOrEmpty(fileName))
                {
                    continue;
                }

                List <ProductInCheckbox> products = null;
                Product addedProduct;

                Product.TryParse(path, out addedProduct);

                if (addedProduct == null || string.IsNullOrEmpty(addedProduct.Name) || string.IsNullOrEmpty(addedProduct.Version) || string.IsNullOrEmpty(addedProduct.Revision))
                {
                    WindowHelper.ShowMessage("Selected file is not a Sitecore module package");
                    return;
                }

                var family = this.GetProductFamily(addedProduct.OriginalName);

                if (family == null)
                {
                    FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(ProfileManager.Profile.LocalRepository, fileName));

                    Product.TryParse(Path.Combine(ProfileManager.Profile.LocalRepository, fileName), out addedProduct);
                    products            = this.productFamilies.ToList();
                    products.Add(family = new ProductInCheckbox(addedProduct.Name, new[]
                    {
                        addedProduct
                    }));

                    this.isProductFamiliesChanged = true;
                }
                else
                {
                    var product = GetProduct(family, addedProduct);

                    if (product == null)
                    {
                        var location = FileSystem.FileSystem.Local.Directory.GetParent(family.Scope.FirstOrDefault().IsNotNull().PackagePath).FullName;
                        FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(location, fileName));
                        Product.TryParse(Path.Combine(location, fileName), out addedProduct);

                        products = this.productFamilies.Where(item => !item.Name.Equals(family.Name, StringComparison.InvariantCultureIgnoreCase)).ToList();
                        products.Insert(this.productFamilies.IndexOf(family), family = new ProductInCheckbox(family.Name, family.Scope.Add(addedProduct).ToArray()));

                        this.isProductFamiliesChanged = true;
                    }
                    else
                    {
                        var location = FileSystem.FileSystem.Local.Directory.GetParent(product.PackagePath).FullName;
                        FileSystem.FileSystem.Local.File.DeleteIfExists(product.PackagePath);
                        FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(location, fileName));
                        addedProduct = product;
                    }
                }

                ProductManager.Initialize(ProfileManager.Profile.LocalRepository);
                this.SelectAddedPackage(family, addedProduct);

                if (this.isProductFamiliesChanged)
                {
                    this.RefreshDataSource(products);
                }
            }
        }
        public void CustomButtonClick()
        {
            var openDialog = new OpenFileDialog
              {
            CheckFileExists = true,
            Filter = "Sitecore Package or ZIP Archive (*.zip)|*.zip",
            Title = "Choose Package",
            Multiselect = true
              };

              if (openDialog.ShowDialog(Window.GetWindow(this)) != true)
              {
            return;
              }

              foreach (var path in openDialog.FileNames)
              {
            var fileName = Path.GetFileName(path);

            if (string.IsNullOrEmpty(fileName))
            {
              continue;
            }

            List<ProductInCheckbox> products = null;
            Product addedProduct;

            Product.TryParse(path, out addedProduct);

            if (addedProduct == null || string.IsNullOrEmpty(addedProduct.Name) || string.IsNullOrEmpty(addedProduct.Version) || string.IsNullOrEmpty(addedProduct.Revision))
            {
              WindowHelper.ShowMessage("Selected file is not a Sitecore module package");
              return;
            }

            var family = this.GetProductFamily(addedProduct.OriginalName);

            if (family == null)
            {
              FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(ProfileManager.Profile.LocalRepository, fileName));

              Product.TryParse(Path.Combine(ProfileManager.Profile.LocalRepository, fileName), out addedProduct);
              products = this.productFamilies.ToList();
              products.Add(family = new ProductInCheckbox(addedProduct.Name, new[]
              {
            addedProduct
              }));

              this.isProductFamiliesChanged = true;
            }
            else
            {
              var product = GetProduct(family, addedProduct);

              if (product == null)
              {
            var location = FileSystem.FileSystem.Local.Directory.GetParent(family.Scope.FirstOrDefault().IsNotNull().PackagePath).FullName;
            FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(location, fileName));
            Product.TryParse(Path.Combine(location, fileName), out addedProduct);

            products = this.productFamilies.Where(item => !item.Name.Equals(family.Name, StringComparison.InvariantCultureIgnoreCase)).ToList();
            products.Insert(this.productFamilies.IndexOf(family), family = new ProductInCheckbox(family.Name, family.Scope.Add(addedProduct).ToArray()));

            this.isProductFamiliesChanged = true;
              }
              else
              {
            var location = FileSystem.FileSystem.Local.Directory.GetParent(product.PackagePath).FullName;
            FileSystem.FileSystem.Local.File.DeleteIfExists(product.PackagePath);
            FileSystem.FileSystem.Local.File.Copy(path, Path.Combine(location, fileName));
            addedProduct = product;
              }
            }

            ProductManager.Initialize(ProfileManager.Profile.LocalRepository);
            this.SelectAddedPackage(family, addedProduct);

            if (this.isProductFamiliesChanged)
            {
              this.RefreshDataSource(products);
            }
              }
        }
 private void SelectAddedPackage(ProductInCheckbox family, Product product)
 {
     family.IsChecked = true;
       family.Value = product;
 }
 private static Product GetProduct(ProductInCheckbox module, Product product)
 {
     return module.Scope.FirstOrDefault(version => version.Version.Equals(product.Version, StringComparison.InvariantCultureIgnoreCase) && version.Revision.Equals(product.Revision, StringComparison.InvariantCultureIgnoreCase));
 }