Exemple #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Creates a <see cref="ScrImportFileInfo"/> based on a file. This is used to build an
 /// in-memory list of files.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public virtual IScrImportFileInfo Create(string fileName, ScrMappingList mappingList,
                                          ImportDomain domain, string wsId, ICmAnnotationDefn noteType,
                                          bool scanInlineBackslashMarkers)
 {
     return(new ScrImportFileInfo(fileName, mappingList, domain, wsId, noteType,
                                  scanInlineBackslashMarkers));
 }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ScrSfFileList"/> class based on an
        /// existing ScrImportSFFiles in the DB.
        /// </summary>
        /// <param name="source">A DB-based collection of Standard Format files</param>
        /// <param name="mappingList">The mapping list to which mappings will be added if any
        /// new ones are found when scanning the files</param>
        /// <param name="importDomain">Main (vernacular Scripture), BT or Annotations</param>
        /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
        /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
        /// must start on a new line, but Paratext considers all backslashes in the data to be
        /// SF markers.)</param>
        /// ------------------------------------------------------------------------------------
        public ScrSfFileList(IScrImportSFFiles source, ScrMappingList mappingList,
                             ImportDomain importDomain, bool scanInlineBackslashMarkers)
            : this(null)
        {
            var deleteList = new List <ICmFile>();
            // Load the files into an in-memory list
            foreach (ICmFile file in source.FilesOC)
            {
                try
                {
                    IScrImportFileInfo info = new ScrImportFileInfo(file, mappingList, importDomain,
                                                                    source.WritingSystem, source.NoteTypeRA, scanInlineBackslashMarkers);
                    Add(info);
                }
                catch (ScriptureUtilsException e)
                {
                    var userAction = source.Services.GetInstance <ILcmUI>();
                    userAction.DisplayMessage(MessageType.Error, string.Format(ScrResources.kstidImportBadFile, e.Message), Strings.ksErrorCaption, e.HelpTopic);
                    deleteList.Add(file);
                }
            }

            // delete all of the files that caused errors
            foreach (ICmFile deleteItem in deleteList)
            {
                source.FilesOC.Remove(deleteItem);
            }

            m_modified = false;
        }
Exemple #3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo based on a filename. This is used to build an
 /// in-memory list of files.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public ScrImportFileInfo(string fileName, ScrMappingList mappingList, ImportDomain domain,
                          string wsId, ICmAnnotationDefn noteType, bool scanInlineBackslashMarkers)
 {
     m_fileName                 = fileName;
     m_mappingList              = mappingList;
     m_domain                   = domain;
     m_wsId                     = wsId;
     m_noteType                 = noteType;
     m_doStrictFileChecking     = false;
     ScanInlineBackslashMarkers = scanInlineBackslashMarkers;
     Initialize();
 }
Exemple #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo from a CmFile owned by a BT source. This is
 /// used when populating the file list from the database.
 /// </summary>
 /// <param name="file">The CmFile</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(ICmFile file, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, bool scanInlineBackslashMarkers) :
     this(file, mappingList, domain, wsId, null, scanInlineBackslashMarkers)
 {
 }
Exemple #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo from a CmFile. This is used when populating the
 /// file list from the database.
 /// </summary>
 /// <param name="file">The CmFile</param>
 /// <param name="mappingList">List of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(ICmFile file, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, ICmAnnotationDefn noteType, bool scanInlineBackslashMarkers) :
     this(file.AbsoluteInternalPath, mappingList, domain, wsId, noteType,
          scanInlineBackslashMarkers)
 {
 }
Exemple #6
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo based on a Toolbox (i.e., non-Paratext 5) filename.
 /// This is used only in tests.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(string fileName, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, ICmAnnotationDefn noteType)
     : this(fileName, mappingList, domain, wsId, noteType, false)
 {
 }