Example #1
0
 public VerseBookMarkTask(
     UserSession us,
     UserProfile user_profile,
     Verse start,
     Verse end,
     DateTime datetime,
     BookmarkVerseRecord bvr)
 {
     this.us = us;
     this.user_profile = user_profile;
     this.start = start;
     this.end = end;
     this.datetime = datetime;
     this.bvr = bvr;
 }
Example #2
0
 /*this method updates the DB, but should not be called from outside. must be called before after the
  * history list has been updated so that in memory data is insync with persistant data.
  */
 private void saveOrUpdateVerseRequestToDB(
     UserSession user_session,
     UserProfile user_profile,
     Verse start,
     Verse end,
     DateTime datetime,
     BookmarkVerseRecord bvr,
     bool isNew)
 {
     VerseBookMarkTask vbmt = new VerseBookMarkTask(
             user_session,
             user_profile,
             start,
             end,
             datetime,
             bvr);
         if (isNew)
         {
             vbmt.BookMarkVerse();
         }
         else
         {
             vbmt.UpdateBookMarkVerse();
         }
 }
Example #3
0
        /*this stores the bookmark  and is responsible for maintaining synchronisation between memory
         * and DB views by also calling the save/update to db method.
         */
        public int saveOrUpdateBookmark(
            UserSession user_session,
            UserProfile user_profile,
            Verse start_verse,
            Verse end_verse)
        {
            DateTime dt = DateTime.Now;
            //update DB

            String verse_start_str = start_verse.getVerseReference();
            String verse_end_str;

            if (end_verse == null)
                verse_end_str = "NULL";
            else
                verse_end_str = end_verse.getVerseReference();

            //now update in Memory View.
            long b_id = -1;
            bool isNew = false;
            if (bookmark_verse != null)
            {
                b_id = bookmark_verse.id;
            }
            else
            {
                isNew = true;
            }
            bookmark_verse = new BookmarkVerseRecord(
                    b_id,
                    user_profile.id,
                    user_session.session_id,
                    dt,
                    verse_start_str,
                    verse_end_str);

            saveOrUpdateVerseRequestToDB(
                user_session,
                user_profile,
                start_verse,
                end_verse,
                dt,
                bookmark_verse,
                isNew);

            return 0;
        }
Example #4
0
        private void loadVBookMarkFromDB(
            UserProfile user_profile,
            UserSession user_session)
        {
            string sqlQuery =
            "SELECT id, user_id, session_id, datetime, start_verse, end_verse " +
            " FROM bookmarks WHERE user_id = '" + user_profile.id + "'";
            MySqlConnection conn = DBManager.getConnection();
            MySqlDataReader rdr = null;
            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(sqlQuery, conn);
                rdr = cmd.ExecuteReader();
                long id = -1;
                long user_id= -1;
                long session_id= -1;
                DateTime datetime;
                String start_verse;
                String end_verse;

                if (rdr.Read())
                {
                    id = long.Parse((rdr[0]).ToString());
                    user_id = long.Parse((rdr[1]).ToString());
                    session_id = long.Parse((rdr[2]).ToString());
                    datetime = DateTime.Parse(rdr[3].ToString());
                    start_verse = rdr[4].ToString();
                    end_verse = rdr[5].ToString();
                    bookmark_verse = new BookmarkVerseRecord(
                        id,
                        user_id,
                        session_id,
                        datetime,
                        start_verse,
                        end_verse);

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (rdr != null)
                    rdr.Close();
                conn.Close();
            }
        }