by Keyvan Nayyeri via Keyvan Nayyeri on 2/6/2007 7:57:25 PM
A while back I was working on a custom control to deploy it to my blog but didn't finish it. Today I worked on it again and may add it to this blog after installing first Beta version of Community Server 2007. This control is about referrals.
What is a referral? Yes, you know! So I can jump into describing available APIs to work with referrals in Community Server.
CommunityServer.Components.Referral and CommunityServer.Components.ReferralSet classes and CommunityServer.Components.Referrals factory have the main role in working with referrals.
there is also a CSJob to store referral data on a regular basis. This means that referral information won't be stored immediately and it takes time to store them by a CSJob (ReferralsJob).
In database there are two tables named cs_Referrals and cs_Urls that are used to store referral URLs in conjunction with cs_Posts table. cs_Referral has a relationship with cs_Urls and cs_Posts. URL of referral is stored in cs_Urls and other information about it are stored in cs_Referrals.
Referral is a class with following properties and no method:
ReferralSet is another class with four properties that are listed below. It's actually a container to keep a list of Referral objects.
Referrals is a method factory that helps you to work with referrals. It's like a queue that keeps tracked data for referrals. Some of its methods are important for default Community Server implementation (to add referrals to queue and other operations) so they're not very common in custom developments and I give a short description about one common methods.
GetReferrals() gets a Referral object and two integer values as page size and page index and returns a ReferralSet for the post. Post is specified via its PostID in incoming Referral object. Therefore you can use this method to get a list of referrals for a post.
In below code I want to get a list of referrals for the post that is being viewed by user to show it somewhere so GetFilteredReferrals() function doesn't get any parameter but returns an ArrayList of referrals. It tries to filter referrals and exclude referrals from some search engines. By default Community Server provides some APIs to filter incoming referrals before storing them into database but as it stores all referrals from search engines and doesn't apply any filter to them, I should filter them here.
ArrayList GetFilteredReferrals()
{
CSContext context = CSContext.Current;
ArrayList results = new ArrayList();
Referral r = new Referral();
r.PostID = context.PostID;
r.SectionID = context.SectionID;
r.SettingsID = context.SettingsID;
ReferralSet referralSet = Referrals.GetReferrals(Referrals, 100, 0);
foreach (Referral referral in referralSet)
if (!(referral.Url.Contains("search.") || referral.Url.Contains("google.")
|| referral.Url.Contains("search.yahoo") || referral.Url.Contains("search.live.com")
|| referral.Url.Contains("technoarti.com")))
results.Add(referral);
}
return results;
Now playing: Eminem - Lose Yourself
Original Post: CS Dev Guide: Referrals
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.