public void AddFilesToNotesList_User()
        {
            m_builder.SelectTab(2);
            TempSFFileMaker fileMaker = new TempSFFileMaker();
            string          file1     = fileMaker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
            string          file2     = fileMaker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
            string          file3     = fileMaker.CreateFile("EXO", new string[] { @"\c 1", @"\v 1" });

            m_builder.m_filenamesToAdd = new string[] { file1 };
            m_builder.SelectNotesWritingSystem("German");
            m_builder.SelectNoteType("Translator");
            m_builder.ClickAddButton();
            m_builder.m_filenamesToAdd = new string[] { file2, file3 };
            m_builder.SelectNotesWritingSystem("German");
            m_builder.SelectNoteType("Consultant");
            m_builder.ClickAddButton();

            // Make sure two files were added to the German Consultant Notes list
            Assert.AreEqual(2, m_builder.NotesFiles.Count);
            Assert.AreEqual(2, m_builder.NotesListView.Items.Count);

            m_builder.SelectNoteType("Translator");
            // Make sure one file was added to the German Translator Notes list
            Assert.AreEqual(1, m_builder.NotesFiles.Count);
            Assert.AreEqual(1, m_builder.NotesListView.Items.Count);

            // Make sure all three annotation files were added properly to the import project
            ImportFileSource files = m_settings.GetImportFiles(ImportDomain.Annotations);

            Assert.AreEqual(3, files.Count);
            ICmAnnotationDefn translatorNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;
            ICmAnnotationDefn consultantNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().ConsultantAnnotationDefn;

            foreach (ScrImportFileInfo info in m_settings.GetImportFiles(ImportDomain.Annotations))
            {
                Assert.AreEqual("de", info.WsId);
                if (info.FileName == file1)
                {
                    Assert.AreEqual(new ScrReference(1, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(translatorNoteDef, info.NoteType);
                }
                else if (info.FileName == file2)
                {
                    Assert.AreEqual(new ScrReference(1, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(consultantNoteDef, info.NoteType);
                }
                else if (info.FileName == file3)
                {
                    Assert.AreEqual(new ScrReference(2, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(consultantNoteDef, info.NoteType);
                }
                else
                {
                    Assert.Fail("Unexpected file in annotations import project: " + info.FileName);
                }
            }
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine if the file list has any accessible files and get a list of any
        /// inaccessible ones.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="filesNotFound">A list of files that couldn't be found.</param>
        /// <returns>true if any SFM files are accessible. Otherwise, false.</returns>
        /// ------------------------------------------------------------------------------------
        private static bool FilesAreAccessible(ImportFileSource source, ref StringCollection filesNotFound)
        {
            bool found = false;

            foreach (IScrImportFileInfo info in source)
            {
                if (info.RecheckAccessibility())
                {
                    found = true;
                }
                else
                {
                    filesNotFound.Add(info.FileName);
                }
            }
            return(found);
        }
Beispiel #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="SCTextEnum"/> class.
        /// </summary>
        /// <param name="settings">The import settings</param>
        /// <param name="domain">The source domain</param>
        /// <param name="startRef">first reference to retrieve</param>
        /// <param name="endRef">last reference to retrieve</param>
        /// <param name="encConverters">The encoding converters repository</param>
        /// ------------------------------------------------------------------------------------
        public SCTextEnum(IScrImportSet settings, ImportDomain domain,
                          BCVRef startRef, BCVRef endRef, IEncConverters encConverters)
        {
            m_settings   = settings;
            m_domain     = domain;
            m_startRef   = new BCVRef(startRef);
            m_endRef     = new BCVRef(endRef);
            m_mappingSet = m_settings.GetMappingSetForDomain(domain);

            // Gets the set of encoding converters
            m_encConverters = encConverters;

            // make a list of all of the begin and end markers for inline markers
            // Also build the map of encoding converters
            m_InlineBeginAndEndMarkers = new List <string>();
            foreach (ImportMappingInfo mapping in m_settings.GetMappingListForDomain(domain))
            {
                if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
                {
                    m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
                    if (mapping.IsInline)
                    {
                        m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
                    }
                }
            }

            m_InlineBeginAndEndMarkers.Sort(new StrLengthComparer(false));

            // Build a list of all of the characters that inline markers start with
            var tempCharList = new HashSet <char>();

            foreach (string marker in m_InlineBeginAndEndMarkers)
            {
                tempCharList.Add(marker[0]);                 // Set ignores duplicates.
            }
            m_InlineMarkerStartChars = tempCharList.ToArray();
            // Get the import file source that will provide the files to import.
            m_importSource     = settings.GetImportFiles(domain);
            m_importSourceEnum = m_importSource.GetEnumerator();
        }