本文整理汇总了C#中Rock.Model.DefinedValueService.GetIdByGuid方法的典型用法代码示例。如果您正苦于以下问题:C# DefinedValueService.GetIdByGuid方法的具体用法?C# DefinedValueService.GetIdByGuid怎么用?C# DefinedValueService.GetIdByGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.DefinedValueService
的用法示例。
在下文中一共展示了DefinedValueService.GetIdByGuid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
/// <summary>
/// Authenticates the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="username">The username.</param>
/// <param name="returnUrl">The return URL.</param>
/// <returns></returns>
public override Boolean Authenticate( HttpRequest request, out string username, out string returnUrl )
{
var fbClient = new FacebookClient();
FacebookOAuthResult oAuthResult;
if ( fbClient.TryParseOAuthCallbackUrl( request.Url, out oAuthResult ) && oAuthResult.IsSuccess )
{
try
{
var redirectUri = new Uri( GetRedirectUrl( request ) );
dynamic parameters = new ExpandoObject();
parameters.client_id = GetAttributeValue( "AppID" );
parameters.client_secret = GetAttributeValue( "AppSecret" );
parameters.redirect_uri = redirectUri.AbsoluteUri;
parameters.code = oAuthResult.Code;
dynamic result = fbClient.Post( "oauth/access_token", parameters );
string accessToken = result.access_token;
fbClient = new FacebookClient( accessToken );
dynamic me = fbClient.Get( "me" );
string facebookId = "FACEBOOK_" + me.id.ToString();
// query for matching id in the user table
var userLoginService = new UserLoginService();
var user = userLoginService.GetByUserName( facebookId );
// if not user was found see if we can find a match in the person table
if ( user == null )
{
try
{
// determine if we can find a match and if so add an user login record
// get properties from Facebook dynamic object
string lastName = me.last_name.ToString();
string firstName = me.first_name.ToString();
string email = me.email.ToString();
var personService = new PersonService();
var person = personService.Queryable().FirstOrDefault( u => u.LastName == lastName && u.FirstName == firstName && u.Email == email );
if ( person != null )
{
// since we have the data enter the birthday from Facebook to the db if we don't have it yet
DateTime birthdate = Convert.ToDateTime( me.birthday.ToString() );
if ( person.BirthDay == null )
{
person.BirthDate = birthdate;
personService.Save( person, person.Id );
}
}
else
{
var dvService = new DefinedValueService();
person = new Person();
person.IsSystem = false;
person.RecordTypeValueId = dvService.GetIdByGuid( new Guid( SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ) );
person.RecordStatusValueId = dvService.GetIdByGuid( new Guid( SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ) );
person.FirstName = me.first_name.ToString();
person.LastName = me.last_name.ToString();
person.Email = me.email.ToString();
if ( me.gender.ToString() == "male" )
person.Gender = Gender.Male;
else if ( me.gender.ToString() == "female" )
person.Gender = Gender.Female;
else
person.Gender = Gender.Unknown;
person.BirthDate = Convert.ToDateTime( me.birthday.ToString() );
person.DoNotEmail = false;
personService.Add( person, null );
personService.Save( person, null );
}
user = userLoginService.Create( person, AuthenticationServiceType.External, this.TypeId, facebookId, "fb", true, person.Id );
}
catch ( Exception ex )
{
string msg = ex.Message;
// TODO: probably should report something...
}
// TODO: Show label indicating inability to find user corresponding to facebook id
//.........这里部分代码省略.........