Wrox Programmer Forums
|
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
 
Old May 29th, 2007, 09:31 AM
Authorized User
 
Join Date: May 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

karim,

i think this last solution is the best thanks.

cheers

 
Old May 29th, 2007, 09:37 AM
Authorized User
 
Join Date: May 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello again,

i prefer get article from cache:

 public static bool IncrementArticleViewCount(int id)
        {
            //BizObject.PurgeCacheItems("articles_article_" + id.ToString());
            //Article article = Article.GetArticleByID(id);
          Article article = BizObject.Cache["articles_article_" + id.ToString()];
            if (article != null)
            {
                article.ViewCount++;
            }
            return SiteProvider.Articles.IncrementArticleViewCount(id );
        }

cheers

 
Old May 29th, 2007, 09:55 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

mesdouri - yes, that looks fine too (my method would have got it from the cache too (via the DAL check), but this is a very neat way too with one less 'step' in the code logic!!)

however, you'll need to cast the cache as so:

        public static bool IncrementArticleViewCount(int id)
        {
            //BizObject.PurgeCacheItems("articles_article_" + id.ToString());
            //Article article = Article.GetArticleByID(id);
            Article article = (Article)BizObject.Cache["articles_article_" + id.ToString()];
            if (article != null)
            {
                article.ViewCount++;
            }
            return SiteProvider.Articles.IncrementArticleViewCount(id );
        }

good stuff...

[edit] - not sure if getting it direct from the cache (versus getting it via Articles.GetArticleByID) actually works correctly!! testing it just now but not 100% sure...

jimi

http://www.jamestollan.com
 
Old May 29th, 2007, 01:08 PM
Authorized User
 
Join Date: May 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'am agree with you, getting it with Article.GetArticleByID(id) is more secure because if it's not exist in the cache, it's will be retrieved from database.

i think this is the best solution for the moment ;). thank you again

cheers


 
Old May 30th, 2007, 05:50 AM
Authorized User
 
Join Date: Jun 2006
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thankssss, you guys.
I got two neat solutions without doing any effort :D

 
Old May 30th, 2007, 06:46 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

tectrix - don't worry, your chance will come soon enough :D

jimi

http://www.jamestollan.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Running up the ViewCount Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 August 20th, 2009 10:38 AM
Reset Article View Count and Rating retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 July 20th, 2008 10:43 AM
Increment By Range & Output Solver Result ibrahim ahmad Excel VBA 0 April 30th, 2008 10:16 PM
Javascript && keeps turnig into && ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM





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