/// ------------------------------------------------------------------------------------ /// <summary> /// Export an Open XML for Exchanging Scripture Annotations (OXESA) file. /// </summary> /// ------------------------------------------------------------------------------------ public bool OnFileExportOXESA(object args) { CheckDisposed(); XmlScrAnnotationsList list = new XmlScrAnnotationsList(Cache); // need to use the dataAccess from the rootbox to get the filtered list - TE-9277 var dataAccess = m_dataEntryView.RootBox.DataAccess; foreach (IScrBookAnnotations annotations in m_scr.BookAnnotationsOS) { List<IScrScriptureNote> notesToExport = new List<IScrScriptureNote>(); // TE-9371: Changed way to get hvo's of filtered notes to improve performance int arraySize = dataAccess.get_VecSize(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes); int[] itemHvos; using (var arrayPtr = MarshalEx.ArrayToNative<int>(arraySize)) { int chvo; dataAccess.VecProp(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes, arraySize, out chvo, arrayPtr); itemHvos = MarshalEx.NativeToArray<int>(arrayPtr, chvo); } foreach (int hvo in itemHvos) { IScrScriptureNote note = Cache.ServiceLocator.GetInstance<IScrScriptureNoteRepository>().GetObject(hvo); if (note.AnnotationTypeRA.Guid == CmAnnotationDefnTags.kguidAnnTranslatorNote || note.AnnotationTypeRA.Guid == CmAnnotationDefnTags.kguidAnnConsultantNote) { // When we are exporting only notes, we only want to export notes that // are translator notes or consultant notes (i.e. no checking error notes). notesToExport.Add(note); } } list.Add(notesToExport); } using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(Cache.ProjectId.Name, FileType.OXESA)) { // TODO: Need to supply a decent default filename. Should it include // a date/time to avoid accidental overwriting? if (dlg.ShowSaveDialog(null, this) == DialogResult.OK) list.SerializeToFile(dlg.FileName); } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Export an Open XML for Exchanging Scripture Annotations (OXESA) file. /// </summary> /// ------------------------------------------------------------------------------------ public bool OnFileExportOXESA(object args) { CheckDisposed(); XmlScrAnnotationsList list = new XmlScrAnnotationsList(Cache); TeNotesVc vc = m_dataEntryView.NotesEditingHelper.CurrentNotesVc; int filterFlid = vc.NotesSequenceHandler.Tag; foreach (int hvoAnnotations in m_scr.BookAnnotationsOS.HvoArray) { int[] allHvos = Cache.GetVectorProperty(hvoAnnotations, filterFlid, true); List<int> notesToExport = new List<int>(); foreach (int noteHvo in allHvos) { ScrScriptureNote note = new ScrScriptureNote(m_cache, noteHvo); if (note.AnnotationTypeRA.Guid == LangProject.kguidAnnTranslatorNote || note.AnnotationTypeRA.Guid == LangProject.kguidAnnConsultantNote) { // When we are exporting only notes, we only want to export notes that // are translator notes or consultant notes (i.e. no checking error notes). notesToExport.Add(noteHvo); } } list.Add(new FdoObjectSet<IScrScriptureNote>(Cache, notesToExport.ToArray(), false)); } using (TeImportExportFileDialog dlg = new TeImportExportFileDialog(Cache, FileType.OXESA)) { // TODO: Need to supply a decent default filename. Should it include // a date/time to avoid accidental overwriting? if (dlg.ShowSaveDialog(null, this) == DialogResult.OK) list.SerializeToFile(dlg.FileName); } return true; }