Пример #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
        /// <summary>
        /// Launches the Data Source Input File in the associated Application
        /// </summary>
        public void PreviewDataSourceFile()
        {
            // Check whether preview is enabled or not
            if (IsPreviewEnabled)
            {
                try
                {
                    switch (DataSourceType)
                    {
                    case DataSourceType.Excel:
                        ExcelParser.OpenWorkSheet(ExcelFilePath, SelectedExcelSheet);
                        break;

                    case DataSourceType.MHT:
                        break;

                    default:
                        throw new InvalidEnumArgumentException("Invalid Enum Value");
                    }
                }
                catch (WorkItemMigratorException te)
                {
                    MessageHelper.ShowMessageWindow(te.Args);
                }
            }
        }
Пример #3
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();
        }
Пример #4
0
 public void ShowLinkingReport()
 {
     if (WizardInfo.LinksManager != null &&
         !string.IsNullOrEmpty(WizardInfo.LinksManager.LinksFilePath))
     {
         string linksReportFilePath = Path.Combine(Path.GetDirectoryName(WizardInfo.LinksManager.LinksFilePath),
                                                   LinksManager.XLReportFileName);
         try
         {
             if (File.Exists(linksReportFilePath))
             {
                 ExcelParser.OpenWorkSheet(linksReportFilePath, "Migration-Summary");
             }
         }
         catch (WorkItemMigratorException we)
         {
             Warning = "Unable to open Linking Report File" + we.Args.Title;
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Load Excel WorkSheets
        /// </summary>
        private void LoadExcelWorkSheets()
        {
            // Clear the Excel Sheets
            App.CallMethodInUISynchronizationContext(ClearExcelSheets, null);

            // Clear Selected Sheet to empty
            SelectedExcelSheet = string.Empty;

            string filePath = ExcelFilePath;

            // Get the List of Name of Worksheets
            List <string> worksheets = ExcelParser.GetWorksheetNames(filePath);

            //If List of worksheet names is not working then add them to ExcelWorksheets
            if (worksheets.Count > 0)
            {
                foreach (string worksheet in worksheets)
                {
                    ExcelSheets.Add(worksheet);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// The Main Working Method
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        protected override WizardActionState DoWork(DoWorkEventArgs e)
        {
            if (m_wizardInfo.DataSourceType != DataSourceType.Excel)
            {
                Message = "Wrong Data Source Type";
                return(WizardActionState.Failed);
            }

            try
            {
                m_wizardInfo.Migrator.SourceWorkItems = new List <ISourceWorkItem>();

                var parser = new ExcelParser(m_wizardInfo.DataSourceParser.StorageInfo as ExcelStorageInfo);

                parser.ParseDataSourceFieldNames();

                parser.FieldNameToFields = m_wizardInfo.Migrator.SourceNameToFieldMapping;

                ISourceWorkItem sourceWorkItem = null;
                while ((sourceWorkItem = parser.GetNextWorkItem()) != null)
                {
                    m_wizardInfo.Migrator.SourceWorkItems.Add(sourceWorkItem);
                }

                m_wizardInfo.DataSourceParser.Dispose();
                parser.Dispose();

                // return success
                return(WizardActionState.Success);
            }
            catch (WorkItemMigratorException ex)
            {
                // is some exception occured during parsing then set the error Message and return state as Failed
                Message = ex.Args.Title;
                return(WizardActionState.Failed);
            }
        }
Пример #7
0
        /// <summary>
        /// Shows Published Report
        /// </summary>
        /// <param name="workSheetName"></param>
        public void ShowReport(string workSheetName)
        {
            try
            {
                switch (m_wizardInfo.DataSourceType)
                {
                case DataSourceType.Excel:
                    ExcelParser.OpenWorkSheet(m_wizardInfo.Reporter.ReportFile, workSheetName);
                    break;

                case DataSourceType.MHT:
                    Process.Start(m_wizardInfo.Reporter.ReportFile);
                    break;

                default:
                    throw new InvalidEnumArgumentException("Invalid Enum Value");
                }
            }
            catch (WorkItemMigratorException te)
            {
                // Display Message if some error occured while trying to show the report
                MessageHelper.ShowMessageWindow(te.Args);
            }
        }
Пример #8
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");
        }