Beispiel #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor based on a hashtable which maps HVOs of ScrImportSource objects to
		/// ScrSfFileList objects
		/// </summary>
		/// <param name="sourceTable">The hashtable</param>
		/// <param name="cache">The FDO cache needed for interpreting the HVOs</param>
		/// ------------------------------------------------------------------------------------
		public ImportFileSource(Hashtable sourceTable, FdoCache cache)
		{
			Debug.Assert(sourceTable != null);
			m_cache = cache;
			m_sourceTable = sourceTable;
			m_fileList = null;
		}
Beispiel #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor based on a ScrSfFileList
		/// </summary>
		/// <param name="fileList">The list of files</param>
		/// ------------------------------------------------------------------------------------
		public ImportFileSource(ScrSfFileList fileList)
		{
			Debug.Assert(fileList != null);
			m_cache = null;
			m_sourceTable = null;
			m_fileList = fileList;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor based on a hashtable which maps HVOs of ScrImportSource objects to
 /// ScrSfFileList objects
 /// </summary>
 /// <param name="sourceTable">The hashtable</param>
 /// <param name="cache">The FDO cache needed for interpreting the HVOs</param>
 /// ------------------------------------------------------------------------------------
 public ImportFileSource(Hashtable sourceTable, FdoCache cache)
 {
     Debug.Assert(sourceTable != null);
     m_cache       = cache;
     m_sourceTable = sourceTable;
     m_fileList    = null;
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor based on a ScrSfFileList
 /// </summary>
 /// <param name="fileList">The list of files</param>
 /// ------------------------------------------------------------------------------------
 public ImportFileSource(ScrSfFileList fileList)
 {
     Debug.Assert(fileList != null);
     m_cache       = null;
     m_sourceTable = null;
     m_fileList    = fileList;
 }
		public void Setup()
		{
			m_resolver = MockRepository.GenerateStrictMock<IOverlappingFileResolver>();
			m_expectedRemovedFiles = new List<IScrImportFileInfo>();
			m_callCountForVerifyFileRemoved = 0;
			m_fileList = new ScrSfFileList(m_resolver);
			m_fileList.FileRemoved += new ScrImportFileEventHandler(VerifyFileRemoved);
		}
 public ImportFileEnumerator(FdoCache cache, ScrSfFileList fileList, Hashtable sourceTable)
 {
     if (sourceTable == null)
     {
         m_fileEnumerator   = fileList.GetEnumerator();
         m_sourceEnumerator = null;
     }
     else
     {
         m_fileEnumerator   = null;
         m_sourceEnumerator = sourceTable.GetEnumerator();
     }
     Reset();
 }
Beispiel #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Abandon the "temporary" in-memory settings and re-load from the permanent properties
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void RevertToSaved()
		{
			lock (SyncRoot)
			{
				m_scrFileInfoList = null;
				m_btFileInfoLists = new Hashtable();
				m_notesFileInfoLists = new Hashtable();
				SetDefaultValuesAfterInit();
			}
		}
Beispiel #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load the in-memory copies of file lists from the database.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void LoadInMemoryFileLists()
		{
			foreach (IScrImportSource source in ScriptureSourcesOC)
			{
				if (source is ScrImportSFFiles)
				{
					m_scrFileInfoList = new ScrSfFileList((ScrImportSFFiles)source,
						m_scrMappingsList, ImportDomain.Main,
						(ImportTypeEnum == TypeOfImport.Paratext5));
					m_scrFileInfoList.OverlappingFileResolver = m_resolver;
					break;
				}
			}
			if (m_scrFileInfoList == null)
				m_scrFileInfoList = new ScrSfFileList(m_resolver);

			foreach (IScrImportSource source in BackTransSourcesOC)
			{
				if (source is ScrImportSFFiles)
				{
					string wsId = source.WritingSystem ?? string.Empty;
					m_btFileInfoLists[wsId] = new ScrSfFileList((ScrImportSFFiles)source,
						m_scrMappingsList, ImportDomain.BackTrans,
						(ImportTypeEnum == TypeOfImport.Paratext5));
				}
			}

			foreach (IScrImportSource source in NoteSourcesOC)
			{
				if (source is ScrImportSFFiles)
				{
					string wsId = source.WritingSystem ?? string.Empty;
					string key = ScriptureServices.CreateImportSourceKey(wsId,
						((ScrImportSFFiles)source).NoteTypeRA);
					m_notesFileInfoLists[key] = new ScrSfFileList((ScrImportSFFiles)source,
						m_notesMappingsList, ImportDomain.Annotations,
						(ImportTypeEnum == TypeOfImport.Paratext5));
				}
			}
		}
Beispiel #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save an in-memory list of files to the given source
		/// </summary>
		/// <param name="files">ScrSfFileList containing in-memory file list</param>
		/// <param name="source">ScrImportSFFiles in the database</param>
		/// ------------------------------------------------------------------------------------
		private void SaveFileList(ScrSfFileList files, ScrImportSFFiles source)
		{
			// If the file list has not changed, don't try to save it
			if (!files.Modified)
				return;

			UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Save file list", "Save file list",
				m_cache.ServiceLocator.GetInstance<IActionHandler>(), () =>
			{
				source.FilesOC.Clear();
				foreach (IScrImportFileInfo fileInfo in files)
				{
					ICmFile file = Services.GetInstance<ICmFileFactory>().Create();
					source.FilesOC.Add(file);
					file.InternalPath = fileInfo.FileName;
				}
			});
		}
Beispiel #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the file list for the given domain, writing system identifier and note type.
		/// </summary>
		/// <param name="domain">The source domain</param>
		/// <param name="wsId">The writing system identifier for the source (ignored for
		/// scripture domain)</param>
		/// <param name="noteType">The CmAnnotationDefn for the note type (ignored for back
		/// trans and scripture domains)</param>
		/// <param name="createListIfNeeded">True to create the list if it does not already
		/// exist for a given writing system identifier and note type</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private ScrSfFileList GetFileList(ImportDomain domain, string wsId,
			ICmAnnotationDefn noteType,	bool createListIfNeeded)
		{
			Debug.Assert(ImportTypeEnum == TypeOfImport.Other || ImportTypeEnum == TypeOfImport.Paratext5);

			if (wsId == null)
				wsId = string.Empty;
			switch (domain)
			{
				default:
				case ImportDomain.Main:
					return m_scrFileInfoList;

				case ImportDomain.BackTrans:
				{
					// Look for a back trans source with the given writing system identifier.
					ScrSfFileList btList = m_btFileInfoLists[wsId] as ScrSfFileList;
					if (btList == null && createListIfNeeded)
					{
						btList = new ScrSfFileList(m_resolver);
						m_btFileInfoLists[wsId] = btList;
					}
					return btList;
				}
				case ImportDomain.Annotations:
				{
					// Look for a annotations source with the given writing system identifier.
					string key = ScriptureServices.CreateImportSourceKey(wsId, noteType);
					ScrSfFileList noteList = m_notesFileInfoLists[key] as ScrSfFileList;
					if (noteList == null && createListIfNeeded)
					{
						noteList = new ScrSfFileList(m_resolver);
						m_notesFileInfoLists[key] = noteList;
					}
					return noteList;
				}
			}
		}
Beispiel #11
0
			public ImportFileEnumerator(FdoCache cache, ScrSfFileList fileList, Hashtable sourceTable)
			{
				if (sourceTable == null)
				{
					m_fileEnumerator = fileList.GetEnumerator();
					m_sourceEnumerator = null;
				}
				else
				{
					m_fileEnumerator = null;
					m_sourceEnumerator = sourceTable.GetEnumerator();
				}
				Reset();
			}