Exemplo n.º 1
0
        protected List <DiscussionPanel> Get_Threads()
        {
            List <DiscussionPanel> panels = new List <DiscussionPanel> {
            };

            DataSetTableAdapters.FilmsTableAdapter filmsta = new DataSetTableAdapters.FilmsTableAdapter();
            DataSet.FilmsDataTable films = filmsta.GetActiveFilmsAlphabetically();

            foreach (DataSet.FilmsRow film in films)
            {
                DataSetTableAdapters.PostsTableAdapter poststa = new DataSetTableAdapters.PostsTableAdapter();
                DataSet.PostsDataTable posts    = poststa.GetPostsByFilmId(film.Id, true);
                DataSet.PostsRow       lastpost = null;
                if (posts.Count > 0)
                {
                    lastpost = posts.Last();
                }

                string url = "/DiscussionBoard/discussion.aspx?id=" + film.Id.ToString();

                DiscussionPanel panel = new DiscussionPanel(film, lastpost, posts.Count, url);
                panels.Add(panel);
            }

            return(panels);
        }
Exemplo n.º 2
0
        protected string PostTextFormatter(string input)
        {
            /*
             *   If there is ever a validation error with post quotes, god help you.
             */
            char[] inputarray = input.ToCharArray();

            for (int i = 0; i < inputarray.Length; i++)
            {
                try
                {
                    if (inputarray[i] == '@' && inputarray[i + 1] == '@')
                    {
                        string command = "";

                        for (int j = i; j < inputarray.Length; j++)
                        {
                            if (Char.IsNumber(inputarray[j]) || inputarray[j] == '@')
                            {
                                command += Char.ToString(inputarray[j]);
                            }
                            else
                            {
                                break;
                            }
                        }

                        if (command != "@@" && !String.IsNullOrEmpty(command))
                        {
                            string trimmedcommand = command;
                            trimmedcommand = trimmedcommand.TrimStart('@');
                            trimmedcommand = trimmedcommand.TrimEnd();
                            try
                            {
                                long postid = Convert.ToInt32(trimmedcommand);
                                DataSet.PostsDataTable data = pta.GetPostByPostId(postid);

                                if (data.Count > 0)
                                {
                                    string quotetext = "<blockquote>" + data[0].Text + "</blockquote>";
                                    input = input.Replace(command, quotetext);
                                }
                            }
                            catch (FormatException exc) { /*String formatting error! Don't bother with it*/ };
                        }
                    }
                }
                catch (IndexOutOfRangeException exc)
                {
                    //Doesn't hurt anyone, don't worry
                }
            }

            //NEW LINE FORMATTING
            input = input.Replace("\n", "<br />");
            //TAB FORMATTING
            input = input.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
            return(input);
        }