コード例 #1
0
        public static HadithPerChapter getHadithInChapter(int HadithId, int PageNo, int ChapterNo, int VerseSize, Languages selLang = Languages.English)
        {
            HadithPerChapter data = new HadithPerChapter();

            try
            {
                data.Chapter = getChapter(HadithId, PageNo, ChapterNo);
                if (data.Chapter == null)
                {
                    data.Chapter = new hadithchapter()
                    {
                        ChapterNo = ChapterNo, HadithID = HadithId, PageNo = PageNo, Title = "Chapter not found", ChapterID = -1, TitleArabic = "...", Intro = "..."
                    };
                }
                data.Contents = new ObservableCollection <HadithContentExt>();

                var connection = new SQLiteConnection(Conn);
                //get all hadith with existing chapter
                using (var context = new DataContext(connection))
                {
                    //CleanUpHtml()
                    var items = (from a in context.GetTable <hadithcontent>()
                                 where a.HadithID == HadithId && a.PageNo == PageNo && a.ChapterNo == ChapterNo
                                 orderby a.HadithOrder ascending
                                 select new HadithContentExt {
                        BookRef = a.BookRef, ChapterNo = a.ChapterNo, ContentArabic = CleanUpHtml(a.ContentArabic), ContentEnglish = a.ContentEnglish.Trim(), ContentID = a.ContentID, ContentIndonesia = a.ContentIndonesia.Trim(), ContentUrdu = a.ContentUrdu.Trim(),
                        Grade = a.Grade.Trim(), HadithID = a.HadithID, HadithOrder = a.HadithOrder, Narated = a.Narated.Trim(), OtherRef = a.OtherRef, PageNo = a.PageNo, Reference = a.Reference, SanadBottom = CleanUpHtml(a.SanadBottom), SanadTop = CleanUpHtml(a.SanadTop), USCRef = a.USCRef, VerseSize = VerseSize, UrlRef = a.UrlRef
                    });
                    foreach (var newNode in items)
                    {
                        //HadithContentExt newNode = item;
                        switch (selLang)
                        {
                        case Languages.English:
                            newNode.Translation = newNode.ContentEnglish;
                            break;

                        case Languages.Indonesia:
                            newNode.Translation = newNode.ContentIndonesia;
                            break;

                        case Languages.Urdu:
                            newNode.Translation = newNode.ContentUrdu;
                            break;
                        }
                        data.Contents.Add(newNode);
                    }
                }
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex.Message + " - " + ex.StackTrace);
            }
            return(data);
        }
コード例 #2
0
        public static ObservableCollection <HadithPerChapter> getHadithInPage(int HadithId, int PageNo, Languages selLang = Languages.English)
        {
            ObservableCollection <HadithPerChapter> data = new ObservableCollection <HadithPerChapter> ();

            try
            {
                var connection = new SQLiteConnection(Conn);
                //get all hadith with existing chapter
                using (var context = new DataContext(connection))
                {
                    var chapters = getChapters(HadithId, PageNo);
                    foreach (var chap in chapters)
                    {
                        var newNode = new HadithPerChapter();
                        newNode.Chapter  = chap;
                        newNode.Contents = getContent(HadithId, PageNo, selLang, chap.ChapterNo);
                        data.Add(newNode);
                    }
                }
                //add all hadith without chapter
                {
                    var newNode = new HadithPerChapter();
                    newNode.Chapter = new hadithchapter()
                    {
                        ChapterNo = 999, Intro = "These hadith have not been mapped to specific chapter", Title = "Hadith without chapters", TitleArabic = "-", HadithID = HadithId, PageNo = PageNo
                    };
                    newNode.Contents = getContent(HadithId, PageNo, selLang, -1);
                    data.Add(newNode);
                }
            }
            catch (Exception ex)
            {
                Logs.WriteLog(ex.Message + " - " + ex.StackTrace);
            }
            return(data);
        }