/// <summary> /// Загрузка файла /// </summary> /// <param name="fileName">Путь к файлу</param> /// <param name="db">БД</param> public string ImportDxlFile(string fileName, NotesDatabase db) { NotesStream = db.Parent.CreateStream(); NotesDxlImporter = db.Parent.CreateDXLImporter(); if (!NotesStream.Open(fileName)) { Loggers.Log4NetLogger.Error(new Exception("Невозможно открыть файл " + fileName)); return(null); } //notesDXLImporter.InputValidationOption = VALIDATIONOPTION.VALIDATE_NEVER; NotesDxlImporter.ACLImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_IGNORE; NotesDxlImporter.DesignImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_REPLACE_ELSE_CREATE; NotesDxlImporter.ReplicaRequiredForReplaceOrUpdate = false; NotesDxlImporter.DocumentImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_CREATE; NotesDxlImporter.ExitOnFirstFatalError = true; try { NotesDxlImporter.Import(NotesStream, db); string text = NotesDxlImporter.GetFirstImportedNoteId(); NotesStream.Truncate(); NotesStream.Close(); return(text); } catch (Exception e) { Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.Log)); Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.LogComment)); Loggers.Log4NetLogger.Error(e); } finally { Dispose(); } return(null); }
/// <summary> /// Освобождение ресурсов памяти /// </summary> public void Dispose() { if (NotesStream != null) { Marshal.ReleaseComObject(NotesStream); } NotesStream = null; if (NotesDxlImporter != null) { Marshal.ReleaseComObject(NotesDxlImporter); } NotesDxlImporter = null; }