void _bw_DoWork(object sender, DoWorkEventArgs e) { if (e.Argument == null) { return; } var taskArgument = (TaskArgument)e.Argument; var mpService = new MigrateProjectsService(taskArgument.SourceStudioVersion, taskArgument.DestinationStudioVersion); //remove the Select al project object which coresponds with to the first line in the list view var selectAllProjectsObj = taskArgument.Projects.FirstOrDefault(s => s.Name == @"Select all projects"); if (selectAllProjectsObj != null) { taskArgument.Projects.Remove(selectAllProjectsObj); } var selectAllProj = taskArgument.ProjectToBeMoved.FirstOrDefault(s => s.Name == @"Select all projects"); if (selectAllProj != null) { taskArgument.ProjectToBeMoved.Remove(selectAllProj); } _projects = taskArgument.ProjectToBeMoved; mpService.MigrateProjects(taskArgument.Projects, taskArgument.ProjectToBeMoved, taskArgument.MigrateCustomers, _bw.ReportProgress); _bw.ReportProgress(95); if (taskArgument.MigrateTranslationMemories) { mpService.MigrateTranslationMemories(); } if (taskArgument.PluginsToBeMoved.Count > 0) { var selectAllPlugins = taskArgument.PluginsToBeMoved.FirstOrDefault(s => s.PluginName == @"Select all plugins"); if (selectAllPlugins != null) { taskArgument.PluginsToBeMoved.Remove(selectAllPlugins); } MovePlugins(taskArgument.PluginsToBeMoved, taskArgument.SourceStudioVersion.ExecutableVersion.Major); } _bw.ReportProgress(100); }
void _bw_DoWork(object sender, DoWorkEventArgs e) { if (e.Argument == null) { return; } var taskArgument = (TaskArgument)e.Argument; var mpService = new MigrateProjectsService(taskArgument.SourceStudioVersion, taskArgument.DestinationStudioVersion); mpService.MigrateProjects(taskArgument.Projects, taskArgument.ProjectToBeMoved, _bw.ReportProgress); _bw.ReportProgress(95); if (taskArgument.MigrateTranslationMemories) { mpService.MigrateTranslationMemories(); } _bw.ReportProgress(100); }
private void projectMigrationWizzard_BeforeSwitchPages(object sender, CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e) { // get wizard page already displayed WizardPage oldPage = projectMigrationWizzard.Pages[e.OldIndex]; // check if we're going forward from options page if (oldPage == fromStudioVersion && e.NewIndex > e.OldIndex) { var selectedStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects; if (selectedStudioVersionsGeneric.Count == 0) { MessageBox.Show(this, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version, MessageBoxButtons.OK); e.Cancel = true; return; } if (selectedStudioVersionsGeneric.Count > 1) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version , MessageBoxButtons.OK); e.Cancel = true; return; } } if (oldPage == toStudioVersion && e.NewIndex > e.OldIndex) { var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects; if (selectedDestinationStudioVersionsGeneric.Count == 0) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version, MessageBoxButtons.OK); e.Cancel = true; return; } if (selectedDestinationStudioVersionsGeneric.Count > 1) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version , MessageBoxButtons.OK); e.Cancel = true; return; } var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects; var destinationStudioVersion = (StudioVersion)selectedDestinationStudioVersionsGeneric[0]; var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0]; if (destinationStudioVersion.Equals(selectedSourceStudioVersionsGeneric[0])) { MessageBox.Show(this, string.Format("Destination version ({0}) must be different than the source version ({1})", destinationStudioVersion.PublicVersion, sourceStudioVersion.PublicVersion), Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Same_version , MessageBoxButtons.OK); e.Cancel = true; return; } var migrateProjects = new MigrateProjectsService(sourceStudioVersion, destinationStudioVersion); var projects = migrateProjects.GetProjectsToBeMigrated(); projectsToBeMoved.SetObjects(projects); foreach (OLVListItem item in from OLVListItem item in projectsToBeMoved.Items let project = (Project)item.RowObject where !Path.IsPathRooted(project.ProjectFilePath) select item) { item.Checked = true; } } }
private void projectMigrationWizzard_BeforeSwitchPages(object sender, CristiPotlog.Controls.Wizard.BeforeSwitchPagesEventArgs e) { // get wizard page already displayed WizardPage oldPage = projectMigrationWizzard.Pages[e.OldIndex]; // check if we're going forward from options page if (oldPage == fromStudioVersion && e.NewIndex > e.OldIndex) { var selectedStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects; if (selectedStudioVersionsGeneric.Count == 0) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version, MessageBoxButtons.OK); e.Cancel = true; return; } if (selectedStudioVersionsGeneric.Count > 1) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version , MessageBoxButtons.OK); e.Cancel = true; return; } } if (oldPage == toStudioVersion && e.NewIndex > e.OldIndex) { var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects; if (selectedDestinationStudioVersionsGeneric.Count == 0) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_a_Studio_version_, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Select_a_studio_version, MessageBoxButtons.OK); e.Cancel = true; return; } if (selectedDestinationStudioVersionsGeneric.Count > 1) { MessageBox.Show(this, Resources .MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Please_select_only_one_version, Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Only_one_version , MessageBoxButtons.OK); e.Cancel = true; return; } var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects; var destinationStudioVersion = (StudioVersion)selectedDestinationStudioVersionsGeneric[0]; var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0]; if (destinationStudioVersion.Equals(selectedSourceStudioVersionsGeneric[0])) { MessageBox.Show(this, string.Format("Destination version ({0}) must be different than the source version ({1})", destinationStudioVersion.PublicVersion, sourceStudioVersion.PublicVersion), Resources.MigrateProjects_projectMigrationWizzard_BeforeSwitchPages_Same_version , MessageBoxButtons.OK); e.Cancel = true; return; } var migrateProjects = new MigrateProjectsService(sourceStudioVersion, destinationStudioVersion); var selectAllProjects = new Project { Name = "Select all projects" }; var projects = migrateProjects.GetProjectsToBeMigrated(); if (projects.Count != 0 && projects.Count != 1) { projects.Insert(0, selectAllProjects); } projectsToBeMoved.SetObjects(projects); foreach (OLVListItem item in from OLVListItem item in projectsToBeMoved.Items let project = (Project)item.RowObject where !Path.IsPathRooted(project.ProjectFilePath) select item) { if (item.Text != @"Select all projects") { item.Checked = true; } } projectsToBeMoved.ItemChecked += ProjectsToBeMoved_ItemChecked; if (projectsToBeMoved.Items.Count > 0) { if (projectsToBeMoved.Items[0].Text == @"Select all projects") { projectsToBeMoved.Items[0].ForeColor = ColorTranslator.FromHtml("#6887B2"); projectsToBeMoved.Items[0].Font = new Font(projectsToBeMoved.Items[0].Font, FontStyle.Bold); } } } #region Plugins page if (oldPage == moveProjects && e.NewIndex > e.OldIndex) { //call Sdl.Community.PluginInfo.dll in order to get the plugin name var currentAssembly = Assembly.GetAssembly(typeof(MigrateProjectsService)); var path = Path.GetDirectoryName(currentAssembly.Location); if (path != null) { var pluginInfoDll = Assembly.LoadFrom(Path.Combine(path, "Sdl.Community.PluginInfo")); var type = pluginInfoDll.GetType("Sdl.Community.PluginInfo.PluginPackageInfo"); var selectedSourceStudioVersionsGeneric = chkSourceStudioVersions.CheckedObjects; var sourceStudioVersion = (StudioVersion)selectedSourceStudioVersionsGeneric[0]; var selectedDestinationStudioVersionsGeneric = chkDestinationStudioVersion.CheckedObjects; var destinationStudioVersion = (StudioVersion)selectedDestinationStudioVersionsGeneric[0]; //get plugins list for source selected studio version var sourcePluginsList = GetInstallledPluginsForSpecificStudioVersion(sourceStudioVersion); //get plugins list for destination selected studio version var destinationPluginsPathList = GetInstallledPluginsForSpecificStudioVersion(destinationStudioVersion); //check if there are any plugins to be migrated for selected verions var pluginsList = sourcePluginsList.Where(p => destinationPluginsPathList.All(d => d.PluginName != p.PluginName)); //call "GetPluginName" method in order to get the plugin name var method = type.GetMethod("GetPluginName"); var constructor = type.GetConstructor( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); var instance = constructor.Invoke(new object[] { }); foreach (var plugin in pluginsList) { var name = method.Invoke(instance, new object[] { plugin.Path }); var pluginToBeMoved = new Model.PluginInfo { Path = plugin.Path, PluginName = name as string }; if (!_pluginsToBeMigrated.Exists(p => p.PluginName == pluginToBeMoved.PluginName)) { _pluginsToBeMigrated.Add(pluginToBeMoved); } } } var selectAllPlugins = new Model.PluginInfo { PluginName = "Select all plugins" }; if (_pluginsToBeMigrated.Count > 1 && !_pluginsToBeMigrated.Exists(p => p.PluginName == selectAllPlugins.PluginName)) { _pluginsToBeMigrated.Insert(0, selectAllPlugins); } installedPluginsListView.SetObjects(_pluginsToBeMigrated); installedPluginsListView.ItemChecked += InstalledPluginsListView_ItemChecked; if (installedPluginsListView.Items.Count > 0) { if (installedPluginsListView.Items[0].Text == @"Select all plugins") { installedPluginsListView.Items[0].ForeColor = ColorTranslator.FromHtml("#6887B2"); installedPluginsListView.Items[0].Font = new Font(installedPluginsListView.Items[0].Font, FontStyle.Bold); } } } #endregion }