Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #61 (permalink)  
Old September 15th, 2007, 08:00 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jimi, I see on your website that you have forumcategories... on your "ShowForums.aspx"

Do you prevent this code on your forums_v3?

What does your "forums_v3" do? (besides add priority to posts)

--------------------------------
I know that you used ajax for your "ShowForums.aspx"
Do you created a "categories" table? Or just added "parentID in your "tbh_forums" ?





  #62 (permalink)  
Old September 16th, 2007, 05:38 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

double post
  #63 (permalink)  
Old September 16th, 2007, 05:43 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Hi again max,

the forums_v3 (or whatever i called it!! :)) includes:

1. tabular layout of data (giving last poster etc)
2. priority flag on posts

that's basically it (from what i remember). Of course, since then, i've made a few amendments to my own code, (such as the link to the category table). Basically, i've added a new column in the forums table (CategoryID) which allows me to 'map' the forums directly to a category. 'global' forums (News and Announcements, Requests and suggestions) have a categoryid=0 which allows them to be seen across all categories, rather than having 'admin' forums for each category.

i've used category as a 'driver' for this particular website due to the fact that my topic areas are very clearly defined and 'fit' into a category type structure. when implementing my forums, it was a no-brainer to carry on with this approach. the only area that i've still to add category filtering onto is my search routine. at present, when i 'save' a search (for the search tags), i'm only saving the generic words and adding a count value onto them. i really 'should' map this by category too as it could be misleading to see 'clay' for example being the top search tag over the past 24 hours when it's unrelated to any category matching (i.e. was the 'clay' related to pottery or is there a band called 'clay' that had been getting looked up. you'll see what i mean if you do a search from my search box (i've still got the default articles and posts etc, so words like ipsum amet etc bring up 'good' results). so, this will be my next minor enhancement to add categories across the search tags.

but getting back to the forums stuff, i never looked into hierarchies with parentid's, (even tho' a lot of data that i work with outside of this project operates in this self referential way) as i really wanted to keep it clean and simple with a narrow scope to begin with. however, i can see a combination of categoryid and parentid being a very powerful way to both present and filter data and may look to implement a similar structure, even if it's 'never' used.

hope this helps....
  #64 (permalink)  
Old September 16th, 2007, 06:43 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Jimi!

In version 1(thePhille) i only had 2 levels:
-Category
-Forum
 ...Topics

But i noted that i had a long forum with this structure....
So, because i'm starting from zero, i will add another level:
-Category
-Forum
-SubForum
 ...Topics

(But this is easy... I made this to my articles sections)

How do you bind your forumCategories and forumCategoriesForums? With a single connection? Or first you bind all categories to your ajax top panel and then bind (with n sqlConnections) the list of forums for each of n categories?

My big problem (I spent many time with this in version 1) is display different images if the Topic/forum/parentForum is new or not! Because this need to be dynamically updated.

Thanks,
Max

  #65 (permalink)  
Old September 16th, 2007, 08:08 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by Maxxim


How do you bind your forumCategories and forumCategoriesForums? With a single connection? Or first you bind all categories to your ajax top panel and then bind (with n sqlConnections) the list of forums for each of n categories?
Max,

I use a repeater with objCategories as the datasourceID. objCategories is populated from GetCategories(). I also have objAllForums which is populated with a method that calls GetForums(int32 CategoryID). in the Repeater1_ItemCreated event in code behind, i change the paramater string:

        protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            Category catList = (Category)e.Item.DataItem;
            if (catList != null)
            {
                objAllForums.SelectParameters["CategoryID"].DefaultValue = catList.ID.ToString();
                GridView gv = (GridView)e.Item.FindControl("gvwForums");
                //GridView gv = (GridView)CloneControl((GridView)e.Item.FindContro l("gvwForums"));
                if (gv != null)
                {
                    gv.DataSource = objAllForums;
                    gv.ID = catList.ID.ToString() + "_gvwForums";
                    gv.AutoGenerateColumns = false;
                    gv.DataBind();
                    PageView pv = new PageView();
                    pv.Controls.Add(gv);
                    // IE browser hack
                    if (Request.Browser.Browser.ToString() == "IE")
                        RadMultiPage1.Height = 20;
                    RadMultiPage1.PageViews.Add(pv);
                    string userName = COOKIE_NAME; //HttpContext.Current.Request.AnonymousID == null ? User.Identity.Name : HttpContext.Current.Request.AnonymousID;
                    if (Request.Cookies[userName] != null)
                    {
                        try
                        {
                            short tabIndex = short.Parse(Request.Cookies[userName].Values["_forums"]);
                            if (pv.Index == tabIndex)
                            {
                                pv.Selected = true;
                                if (RadTabStrip1.Tabs.Count > 0)
                                {
                                    RadTabStrip1.Tabs[tabIndex > 0 ? tabIndex : (short)0].Selected = true;
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
        }

and then rebind the gridview to the objAllForums with the newly changed parameter. it's a very simple way to do it but quite effective. at the same time in this event i do my ajax stuff and add new tabs as the categories repeater item is created and then add a new gridview into a new ajax PageView, which is then added to the RadMultiPage (this is all done with telerik controls, but the same thing would be possible with MS ajax).

That's basically it - ie, just a single connection, requeried as the Repeater1_ItemCreated event is called.

hopefully, this should give you a quick start on how you'd like to implement your 'idea'

jimi

http://www.originaltalent.com
  #66 (permalink)  
Old September 16th, 2007, 11:58 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by jimibt
I also have objAllForums which is populated with a method that calls GetForums(int32 CategoryID).
but jimi, everytime you call "GetForums(int32 CategoryID)" you are making an sql connection!

If you have 6 categories you do one connection to get categories and bind your repeater and then you make 6 more connections to bind the forums for each category! Right?



  #67 (permalink)  
Old September 16th, 2007, 01:15 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
quote:Originally posted by Maxxim
 
Quote:
quote:Originally posted by jimibt
Quote:
I also have objAllForums which is populated with a method that calls GetForums(int32 CategoryID).
but jimi, everytime you call "GetForums(int32 CategoryID)" you are making an sql connection!

If you have 6 categories you do one connection to get categories and bind your repeater and then you make 6 more connections to bind the forums for each category! Right?
yes, i guess that is correct. though with it being cached, then it's not so bad, but i see your point. possibly a better approcah may be to bring back all forums in a single 'hit' and key into the subsets as the repeater goes into the event.

jimi

http://www.originaltalent.com
  #68 (permalink)  
Old September 16th, 2007, 01:40 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by jimibtPossibly a better approcah may be to bring back all forums in a single 'hit' and key into the subsets as the repeater goes into the event.
If you can, talk a little more about this... I think i don't understand the best way to do that with a single connection.

We have a repeater to bind categories, and a gridview to bind forums for each repeater_item!

How can we do this a single connection?

  #69 (permalink)  
Old September 17th, 2007, 05:25 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Max,

'we' could transfer the processing to the code behind, rather than connecting n-number of times. i.e. here's a 'mock-up' of the kind of thing i mean (with my existing method by categoryid 1st, followed by a 'code' solution):

      /// <summary>
      /// Returns a collection with all the forums
      /// </summary>
       public static List<Forum> GetForums(int CategoryID)
       {
           List<Forum> forums = null;
           string key = "Forums_Forums_" + CategoryID.ToString();

           if (BaseForum.Settings.EnableCaching && BizObject.Cache[key] != null)
           {
               forums = (List<Forum>)BizObject.Cache[key];
           }
           else
           {
               List<ForumDetails> recordset = SiteProvider.Forums.GetForums(CategoryID);
               forums = GetForumListFromForumDetailsList(recordset);
               BaseForum.CacheData(key, forums);
           }
           return forums;
       }

       // code based solution to only connect once (getting ALL forums
       // then iterating round the code
       public static List<Forum> GetForums(int CategoryID)
       {
           List<Forum> forums = null;
           string key = "Forums_Forums_" + CategoryID.ToString();

           if (BaseForum.Settings.EnableCaching && BizObject.Cache[key] != null)
           {
               forums = (List<Forum>)BizObject.Cache[key];
           }
           else
           {
               List<Forum> allforums = BLL.Forums.Forum.GetForums();
               forums = new List<Forum>();
               foreach (Forum forumCat in allforums)
               {
                   if (forumCat.CategoryID == CategoryID || forumCat.CategoryID==0)
                   {
                       forums.Add(forumCat);
                   }
               }
               BaseForum.CacheData(key, forums);
           }
           return forums;
       }

it's not 'great' but is a 1st stab at an attempt to cut down on connectivity and use the cache as a kind of hashtable for extrating forums by categoryid.

looking fwd to seeing a more 'clever' and efficient way to do this, as it'd be a nice way to work with sub-sets of data. can you think of a good way to extend this in such a way??

jimi

http://www.originaltalent.com
  #70 (permalink)  
Old September 17th, 2007, 10:34 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:looking fwd to seeing a more 'clever' and efficient way to do this, as it'd be a nice way to work with sub-sets of data. can you think of a good way to extend this in such a way??
Hello jimi!
I think your code is well!

If you have 6 categories, you call "BLL.Forums.Forum.GetForums();" six times, but only do a connection to db the first time because the last five times you gonna catch this list(allforums) from cache!!

I think it's enough!
At the mean time I need to (read the book)/(view the code) about the rest part of the forums stuff...
I need to see how the cache system works everytime a user see one post (because viewcount increment +1). But this is outside of "categories/Foruns" page!

By curiosity, how much time do you have for your "CacheDuration" ?






Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX Extensions ilegend .NET Framework 3.5 1 September 19th, 2008 03:32 AM
Some Extensions plb BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 July 29th, 2008 11:57 AM
PHP Extensions Dnigma Pro PHP 0 June 22nd, 2006 12:41 AM
File Extensions nbnelson C# 2 August 25th, 2003 12:09 PM
converting Forum.aspx to Forum.ascx (help) drfunkie BOOK: ASP.NET Website Programming Problem-Design-Solution 1 July 11th, 2003 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.