private void btnAddWords_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var currentControl = VerseControl;//this.Controls.OfType<Control>().Where(x => x is VerseEditorControl).FirstOrDefault() as VerseEditorControl; if (currentControl.IsNotNull()) { var start = 1; if (currentControl.Verse.VerseWords.IsNotNull() && currentControl.Verse.VerseWords.Count > 0) { start = currentControl.Verse.VerseWords.Max(x => x.NumberOfVerseWord) + 1; } var words = XtraInputBox.Show("Type words:", "Add words", ""); if (words.IsNotNullOrEmpty()) { var table = words.Split(' '); if (table.Length > 0) { for (int i = 0; i < table.Length; i++) { var _word = table[i]; var word = new VerseWord(Uow) { ParentVerse = currentControl.Verse, Translation = String.Empty, Transliteration = TransliterationController.TransliterateWord(_word), Citation = false, StrongCode = null, FootnoteText = String.Empty, GrammarCode = null, NumberOfVerseWord = start + i, SourceWord = _word, WordOfJesus = false }; word.Save(); var control = currentControl.CreateVerseWordControl(word); currentControl.VerseWordsControl.Controls.Add(control); } currentControl.Verse.Save(); Uow.CommitChanges(); } } } }
private void btnAddWords_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (VerseControl.IsNotNull()) { var start = 1; if (VerseControl.Verse.VerseWords.IsNotNull() && VerseControl.Verse.VerseWords.Count > 0) { start = VerseControl.Verse.VerseWords.Max(x => x.NumberOfVerseWord) + 1; } var words = XtraInputBox.Show("Type words:", "Add words", ""); if (words.IsNotNullOrEmpty()) { var table = words.Split(' '); if (table.Length > 0) { VerseControl.Save(); // save changes before for (int i = 0; i < table.Length; i++) { var _word = table[i]; var word = new VerseWord(Uow) { ParentVerse = VerseControl.Verse, Translation = String.Empty, Transliteration = TransliterationController.TransliterateWord(_word), Citation = false, StrongCode = null, FootnoteText = String.Empty, GrammarCode = null, NumberOfVerseWord = start + i, SourceWord = _word, WordOfJesus = false }; word.Save(); } VerseControl.Verse.Save(); Uow.CommitChanges(); VerseControl.LoadData(VerseControl.Verse); } } } }
private void btnAddWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var currentControl = VerseControl;// this.Controls.OfType<Control>().Where(x => x is VerseEditorControl).FirstOrDefault() as VerseEditorControl; if (currentControl.IsNotNull()) { var position = XtraInputBox.Show("Indicate the word index :", "Insert new word at index", "1"); if (position.IsNotNullOrEmpty()) { var index = position.ToInt(); foreach (var item in currentControl.Verse.VerseWords) { if (item.NumberOfVerseWord >= index) { item.NumberOfVerseWord++; } } var word = new VerseWord(Uow) { ParentVerse = currentControl.Verse, Translation = String.Empty, Transliteration = String.Empty, Citation = false, StrongCode = null, FootnoteText = String.Empty, GrammarCode = null, NumberOfVerseWord = index, SourceWord = String.Empty, WordOfJesus = false }; word.Save(); var control = currentControl.CreateVerseWordControl(word); currentControl.VerseWordsControl.Controls.Add(control); currentControl.VerseWordsControl.Controls.SetChildIndex(control, index - 1); currentControl.Verse.Save(); Uow.CommitChanges(); } } }
private void btnAddWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (VerseControl.IsNotNull()) { var position = XtraInputBox.Show("Indicate the word index :", "Insert new word at index", "1"); if (position.IsNotNullOrEmpty()) { VerseControl.Save(); // save changes var index = position.ToInt(); foreach (var item in VerseControl.Verse.VerseWords) { if (item.NumberOfVerseWord >= index) { item.NumberOfVerseWord++; } } var word = new VerseWord(Uow) { ParentVerse = VerseControl.Verse, Translation = String.Empty, Transliteration = String.Empty, Citation = false, StrongCode = null, FootnoteText = String.Empty, GrammarCode = null, NumberOfVerseWord = index, SourceWord = String.Empty, WordOfJesus = false }; word.Save(); VerseControl.Verse.Save(); Uow.CommitChanges(); VerseControl.LoadData(VerseControl.Verse, false); } } }
public void Build(UnitOfWork uow, string byzPath, string troPath, string pbpwPath) { var byzConnection = GetConnection(byzPath); var troConnection = GetConnection(troPath); var pbpwConnection = GetConnection(pbpwPath); var translation = CreateTranslation(uow); TroVerses = GetTroVerseInfos(troConnection); ByzVerses = GetByzVerses(byzConnection); PbpwVerses = GetPbpwVerseInfos(pbpwConnection); Strongs = new XPQuery <StrongCode>(uow).Where(x => x.Lang == Language.Greek); BaseBooks = new XPQuery <BookBase>(uow).Where(x => x.Status.BiblePart == BiblePart.NewTestament).OrderBy(x => x.NumberOfBook); GrammarCodes = new XPQuery <GrammarCode>(uow).OrderBy(x => x.GrammarCodeVariant1); foreach (var baseBook in BaseBooks) { var chapterCount = ByzVerses.Where(x => x.Book == baseBook.NumberOfBook) .Max(x => x.Chapter); Book book = null; if (book.IsNull()) { book = new Book(uow) { BaseBook = baseBook, BookName = baseBook.BookName, BookShortcut = baseBook.BookShortcut, Color = baseBook.Color, NumberOfBook = baseBook.NumberOfBook, NumberOfChapters = chapterCount, ParentTranslation = translation }; book.Save(); uow.CommitChanges(); uow.ReloadChangedObjects(); #if DEBUG System.Diagnostics.Debug.WriteLine("-----------------------------------------------"); System.Diagnostics.Debug.Write($"{baseBook.BookTitle}"); #endif } for (int chapterIndex = 1; chapterIndex <= chapterCount; chapterIndex++) { var versesCount = ByzVerses.Where(x => x.Book == baseBook.NumberOfBook && x.Chapter == chapterIndex) .Max(x => x.Verse); Chapter chapter = null; if (chapter.IsNull()) { chapter = new Chapter(uow) { NumberOfChapter = chapterIndex, NumberOfVerses = versesCount, ParentBook = book }; chapter.Save(); uow.CommitChanges(); uow.ReloadChangedObjects(); #if DEBUG System.Diagnostics.Debug.WriteLine(""); System.Diagnostics.Debug.Write($"Rozdział {chapterIndex}"); #endif } for (int verseIndex = 1; verseIndex <= versesCount; verseIndex++) { Verse verse = null; if (verse.IsNull()) { var pbpwVerse = PbpwVerses.Where(x => x.Book == baseBook.NumberOfBook && x.Chapter == chapterIndex && x.Verse == verseIndex).FirstOrDefault(); verse = new Verse(uow) { NumberOfVerse = verseIndex, ParentChapter = chapter, Text = pbpwVerse.IsNotNull() ? pbpwVerse.VerseText : String.Empty }; verse.Save(); uow.CommitChanges(); uow.ReloadChangedObjects(); #if DEBUG System.Diagnostics.Debug.WriteLine(""); System.Diagnostics.Debug.Write($"{verseIndex}. "); #endif } var vi = ByzVerses.Where(x => x.Book == baseBook.NumberOfBook && x.Chapter == chapterIndex && x.Verse == verseIndex).FirstOrDefault(); if (vi.IsNotNull()) { var ti = GetTroVerseInfo(vi); if (ti.IsNotNull()) { var wordIndex = 1; foreach (var viWord in vi.Words) { var tiWord = ti.Words.Where(x => x.WordIndex == viWord.WordIndex).FirstOrDefault(); if (tiWord.IsNotNull()) { if (tiWord.StrongCode != viWord.StrongCode) { // może kod się różni ale dla pewności porównam transliterację if (!Compare(viWord, tiWord)) { // tu trzeba sprawdzić czy to słowo nie występuje gdzieś dalej // wówczas trzeba przetłumaczyć słowa w oparciu o wcześniej // zbudowany słownik aż do wystąpienia tego słowa w tekście // TRO tiWord = ti.Words.Where(x => x.StrongCode == viWord.StrongCode && x.GrammarCode != null && x.GrammarCode.Contains(viWord.GrammarCode) && x.WordIndex >= viWord.WordIndex).FirstOrDefault(); if (tiWord.IsNull()) { tiWord = ti.Words.Where(x => x.StrongCode == viWord.StrongCode && x.GrammarCode != null && x.GrammarCode.Contains(viWord.GrammarCode)).FirstOrDefault(); } if (tiWord.IsNull()) { tiWord = new TroVerseWordInfo() { GrammarCode = viWord.GrammarCode, Text = viWord.Text, StrongCode = viWord.StrongCode, Translation = viWord.Text.TransliterateAncientGreek(), Transliterit = viWord.Text.TransliterateAncientGreek(), WordIndex = viWord.WordIndex }; } } } } else { tiWord = new TroVerseWordInfo() { GrammarCode = viWord.GrammarCode, Text = viWord.Text, StrongCode = viWord.StrongCode, Translation = EMPTY_TRANSLATION, Transliterit = viWord.Text.TransliterateAncientGreek(), WordIndex = viWord.WordIndex }; } VerseWord word = null; if (word.IsNull()) { word = new VerseWord(uow) { GrammarCode = GetGrammarCode(uow, viWord.GrammarCode, tiWord.IsNotNull() ? tiWord.GrammarCode : null), StrongCode = GetStrongCode(viWord.StrongCode), NumberOfVerseWord = wordIndex, ParentVerse = verse, SourceWord = viWord.Text, Translation = tiWord.IsNotNull() ? tiWord.Translation : String.Empty, Transliteration = tiWord.IsNotNull() ? tiWord.Transliterit : viWord.Text.TransliterateAncientGreek() }; word.Save(); uow.CommitChanges(); uow.ReloadChangedObjects(); #if DEBUG System.Diagnostics.Debug.Write($"{word.Translation} "); #endif } wordIndex++; } } } } } } }