Beispiel #1
0
        public void DefaultToSingleVoice_TooComplexToAssignAccurately_ReturnsTrue(string bookCode)
        {
            SingleVoiceReason singleVoiceReason;

            Assert.True(BookMetadata.DefaultToSingleVoice(bookCode, out singleVoiceReason));
            Assert.AreEqual(SingleVoiceReason.TooComplexToAssignAccurately, singleVoiceReason);
        }
Beispiel #2
0
        private IBookImporter GetBookImporter(TxtBookImporter txtToBookConverter, BookMetadata bookMetadata)
        {
            if (bookMetadata.BookImportType == BookImportType.Voice ||
                bookMetadata.BookImportType == BookImportType.Simple)
            {
                if (bookMetadata.BookPath.ToLower().EndsWith(".txt"))
                {
                    return(txtToBookConverter);
                }
            }

            throw new NotSupportedException($"Couldn't find book import type for book import {bookMetadata.BookImportType}, path: {bookMetadata.BookPath}.");
        }
        private void BtnOk_Click(object sender, EventArgs e)
        {
            List <BookScript> booksToAskUserAbout = new List <BookScript>();

            foreach (var book in m_project.AvailableBooks)
            {
                book.IncludeInScript = m_includeInScript[book.Code];

                if (!book.IncludeInScript)
                {
                    continue;
                }

                var bookScript = m_project.IncludedBooks.Single(b => b.BookId == book.Code);
                if (bookScript.SingleVoice != m_multiVoice[book.Code])
                {
                    continue;
                }

                SingleVoiceReason singleVoiceReason;
                if (m_multiVoice[book.Code] && BookMetadata.DefaultToSingleVoice(book.Code, out singleVoiceReason) && singleVoiceReason == SingleVoiceReason.TooComplexToAssignAccurately)
                {
                    booksToAskUserAbout.Add(bookScript);
                    continue;
                }

                bookScript.SingleVoice = !m_multiVoice[book.Code];
                Analytics.Track("SetSingleVoice", new Dictionary <string, string>
                {
                    { "book", book.Code },
                    { "singleVoice", bookScript.SingleVoice.ToString() },
                    { "method", "ScriptureRangeSelectionDlg.m_btnOk_Click" }
                });
            }

            if (booksToAskUserAbout.Any() && !ConfirmSetToMultiVoice(booksToAskUserAbout))
            {
                DialogResult = DialogResult.None;
                return;
            }

            m_project.BookSelectionStatus = BookSelectionStatus.Reviewed;

            Analytics.Track("SelectBooks", new Dictionary <string, string> {
                { "bookSummary", m_project.BookSelectionSummary }
            });
        }
Beispiel #4
0
        public BookMetadata GetNextSearchResult(SessionData sessionData, int bookId)
        {
            if (bookId == -1)
            {
                return(null); // no results
            }
            // take the one with bookId
            var work = Ctx.Works
                       .Include(w => w.Fragments.First().FrozenFragment.Published)
                       .FirstOrDefault(w => w.Id == bookId);
            // Create Meta Data
            var book = new BookMetadata();

            SetBookMetaData(book, work);
            //
            SaveChanges();
            return(book);
        }
Beispiel #5
0
        private async Task <DlMetadataDetails> SetDlBookMetaData(int bookId, UserCredential userCredential, string deviceId)
        {
            DlMetadata dlMetaData = new DlMetadata()
            {
                Email    = userCredential.Email,
                DeviceId = deviceId,
                DlId     = bookId
            };
            DlMetadataDetails dlMetaDataDetails = null;
            //before call this function,program has ensured network available.
            var result = await deliveryService.DlMetadata(dlMetaData);

            if (result.IsSuccess)
            {
                dlMetaDataDetails = JsonConvert.DeserializeObject <DlMetadataDetails>(result.Content);
                if (dlMetaDataDetails != null)
                {
                    var metadata = publicationAccess.GetDlBookMetedata(bookId, userCredential);
                    if (metadata == null)//insert metadata
                    {
                        BookMetadata entity = new BookMetadata
                        {
                            BookId            = bookId,
                            ServiceCode       = userCredential.ServiceCode,
                            Email             = userCredential.Email,
                            IncludedGuideCard = JsonConvert.SerializeObject(dlMetaDataDetails.GuideCard)
                        };
                        publicationAccess.InsertMetadata(entity);
                    }
                    else//update metadata
                    {
                        metadata.IncludedGuideCard = JsonConvert.SerializeObject(dlMetaDataDetails.GuideCard);
                        publicationAccess.Update(metadata);
                    }
                }
            }
            return(dlMetaDataDetails);
        }
 public void InsertMetadata(BookMetadata metadata)
 {
     Insert <BookMetadata>(MainDbPath, metadata);
 }
 public int Update(BookMetadata entity)
 {
     return(Update <BookMetadata>(MainDbPath, entity));
 }
Beispiel #8
0
        private IBookmarksImporter GetBookmarksImporter(VoiceBookmarksImporter voiceBookMarksImporter, SimpleBookmarksImporter simpleBookmarksImporter, BookMetadata bookMetadata)
        {
            if (bookMetadata.BookImportType == BookImportType.Voice)
            {
                return(voiceBookMarksImporter);
            }

            if (bookMetadata.BookImportType == BookImportType.Simple)
            {
                return(simpleBookmarksImporter);
            }

            throw new NotSupportedException($"Couldn't find book importer for book import type {bookMetadata.BookImportType}.");
        }