public bool SaveChanges(WizardArgs wizardArgs)
    {
      ImportWizardArgs args = (ImportWizardArgs)wizardArgs;
      List<string> usedBindings = new List<string>();
      foreach (var binding in args.bindings.Where(x => x.IsChecked == true))
      {
        if (this.BindingUsing(binding.hostName))
        {
          usedBindings.Add(binding.hostName);
        }
      }

      if (usedBindings.Count > 0)
      {
        string usedBindingsMessage = string.Empty;
        foreach (string binding in usedBindings)
        {
          usedBindingsMessage += binding + "\n";
        }

        MessageBox.Show("The following bindings are already used:\n" + usedBindingsMessage);
        return false;
      }
      else
      {
        return true;
      }
    }
    bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
    {
      var args = (RestoreWizardArgs)wizardArgs;
      args.Backup = this.backups.SelectedItem as InstanceBackup;

      return true;
    }
 bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
 {
     var args = (SetupWizardArgs)wizardArgs;
       args.LicenseFilePath = this.LicenseFile.Text;
       args.LocalRepositoryFolderPath = this.LocalRepositoryFolder.Text;
       return true;
 }
 bool IFlowControl.OnMovingNext(WizardArgs wizardArgs)
 {
     var args = (SetupWizardArgs)wizardArgs;
       SqlConnection connection = null;
       try
       {
     connection = SIM.Adapters.SqlServer.SqlServerManager.Instance.OpenConnection(new SqlConnectionStringBuilder(args.ConnectionString), true);
     connection.Close();
     return true;
       }
       catch (SqlException ex)
       {
     WindowHelper.HandleError(ex.Message, false, ex, this);
     return false;
       }
       catch (Exception ex)
       {
     WindowHelper.HandleError(ex.Message, true, ex, this);
     return false;
       }
       finally
       {
     if (connection != null)
     {
       connection.Close();
     }
       }
 }
    public void InitializeStep(WizardArgs wizardArgs)
    {
      ImportWizardArgs args = (ImportWizardArgs)wizardArgs;

      // TODO: Parse bindings in (ImportWizardArgs), Fill user control from bindings dictionary, Append all bindings in hosts
      this.siteBindings.DataContext = args.bindings;
    }
    bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
    {
      var args = (ExportWizardArgs)wizardArgs;
      args.ExportFilePath = this.ExportedFile.Text;
      args.IncludeTempFolderContents = !(this.ExcludeTempFolderContents.IsChecked ?? true);
      args.IncludeMediaCacheFolderContents = !(this.ExcludeMediaCacheFolderContents.IsChecked ?? true);
      args.ExcludeLicenseFile = this.ExcludeLicenseFile.IsChecked ?? false;
      args.ExcludeDiagnosticsFolderContents = this.ExcludeDiagnosticsFolderContents.IsChecked ?? false;
      args.ExcludeLogsFolderContents = this.ExcludeLogsFolderContents.IsChecked ?? false;
      args.ExcludePackagesFolderContents = this.ExcludePackagesFolderContents.IsChecked ?? false;
      args.ExcludeUploadFolderContents = this.ExcludeUploadFolderContents.IsChecked ?? false;

      if (this.IsPathValid())
      {
        var path = Path.GetDirectoryName(this.ExportedFile.Text);

        if (!string.IsNullOrEmpty(path))
        {
          FileSystem.FileSystem.Local.Directory.CreateDirectory(path);
          return true;
        }
      }

      WindowHelper.ShowMessage("You have specified the incorrect path or file name.");
      return false;
    }
    void IWizardStep.InitializeStep(WizardArgs wizardArgs)
    {
      var args = (RestoreWizardArgs)wizardArgs;
      this.checkBoxItems.Clear();

      this.checkBoxItems.AddRange(args.Instance.Backups);


      this.backups.DataContext = this.checkBoxItems;
    }
    public bool OnMovingNext(WizardArgs wizardArgs)
    {
      if (this._selectedInstances.Count != 0)
      {
        return true;
      }

      MessageBox.Show("You haven't selected any of the instances");
      return false;
    }
    public bool SaveChanges(WizardArgs wizardArgs)
    {
      var args = (MultipleDeletionWizardArgs)wizardArgs;

      if (this._selectedInstances.Count != 0)
      {
        args.SelectedInstances = this._selectedInstances;
      }

      return true;
    }
    public bool OnMovingNext(WizardArgs wizardArgs)
    {
      var args = (BackupSettingsWizardArgs)wizardArgs;

      if (args.Databases || args.MongoDatabases || args.Files)
      {
        return true;
      }

      MessageBox.Show("You haven't chosen any backup option");
      return false;
    }
        public bool OnMovingNext(WizardArgs wizardArgs)
        {
            var args = (DownloadWizardArgs)wizardArgs;
              bool canMoveNext = args.Products.Count > 0;
              if (!canMoveNext)
              {
            WindowHelper.HandleError("You didn't select any download, please select one to go further", false);
              }

              WindowHelper.LongRunningTask(() => this.PrepareData(args), "Sitecore Versions Downloader", Window.GetWindow(this), "Preparing for downloading");

              return canMoveNext;
        }
        bool IFlowControl.OnMovingNext(WizardArgs wizardArgs)
        {
            var args = (DownloadWizardArgs)wizardArgs;
              if (!string.IsNullOrEmpty(args.Cookies) && this.UserName.Text.EqualsIgnoreCase(args.UserName) && this.Passowrd.Password.EqualsIgnoreCase(args.Password) && args.Releases.Length > 0)
              {
            return true;
              }

              args.Releases = Product.Service.GetVersions("Sitecore CMS")
            .With(x => x.FirstOrDefault(z => !z.Name.StartsWith("8")))
            .With(x => x.Releases.ToArray());

              var username = args.UserName;
              var password = args.Password;
              if (string.IsNullOrEmpty(username))
              {
            WindowHelper.HandleError("The provided username is empty", false);
            return false;
              }

              if (!username.Contains('@'))
              {
            WindowHelper.HandleError("The provided username is not an email", false);
            return false;
              }

              if (string.IsNullOrEmpty(password))
              {
            WindowHelper.HandleError("The provided password is empty", false);
            return false;
              }

              var cookies = string.Empty;
              WindowHelper.LongRunningTask(
            () => cookies = GetSdnCookie(username, password),
            "Download Sitecore 6.x and 7.x Wizard",
            Window.GetWindow(this),
            "Authenticating"); // , "Validating provided credentials and getting an authentication token for downloading files");

              if (string.IsNullOrEmpty(cookies))
              {
            return false;
              }

              args.Cookies = cookies;

              return true;
        }
    bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
    {
      var args = (ExportWizardArgs)wizardArgs;
      args.SelectedDatabases = ((List<ExportDatabase>)this.Databases.DataContext).Where(database => database.IsChecked).Select(database => database.DatabaseName);
      if (this.WipeSqlServerCredentials.IsChecked != null)
      {
        args.WipeSqlServerCredentials = (bool)this.WipeSqlServerCredentials.IsChecked;
      }

      if (this.IncludeMongoDatabases.IsChecked != null)
      {
        args.IncludeMongoDatabases = (bool)this.IncludeMongoDatabases.IsChecked;
      }

      return true;
    }
        public void InitializeStep(WizardArgs wizardArgs)
        {
            var args = (DownloadWizardArgs)wizardArgs;
              this.checkBoxItems.Clear();
              this.Append(args.Releases);

              foreach (var product in args.Products)
              {
            var selectedPRoduct = product;
            ProductDownload8InCheckbox checkBoxItem = this.checkBoxItems.SingleOrDefault(cbi => cbi.Value.Equals(selectedPRoduct));
            if (checkBoxItem != null)
            {
              checkBoxItem.IsChecked = true;
            }
              }

              this.filePackages.DataContext = this.checkBoxItems;
        }
    bool IFlowControl.OnMovingNext(WizardArgs wizardArgs)
    {
      var args = (DownloadWizardArgs)wizardArgs;
      if (!string.IsNullOrEmpty(args.Cookies) && this.UserName.Text.EqualsIgnoreCase(args.UserName) && this.Passowrd.Password.EqualsIgnoreCase(args.Password) && args.Releases.Length > 0)
      {
        return true;
      }

      var username = args.UserName;
      var password = args.Password;
      if (string.IsNullOrEmpty(username))
      {
        WindowHelper.HandleError("The provided username is empty", false);
        return false;
      }

      if (!username.Contains('@'))
      {
        WindowHelper.HandleError("The provided username is not an email", false);
        return false;
      }

      if (string.IsNullOrEmpty(password))
      {
        WindowHelper.HandleError("The provided password is empty", false);
        return false;
      }

      var cookies = string.Empty;
      WindowHelper.LongRunningTask(
        () => cookies = GetMarketplaceCookie(username, password), 
        "Download Sitecore 8.x Wizard", 
        Window.GetWindow(this), 
        "Authenticating");

      if (string.IsNullOrEmpty(cookies))
      {
        return false;
      }

      args.Cookies = cookies;
      return true;
    }
        bool IFlowControl.OnMovingNext(WizardArgs wizardArgs)
        {
            var args = (SetupWizardArgs)wizardArgs;
              var repository = args.LocalRepositoryFolderPath;
              var one = !string.IsNullOrEmpty(repository) && FileSystem.FileSystem.Local.Directory.Exists(repository);
              if (!one)
              {
            WindowHelper.ShowMessage("The Local Repository folder does not exist, please choose existing folder", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK);
            return false;
              }

              var license = args.LicenseFilePath;
              var two = !string.IsNullOrEmpty(license) && FileSystem.FileSystem.Local.File.Exists(license);
              if (!two)
              {
            WindowHelper.ShowMessage("The Sitecore License file does not exist, please choose existing file", MessageBoxButton.OK, MessageBoxImage.Hand, MessageBoxResult.OK);
            return false;
              }

              return true;
        }
        bool IFlowControl.OnMovingNext(WizardArgs wizardArgs)
        {
            var args = (SetupWizardArgs)wizardArgs;

              if (this.Accounts == null)
              {
            return false;
              }

              try
              {
            const string message = "You probably don't have necessary permissions set. Please try to click 'Grant' button before you proceed.";
            foreach (var account in this.Accounts)
            {
              if (!this.ValidateAccount(account))
              {
            return false;
              }

              if (!FileSystem.FileSystem.Local.Security.HasPermissions(args.InstancesRootFolderPath, account, FileSystemRights.FullControl))
              {
            WindowHelper.ShowMessage(message, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            return false;
              }
            }

            if (!SqlServerManager.Instance.TestSqlServer(args.InstancesRootFolderPath, args.ConnectionString))
            {
              WindowHelper.ShowMessage(message, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
              return false;
            }

            return true;
              }
              catch (Exception ex)
              {
            Log.Error("Cannot verify permissions", this, ex);
            return true;
              }
        }
    public override IEnumerable<FinishAction> GetFinishActions(WizardArgs wizardArgs)
    {
      InstallModulesWizardArgs installModulesWizardArgs = (InstallModulesWizardArgs)wizardArgs;
      List<Product> modules = installModulesWizardArgs.Modules;
      foreach (Product 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, this.WizardArgumentsType))
          {
            yield return new FinishAction(action.Text, action.Method);
          }
        }
      }
    }
        bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
        {
            var args = (ImportWizardArgs)wizardArgs;
              if (WebServerManager.WebsiteExists(this.websiteName.Text))
              {
            this.websiteNameWarn.Visibility = System.Windows.Visibility.Visible;
            return false;
              }

              this.websiteNameWarn.Visibility = System.Windows.Visibility.Hidden;

              if (FileSystem.FileSystem.Local.Directory.Exists(this.rootFolderPath.Text) && FileSystem.FileSystem.Local.Directory.GetFiles(this.rootFolderPath.Text).Length > 0)
              {
            this.rootPathWarn.Visibility = System.Windows.Visibility.Visible;
            return false;
              }

              args.siteName = this.websiteName.Text;
              args.rootPath = this.rootFolderPath.Text;
              args.updateLicense = this.updateLicense.IsChecked == true ? true : false;
              args.pathToLicenseFile = ProfileManager.Profile.License;
              return true;
        }
        public void InitializeStep(WizardArgs wizardArgs)
        {
            this.WizardArgs = wizardArgs;
              var args = (InstallModulesWizardArgs)wizardArgs;
              this.checkBoxItems.Clear();
              foreach (var folder in EnvironmentHelper.ConfigurationPackageFolders)
              {
            this.Append(folder, args.Product);
              }

              this.unfilteredCheckBoxItems = new ObservableCollection<ProductInCheckbox>(this.checkBoxItems);

              foreach (Product module in args.Modules)
              {
            Product alreadySelectedModule = module;
            ProductInCheckbox checkBoxItem = this.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 this.checkBoxItems.NotNull())
            {
              if ((WindowsSettings.AppInstallDefaultCustomPackages.Value ?? string.Empty).Split('|').Any(s => cbi.Name.EqualsIgnoreCase(s)))
              {
            cbi.IsChecked = true;
              }
            }
              }

              this.DoSearch(this.SearchTextBox.Text = string.Empty);
        }
        public bool SaveChanges(WizardArgs wizardArgs)
        {
            var args = (InstallModulesWizardArgs)wizardArgs;
              Product product = args.Product;
              Assert.IsNotNull(product, "product");
              IEnumerable<Product> selected = this.unfilteredCheckBoxItems.Where(mm => mm.IsChecked).Select(s => s.Value);

              foreach (ProductInCheckbox boxItem in this.unfilteredCheckBoxItems)
              {
            int moduleIndex = args.Modules.FindIndex(m => string.Equals(m.Name, boxItem.Value.Name, StringComparison.OrdinalIgnoreCase));
            while (moduleIndex >= 0)
            {
              args.Modules.RemoveAt(moduleIndex);
              moduleIndex = args.Modules.FindIndex(m => string.Equals(m.Name, boxItem.Value.Name, StringComparison.OrdinalIgnoreCase));
            }
              }

              args.Modules.AddRange(selected);

              return true;
        }
 public bool OnMovingNext(WizardArgs wizardArgs)
 {
     return true;
 }
 public bool OnMovingBack(WizardArgs wizardArgs)
 {
     return true;
 }
 void IWizardStep.InitializeStep(WizardArgs wizardArgs)
 {
   ImportWizardArgs args = (ImportWizardArgs)wizardArgs;
   this.websiteName.Text = args.siteName;
   this.rootFolderPath.Text = args.rootPath;
 }
        public bool SaveChanges(WizardArgs wizardArgs)
        {
            var args = (DownloadWizardArgs)wizardArgs;
              var selected = this.checkBoxItems.Where(mm => mm.IsChecked);
              args.Products.AddRange(selected);

              return true;
        }
 public abstract IEnumerable <FinishAction> GetFinishActions(WizardArgs wizardArgs);
        bool IWizardStep.SaveChanges(WizardArgs wizardArgs)
        {
            string username = this.UserName.Text.Trim();

              string password = this.Passowrd.Password;

              var args = (DownloadWizardArgs)wizardArgs;
              args.UserName = username;
              args.Password = password;

              return true;
        }
 void IWizardStep.InitializeStep(WizardArgs wizardArgs)
 {
     var args = (DownloadWizardArgs)wizardArgs;
       this.UserName.Text = args.UserName;
       this.Passowrd.Password = args.Password;
 }
 bool IFlowControl.OnMovingBack(WizardArgs wizardArgs)
 {
     return true;
 }
 public abstract IEnumerable<FinishAction> GetFinishActions(WizardArgs wizardArgs);
 void IWizardStep.InitializeStep(WizardArgs wizardArgs)
 {
     var args = (SetupWizardArgs)wizardArgs;
       this.LicenseFile.Text = args.LicenseFilePath;
       this.LocalRepositoryFolder.Text = args.LocalRepositoryFolderPath.EmptyToNull() ?? GetRepositoryPath();
 }