예제 #1
0
        private void LibraryGridView_Click(object sender, AdapterView.ItemClickEventArgs e)
        {
            NavStruct navStruct;
            int       book    = 0;
            int       chapter = 0;
            int       verse   = 0;
            string    nav     = string.Empty;
            string    tag     = (string)((LibraryGridView)sender).Tag;

            // Bible Book
            if (LibraryMode == Library.Bible)
            {
                book    = (tag == "hebrew") ? e.Position + 1 : e.Position + 40;
                nav     = LibraryMode.ToString() + book.ToString();
                chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : 1;
            }
            else if (App.STATE.CurrentLibrary == Library.Books)
            {
                // Selected book
                string selectedBook = (string)(sender as LibraryGridView).adapter.GetItem(e.Position);

                WOLArticle pub = App.STATE.PrimaryBooks.Single(a => a.PublicationName.Contains(selectedBook));

                book    = NavStruct.Parse(pub.ArticleMEPSID).Book;
                nav     = LibraryMode.ToString() + book.ToString();
                chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : 1;
            }
            else if (App.STATE.CurrentLibrary == Library.Insight)
            {
                InsightArticle insight;

                insight = App.FUNCTIONS.GetInsightArticlesByGroup(e.Position).FirstOrDefault();

                //book = e.Position;
                //nav = LibraryMode.ToString() + e.Position.ToString();
                //chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : int.Parse(insight.MEPSID);
                //verse = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Verse : insight.OrderNumber;

                book    = e.Position;
                chapter = int.Parse(insight.MEPSID);
                verse   = insight.OrderNumber;
            }

            App.STATE.CurrentArticleGroup = e.Position;

            NavStruct article = new NavStruct()
            {
                Book    = book,
                Chapter = chapter,
                Verse   = verse
            };

            LoadArticle(article);
        }
예제 #2
0
        private string GetArticle(string storehouse)
        {
            if (primaryArticles == null || secondaryArticles == null)
            {
                return(GetArticleFromStorehouse(storehouse));
            }

            Library    library = App.STATE.CurrentLibrary;
            WOLArticle article = new WOLArticle();
            string     title   = string.Empty;
            string     html    = string.Empty;

            //////////////////////////////////////////////////////////////////////////
            // TRY TO GET ARTICLE, IF NOT, DISPLAY NOTHING
            //////////////////////////////////////////////////////////////////////////
            try
            {
                string meps = (library == Library.Insight) ? SelectedArticle.Chapter.ToString() : SelectedArticle.ToString();

                // Get article
                if (storehouse == Storehouse.Primary)
                {
                    article = primaryArticles.Single(a => a.ArticleMEPSID.Contains(meps));
                }
                else if (storehouse == Storehouse.Secondary)
                {
                    article = secondaryArticles.Single(a => a.ArticleMEPSID.Contains(meps));
                }

                // Set Publication title and content
                if (library == Library.Bible)
                {
                    title = article.ArticleTitle.Replace("\n", "<br/>");
                    html  = "<center><h3>" + title + "</h3></center>" + article.ArticleContent;
                }
                else
                {
                    title = article.PublicationName.Replace("\n", "<br/>");
                    html  = article.ArticleContent;
                }

                if (storehouse == ((App.STATE.Swapped == false) ? Storehouse.Primary : Storehouse.Secondary))
                {
                    text.SetText(Html.FromHtml("<center>" + App.FUNCTIONS.RemoveDigits(title) + "</center>"), TextView.BufferType.Normal);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(html);
        }
예제 #3
0
        public long AddToLibrary(WOLArticle article)
        {
            var initialValues = new ContentValues();

            initialValues.Put(KeyPublicationCode, (article.PublicationCode != null) ? article.PublicationCode : "");
            initialValues.Put(KeyPublicationName, (article.PublicationName != null) ? article.PublicationName : "");
            initialValues.Put(KeyArticleTitle, article.ArticleTitle);
            initialValues.Put(KeyArticleMEPSID, article.ArticleMEPSID);
            initialValues.Put(KeyArticleLocation, article.ArticleLocation);
            initialValues.Put(KeyArticleContent, article.ArticleContent);
            initialValues.Put(KeyArticleGroup, article.ArticleGroup);
            initialValues.Put(KeyArticleURL, article.ArticleURL);

            return(this.Database.Insert(Type, null, initialValues));
        }
예제 #4
0
        public static WOLArticle ToArticle(this ICursor cursor)
        {
            cursor.MoveToFirst();

            WOLArticle article = new WOLArticle();

            try
            {
                article.ArticleContent  = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleContent));
                article.ArticleLocation = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleLocation));
                article.ArticleMEPSID   = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleMEPSID));
                article.ArticleTitle    = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleTitle));
                article.PublicationCode = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyPublicationCode));
                article.PublicationName = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyPublicationName));
                article.ArticleGroup    = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleGroup));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(article);
        }
예제 #5
0
        private string GetArticleFromStorehouse(string storehouse)
        {
            Library    library = App.STATE.CurrentLibrary;
            WOLArticle article = new WOLArticle();
            string     title   = string.Empty;
            string     html    = string.Empty;

            JwStore database = new JwStore(storehouse);

            database.Open();

            //////////////////////////////////////////////////////////////////////////
            // TRY TO GET ARTICLE, IF NOT, DISPLAY NOTHING
            //////////////////////////////////////////////////////////////////////////
            //try
            //{
            //////////////////////////////////////////////////////////////////////////
            // BIBLE
            //////////////////////////////////////////////////////////////////////////
            if (library == Library.Bible)
            {
                article = database.QueryBible(SelectedArticle).ToArticle();
                title   = article.ArticleTitle.Replace("\n", "<br/>");

                if (storehouse == Storehouse.Primary)
                {
                    primaryArticles = database.QueryAllArticlesByBibleChapter(title.Split('<')[0]).ToArticleList();

                    foreach (var a in primaryArticles)
                    {
                        primaryChapters.Add(Html.FromHtml(a.ArticleLocation));
                    }
                }
                else if (storehouse == Storehouse.Secondary)
                {
                    secondaryArticles = database.QueryAllArticlesByBibleChapter(title.Split('<')[0]).ToArticleList();

                    foreach (var a in secondaryArticles)
                    {
                        secondaryChapters.Add(Html.FromHtml(a.ArticleLocation));
                    }
                }
            }
            //////////////////////////////////////////////////////////////////////////
            // DAILY TEXT
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.DailyText)
            {
                article = database.QueryDailyText(SelectedArticle.ToString()).ToArticle();

                if (storehouse == Storehouse.Primary)
                {
                    primaryArticles = database.QueryArticles(article.PublicationCode).ToArticleList();

                    foreach (var a in primaryArticles)
                    {
                        primaryChapters.Add(Html.FromHtml(a.ArticleTitle));
                    }
                }
                else if (storehouse == Storehouse.Secondary)
                {
                    secondaryArticles = database.QueryArticles(article.PublicationCode).ToArticleList();

                    foreach (var a in secondaryArticles)
                    {
                        secondaryChapters.Add(Html.FromHtml(a.ArticleTitle));
                    }
                }

                title = article.PublicationName.Replace("\n", "<br/>");
            }
            //////////////////////////////////////////////////////////////////////////
            // INSIGHT VOLUMES
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.Insight)
            {
                article = database.QueryInsight(SelectedArticle).ToArticle();

                if (storehouse == Storehouse.Primary)
                {
                    //primaryArticles = database.QueryArticles("it").ToArticleList();
                    primaryArticles = database.QueryMatchingArticles(insightMEPS.ToList()).ToArticleList();

                    foreach (var a in primaryArticles)
                    {
                        primaryChapters.Add(Html.FromHtml(a.ArticleTitle + "<br/><i>" + a.ArticleLocation + "</i>"));
                    }
                }
                else if (storehouse == Storehouse.Secondary)
                {
                    //secondaryArticles = database.QueryArticles("it").ToArticleList();
                    secondaryArticles = database.QueryMatchingArticles(insightMEPS.ToList()).ToArticleList();

                    foreach (var a in secondaryArticles)
                    {
                        secondaryChapters.Add(Html.FromHtml(a.ArticleTitle + "<br/><i>" + a.ArticleLocation + "</i>"));
                    }
                }

                title = article.PublicationName.Replace("\n", "<br/>");
            }
            //////////////////////////////////////////////////////////////////////////
            // BOOKS & PUBLICATIONS
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.Books)
            {
                article = database.QueryPublication(SelectedArticle).ToArticle();

                if (storehouse == Storehouse.Primary)
                {
                    primaryArticles = database.QueryArticles(article.PublicationCode).ToArticleList();

                    foreach (var a in primaryArticles)
                    {
                        primaryChapters.Add(Html.FromHtml(a.ArticleTitle + "<br/><i>" + a.ArticleLocation + "</i>"));
                    }
                }
                else if (storehouse == Storehouse.Secondary)
                {
                    secondaryArticles = database.QueryArticles(article.PublicationCode).ToArticleList();

                    foreach (var a in secondaryArticles)
                    {
                        secondaryChapters.Add(Html.FromHtml(a.ArticleTitle + "<br/><i>" + a.ArticleLocation + "</i>"));
                    }
                }

                title = article.PublicationName.Replace("\n", "<br/>");
            }
            //////////////////////////////////////////////////////////////////////////
            // ALL OTHER
            //////////////////////////////////////////////////////////////////////////
            else
            {
                if (storehouse == Storehouse.Primary)
                {
                }
                else if (storehouse == Storehouse.Secondary)
                {
                }
            }
            //}
            //catch(Exception e)
            //{
            //    Console.WriteLine(e.Message);
            //}

            // Close database
            database.Close();

            // Set Publication title
            if (storehouse == ((App.STATE.Swapped == false) ? Storehouse.Primary : Storehouse.Secondary))
            {
                text.SetText(Html.FromHtml("<center>" + App.FUNCTIONS.RemoveDigits(title) + "</center>"), TextView.BufferType.Normal);
            }

            // Set Article content html
            if (library == Library.Bible)
            {
                html = "<center><h3>" + title + "</h3></center>" + article.ArticleContent;
            }
            else
            {
                html = article.ArticleContent;
            }

            return(html);
        }