Posts Analyzer for Windows Phone 7

Download application source - 156 Kb

 

CP Posts Analyzer in action - posts view

 

CP Posts Analyzer in action - categories view

Introduction

CP Posts Analyzer is a Windows Phone 7 application that will analyze the last 200 posts made by any CP member (across all forums, articles, surveys etc.). You will need a developer license to be able to deploy and run this on your WP7 device, but if you don't have one, you can still run this off the emulator. I've tested the app on the emulator as well as on a Samsung Focus.

Warning

Since the application scrapes HTML from the CP website, the application can potentially stop functioning if the site undergoes a layout change (in the scraped pages). Here's to hoping that, that will not happen too frequently as to make the app tedious to maintain.

This application uses the excellent and highly recommended HTML Agility Pack for parsing HTML.

Using the app

I've included screenshots below that you can look at, but the app is quite simple to use. When you run the app, you get a panorama view and the first page prompts you to enter the member id (example, my member id is 20248). You can get your member id from your profile page. Since the app does not require you to be logged in, you can run this on any member id you want to. The app will maintain a history of the last 10 member ids that you ran it on, so it will save you some typing (which is not pleasant on such small devices with virtual keypads). The recent member ids are stored using isolated storage and are thus persisted until you uninstall the app.

When you run a fetch, the other three pages in the panorama view come into play. The first page gives you a categories based spit up of your last 200 posts. The Lounge falls under the Page category but most other forums including technical and some non-technical ones like the Indian forum fall under Forum. Any posts you make on articles are classified unsurprisingly under Article,  and then you have Survey and Member categories (self explanatory). There may be others I missed or did not encounter, those will show up as Unknown for now.

The next page is the forum-wide split up of your posts, so you can see how many posts you made in a specific forum. Since Chris chose to expose only the last 200 messages you posted, that's the limit for this app too. So the app will basically analyze your most recent posting activity. While debugging/testing the app I found that most of mine were in the Lounge until the India-SA ODI game  happened, and then my posts in the Indian forum dominated like crazy. I ran it on Chris and found that he spends most of his time answering questions in the Site Bugs / Suggestions forum (he does perform a mostly thankless job I guess).

The last page in the panorama view will list all the 200 posts to give you a quick summary of what you posted recently. Just the thread titles (not the messages).

The app has support for tombstoning, so you can switch to another app and come back and your state will be persisted. Well I reckon that's about it. If you can think of something useful that I can add to the app taking into consideration the limitation that all my input data is from html scraping, I'll be happy to try and make that change for you (provided I have the time). Check out a few more screenshots and then there's a brief section on the technical implementation details.

More screenshots

CP Posts Analyzer in the application list

CP Posts Analyzer in action - running a fetch

CP Posts Analyzer in action - categories view for Roger

CP Posts Analyzer in action - forums view

CP Posts Analyzer in action - tile icon

Implementation details

The app was written in SilverLight for WP7 and the project attempts to use a basic MVVM model. To help with data binding, I use these following types that represent the returned data.

There is a PostsFetcher class that handles the HTML fetch and parsing, and it uses the excellent HTML Agility Pack library.

 
Just basic HTML parsing there - as you can see I had to make some high risk assumptions (since some of the tables did not have identifiable ids associated with them). Oh and the reason I use Enum.Parse is because WP7's mscorlib does not have TryParse!
Tombstoning

As I mentioned earlier, the app supports tombstoning, and one of the things I had to do was to ensure that all the types I wanted to restore were fully compatible with serialization (which basically means they had to have public properties along other things). Here's the code that handles tombstoning.

 

And here are the implementations in the view model.

 

I'll just mention in passing that I made some unsuccessful attempts to serialize the entire view model and it was doomed from the very beginning. I eventually gave up and decided to serialize what I specifically wanted. I guess I could have got it to work but it would have been too much hassle for no return at all, except maybe some artificially boosted self-esteem which I don't care for anyway!

Isolated Storage

The recipients list is stored via isolated storage so your most recent 10 searches will be remembered.

 

The built-in support makes it incredibly easy to use isolated storage. Initially, I did consider saving posts and then accumulating them so I can analyze more than 200 posts, but that assumes the user will run it frequently enough that there won't be missing posts (which was very hard to enforce, actually quite impossible). So I gave up and thought 200 is good enough. Some day if Chris increases that limit to 1000, then I'll update the app at that time.

Conclusion

Well that's it. It's been tested reasonably thoroughly but there may be issues, specially on other phone models. The error handling is kinda silent, so if it encounters any errors it won't break down but it won't tell you either. You could try running a Fetch again, or close and re-run the app (although I have never had to do that so far) .

Feel free to submit feedback, criticism, and suggestions as usual.

History

  • January 23rd 2011 - Article first published.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值