Hello,
in which table i can find the user-occupation and the user-Interests in the database?Jan
German DotNet Community
You'll find this in the aspnet_profile table however, it is not in an easily readable form.
My suggestion would be to use CS API to get the user, and then get the required values from that user. If you need to access this data outside of CS, then either wait for CS2008 and then use the webservices API to get this data or, if you want to stick with CS2007, create your own webservice in CS that will get the data using the CS API, and you can then call this webservice in your external application.
Community Server Documentation
Nintendo Wiikly
I use CS 2007, I need a Webservice that returns some user data. This Webservice is for an AJAX extension.I will take a look into the CS API documentation. I hope the data access is easier.Thanks, Jan
Just use something similar to the folowing
CommunityServer.Components.User u = CommunityServer.Users.GetUser("SOME USERNAME");
return u.Profile.Occupation; /* OR */ return u.Profile.Location;
that should do the job
afscrome:You'll find this in the aspnet_profile table however, it is not in an easily readable form.
With these Snippets you can extract the Data:
/// <summary>/// Gets the location from value string./// </summary>/// <param name="propertyNames">The property names.</param>/// <param name="propertyValuesString">The property values string.</param>/// <returns></returns>private string GetLocationFromValueString(string propertyNames, string propertyValuesString){ if (string.IsNullOrEmpty(propertyNames) || string.IsNullOrEmpty(propertyValuesString)) return string.Empty; else { Regex regex = new Regex(@"location:S:(\d*[:]\d*)"); string[] indexer = regex.Match(propertyNames).Value.Split(':'); return propertyValuesString.Substring(Convert.ToInt32(indexer[2]), Convert.ToInt32(indexer[3])); }}
/// <summary>/// Gets the occupation from value string./// </summary>/// <param name="propertyNames">The property names.</param>/// <param name="propertyValuesString">The property values string.</param>/// <returns></returns>private string GetOccupationFromValueString(string propertyNames, string propertyValuesString){ if (string.IsNullOrEmpty(propertyNames) || string.IsNullOrEmpty(propertyValuesString)) return string.Empty; else { Regex regex = new Regex(@"occupation:S:(\d*[:]\d*)"); string[] indexer = regex.Match(propertyNames).Value.Split(':'); return propertyValuesString.Substring(Convert.ToInt32(indexer[2]), Convert.ToInt32(indexer[3])); }}
Jan
Is there a way to get a list of distinct values in a user property?
I am building a custom user report and would like to be able to get a dropdown of all the distinct locations (which are standardized) so I can do a filter in the report. Is there a way to get this data using the API?
Not easily or effectively
You'll have to loop through every user on the site and for each user, add the item to the list if it hasn't been added. To then filter by this, you'll have to get a list of all users, then remove those users wo do not have the specified location, and then use that as your report's datasource. Depending on the number of users on your site, there may be performance issues with doing this.
See http://communityserver.org/forums/p/498177/616228.aspx#616228
What is the API call to get a full list of all users?
I can then run through that list and get the location and the poll vote. I'll cache the result and loop through it again to get the distinct locations.
The report will only be run every once-and-a-while by admins so performance isn't the largest issue in the world.
-Dirk
You'll need to use something like
CommunityServer.UserQuery query = new CommunityServer.UserQuery();
//Set Query here
UserSet users = Users.GetUsers(query, true);
As for caching, I wouldn't bother as CS will cache the query by default.
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com