user occupation

This post has 8 Replies | 3 Followers

Not Ranked
Posts 15
Points 190
jan223 Posted: Sun, Mar 30 2008 12:37 PM

Hello,

in which table i can find the user-occupation and the user-Interests in the database?

Jan

  • | Post Points: 20
Top 10 Contributor
Posts 4,039
Points 61,285
TelligentSupportTeam

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.

  • | Post Points: 35
Not Ranked
Posts 15
Points 190
jan223 replied on Sun, Mar 30 2008 6:09 PM

Hello,

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

  • | Post Points: 20
Top 10 Contributor
Posts 4,039
Points 61,285
TelligentSupportTeam

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

  • | Post Points: 20
Not Ranked
Posts 15
Points 190
jan223 replied on Mon, Mar 31 2008 5:34 PM

afscrome:
You'll find this in the aspnet_profile table however, it is not in an easily readable form.
 
Hello,

yes, this is not easy Smile

to get the user-occupation and the user-location without the CS API you can read out the fields “PropertyNames” and “PropertyValuesString” from the table “aspnet_Profile”.

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

  • | Post Points: 5
Top 500 Contributor
Posts 62
Points 760
drq replied on Fri, Apr 4 2008 10:50 AM

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?

Top 10 Contributor
Posts 4,039
Points 61,285
TelligentSupportTeam

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.

  • | Post Points: 20
Top 500 Contributor
Posts 62
Points 760
drq replied on Mon, Apr 7 2008 10:10 AM

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

Top 10 Contributor
Posts 4,039
Points 61,285
TelligentSupportTeam

 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.

  • | Post Points: 5
Page 1 of 1 (9 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com