本文整理汇总了C#中Rock.Model.AttributeService.GetByEntityTypeId方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeService.GetByEntityTypeId方法的具体用法?C# AttributeService.GetByEntityTypeId怎么用?C# AttributeService.GetByEntityTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.AttributeService
的用法示例。
在下文中一共展示了AttributeService.GetByEntityTypeId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowEdit
/// <summary>
/// Shows the edit.
/// </summary>
/// <param name="marketingCampaignAdTypeId">The marketing campaign ad type id.</param>
protected void ShowEdit( int marketingCampaignAdTypeId )
{
pnlList.Visible = false;
pnlDetails.Visible = true;
MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
MarketingCampaignAdType marketingCampaignAdType = marketingCampaignAdTypeService.Get( marketingCampaignAdTypeId );
bool readOnly = false;
AttributesState = new List<Attribute>().ToDto();
if ( marketingCampaignAdType != null )
{
hfMarketingCampaignAdTypeId.Value = marketingCampaignAdType.Id.ToString();
tbName.Text = marketingCampaignAdType.Name;
ddlDateRangeType.SelectedValue = ( (int)marketingCampaignAdType.DateRangeType ).ToString();
AttributeService attributeService = new AttributeService();
var qry = attributeService.GetByEntityTypeId( new MarketingCampaignAd().TypeId ).AsQueryable()
.Where( a => a.EntityTypeQualifierColumn.Equals( "MarketingCampaignAdTypeId", StringComparison.OrdinalIgnoreCase )
&& a.EntityTypeQualifierValue.Equals( marketingCampaignAdType.Id.ToString() ) );
AttributesState = qry.ToList().ToDto();
readOnly = marketingCampaignAdType.IsSystem;
if ( marketingCampaignAdType.IsSystem )
{
lActionTitle.Text = ActionTitle.View( MarketingCampaignAdType.FriendlyTypeName );
btnCancel.Text = "Close";
}
else
{
lActionTitle.Text = ActionTitle.Edit( MarketingCampaignAdType.FriendlyTypeName );
btnCancel.Text = "Cancel";
}
}
else
{
lActionTitle.Text = ActionTitle.Add( MarketingCampaignAdType.FriendlyTypeName );
hfMarketingCampaignAdTypeId.Value = 0.ToString();
tbName.Text = string.Empty;
}
iconIsSystem.Visible = readOnly;
btnSave.Visible = !readOnly;
BindMarketingCampaignAdAttributeTypeGrid();
}
示例2: ShowEditDetails
//.........这里部分代码省略.........
tbGroupMemberTerm.ReadOnly = groupType.IsSystem;
tbGroupMemberTerm.Text = groupType.GroupMemberTerm;
ddlGroupTypePurpose.Enabled = !groupType.IsSystem;
ddlGroupTypePurpose.SetValue( groupType.GroupTypePurposeValueId );
ChildGroupTypesDictionary = new Dictionary<int, string>();
groupType.ChildGroupTypes.ToList().ForEach( a => ChildGroupTypesDictionary.Add( a.Id, a.Name ) );
BindChildGroupTypesGrid();
// Display
cbShowInGroupList.Checked = groupType.ShowInGroupList;
cbShowInNavigation.Checked = groupType.ShowInNavigation;
tbIconCssClass.Text = groupType.IconCssClass;
// Locations
cbAllowMultipleLocations.Enabled = !groupType.IsSystem;
cbAllowMultipleLocations.Checked = groupType.AllowMultipleLocations;
cblScheduleTypes.Enabled = !groupType.IsSystem;
foreach ( ListItem li in cblScheduleTypes.Items )
{
ScheduleType scheduleType = (ScheduleType)li.Value.AsInteger();
li.Selected = ( groupType.AllowedScheduleTypes & scheduleType ) == scheduleType;
}
ScheduleExclusionDictionary = new Dictionary<Guid, DateRange>();
groupType.GroupScheduleExclusions.ToList().ForEach( s => ScheduleExclusionDictionary.Add( s.Guid, new DateRange( s.StartDate, s.EndDate ) ) );
BindScheduleExclusionsGrid();
cblLocationSelectionModes.Enabled = !groupType.IsSystem;
foreach ( ListItem li in cblLocationSelectionModes.Items )
{
GroupLocationPickerMode mode = (GroupLocationPickerMode)li.Value.AsInteger();
li.Selected = ( groupType.LocationSelectionMode & mode ) == mode;
}
LocationTypesDictionary = new Dictionary<int, string>();
groupType.LocationTypes.ToList().ForEach( a => LocationTypesDictionary.Add( a.LocationTypeValueId, a.LocationTypeValue.Value ) );
BindLocationTypesGrid();
// Support Location Schedules
cbEnableLocationSchedules.Enabled = !groupType.IsSystem;
cbEnableLocationSchedules.Checked = groupType.EnableLocationSchedules ?? false;
// Check In
cbTakesAttendance.Checked = groupType.TakesAttendance;
cbSendAttendanceReminder.Checked = groupType.SendAttendanceReminder;
ddlAttendanceRule.SetValue( (int)groupType.AttendanceRule );
ddlPrintTo.SetValue( (int)groupType.AttendancePrintTo );
// Attributes
gtpInheritedGroupType.Enabled = !groupType.IsSystem;
gtpInheritedGroupType.SelectedGroupTypeId = groupType.InheritedGroupTypeId;
var groupTypeRoles = new List<GroupTypeRole>();
foreach ( var role in groupType.Roles )
{
role.LoadAttributes();
groupTypeRoles.Add( role );
}
GroupTypeRolesState = new ViewStateList<GroupTypeRole>();
GroupTypeRolesState.AddAll( groupTypeRoles );
BindGroupTypeRolesGrid();
string qualifierValue = groupType.Id.ToString();
GroupTypeAttributesState = new ViewStateList<Attribute>();
GroupTypeAttributesState.AddAll( attributeService.GetByEntityTypeId( new GroupType().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "Id", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() );
BindGroupTypeAttributesGrid();
GroupAttributesState = new ViewStateList<Attribute>();
GroupAttributesState.AddAll( attributeService.GetByEntityTypeId( new Group().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() );
BindGroupAttributesGrid();
GroupMemberAttributesState = new ViewStateList<Attribute>();
GroupMemberAttributesState.AddAll( attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() );
BindGroupMemberAttributesGrid();
BindInheritedAttributes( groupType.InheritedGroupTypeId, groupTypeService, attributeService );
}
示例3: ShowEditDetails
/// <summary>
/// Shows the edit details.
/// </summary>
/// <param name="workflowType">Type of the workflow.</param>
private void ShowEditDetails( WorkflowType workflowType, RockContext rockContext )
{
if ( workflowType.Id == 0 )
{
lReadOnlyTitle.Text = ActionTitle.Add( WorkflowType.FriendlyTypeName ).FormatAsHtmlTitle();
hlInactive.Visible = false;
}
SetEditMode( true );
LoadDropDowns();
tbName.Text = workflowType.Name;
tbDescription.Text = workflowType.Description;
cbIsActive.Checked = workflowType.IsActive ?? false;
cpCategory.SetValue( workflowType.CategoryId );
tbWorkTerm.Text = workflowType.WorkTerm;
tbProcessingInterval.Text = workflowType.ProcessingIntervalSeconds != null ? workflowType.ProcessingIntervalSeconds.ToString() : string.Empty;
cbIsPersisted.Checked = workflowType.IsPersisted;
ddlLoggingLevel.SetValue( (int)workflowType.LoggingLevel );
var attributeService = new AttributeService( rockContext );
AttributesState = new ViewStateList<Attribute>();
AttributesState.AddAll( attributeService.GetByEntityTypeId( new Workflow().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "WorkflowTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( workflowType.Id.ToString() ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() );
BindAttributesGrid();
phActivities.Controls.Clear();
foreach ( WorkflowActivityType workflowActivityType in workflowType.ActivityTypes.OrderBy( a => a.Order ) )
{
CreateWorkflowActivityTypeEditorControls( workflowActivityType );
}
RefreshActivityLists();
}
示例4: BindDefinedValuesGrid
/// <summary>
/// Binds the defined values grid.
/// </summary>
protected void BindDefinedValuesGrid()
{
AttributeService attributeService = new AttributeService();
int definedTypeId = hfDefinedTypeId.ValueAsInt();
// add attributes with IsGridColumn to grid
string qualifierValue = hfDefinedTypeId.Value;
var qryDefinedTypeAttributes = attributeService.GetByEntityTypeId( new DefinedValue().TypeId ).AsQueryable()
.Where( a => a.EntityTypeQualifierColumn.Equals( "DefinedTypeId", StringComparison.OrdinalIgnoreCase )
&& a.EntityTypeQualifierValue.Equals( qualifierValue ) );
qryDefinedTypeAttributes = qryDefinedTypeAttributes.Where( a => a.IsGridColumn );
List<Attribute> gridItems = qryDefinedTypeAttributes.ToList();
foreach ( var item in gDefinedValues.Columns.OfType<AttributeField>().ToList() )
{
gDefinedValues.Columns.Remove( item );
}
foreach ( var item in gridItems.OrderBy( a => a.Order ).ThenBy( a => a.Name ) )
{
string dataFieldExpression = item.Key;
bool columnExists = gDefinedValues.Columns.OfType<AttributeField>().FirstOrDefault( a => a.DataField.Equals( dataFieldExpression ) ) != null;
if ( !columnExists )
{
AttributeField boundField = new AttributeField();
boundField.DataField = dataFieldExpression;
boundField.HeaderText = item.Name;
boundField.SortExpression = string.Empty;
int insertPos = gDefinedValues.Columns.IndexOf( gDefinedValues.Columns.OfType<DeleteField>().First());
gDefinedValues.Columns.Insert(insertPos, boundField );
}
}
var queryable = new DefinedValueService().Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order );
var result = queryable.ToList();
gDefinedValues.DataSource = result;
gDefinedValues.DataBind();
}
示例5: LoadStateDetails
private void LoadStateDetails( WorkflowType workflowType, RockContext rockContext )
{
if ( workflowType != null )
{
var attributeService = new AttributeService( rockContext );
AttributesState = attributeService
.GetByEntityTypeId( new Workflow().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "WorkflowTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( workflowType.Id.ToString() ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList();
ActivityTypesState = workflowType.ActivityTypes.OrderBy( a => a.Order ).ToList();
ActivityAttributesState = new Dictionary<Guid, List<Attribute>>();
foreach ( var activityType in ActivityTypesState )
{
var activityTypeAttributes = attributeService
.GetByEntityTypeId( new WorkflowActivity().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "ActivityTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( activityType.Id.ToString() ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList();
ActivityAttributesState.Add( activityType.Guid, activityTypeAttributes );
foreach ( var actionType in activityType.ActionTypes )
{
var action = EntityTypeCache.Read( actionType.EntityTypeId );
if ( action != null )
{
Rock.Attribute.Helper.UpdateAttributes( action.GetEntityType(), actionType.TypeId, "EntityTypeId", actionType.EntityTypeId.ToString(), rockContext );
actionType.LoadAttributes( rockContext );
}
}
}
}
else
{
AttributesState = new List<Attribute>();
ActivityTypesState = new List<WorkflowActivityType>();
ActivityAttributesState = new Dictionary<Guid, List<Attribute>>();
}
}
示例6: LoadStateDetails
/// <summary>
/// Loads the state details.
/// </summary>
/// <param name="eventCalendar">The event calendar.</param>
/// <param name="rockContext">The rock context.</param>
private void LoadStateDetails( EventCalendar eventCalendar, RockContext rockContext )
{
var attributeService = new AttributeService( rockContext );
AttributesState = attributeService
.GetByEntityTypeId( new EventCalendarItem().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "EventCalendarId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( eventCalendar.Id.ToString() ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList();
ContentChannelsState = new Dictionary<Guid,string>();
new EventCalendarContentChannelService( rockContext )
.Queryable()
.Where( c => c.EventCalendarId == eventCalendar.Id )
.ToList()
.ForEach( c => ContentChannelsState.Add( c.ContentChannel.Guid, c.ContentChannel.Name ) );
}
示例7: MapCommunication
/// <summary>
/// Maps the communication data.
/// </summary>
/// <param name="tableData">The table data.</param>
/// <returns></returns>
private void MapCommunication( IQueryable<Row> tableData )
{
var lookupContext = new RockContext();
var personService = new PersonService( lookupContext );
var attributeService = new AttributeService( lookupContext );
var definedTypePhoneType = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_PHONE_TYPE ), lookupContext );
var otherNumberType = definedTypePhoneType.DefinedValues.Where( dv => dv.Value.StartsWith( "Other" ) ).Select( v => (int?)v.Id ).FirstOrDefault();
if ( otherNumberType == null )
{
var otherType = new DefinedValue();
otherType.IsSystem = false;
otherType.DefinedTypeId = definedTypePhoneType.Id;
otherType.Order = 0;
otherType.Value = "Other";
otherType.Description = "Imported from FellowshipOne";
otherType.CreatedByPersonAliasId = ImportPersonAliasId;
lookupContext.DefinedValues.Add( otherType );
lookupContext.SaveChanges( DisableAuditing );
}
// Look up existing Person attributes
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
// Cached Rock attributes: Facebook, Twitter, Instagram
var twitterAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "Twitter", StringComparison.InvariantCultureIgnoreCase ) ) );
var facebookAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "Facebook", StringComparison.InvariantCultureIgnoreCase ) ) );
var instagramAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "Instagram", StringComparison.InvariantCultureIgnoreCase ) ) );
var newNumbers = new List<PhoneNumber>();
var existingNumbers = new PhoneNumberService( lookupContext ).Queryable().AsNoTracking().ToList();
var newPeopleAttributes = new Dictionary<int, Person>();
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Verifying communication import ({0:N0} found, {1:N0} already exist).", totalRows, existingNumbers.Count ) );
foreach ( var groupedRows in tableData.OrderByDescending( r => r["LastUpdatedDate"] ).GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
{
foreach ( var row in groupedRows.Where( r => r != null ) )
{
string value = row["Communication_Value"] as string;
int? individualId = row["Individual_ID"] as int?;
int? householdId = row["Household_ID"] as int?;
var peopleToUpdate = new List<PersonKeys>();
if ( individualId != null )
{
var matchingPerson = GetPersonKeys( individualId, householdId, includeVisitors: false );
if ( matchingPerson != null )
{
peopleToUpdate.Add( matchingPerson );
}
}
else
{
peopleToUpdate = GetFamilyByHouseholdId( householdId, includeVisitors: false );
}
if ( peopleToUpdate.Any() && !string.IsNullOrWhiteSpace( value ) )
{
DateTime? lastUpdated = row["LastUpdatedDate"] as DateTime?;
string communicationComment = row["Communication_Comment"] as string;
string type = row["Communication_Type"] as string;
bool isListed = (bool)row["Listed"];
value = value.RemoveWhitespace();
// Communication value is a number
if ( type.Contains( "Phone" ) || type.Contains( "Mobile" ) )
{
var extension = string.Empty;
var countryCode = PhoneNumber.DefaultCountryCode();
var normalizedNumber = string.Empty;
var countryIndex = value.IndexOf( '+' );
int extensionIndex = value.LastIndexOf( 'x' ) > 0 ? value.LastIndexOf( 'x' ) : value.Length;
if ( countryIndex >= 0 )
{
countryCode = value.Substring( countryIndex, countryIndex + 3 ).AsNumeric();
normalizedNumber = value.Substring( countryIndex + 3, extensionIndex - 3 ).AsNumeric();
extension = value.Substring( extensionIndex );
}
else if ( extensionIndex > 0 )
{
normalizedNumber = value.Substring( 0, extensionIndex ).AsNumeric();
extension = value.Substring( extensionIndex ).AsNumeric();
}
else
{
normalizedNumber = value.AsNumeric();
}
if ( !string.IsNullOrWhiteSpace( normalizedNumber ) )
{
//.........这里部分代码省略.........
示例8: LoadExistingRockData
/// <summary>
/// Loads Rock data that's used globally by the transform
/// </summary>
private void LoadExistingRockData()
{
var lookupContext = new RockContext();
var attributeValueService = new AttributeValueService( lookupContext );
var attributeService = new AttributeService( lookupContext );
IntegerFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.INTEGER ) ).Id;
TextFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.TEXT ) ).Id;
PersonEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
CampusList = CampusCache.All();
int attributeEntityTypeId = EntityTypeCache.Read( "Rock.Model.Attribute" ).Id;
int batchEntityTypeId = EntityTypeCache.Read( "Rock.Model.FinancialBatch" ).Id;
int userLoginTypeId = EntityTypeCache.Read( "Rock.Model.UserLogin" ).Id;
int visitInfoCategoryId = new CategoryService( lookupContext ).GetByEntityTypeId( attributeEntityTypeId )
.Where( c => c.Name == "Visit Information" ).Select( c => c.Id ).FirstOrDefault();
// Look up and create attributes for F1 unique identifiers if they don't exist
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).AsNoTracking().ToList();
var householdAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "F1HouseholdId", StringComparison.InvariantCultureIgnoreCase ) );
if ( householdAttribute == null )
{
householdAttribute = new Rock.Model.Attribute();
householdAttribute.Key = "F1HouseholdId";
householdAttribute.Name = "F1 Household Id";
householdAttribute.FieldTypeId = IntegerFieldTypeId;
householdAttribute.EntityTypeId = PersonEntityTypeId;
householdAttribute.EntityTypeQualifierValue = string.Empty;
householdAttribute.EntityTypeQualifierColumn = string.Empty;
householdAttribute.Description = "The FellowshipOne household identifier for the person that was imported";
householdAttribute.DefaultValue = string.Empty;
householdAttribute.IsMultiValue = false;
householdAttribute.IsRequired = false;
householdAttribute.Order = 0;
lookupContext.Attributes.Add( householdAttribute );
lookupContext.SaveChanges( DisableAuditing );
personAttributes.Add( householdAttribute );
}
var individualAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "F1IndividualId", StringComparison.InvariantCultureIgnoreCase ) );
if ( individualAttribute == null )
{
individualAttribute = new Rock.Model.Attribute();
individualAttribute.Key = "F1IndividualId";
individualAttribute.Name = "F1 Individual Id";
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
lookupContext.Attributes.Add( individualAttribute );
lookupContext.SaveChanges( DisableAuditing );
personAttributes.Add( individualAttribute );
}
var secondaryEmailAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "SecondaryEmail", StringComparison.InvariantCultureIgnoreCase ) );
if ( secondaryEmailAttribute == null )
{
secondaryEmailAttribute = new Rock.Model.Attribute();
secondaryEmailAttribute.Key = "SecondaryEmail";
secondaryEmailAttribute.Name = "Secondary Email";
secondaryEmailAttribute.FieldTypeId = TextFieldTypeId;
secondaryEmailAttribute.EntityTypeId = PersonEntityTypeId;
secondaryEmailAttribute.EntityTypeQualifierValue = string.Empty;
secondaryEmailAttribute.EntityTypeQualifierColumn = string.Empty;
secondaryEmailAttribute.Description = "The secondary email for this person";
secondaryEmailAttribute.DefaultValue = string.Empty;
secondaryEmailAttribute.IsMultiValue = false;
secondaryEmailAttribute.IsRequired = false;
secondaryEmailAttribute.Order = 0;
lookupContext.Attributes.Add( secondaryEmailAttribute );
var visitInfoCategory = new CategoryService( lookupContext ).Get( visitInfoCategoryId );
secondaryEmailAttribute.Categories.Add( visitInfoCategory );
lookupContext.SaveChanges( DisableAuditing );
}
var infellowshipLoginAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "InFellowshipLogin", StringComparison.InvariantCultureIgnoreCase ) );
if ( infellowshipLoginAttribute == null )
{
infellowshipLoginAttribute = new Rock.Model.Attribute();
infellowshipLoginAttribute.Key = "InFellowshipLogin";
infellowshipLoginAttribute.Name = "InFellowship Login";
infellowshipLoginAttribute.FieldTypeId = TextFieldTypeId;
infellowshipLoginAttribute.EntityTypeId = PersonEntityTypeId;
infellowshipLoginAttribute.EntityTypeQualifierValue = string.Empty;
infellowshipLoginAttribute.EntityTypeQualifierColumn = string.Empty;
infellowshipLoginAttribute.Description = "The InFellowship login for this person";
infellowshipLoginAttribute.DefaultValue = string.Empty;
//.........这里部分代码省略.........
示例9: BindGrid
/// <summary>
/// Binds the grid.
/// </summary>
private void BindGrid()
{
IQueryable<Rock.Model.Attribute> query = null;
AttributeService attributeService = new AttributeService( new RockContext() );
if ( _configuredType )
{
query = attributeService.Get( _entityTypeId, _entityQualifierColumn, _entityQualifierValue );
}
else
{
int entityTypeId = int.MinValue;
if ( int.TryParse( rFilter.GetUserPreference( "Entity Type" ), out entityTypeId ) )
{
if ( entityTypeId > 0 )
{
query = attributeService.GetByEntityTypeId( entityTypeId );
}
}
}
if ( query == null )
{
query = attributeService.GetByEntityTypeId( null );
}
var selectedCategoryIds = new List<int>();
rFilter.GetUserPreference( "Categories" ).SplitDelimitedValues().ToList().ForEach( s => selectedCategoryIds.Add( int.Parse( s ) ) );
if ( selectedCategoryIds.Any() )
{
query = query.Where( a => a.Categories.Any( c => selectedCategoryIds.Contains( c.Id ) ) );
}
SortProperty sortProperty = rGrid.SortProperty;
if ( sortProperty != null )
{
query = query.Sort( sortProperty );
}
else
{
query = query.OrderBy( a => a.Key );
}
rGrid.DataSource = query.ToList();
rGrid.DataBind();
}
示例10: LoadExistingRockData
/// <summary>
/// Loads Rock data that's used globally by the transform
/// </summary>
private void LoadExistingRockData()
{
var attributeValueService = new AttributeValueService();
var attributeService = new AttributeService();
IntegerFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.INTEGER ) ).Id;
TextFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.TEXT ) ).Id;
PersonEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
BatchEntityTypeId = EntityTypeCache.Read( "Rock.Model.FinancialBatch" ).Id;
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
var householdAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" );
if ( householdAttribute == null )
{
householdAttribute = new Rock.Model.Attribute();
householdAttribute.Key = "F1HouseholdId";
householdAttribute.Name = "F1 Household Id";
householdAttribute.FieldTypeId = IntegerFieldTypeId;
householdAttribute.EntityTypeId = PersonEntityTypeId;
householdAttribute.EntityTypeQualifierValue = string.Empty;
householdAttribute.EntityTypeQualifierColumn = string.Empty;
householdAttribute.Description = "The FellowshipOne household identifier for the person that was imported";
householdAttribute.DefaultValue = string.Empty;
householdAttribute.IsMultiValue = false;
householdAttribute.IsRequired = false;
householdAttribute.Order = 0;
attributeService.Add( householdAttribute, ImportPersonAlias );
attributeService.Save( householdAttribute, ImportPersonAlias );
personAttributes.Add( householdAttribute );
}
var individualAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" );
if ( individualAttribute == null )
{
individualAttribute = new Rock.Model.Attribute();
individualAttribute.Key = "F1IndividualId";
individualAttribute.Name = "F1 Individual Id";
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
attributeService.Add( individualAttribute, ImportPersonAlias );
attributeService.Save( individualAttribute, ImportPersonAlias );
personAttributes.Add( individualAttribute );
}
IndividualAttributeId = individualAttribute.Id;
HouseholdAttributeId = householdAttribute.Id;
ReportProgress( 0, "Checking for existing people..." );
var listHouseholdId = attributeValueService.GetByAttributeId( householdAttribute.Id ).Select( av => new { PersonId = av.EntityId, HouseholdId = av.Value } ).ToList();
var listIndividualId = attributeValueService.GetByAttributeId( individualAttribute.Id ).Select( av => new { PersonId = av.EntityId, IndividualId = av.Value } ).ToList();
ImportedPeople = listHouseholdId.GroupJoin( listIndividualId, household => household.PersonId,
individual => individual.PersonId, ( household, individual ) => new ImportedPerson
{
PersonId = household.PersonId,
HouseholdId = household.HouseholdId.AsType<int?>(),
IndividualId = individual.Select( i => i.IndividualId.AsType<int?>() ).FirstOrDefault()
} ).ToList();
var batchAttribute = attributeService.Queryable().FirstOrDefault( a => a.EntityTypeId == BatchEntityTypeId
&& a.Key == "F1BatchId" );
if ( batchAttribute == null )
{
batchAttribute = new Rock.Model.Attribute();
batchAttribute.Key = "F1BatchId";
batchAttribute.Name = "F1 Batch Id";
batchAttribute.FieldTypeId = IntegerFieldTypeId;
batchAttribute.EntityTypeId = BatchEntityTypeId;
batchAttribute.EntityTypeQualifierValue = string.Empty;
batchAttribute.EntityTypeQualifierColumn = string.Empty;
batchAttribute.Description = "The FellowshipOne identifier for the batch that was imported";
batchAttribute.DefaultValue = string.Empty;
batchAttribute.IsMultiValue = false;
batchAttribute.IsRequired = false;
batchAttribute.Order = 0;
attributeService.Add( batchAttribute, ImportPersonAlias );
attributeService.Save( batchAttribute, ImportPersonAlias );
}
BatchAttributeId = batchAttribute.Id;
ReportProgress( 0, "Checking for existing contributions..." );
ImportedBatches = new AttributeValueService().GetByAttributeId( batchAttribute.Id )
.Select( av => new { F1BatchId = av.Value.AsType<int?>(), RockBatchId = av.EntityId } )
.ToDictionary( t => t.F1BatchId, t => t.RockBatchId );
//.........这里部分代码省略.........
示例11: ShowEditDetails
//.........这里部分代码省略.........
// set dataview
dvpSyncDataview.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
dvpSyncDataview.SetValue( group.SyncDataViewId );
if ( group.AddUserAccountsDuringSync.HasValue )
{
rbCreateLoginDuringSync.Checked = group.AddUserAccountsDuringSync.Value;
}
if ( group.WelcomeSystemEmailId.HasValue )
{
ddlWelcomeEmail.SetValue( group.WelcomeSystemEmailId );
}
if ( group.ExitSystemEmailId.HasValue )
{
ddlExitEmail.SetValue( group.ExitSystemEmailId );
}
// GroupType depends on Selected ParentGroup
ddlParentGroup_SelectedIndexChanged( null, null );
gpParentGroup.Label = "Parent Group";
if ( group.Id == 0 && group.GroupType == null && ddlGroupType.Items.Count > 1 )
{
if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
{
// default GroupType for new Group to "Security Roles" if LimittoSecurityRoleGroups
var securityRoleGroupType = GroupTypeCache.GetSecurityRoleGroupType();
if ( securityRoleGroupType != null )
{
CurrentGroupTypeId = securityRoleGroupType.Id;
ddlGroupType.SetValue( securityRoleGroupType.Id );
}
else
{
ddlGroupType.SelectedIndex = 0;
}
}
else
{
// if this is a new group (and not "LimitToSecurityRoleGroups", and there is more than one choice for GroupType, default to no selection so they are forced to choose (vs unintentionallly choosing the default one)
ddlGroupType.SelectedIndex = 0;
}
}
else
{
CurrentGroupTypeId = group.GroupTypeId;
if ( CurrentGroupTypeId == 0 )
{
CurrentGroupTypeId = ddlGroupType.SelectedValueAsInt() ?? 0;
}
var groupType = GroupTypeCache.Read( CurrentGroupTypeId, rockContext );
lGroupType.Text = groupType != null ? groupType.Name : string.Empty;
ddlGroupType.SetValue( CurrentGroupTypeId );
}
ddlCampus.SetValue( group.CampusId );
GroupRequirementsState = group.GroupRequirements.ToList();
GroupLocationsState = group.GroupLocations.ToList();
var groupTypeCache = CurrentGroupTypeCache;
nbGroupCapacity.Visible = groupTypeCache != null && groupTypeCache.GroupCapacityRule != GroupCapacityRule.None;
SetScheduleControls( groupTypeCache, group );
ShowGroupTypeEditDetails( groupTypeCache, group, true );
// if this block's attribute limit group to SecurityRoleGroups, don't let them edit the SecurityRole checkbox value
if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
{
cbIsSecurityRole.Enabled = false;
cbIsSecurityRole.Checked = true;
}
string qualifierValue = group.Id.ToString();
GroupMemberAttributesState = attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "GroupId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList();
BindGroupMemberAttributesGrid();
BindInheritedAttributes( group.GroupTypeId, attributeService );
cbMembersMustMeetRequirementsOnAdd.Checked = group.MustMeetRequirementsToAddMember ?? false;
BindGroupRequirementsGrid();
MemberWorkflowTriggersState = new List<GroupMemberWorkflowTrigger>();
foreach ( var trigger in group.GroupMemberWorkflowTriggers )
{
MemberWorkflowTriggersState.Add( trigger );
}
BindMemberWorkflowTriggersGrid();
}
示例12: LoadExistingRockData
/// <summary>
/// Loads Rock data that's used globally by the transform
/// </summary>
private void LoadExistingRockData()
{
var lookupContext = new RockContext();
var attributeValueService = new AttributeValueService( lookupContext );
var attributeService = new AttributeService( lookupContext );
IntegerFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.INTEGER ) ).Id;
TextFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.TEXT ) ).Id;
PersonEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
CampusList = CampusCache.All( lookupContext );
int attributeEntityTypeId = EntityTypeCache.Read( "Rock.Model.Attribute" ).Id;
int batchEntityTypeId = EntityTypeCache.Read( "Rock.Model.FinancialBatch" ).Id;
int userLoginTypeId = EntityTypeCache.Read( "Rock.Model.UserLogin" ).Id;
int visitInfoCategoryId = new CategoryService( lookupContext ).GetByEntityTypeId( attributeEntityTypeId )
.Where( c => c.Name == "Visit Information" ).Select( c => c.Id ).FirstOrDefault();
// Look up and create attributes for F1 unique identifiers if they don't exist
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
var householdAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" );
if ( householdAttribute == null )
{
householdAttribute = new Rock.Model.Attribute();
householdAttribute.Key = "F1HouseholdId";
householdAttribute.Name = "F1 Household Id";
householdAttribute.FieldTypeId = IntegerFieldTypeId;
householdAttribute.EntityTypeId = PersonEntityTypeId;
householdAttribute.EntityTypeQualifierValue = string.Empty;
householdAttribute.EntityTypeQualifierColumn = string.Empty;
householdAttribute.Description = "The FellowshipOne household identifier for the person that was imported";
householdAttribute.DefaultValue = string.Empty;
householdAttribute.IsMultiValue = false;
householdAttribute.IsRequired = false;
householdAttribute.Order = 0;
lookupContext.Attributes.Add( householdAttribute );
lookupContext.SaveChanges( DisableAudit );
personAttributes.Add( householdAttribute );
}
var individualAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" );
if ( individualAttribute == null )
{
individualAttribute = new Rock.Model.Attribute();
individualAttribute.Key = "F1IndividualId";
individualAttribute.Name = "F1 Individual Id";
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
lookupContext.Attributes.Add( individualAttribute );
lookupContext.SaveChanges( DisableAudit );
personAttributes.Add( individualAttribute );
}
var secondaryEmailAttribute = personAttributes.FirstOrDefault( a => a.Key == "SecondaryEmail" );
if ( secondaryEmailAttribute == null )
{
secondaryEmailAttribute = new Rock.Model.Attribute();
secondaryEmailAttribute.Key = "SecondaryEmail";
secondaryEmailAttribute.Name = "Secondary Email";
secondaryEmailAttribute.FieldTypeId = TextFieldTypeId;
secondaryEmailAttribute.EntityTypeId = PersonEntityTypeId;
secondaryEmailAttribute.EntityTypeQualifierValue = string.Empty;
secondaryEmailAttribute.EntityTypeQualifierColumn = string.Empty;
secondaryEmailAttribute.Description = "The secondary email for this person";
secondaryEmailAttribute.DefaultValue = string.Empty;
secondaryEmailAttribute.IsMultiValue = false;
secondaryEmailAttribute.IsRequired = false;
secondaryEmailAttribute.Order = 0;
lookupContext.Attributes.Add( secondaryEmailAttribute );
var visitInfoCategory = new CategoryService( lookupContext ).Get( visitInfoCategoryId );
secondaryEmailAttribute.Categories.Add( visitInfoCategory );
lookupContext.SaveChanges( DisableAudit );
}
IndividualAttributeId = individualAttribute.Id;
HouseholdAttributeId = householdAttribute.Id;
SecondaryEmailAttributeId = secondaryEmailAttribute.Id;
ReportProgress( 0, "Checking for existing data..." );
var listHouseholdId = attributeValueService.GetByAttributeId( householdAttribute.Id ).Select( av => new { PersonId = av.EntityId, HouseholdId = av.Value } ).ToList();
var listIndividualId = attributeValueService.GetByAttributeId( individualAttribute.Id ).Select( av => new { PersonId = av.EntityId, IndividualId = av.Value } ).ToList();
// var listHouseholdId = new PersonService().Queryable().Select( )
ImportedPeople = listHouseholdId.GroupJoin( listIndividualId,
household => household.PersonId,
individual => individual.PersonId,
//.........这里部分代码省略.........
示例13: BindWorkflowTypeAttributesGrid
/// <summary>
/// Binds the workflow type attributes grid.
/// </summary>
private void BindWorkflowTypeAttributesGrid()
{
AttributeService attributeService = new AttributeService();
int workflowTypeId = hfWorkflowTypeId.ValueAsInt();
string qualifierValue = workflowTypeId.ToString();
var qryWorkflowTypeAttributes = attributeService.GetByEntityTypeId( new Workflow().TypeId ).AsQueryable()
.Where( a => a.EntityTypeQualifierColumn.Equals( "WorkflowTypeId", StringComparison.OrdinalIgnoreCase )
&& a.EntityTypeQualifierValue.Equals( qualifierValue ) );
gWorkflowTypeAttributes.DataSource = qryWorkflowTypeAttributes.OrderBy( a => a.Name ).ToList();
gWorkflowTypeAttributes.DataBind();
}
示例14: MapCommunication
/// <summary>
/// Maps the communication data.
/// </summary>
/// <param name="tableData">The table data.</param>
/// <returns></returns>
private void MapCommunication( IQueryable<Row> tableData )
{
var lookupContext = new RockContext();
var personService = new PersonService( lookupContext );
var attributeService = new AttributeService( lookupContext );
var numberTypeValues = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_PHONE_TYPE ), lookupContext ).DefinedValues;
// Look up additional Person attributes (existing)
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
// Remove previously defined Excavator social attributes & categories if they exist
var oldFacebookAttribute = personAttributes.Where( a => a.Key == "FacebookUsername" ).FirstOrDefault();
if ( oldFacebookAttribute != null )
{
Rock.Web.Cache.AttributeCache.Flush( oldFacebookAttribute.Id );
attributeService.Delete( oldFacebookAttribute );
lookupContext.SaveChanges( true );
}
var oldTwitterAttribute = personAttributes.Where( a => a.Key == "TwitterUsername" ).FirstOrDefault();
if ( oldTwitterAttribute != null )
{
Rock.Web.Cache.AttributeCache.Flush( oldTwitterAttribute.Id );
attributeService.Delete( oldTwitterAttribute );
lookupContext.SaveChanges( true );
}
int attributeEntityTypeId = EntityTypeCache.Read( "Rock.Model.Attribute" ).Id;
var socialMediaCategory = new CategoryService( lookupContext ).GetByEntityTypeId( attributeEntityTypeId )
.Where( c => c.Name == "Social Media" &&
c.EntityTypeQualifierValue == PersonEntityTypeId.ToString() &&
c.IconCssClass == "fa fa-twitter" )
.FirstOrDefault();
if ( socialMediaCategory != null )
{
lookupContext.Categories.Remove( socialMediaCategory );
lookupContext.SaveChanges( true );
}
// Cached Rock attributes: Facebook, Twitter, Instagram
var twitterAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Twitter" ) );
var facebookAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Facebook" ) );
var instagramAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Instagram" ) );
var secondaryEmailAttribute = AttributeCache.Read( SecondaryEmailAttributeId );
var existingNumbers = new PhoneNumberService( lookupContext ).Queryable().ToList();
var newNumberList = new List<PhoneNumber>();
var updatedPersonList = new List<Person>();
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Verifying communication import ({0:N0} found, {1:N0} already exist).", totalRows, existingNumbers.Count() ) );
foreach ( var row in tableData )
{
string value = row["Communication_Value"] as string;
int? individualId = row["Individual_ID"] as int?;
int? householdId = row["Household_ID"] as int?;
var personList = new List<int?>();
if ( individualId != null )
{
int? personId = GetPersonAliasId( individualId, householdId );
if ( personId != null )
{
personList.Add( personId );
}
}
else
{
List<int?> personIds = GetFamilyByHouseholdId( householdId );
if ( personIds.Any() )
{
personList.AddRange( personIds );
}
}
if ( personList.Any() && !string.IsNullOrWhiteSpace( value ) )
{
DateTime? lastUpdated = row["LastUpdatedDate"] as DateTime?;
string communicationComment = row["Communication_Comment"] as string;
string type = row["Communication_Type"] as string;
bool isListed = (bool)row["Listed"];
value = value.RemoveWhitespace();
// Communication value is a number
if ( type.Contains( "Phone" ) || type.Contains( "Mobile" ) )
{
var extension = string.Empty;
var countryCode = Rock.Model.PhoneNumber.DefaultCountryCode();
var normalizedNumber = string.Empty;
var countryIndex = value.IndexOf( '+' );
//.........这里部分代码省略.........
示例15: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="contentTypeId">The marketing campaign ad type identifier.</param>
public void ShowDetail( int contentTypeId )
{
var rockContext = new RockContext();
ContentChannelType contentType = null;
if ( !contentTypeId.Equals( 0 ) )
{
contentType = GetContentChannelType( contentTypeId );
}
if ( contentType == null )
{
contentType = new ContentChannelType { Id = 0 };
}
string title = contentType.Id > 0 ?
ActionTitle.Edit( ContentChannelType.FriendlyTypeName ) :
ActionTitle.Add( ContentChannelType.FriendlyTypeName );
lTitle.Text = title.FormatAsHtmlTitle();
hfId.Value = contentType.Id.ToString();
tbName.Text = contentType.Name;
ddlDateRangeType.BindToEnum<ContentChannelDateType>();
ddlDateRangeType.SetValue( (int)contentType.DateRangeType );
cbIncludeTime.Checked = contentType.IncludeTime;
cbDisablePriority.Checked = contentType.DisablePriority;
// load attribute data
ChannelAttributesState = new List<Attribute>();
ItemAttributesState = new List<Attribute>();
AttributeService attributeService = new AttributeService( new RockContext() );
string qualifierValue = contentType.Id.ToString();
attributeService.GetByEntityTypeId( new ContentChannel().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "ContentChannelTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.ToList()
.ForEach( a => ChannelAttributesState.Add( a ) );
BindChannelAttributesGrid();
attributeService.GetByEntityTypeId( new ContentChannelItem().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "ContentChannelTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.ToList()
.ForEach( a => ItemAttributesState.Add( a ) );
BindItemAttributesGrid();
}