コード例 #1
0
        private static bool SFProjectFilesAccessible(IScrImportSet importSettings, out StringCollection filesNotFound)
        {
            filesNotFound = new StringCollection();

            bool fProjectFileFound = false;

            fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.Main), ref filesNotFound);
            fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.BackTrans), ref filesNotFound);
            fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.Annotations), ref filesNotFound);

            return(fProjectFileFound);
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a list of books that exist for all of the files in this project.
        /// </summary>
        /// <returns>A List of integers representing 1-based canonical book numbers that exist
        /// in any source represented by these import settings</returns>
        /// <exception cref="NotSupportedException">If project is not a supported type</exception>
        /// ------------------------------------------------------------------------------------
        public static List <int> BooksForProject(this IScrImportSet importSettings)
        {
            Debug.Assert(importSettings.BasicSettingsExist, "Vernacular Scripture project not defined.");
            switch (importSettings.ImportTypeEnum)
            {
            case TypeOfImport.Paratext6:
                // TODO (TE-5903): Check BT and Notes projects as well.
                return(ParatextHelper.GetProjectBooks(importSettings.ParatextScrProj).ToList());

            case TypeOfImport.Paratext5:
            case TypeOfImport.Other:
                List <int> booksPresent = new List <int>();
                foreach (IScrImportFileInfo file in importSettings.GetImportFiles(ImportDomain.Main))
                {
                    foreach (int iBook in file.BooksInFile)
                    {
                        if (!booksPresent.Contains(iBook))
                        {
                            booksPresent.Add(iBook);
                        }
                    }
                }

                foreach (IScrImportFileInfo file in importSettings.GetImportFiles(ImportDomain.BackTrans))
                {
                    foreach (int iBook in file.BooksInFile)
                    {
                        if (!booksPresent.Contains(iBook))
                        {
                            booksPresent.Add(iBook);
                        }
                    }
                }

                foreach (IScrImportFileInfo file in importSettings.GetImportFiles(ImportDomain.Annotations))
                {
                    foreach (int iBook in file.BooksInFile)
                    {
                        if (!booksPresent.Contains(iBook))
                        {
                            booksPresent.Add(iBook);
                        }
                    }
                }
                booksPresent.Sort();
                return(booksPresent);

            default:
                throw new NotSupportedException("Unexpected type of Import Project");
            }
        }
コード例 #3
0
        public void AddFileAndCheckAccessibility_Locked()
        {
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LanguageProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ImportTypeEnum = TypeOfImport.Other;

            var fileOs = new MockFileOS();

            try
            {
                FileUtils.Manager.SetFileAdapter(fileOs);
                string filename = fileOs.MakeSfFile("EPH", @"\c 1", @"\v 1");
                fileOs.LockFile(filename);

                IScrImportFileInfo info = importSettings.AddFile(filename, ImportDomain.Main, null, null);
                Assert.AreEqual(Encoding.ASCII, info.FileEncoding);
                Assert.AreEqual(1, importSettings.GetImportFiles(ImportDomain.Main).Count);
                StringCollection notFound;
                Assert.IsFalse(importSettings.ImportProjectIsAccessible(out notFound));
                Assert.AreEqual(1, notFound.Count);
                Assert.AreEqual(filename, notFound[0]);
            }
            finally
            {
                FileUtils.Manager.Reset();
            }
        }
コード例 #4
0
        public void AddFilesToBtList_User()
        {
            m_builder.SelectTab(1);
            TempSFFileMaker fileMaker = new TempSFFileMaker();
            string          file1     = fileMaker.CreateFile("EPH", new string[] { @"\c 1", @"\v 1" });
            string          file2     = fileMaker.CreateFile("1CO", new string[] { @"\c 1", @"\v 1" });

            m_builder.m_filenamesToAdd = new string[] { file1, file2 };
            m_builder.SelectBtWritingSystem("Spanish");
            m_builder.ClickAddButton();
            // Make sure two files were added to BT list
            Assert.AreEqual(2, m_builder.BackTransFiles.Count);
            Assert.AreEqual(2, m_builder.BtListView.Items.Count);
            foreach (ScrImportFileInfo info in m_settings.GetImportFiles(ImportDomain.BackTrans))
            {
                Assert.AreEqual("es", info.WsId);
            }
        }
コード例 #5
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
            Set <char> tempCharList = new Set <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();
        }
コード例 #6
0
		private static bool SFProjectFilesAccessible(IScrImportSet importSettings, out StringCollection filesNotFound)
		{
			filesNotFound = new StringCollection();

			bool fProjectFileFound = false;

			fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.Main), ref filesNotFound);
			fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.BackTrans), ref filesNotFound);
			fProjectFileFound |= FilesAreAccessible(importSettings.GetImportFiles(ImportDomain.Annotations), ref filesNotFound);

			return (fProjectFileFound);
		}
コード例 #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verifies the list of import files (that they are named as expected).
		/// </summary>
		/// <param name="settings">The import settings.</param>
		/// <param name="domain">The import domain.</param>
		/// <param name="strFileName">Name of the file.</param>
		/// <param name="numFiles">The number files.</param>
		/// ------------------------------------------------------------------------------------
		private void VerifyImportFiles(IScrImportSet settings, ImportDomain domain,
			string strFileName, int numFiles)
		{
			ImportFileSource source = settings.GetImportFiles(domain);
			Assert.AreEqual(numFiles, source.Count);
			int fileNum = 1;
			foreach (ScrImportFileInfo info in source)
			{
				Assert.AreEqual(@"c:\" + strFileName + fileNum, info.FileName);
				fileNum++;
			}
		}
コード例 #8
0
ファイル: SCTextEnum.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <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
			Set<char> tempCharList = new Set<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();
		}