Exemple #1
0
        public static void HandleNextEvent()
        {
            if (CurrentNum.Equals(null))
            {
                CurrentNum = 0;

                /*string queryString0 = "SELECT* FROM CommentEvent WHERE num = 0;";
                 * SqlCommand command0 = new SqlCommand(queryString0, connectDatabase.myConnection);
                 * SqlDataReader reader0 = command0.ExecuteReader();
                 *
                 * reader0.Read();
                 * CurrentNum++UUID"].ToString());*/
            }

            string temp = "SELECT * " +
                          "FROM CommentEvent" +
                          "WHERE num = {0} ;";

            string        queryString = string.Format(temp, CurrentNum);
            SqlCommand    command     = new SqlCommand(queryString, connectDatabase.myConnection);
            SqlDataReader reader      = command.ExecuteReader();

            reader.Read();
            int state = Int16.Parse(reader["action"].ToString());

            Guid   ID        = Guid.Parse(reader["UUID"].ToString());
            Guid   parent_ID = Guid.Parse(reader["parent_UUID"].ToString());
            Guid   post_ID   = Guid.Parse(reader["post_ID"].ToString());
            string text      = reader["text"].ToString();
            string author    = reader["author"].ToString();

            CurrentNum++;

            if (state == 1)
            {
                Comment myComment = new Comment(ID, parent_ID, post_ID, text, new User(), EventSourcingManager.SearchChildComments(ID));

                //  should pass comment to front-end in order to dispaly on the site
                //
                //

                // AddCommentToFrontEnd();
            }
        }
        /// <summary>
        /// Will look up and return comment based on given GUID.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Comment displayComment(Guid id)
        {
            string temp = "SELECT * " +
                          "FROM CommentEvent" +
                          "WHERE UUID = {0} ;";

            string queryString = string.Format(temp, id);

            SqlCommand    command = new SqlCommand(queryString, connectDatabase.myConnection);
            SqlDataReader reader  = command.ExecuteReader();

            Guid   ID;
            Guid   Parent_ID;
            Guid   Post_ID;
            string Text;
            Guid   User_ID;

            reader.Read();

            ID        = Guid.Parse(reader["UUID"].ToString());
            Parent_ID = Guid.Parse(reader["parent_UUID"].ToString());
            Post_ID   = Guid.Parse(reader["post_ID"].ToString());
            Text      = reader["text"].ToString();
            User_ID   = Guid.Parse(reader["author"].ToString());
            Comment myComment = new Comment(ID, Parent_ID, Post_ID, Text, new User(), EventSourcingManager.SearchChildComments(id));

            reader.Close();
            return(myComment);
        }