/// <summary> /// Constructor to intialize the action. it also supports Cancellation in course of operation /// </summary> /// <param name="wizardInfo"></param> public MigrateWorkItemsAction(WizardInfo wizardInfo) : base(wizardInfo) { Description = Resources.MigrateWorkItemsAction_Description; ActionName = WizardActionName.MigrateWorkItems; m_worker.WorkerSupportsCancellation = true; }
public void Reset() { if (WizardInfo != null) { foreach (IWizardPart part in m_wizardPageHashTable.Values) { part.Clear(); } WizardInfo.PropertyChanged -= new PropertyChangedEventHandler(WizardInfo_PropertyChanged); WizardInfo.Dispose(); } WizardInfo = new WizardInfo(); WizardInfo.PropertyChanged += new PropertyChangedEventHandler(WizardInfo_PropertyChanged); if (m_wizardPages == null) { InitializeWizardPages(); InitializeWizardHashTable(); } LoadWizardPart(WizardPage.Welcome); m_wizardPageHashTable[WizardPage.Welcome].CanShow = true; CanStartAgain = false; Title = "Test Case Migrator Plus"; }
/// <summary> /// We can initialize it if Data Source and Server connection is provided /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { string title = null; string likelyCause = null; string potentialSolution = null; m_canShow = true; if (info.DataSourceParser == null) { m_canShow = false; title = Resources.SettingsFilePart_CantShowTitle; likelyCause = Resources.DataSourceNotEnteredErrorLikelyCause; potentialSolution = Resources.DataSourceNotEnteredErrorPotentialSolution; } else if (info.WorkItemGenerator == null || info.WorkItemGenerator.TfsNameToFieldMapping == null || info.WorkItemGenerator.TfsNameToFieldMapping.Count == 0) { m_canShow = false; title = Resources.SettingsFilePart_CantShowTitle; likelyCause = Resources.ServerNotSpecifiedErrorLikelyCause; potentialSolution = Resources.ServerNotSpecifiedErrorPotentialSolution; } if (!m_canShow) { Warning = title; } return(m_canShow); }
protected override bool CanInitializeWizardPage(WizardInfo info) { string title = null; string likelyCause = null; string potentialSolution = null; m_canShow = true; // If Data Source is not initialized then raise error if (info.DataSourceParser == null) { m_canShow = false; title = Resources.ColumnMappingPart_CantShowTitle; likelyCause = Resources.DataSourceNotEnteredErrorLikelyCause; potentialSolution = Resources.DataSourceNotEnteredErrorPotentialSolution; } // else if Workitem Fields have not been populated by TFS Server else if (info.WorkItemGenerator == null || info.WorkItemGenerator.TfsNameToFieldMapping == null || info.WorkItemGenerator.TfsNameToFieldMapping.Count == 0) { m_canShow = false; title = Resources.ColumnMappingPart_CantShowTitle; likelyCause = Resources.ServerNotSpecifiedErrorLikelyCause; potentialSolution = Resources.ServerNotSpecifiedErrorPotentialSolution; } if (!m_canShow) { Warning = title; } return(m_canShow); }
protected override bool IsInitializationRequired(WizardInfo state) { return(m_wizardInfo == null || m_prerequisite.IsSettingsFilePathChanged() || m_prerequisite.IsDataSourceTypeChanged() || m_prerequisite.IsServerConnectionChanged()); }
/// <summary> /// If all mandatory fields are maped in Field Mapping only then we can initialize and show this /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { if (info.WorkItemGenerator == null || info.WorkItemGenerator.TfsNameToFieldMapping == null) { return(false); } m_canShow = true; foreach (IWorkItemField field in info.WorkItemGenerator.TfsNameToFieldMapping.Values) { if (field.IsMandatory && string.IsNullOrEmpty(field.SourceName)) { Warning = Resources.MandatoryFieldsNotMappedErrorTitle; m_canShow = false; break; } } if (info.IsLinking && string.IsNullOrEmpty(info.DataSourceParser.StorageInfo.SourceIdFieldName)) { Warning = "Source Id is not specified for Linking"; m_canShow = false; } return(m_canShow); }
/// <summary> /// Constructor - Creates Data Mapping row in editable mode /// </summary> /// <param name="info"></param> public DataMappingRow(WizardInfo info) { m_wizardInfo = info; AllowedNewValues = new ObservableCollection <string>(); InitializeDataSourceFields(); IsEditable = true; IsEnabled = true; }
/// <summary> /// Initialization is required if there is any change in Data Source or Server Connection /// </summary> /// <param name="state"></param> /// <returns></returns> protected override bool IsInitializationRequired(WizardInfo state) { if (m_wizardInfo == null || m_prerequisite.IsDataSourceChanged() || m_prerequisite.IsServerConnectionChanged()) { return(true); } return(false); }
/// <summary> /// Constructor - Creates Data Mapping row in Non-Editable Mode /// </summary> /// <param name="info"></param> /// <param name="field"></param> /// <param name="oldValue"></param> /// <param name="newValue"></param> public DataMappingRow(WizardInfo info, string field, string oldValue, string newValue) { m_wizardInfo = info; AllowedNewValues = new ObservableCollection <string>(); DataSourceField = field; DataSourceValue = oldValue; FillAllowedValues(); NewValue = newValue; IsEnabled = true; }
/// <summary> /// We can initialize this part if data source and server connection are provided /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { string title = null; string likelyCause = null; string potentialSolution = null; m_canShow = true; if (info.DataSourceParser == null) { m_canShow = false; title = Resources.MiscSettingsPart_CantShowTitle; likelyCause = Resources.DataSourceNotEnteredErrorLikelyCause; potentialSolution = Resources.DataSourceNotEnteredErrorPotentialSolution; } else if (info.DataSourceParser.StorageInfo.FieldNames == null || info.DataSourceParser.StorageInfo.FieldNames.Count == 0) { m_canShow = false; title = Resources.MiscSettingsPart_CantShowTitle; likelyCause = Resources.DataSourceFieldNamesNotFoundErrorLikelyCause; potentialSolution = Resources.DataSourceFieldNamesNotFoundErrorPotentialSolution; } else if (info.WorkItemGenerator.TfsNameToFieldMapping == null || info.WorkItemGenerator.TfsNameToFieldMapping.Count == 0) { m_canShow = false; title = Resources.MiscSettingsPart_CantShowTitle; likelyCause = Resources.ServerNotSpecifiedErrorLikelyCause; potentialSolution = Resources.ServerNotSpecifiedErrorPotentialSolution; } else { foreach (IWorkItemField field in info.WorkItemGenerator.TfsNameToFieldMapping.Values) { if (field.IsMandatory && string.IsNullOrEmpty(field.SourceName)) { Warning = Resources.MandatoryFieldsNotMappedErrorTitle; m_canShow = false; break; } } } if (info.IsLinking && string.IsNullOrEmpty(info.DataSourceParser.StorageInfo.SourceIdFieldName)) { title = "Source Id is not specified for Linking"; m_canShow = false; } if (!m_canShow) { Warning = title; } return(m_canShow); }
/// <summary> /// We can always initialize it /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { if (info.DataSourceParser == null) { m_canShow = false; } else { m_canShow = true; } return(m_canShow); }
/// <summary> /// Initializes the Data Mapping part /// </summary> /// <param name="info"></param> public override void Initialize(WizardInfo info) { CanNext = true; // if we can't Initialize the Data mapping part then just returns if (!CanInitializeWizardPage(info)) { return; } // If initialization is required if (IsInitializationRequired(m_wizardInfo)) { m_wizardInfo = info; if (m_prerequisite == null) { m_prerequisite = new WizardPartPrerequisite(m_wizardInfo); } try { Reset(); } catch (WorkItemMigratorException ex) { Warning = ex.Args.Title; CanShow = false; return; } } else { // else Just Updates the Data Mapping for removed Column mappings UpdateDatamappingRowsOnRemovedColumnMappings(); // Update Allowed Values of Data Mappings if only WorkItem fields are changed in Field Mappings foreach (DataMappingRow row in DataMappingRows) { if (row.DataSourceField != null && m_wizardInfo.Migrator.SourceNameToFieldMapping.ContainsKey(row.DataSourceField)) { row.UpdateAllowedValues(m_wizardInfo.Migrator.SourceNameToFieldMapping[row.DataSourceField]); } } } m_prerequisite.Save(); // Send Notifications FireStateNotifications(); }
/// <summary> /// Can Controller show Migration Wizard part /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { m_canShow = true; foreach (IWorkItemField field in info.WorkItemGenerator.TfsNameToFieldMapping.Values) { if (field.IsMandatory && string.IsNullOrEmpty(field.SourceName)) { Warning = Resources.MandatoryFieldsNotMappedErrorTitle; m_canShow = false; break; } } return(m_canShow); }
/// <summary> /// Constructor to initailize links and IDMapping /// </summary> /// <param name="m_wizardInfo"></param> public LinksManager(WizardInfo wizardInfo) { m_wizardInfo = wizardInfo; WorkItemCategoryToIdMappings = new Dictionary <string, IDictionary <string, WorkItemMigrationStatus> >(); m_links = new List <ILink>(); SessionId = 1; try { // Try to load links LoadLinksAndIDMapping(); } // Links file may be corrupted in that case ignore the links file catch (XmlException) { } }
public XMLReporter(WizardInfo wizardInfo) { m_wizardInfo = wizardInfo; m_document = new XmlDocument(); var rootNode = m_document.CreateElement(RootNodeName); XmlDeclaration dec = m_document.CreateXmlDeclaration("1.0", null, null); m_document.AppendChild(dec); String pi = "type='text/xsl' href='" + XSLFileName + "'"; var ins = m_document.CreateProcessingInstruction("xml-stylesheet", pi); m_document.AppendChild(ins); m_summaryNode = m_document.CreateElement(SummaryNodeName); rootNode.AppendChild(m_summaryNode); var workItemsNode = m_document.CreateElement(WorkitemsNodeName); m_passedWorkItemsNode = m_document.CreateElement(PassedWorkItemsNodeName); workItemsNode.AppendChild(m_passedWorkItemsNode); m_warningWorkItemsNode = m_document.CreateElement(WarningWorkItemsNodeName); workItemsNode.AppendChild(m_warningWorkItemsNode); m_failedWorkItemsNode = m_document.CreateElement(FailedWorkItemsNodeName); workItemsNode.AppendChild(m_failedWorkItemsNode); rootNode.AppendChild(workItemsNode); m_document.AppendChild(rootNode); m_passedWorkItemSourceFiles = new List <string>(); m_warningWorkItemSourceFiles = new List <string>(); m_failedWorkItemSourceFiles = new List <string>(); }
/// <summary> /// We can always initialize the Data Source /// </summary> /// <param name="info"></param> /// <returns></returns> protected override bool CanInitializeWizardPage(WizardInfo info) { m_canShow = true; return(m_canShow); }
/// <summary> /// Constructor to initialize Success and Failed Sheet. Initializes corresponding header to column Mapping. /// Gets test step/expected field name. /// </summary> /// <param name="headerToColumn">The Orignal Header to column mapping</param> /// <param name="columnMapping">Excel Field Name to TFS Workitem field name mapping</param> public ExcelReporter(WizardInfo wizardInfo) { m_wizardInfo = wizardInfo; m_sourceNameToFieldMapping = m_wizardInfo.Migrator.SourceNameToFieldMapping; }
/// <summary> /// Initializes the m_wizardInfo and BackgroundWorker. /// Also sets the Current State of WizardAction as pending /// </summary> /// <param name="wizardInfo"></param> public WizardAction(WizardInfo wizardInfo) { m_wizardInfo = wizardInfo; m_state = WizardActionState.Pending; InitializeBackgroundWorker(); }
/// <summary> /// Constructor /// </summary> /// <param name="wizardInfo"></param> public ParseDataSourceAction(WizardInfo wizardInfo) : base(wizardInfo) { Description = Resources.ParseDataSourceAction_Description; ActionName = WizardActionName.ParseDataSource; }
protected override bool IsInitializationRequired(WizardInfo state) { return(true); }
private void ParseCLIArguments(string[] args) { Dictionary <CommandLineSwitch, string> arguments; SetConsoleMode(); try { if (ParseArguments(args, out arguments)) { VerifyArguments(arguments); WizardInfo = new WizardInfo(); Console.Write("Loading Data Source..."); if (arguments.ContainsKey(CommandLineSwitch.Excel)) { InitializeExcelDataSource(arguments); } else if (arguments.ContainsKey(CommandLineSwitch.MHT)) { InitializeMHTDataSource(arguments); } Console.Write("\nInitializing TFS Server Connection..."); WizardInfo.WorkItemGenerator = new WorkItemGenerator(arguments[CommandLineSwitch.TFSCollection], arguments[CommandLineSwitch.Project]); if (WizardInfo.DataSourceType == DataSourceType.MHT) { WizardInfo.WorkItemGenerator.AddTestStepsField = false; } else if (WizardInfo.DataSourceType == DataSourceType.Excel) { WizardInfo.WorkItemGenerator.AddTestStepsField = true; } if (!WizardInfo.WorkItemGenerator.WorkItemTypeNames.Contains(arguments[CommandLineSwitch.WorkItemType])) { throw new WorkItemMigratorException("Wrong Type Name:" + arguments[CommandLineSwitch.WorkItemType] + " is given", null, null); } WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName = arguments[CommandLineSwitch.WorkItemType]; Console.Write("\nLoading Settings..."); WizardInfo.LoadSettings(arguments[CommandLineSwitch.SettingsPath]); if (WizardInfo.DataSourceType == DataSourceType.Excel) { WizardInfo.Reporter.ReportFile = Path.Combine(arguments[CommandLineSwitch.ReportPath], "Report.xls"); } else { WizardInfo.Reporter.ReportFile = Path.Combine(arguments[CommandLineSwitch.ReportPath], "Report.xml"); } WizardInfo.LinksManager = new LinksManager(WizardInfo); Console.WriteLine("\n\nStarting Migration:\n"); WizardInfo.Migrator.PostMigration = ShowMigrationStatus; var resultSourceWorkItems = WizardInfo.Migrator.Migrate(WizardInfo.WorkItemGenerator); WizardInfo.ResultWorkItems = resultSourceWorkItems; Console.Write("\n\nPublishing Report:"); foreach (var dsWorkItem in resultSourceWorkItems) { WizardInfo.Reporter.AddEntry(dsWorkItem); } WizardInfo.Reporter.Publish(); if (WizardInfo.DataSourceType == DataSourceType.Excel) { ProcessLinks(); } } else { if (arguments.Count > 0) { if (arguments.ContainsKey(CommandLineSwitch.MHT)) { DisplayMHTUsage(); } else if (arguments.ContainsKey(CommandLineSwitch.Excel)) { DisplayExcelUsage(); } else { DisplayGenericUsage(); } } else { DisplayGenericUsage(); } } } catch (WorkItemMigratorException te) { Console.WriteLine(te.Args.Title); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { if (WizardInfo != null) { WizardInfo.Dispose(); } MHTParser.Quit(); ExcelParser.Quit(); } Console.Write("\n\nPress Enter to exit...\n"); }
/// <summary> /// Initialize the Wizard Info /// </summary> /// <param name="wizardInfo"></param> public WizardPartPrerequisite(WizardInfo wizardInfo) { m_wizardInfo = wizardInfo; }