本文整理汇总了C#中Rock.Model.PersonService.GetByPhonePartial方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.GetByPhonePartial方法的具体用法?C# PersonService.GetByPhonePartial怎么用?C# PersonService.GetByPhonePartial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.GetByPhonePartial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if (checkInState != null)
{
using ( new Rock.Data.UnitOfWorkScope() )
{
var personService = new PersonService();
var memberService = new GroupMemberService();
IQueryable<Person> people = null;
if ( checkInState.CheckIn.SearchType.Guid.Equals( new Guid( SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_PHONE_NUMBER ) ) )
{
people = personService.GetByPhonePartial( checkInState.CheckIn.SearchValue );
}
else if ( checkInState.CheckIn.SearchType.Guid.Equals( new Guid( SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_NAME ) ) )
{
people = personService.GetByFullName( checkInState.CheckIn.SearchValue );
}
else
{
errorMessages.Add( "Invalid Search Type" );
return false;
}
foreach ( var person in people.ToList() )
{
foreach ( var group in person.Members.Where( m => m.Group.GroupType.Guid == new Guid( SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).Select( m => m.Group ).ToList() )
{
var family = checkInState.CheckIn.Families.Where( f => f.Group.Id == group.Id ).FirstOrDefault();
if ( family == null )
{
family = new CheckInFamily();
family.Group = group.Clone( false );
family.Group.LoadAttributes();
family.Caption = group.ToString();
family.SubCaption = memberService.GetFirstNames( group.Id ).ToList().AsDelimited( ", " );
checkInState.CheckIn.Families.Add( family );
}
}
}
return true;
}
}
errorMessages.Add( "Invalid Check-in State" );
return false;
}
示例2: ShowPersonSelectPanel
// show person select panel
private void ShowPersonSelectPanel()
{
int minLength = int.Parse( GetAttributeValue( "MinimumPhoneNumberLength" ) );
int maxLength = int.Parse( GetAttributeValue( "MaximumPhoneNumberLength" ) );
if ( tbPhone.Text.Length >= minLength && tbPhone.Text.Length <= maxLength )
{
// run regex expression on input if provided
string searchInput = tbPhone.Text;
if ( !string.IsNullOrWhiteSpace( GetAttributeValue( "SearchRegex" ) ) )
{
Regex regex = new Regex( GetAttributeValue( "SearchRegex" ) );
Match match = regex.Match( searchInput );
if ( match.Success )
{
if ( match.Groups.Count == 2 )
{
searchInput = match.Groups[1].ToString();
}
}
}
var searchResults = new List<PersonDto>();
RockContext rockContext = new RockContext();
PersonService personService = new PersonService( rockContext );
var people = personService.GetByPhonePartial( searchInput, false, true );
foreach ( var person in people.ToList() )
{
searchResults.Add( new PersonDto( person.Id, person.LastName, person.NickName ) );
}
this.PeopleResults = searchResults;
BuildPersonControls();
HidePanels();
pnlPersonSelect.Visible = true;
}
else
{
if ( tbPhone.Text.Length < minLength )
{
nbSearch.Text = String.Format( "Please enter at least {0} numbers of your phone.", minLength.ToString() );
}
else
{
nbSearch.Text = String.Format( "Please enter no more than {0} numbers to search on.", maxLength.ToString() );
}
}
}
示例3: ShowGivingUnitSelectPanel
// show giving unit select panel
private void ShowGivingUnitSelectPanel()
{
int minLength = int.Parse( GetAttributeValue( "MinimumPhoneNumberLength" ) );
int maxLength = int.Parse( GetAttributeValue( "MaximumPhoneNumberLength" ) );
if ( tbPhone.Text.Length >= minLength && tbPhone.Text.Length <= maxLength )
{
// run regex expression on input if provided
string searchInput = tbPhone.Text;
if ( !string.IsNullOrWhiteSpace( GetAttributeValue( "SearchRegex" ) ) )
{
Regex regex = new Regex( GetAttributeValue( "SearchRegex" ) );
Match match = regex.Match( searchInput );
if ( match.Success )
{
if ( match.Groups.Count == 2 )
{
searchInput = match.Groups[1].ToString();
}
}
}
var searchResults = new List<GivingUnit>();
RockContext rockContext = new RockContext();
PersonService personService = new PersonService( rockContext );
var people = personService.GetByPhonePartial( searchInput, false, true );
foreach ( var person in people.ToList() )
{
if ( person.GivingGroupId == null )
{
// giving as an individuals
searchResults.Add( new GivingUnit(person.PrimaryAliasId.Value, person.LastName, person.FirstName));
}
else
{
var givingGroupMembers = person.GivingGroup.Members
.Where( g => g.Person.GivingGroupId == g.GroupId )
.OrderBy( g => g.GroupRole.Order )
.ThenBy( g => g.Person.Gender )
.ThenBy( g => g.Person.Age );
if ( givingGroupMembers.ToList().Count == 1 )
{
// only one person in the giving group display as an individual
if ( searchResults.Where( s => s.PersonAliasId == person.PrimaryAliasId.Value ).Count() == 0 )
{
searchResults.Add( new GivingUnit( person.PrimaryAliasId.Value, person.LastName, person.FirstName ) );
}
}
else
{
// display as a family
string firstNameList = string.Join( ", ", givingGroupMembers.Select( g => g.Person.NickName ) ).ReplaceLastOccurrence( ",", " &" );
int headOfHousePersonAliasId = givingGroupMembers.Select( g => g.Person.PrimaryAliasId.Value ).FirstOrDefault();
string lastName = givingGroupMembers.Select( g => g.Person.LastName ).FirstOrDefault();
// only add them if this giving unit is not already in collection
if ( searchResults.Where( s => s.PersonAliasId == headOfHousePersonAliasId ).Count() == 0 )
{
searchResults.Add( new GivingUnit( headOfHousePersonAliasId, person.LastName, firstNameList ) );
}
}
}
}
this.GivingUnits = searchResults;
BuildGivingUnitControls();
HidePanels();
pnlGivingUnitSelect.Visible = true;
}
else
{
if ( tbPhone.Text.Length < minLength )
{
nbSearch.Text = String.Format( "Please enter at least {0} numbers of your phone.", minLength.ToString() );
}
else
{
nbSearch.Text = String.Format( "Please enter no more than {0} numbers to search on.", maxLength.ToString() );
}
}
}