예제 #1
0
 /// <summary>
 /// Disposes the Data Source
 /// </summary>
 public void Dispose()
 {
     m_wizardInfo.PropertyChanged -= WizardInfo_PropertyChanged;
     m_wizardInfo.Dispose();
     ExcelParser.Quit();
     MHTParser.Quit();
 }
예제 #2
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException -= new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            MessageHelper.ShowMessageWindow = null;
            if (WizardInfo != null)
            {
                WizardInfo.Dispose();
            }
            ExcelParser.Quit();
            MHTParser.Quit();
        }
예제 #3
0
        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");
        }