Esempio n. 1
0
        private void FillLinksRawDataInReport(Worksheet sheet)
        {
            foreach (ILink link in m_links)
            {
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 1, m_currentRow - 1);
                if (link.SessionId > 0)
                {
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 2, link.SessionId);
                }
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 4, link.LinksStatus);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 5, link.StartWorkItemTfsTypeName);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 6, link.StartWorkItemSourceId);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 7, link.StartWorkItemTfsId);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 8, link.LinkTypeName);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 9, link.EndWorkItemTfsTypeName);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 10, link.EndWorkItemSourceId);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 11, link.EndWorkItemTfsId);
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 12, link.IsExistInTfs);

                string message = link.Message != null ? link.Message : string.Empty;
                if (!link.IsExistInTfs && string.IsNullOrEmpty(link.Message))
                {
                    message = "Target work item is not migrated yet.";
                }
                ExcelReporter.WriteValueAt(sheet, m_currentRow, 13, message);
                m_currentRow++;
            }
        }
Esempio n. 2
0
        private void FillIDMappingsInReport(Worksheet sheet)
        {
            var wiTypeToIdMapping = GetWorkItemTypeIDmapping();

            foreach (var workItemTypeToIDMapping in wiTypeToIdMapping)
            {
                foreach (var idMapping in workItemTypeToIDMapping.Value)
                {
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 1, m_currentRow - 1);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 2, idMapping.Value.SessionId);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 3, idMapping.Value.Status);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 5, workItemTypeToIDMapping.Key);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 6, idMapping.Key);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 7, idMapping.Value.TfsId);
                    ExcelReporter.WriteValueAt(sheet, m_currentRow, 13, idMapping.Value.Message);
                    m_currentRow++;
                }
            }
        }
Esempio n. 3
0
        private void ParseDataSource()
        {
            IDictionary <string, IWorkItemField> sourceNameToFieldMapping = Migrator.SourceNameToFieldMapping;
            int count = 0;

            if (ProgressPart != null)
            {
                ProgressPart.Text = "Parsing Source...";
            }
            Console.WriteLine("\nParsing Source...\n");
            IList <ISourceWorkItem> sourceWorkItems    = new List <ISourceWorkItem>();
            IList <ISourceWorkItem> rawSourceWorkItems = new List <ISourceWorkItem>();

            if (DataSourceType == DataSourceType.MHT)
            {
                MHTStorageInfo sampleInfo = DataSourceParser.StorageInfo as MHTStorageInfo;

                IList <IDataStorageInfo> storageInfos = DataStorageInfos;

                foreach (IDataStorageInfo storageInfo in storageInfos)
                {
                    if (ProgressPart == null)
                    {
                        break;
                    }
                    MHTStorageInfo info = storageInfo as MHTStorageInfo;
                    info.IsFirstLineTitle = sampleInfo.IsFirstLineTitle;
                    info.IsFileNameTitle  = sampleInfo.IsFileNameTitle;
                    info.TitleField       = sampleInfo.TitleField;
                    info.StepsField       = sampleInfo.StepsField;
                    IDataSourceParser parser = new MHTParser(info);

                    info.FieldNames          = sampleInfo.FieldNames;
                    parser.FieldNameToFields = sourceNameToFieldMapping;

                    while (parser.GetNextWorkItem() != null)
                    {
                        count++;
                        if (ProgressPart != null)
                        {
                            ProgressPart.Text = "Parsing " + count + " of " + DataStorageInfos.Count + ":\n" + info.Source;
                            Console.Write("\r" + ProgressPart.Text);
                            ProgressPart.ProgressValue = (count * 100) / DataStorageInfos.Count;
                        }
                    }

                    for (int i = 0; i < parser.ParsedSourceWorkItems.Count; i++)
                    {
                        sourceWorkItems.Add(parser.ParsedSourceWorkItems[i]);
                        rawSourceWorkItems.Add(parser.RawSourceWorkItems[i]);
                    }
                    parser.Dispose();
                }
            }
            else if (DataSourceType == DataSourceType.Excel)
            {
                var parser    = DataSourceParser;
                var excelInfo = parser.StorageInfo as ExcelStorageInfo;
                while (parser.GetNextWorkItem() != null)
                {
                    if (ProgressPart == null)
                    {
                        break;
                    }
                    count++;
                    ProgressPart.ProgressValue = excelInfo.ProgressPercentage;
                    ProgressPart.Text          = "Parsing work item # " + count;
                    Console.Write("\r" + ProgressPart.Text);
                }
                for (int i = 0; i < parser.ParsedSourceWorkItems.Count; i++)
                {
                    sourceWorkItems.Add(parser.ParsedSourceWorkItems[i]);
                    rawSourceWorkItems.Add(parser.RawSourceWorkItems[i]);
                }
            }

            Migrator.RawSourceWorkItems = rawSourceWorkItems;
            Migrator.SourceWorkItems    = sourceWorkItems;

            if (Reporter != null)
            {
                Reporter.Dispose();
            }
            string reportDirectory = Path.Combine(Path.GetDirectoryName(DataSourceParser.StorageInfo.Source),
                                                  "Report" + DateTime.Now.ToString("g", System.Globalization.CultureInfo.CurrentCulture).
                                                  Replace(":", "_").Replace(" ", "_").Replace("/", "_"));

            switch (DataSourceType)
            {
            case DataSourceType.Excel:
                Reporter = new ExcelReporter(this);
                string fileNameWithoutExtension = "Report";
                string fileExtension            = Path.GetExtension(DataSourceParser.StorageInfo.Source);
                Reporter.ReportFile = Path.Combine(reportDirectory, fileNameWithoutExtension + fileExtension);
                break;

            case DataSourceType.MHT:
                Reporter = new XMLReporter(this);
                string fileName = "Report.xml";;
                Reporter.ReportFile = Path.Combine(reportDirectory, fileName);
                break;

            default:
                throw new InvalidEnumArgumentException("Invalid Data Source type");
            }
        }