本文整理汇总了C#中Rock.Model.DefinedValueService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# DefinedValueService.Get方法的具体用法?C# DefinedValueService.Get怎么用?C# DefinedValueService.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.DefinedValueService
的用法示例。
在下文中一共展示了DefinedValueService.Get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoad
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( Page.IsPostBack )
{
using ( var rockContext = new RockContext() )
{
var definedValueService = new DefinedValueService( rockContext );
foreach ( RepeaterItem item in rptrValues.Items )
{
var hfValue = item.FindControl( "hfValue" ) as HiddenField;
var cbValue = item.FindControl( "cbValue" ) as CheckBox;
if ( hfValue != null && cbValue != null )
{
var value = definedValueService.Get( hfValue.ValueAsInt() );
if ( value != null )
{
Helper.LoadAttributes( value );
if ( value.GetAttributeValue( attributeKey ) != cbValue.Checked.ToString() )
{
value.SetAttributeValue( attributeKey, cbValue.Checked.ToString() );
value.SaveAttributeValues( rockContext );
DefinedValueCache.Flush( value.Id );
}
}
}
}
}
}
bool wasVisible = this.Visible;
ShowList();
if ( Page.IsPostBack && wasVisible && this.Visible == false )
{
// If last item was just checked do a redirect back to the same page.
// This is needed to hide the control since content is inside an update
// panel
Response.Redirect( CurrentPageReference.BuildUrl(), false );
}
}
示例2: btnSaveValue_Click
/// <summary>
/// Handles the Click event of the btnSaveDefinedValue control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSaveValue_Click( object sender, EventArgs e )
{
DefinedValue definedValue;
DefinedValueService definedValueService = new DefinedValueService();
int definedValueId = hfDefinedValueId.ValueAsInt();
if ( definedValueId.Equals( 0 ) )
{
int definedTypeId = hfDefinedTypeId.ValueAsInt();
definedValue = new DefinedValue { Id = 0 };
definedValue.DefinedTypeId = definedTypeId;
definedValue.IsSystem = false;
var orders = definedValueService.Queryable()
.Where( d => d.DefinedTypeId == definedTypeId )
.Select( d => d.Order)
.ToList();
definedValue.Order = orders.Any() ? orders.Max() + 1 : 0;
}
else
{
definedValue = definedValueService.Get( definedValueId );
}
definedValue.Name = tbValueName.Text;
definedValue.Description = tbValueDescription.Text;
definedValue.LoadAttributes();
Rock.Attribute.Helper.GetEditValues( phDefinedValueAttributes, definedValue );
if ( !Page.IsValid )
{
return;
}
if ( !definedValue.IsValid )
{
// Controls will render the error messages
return;
}
RockTransactionScope.WrapTransaction( () =>
{
if ( definedValue.Id.Equals( 0 ) )
{
definedValueService.Add( definedValue, CurrentPersonId );
}
definedValueService.Save( definedValue, CurrentPersonId );
Rock.Attribute.Helper.SaveAttributeValues( definedValue, CurrentPersonId );
Rock.Web.Cache.DefinedTypeCache.Flush( definedValue.DefinedTypeId );
Rock.Web.Cache.DefinedValueCache.Flush( definedValue.Id );
} );
BindDefinedValuesGrid();
hfDefinedValueId.Value = string.Empty;
modalValue.Hide();
}
示例3: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSave_Click( object sender, EventArgs e )
{
GroupType groupType;
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
GroupTypeRoleService groupTypeRoleService = new GroupTypeRoleService( rockContext );
AttributeService attributeService = new AttributeService( rockContext );
AttributeQualifierService qualifierService = new AttributeQualifierService( rockContext );
CategoryService categoryService = new CategoryService( rockContext );
GroupScheduleExclusionService scheduleExclusionService = new GroupScheduleExclusionService( rockContext );
int groupTypeId = int.Parse( hfGroupTypeId.Value );
if ( groupTypeId == 0 )
{
groupType = new GroupType();
groupTypeService.Add( groupType );
}
else
{
groupType = groupTypeService.Get( groupTypeId );
// selected roles
var selectedRoleGuids = GroupTypeRolesState.Select( r => r.Guid );
foreach ( var role in groupType.Roles.Where( r => !selectedRoleGuids.Contains( r.Guid ) ).ToList() )
{
groupType.Roles.Remove( role );
groupTypeRoleService.Delete( role );
}
}
foreach ( var roleState in GroupTypeRolesState )
{
GroupTypeRole role = groupType.Roles.Where( r => r.Guid == roleState.Guid ).FirstOrDefault();
if ( role == null )
{
role = new GroupTypeRole();
groupType.Roles.Add( role );
}
else
{
roleState.Id = role.Id;
roleState.Guid = role.Guid;
}
role.CopyPropertiesFrom( roleState );
}
ScheduleType allowedScheduleTypes = ScheduleType.None;
foreach( ListItem li in cblScheduleTypes.Items )
{
if ( li.Selected )
{
allowedScheduleTypes = allowedScheduleTypes | (ScheduleType)li.Value.AsInteger();
}
}
GroupLocationPickerMode locationSelectionMode = GroupLocationPickerMode.None;
foreach ( ListItem li in cblLocationSelectionModes.Items )
{
if ( li.Selected )
{
locationSelectionMode = locationSelectionMode | (GroupLocationPickerMode)li.Value.AsInteger();
}
}
groupType.Name = tbName.Text;
groupType.Description = tbDescription.Text;
groupType.GroupTerm = tbGroupTerm.Text;
groupType.GroupMemberTerm = tbGroupMemberTerm.Text;
groupType.ShowInGroupList = cbShowInGroupList.Checked;
groupType.ShowInNavigation = cbShowInNavigation.Checked;
groupType.IconCssClass = tbIconCssClass.Text;
groupType.TakesAttendance = cbTakesAttendance.Checked;
groupType.SendAttendanceReminder = cbSendAttendanceReminder.Checked;
groupType.AttendanceRule = ddlAttendanceRule.SelectedValueAsEnum<AttendanceRule>();
groupType.AttendancePrintTo = ddlPrintTo.SelectedValueAsEnum<PrintTo>();
groupType.AllowedScheduleTypes = allowedScheduleTypes;
groupType.LocationSelectionMode = locationSelectionMode;
groupType.GroupTypePurposeValueId = ddlGroupTypePurpose.SelectedValueAsInt();
groupType.AllowMultipleLocations = cbAllowMultipleLocations.Checked;
groupType.InheritedGroupTypeId = gtpInheritedGroupType.SelectedGroupTypeId;
groupType.EnableLocationSchedules = cbEnableLocationSchedules.Checked;
groupType.ChildGroupTypes = new List<GroupType>();
groupType.ChildGroupTypes.Clear();
foreach ( var item in ChildGroupTypesDictionary )
{
var childGroupType = groupTypeService.Get( item.Key );
if ( childGroupType != null )
{
groupType.ChildGroupTypes.Add( childGroupType );
}
}
//.........这里部分代码省略.........
示例4: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
/// <exception cref="System.NotImplementedException"></exception>
protected void btnSave_Click( object sender, EventArgs e )
{
var rockContext = new RockContext();
var financialPledgeService = new FinancialPledgeService( rockContext );
var financialAccountService = new FinancialAccountService( rockContext );
var definedValueService = new DefinedValueService( rockContext );
var person = FindPerson( rockContext );
FinancialPledge financialPledge = new FinancialPledge();
financialPledge.PersonAliasId = person.PrimaryAliasId;
var financialAccount = financialAccountService.Get( GetAttributeValue( "Account" ).AsGuid() );
if ( financialAccount != null )
{
financialPledge.AccountId = financialAccount.Id;
}
financialPledge.TotalAmount = tbTotalAmount.Text.AsDecimal();
var pledgeFrequencySelection = DefinedValueCache.Read( bddlFrequency.SelectedValue.AsInteger() );
if ( pledgeFrequencySelection != null )
{
financialPledge.PledgeFrequencyValueId = pledgeFrequencySelection.Id;
}
financialPledge.StartDate = drpDateRange.LowerValue ?? DateTime.MinValue;
financialPledge.EndDate = drpDateRange.UpperValue ?? DateTime.MaxValue;
if ( sender != btnConfirm )
{
var duplicatePledges = financialPledgeService.Queryable()
.Where( a => a.PersonAlias.PersonId == person.Id )
.Where( a => a.AccountId == financialPledge.AccountId )
.Where( a => a.StartDate == financialPledge.StartDate )
.Where( a => a.EndDate == financialPledge.EndDate ).ToList();
if ( duplicatePledges.Any() )
{
pnlAddPledge.Visible = false;
pnlConfirm.Visible = true;
nbDuplicatePledgeWarning.Text = "The following pledges have already been entered for you:";
nbDuplicatePledgeWarning.Text += "<ul>";
foreach ( var pledge in duplicatePledges.OrderBy( a => a.StartDate ).ThenBy( a => a.Account.Name ) )
{
nbDuplicatePledgeWarning.Text += string.Format( "<li>{0} {1} {2}</li>", pledge.Account, pledge.PledgeFrequencyValue, pledge.TotalAmount );
}
nbDuplicatePledgeWarning.Text += "</ul>";
return;
}
}
financialPledgeService.Add( financialPledge );
rockContext.SaveChanges();
// populate account so that Liquid can access it
financialPledge.Account = financialAccount;
// populate PledgeFrequencyValue so that Liquid can access it
financialPledge.PledgeFrequencyValue = definedValueService.Get( financialPledge.PledgeFrequencyValueId ?? 0 );
var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );
mergeFields.Add( "Person", person );
mergeFields.Add( "FinancialPledge", financialPledge );
mergeFields.Add( "PledgeFrequency", pledgeFrequencySelection );
mergeFields.Add( "Account", financialAccount );
lReceipt.Text = GetAttributeValue( "ReceiptText" ).ResolveMergeFields( mergeFields );
// Resolve any dynamic url references
string appRoot = ResolveRockUrl( "~/" );
string themeRoot = ResolveRockUrl( "~~/" );
lReceipt.Text = lReceipt.Text.Replace( "~~/", themeRoot ).Replace( "~/", appRoot );
// show liquid help for debug
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lReceipt.Text += mergeFields.lavaDebugInfo();
}
lReceipt.Visible = true;
pnlAddPledge.Visible = false;
pnlConfirm.Visible = false;
// if a ConfirmationEmailTemplate is configured, send an email
var confirmationEmailTemplateGuid = GetAttributeValue( "ConfirmationEmailTemplate" ).AsGuidOrNull();
if ( confirmationEmailTemplateGuid.HasValue )
{
var recipients = new List<Rock.Communication.RecipientData>();
// add person and the mergeObjects (same mergeobjects as receipt)
recipients.Add( new Rock.Communication.RecipientData( person.Email, mergeFields ) );
//.........这里部分代码省略.........
示例5: gDefinedValues_Delete
/// <summary>
/// Handles the Delete event of the gDefinedValues control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gDefinedValues_Delete( object sender, RowEventArgs e )
{
var valueService = new DefinedValueService();
DefinedValue value = valueService.Get( (int)e.RowKeyValue );
DefinedTypeCache.Flush(value.DefinedTypeId);
DefinedValueCache.Flush(value.Id);
if ( value != null )
{
valueService.Delete( value, CurrentPersonId );
valueService.Save( value, CurrentPersonId );
}
BindDefinedValuesGrid();
}
示例6: dlgPackage_SaveClick
protected void dlgPackage_SaveClick( object sender, EventArgs e )
{
int definedValueId = hfDefinedValueId.Value.AsInteger();
var definedType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() );
if ( definedType != null )
{
using ( var rockContext = new RockContext() )
{
var service = new DefinedValueService( rockContext );
DefinedValue definedValue = null;
if ( !definedValueId.Equals( 0 ) )
{
definedValue = service.Get( definedValueId );
}
if ( definedValue == null )
{
definedValue = new DefinedValue();
definedValue.DefinedTypeId = definedType.Id;
service.Add( definedValue );
}
definedValue.Value = tbTitle.Text;
definedValue.Description = tbDescription.Text;
rockContext.SaveChanges();
definedValue.LoadAttributes( rockContext );
Guid? dvJurisdicationCodeGuid = null;
int? dvJurisdictionCodeId = ddlMVRJurisdication.SelectedValueAsInt();
if ( dvJurisdictionCodeId.HasValue && dvJurisdictionCodeId.Value > 0 )
{
var dvJurisdicationCode = DefinedValueCache.Read( dvJurisdictionCodeId.Value );
if ( dvJurisdicationCode != null )
{
dvJurisdicationCodeGuid = dvJurisdicationCode.Guid;
}
}
definedValue.SetAttributeValue( "PMMPackageName", tbPackageName.Text );
definedValue.SetAttributeValue( "DefaultCounty", tbDefaultCounty.Text );
definedValue.SetAttributeValue( "SendHomeCounty", cbSendCounty.Checked.ToString() );
definedValue.SetAttributeValue( "DefaultState", tbDefaultState.Text );
definedValue.SetAttributeValue( "SendHomeState", cbSendState.Checked.ToString() );
definedValue.SetAttributeValue( "MVRJurisdiction", dvJurisdicationCodeGuid.HasValue ? dvJurisdicationCodeGuid.Value.ToString() : string.Empty );
definedValue.SetAttributeValue( "SendHomeStateMVR", cbSendStateMVR.Checked.ToString() );
definedValue.SaveAttributeValues( rockContext );
DefinedTypeCache.Flush( definedType.Id );
DefinedValueCache.Flush( definedValue.Id );
}
}
BindPackageGrid();
HideDialog();
}
示例7: gDefinedValues_Delete
/// <summary>
/// Handles the Delete event of the gDefinedValues control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
protected void gDefinedValues_Delete( object sender, RowEventArgs e )
{
using ( var rockContext = new RockContext() )
{
var definedValueService = new DefinedValueService( rockContext );
var value = definedValueService.Get( e.RowKeyId );
if ( value != null )
{
string errorMessage;
if ( !definedValueService.CanDelete( value, out errorMessage ) )
{
mdGridWarningValues.Show( errorMessage, ModalAlertType.Information );
return;
}
definedValueService.Delete( value );
rockContext.SaveChanges();
DefinedTypeCache.Flush( value.DefinedTypeId );
DefinedValueCache.Flush( value.Id );
}
BindPackageGrid();
}
}
示例8: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSave_Click( object sender, EventArgs e )
{
GroupType groupType;
using ( new UnitOfWorkScope() )
{
GroupTypeService groupTypeService = new GroupTypeService();
GroupTypeRoleService groupTypeRoleService = new GroupTypeRoleService();
AttributeService attributeService = new AttributeService();
AttributeQualifierService qualifierService = new AttributeQualifierService();
CategoryService categoryService = new CategoryService();
int groupTypeId = int.Parse( hfGroupTypeId.Value );
if ( groupTypeId == 0 )
{
groupType = new GroupType();
groupTypeService.Add( groupType, CurrentPersonId );
}
else
{
groupType = groupTypeService.Get( groupTypeId );
// selected roles
var selectedRoleGuids = GroupTypeRolesState.Select( r => r.Guid );
foreach ( var role in groupType.Roles.Where( r => !selectedRoleGuids.Contains( r.Guid ) ).ToList() )
{
groupType.Roles.Remove( role );
groupTypeRoleService.Delete( role, CurrentPersonId );
}
}
foreach ( var roleState in GroupTypeRolesState )
{
GroupTypeRole role = groupType.Roles.Where( r => r.Guid == roleState.Guid ).FirstOrDefault();
if ( role == null )
{
role = new GroupTypeRole();
groupType.Roles.Add( role );
}
else
{
roleState.Id = role.Id;
roleState.Guid = role.Guid;
}
role.CopyPropertiesFrom( roleState );
}
GroupLocationPickerMode locationSelectionMode = GroupLocationPickerMode.None;
foreach(ListItem li in cblLocationSelectionModes.Items)
{
if ( li.Selected )
{
locationSelectionMode = locationSelectionMode | (GroupLocationPickerMode)li.Value.AsInteger().Value;
}
}
groupType.Name = tbName.Text;
groupType.Description = tbDescription.Text;
groupType.GroupTerm = tbGroupTerm.Text;
groupType.GroupMemberTerm = tbGroupMemberTerm.Text;
groupType.ShowInGroupList = cbShowInGroupList.Checked;
groupType.ShowInNavigation = cbShowInNavigation.Checked;
groupType.IconCssClass = tbIconCssClass.Text;
groupType.TakesAttendance = cbTakesAttendance.Checked;
groupType.AttendanceRule = ddlAttendanceRule.SelectedValueAsEnum<AttendanceRule>();
groupType.AttendancePrintTo = ddlAttendancePrintTo.SelectedValueAsEnum<PrintTo>();
groupType.LocationSelectionMode = locationSelectionMode;
groupType.GroupTypePurposeValueId = ddlGroupTypePurpose.SelectedValueAsInt();
groupType.AllowMultipleLocations = cbAllowMultipleLocations.Checked;
groupType.InheritedGroupTypeId = gtpInheritedGroupType.SelectedGroupTypeId;
groupType.ChildGroupTypes = new List<GroupType>();
groupType.ChildGroupTypes.Clear();
foreach ( var item in ChildGroupTypesDictionary )
{
var childGroupType = groupTypeService.Get( item.Key );
if ( childGroupType != null )
{
groupType.ChildGroupTypes.Add( childGroupType );
}
}
DefinedValueService definedValueService = new DefinedValueService();
groupType.LocationTypes = new List<GroupTypeLocationType>();
groupType.LocationTypes.Clear();
foreach ( var item in LocationTypesDictionary )
{
var locationType = definedValueService.Get( item.Key );
if ( locationType != null )
{
groupType.LocationTypes.Add( new GroupTypeLocationType { LocationTypeValueId = locationType.Id } );
}
//.........这里部分代码省略.........
示例9: MapPerson
/// <summary>
/// Maps the person.
/// </summary>
/// <param name="tableData">The table data.</param>
/// <param name="selectedColumns">The selected columns.</param>
private void MapPerson( IQueryable<Row> tableData, List<string> selectedColumns = null )
{
var groupTypeRoleService = new GroupTypeRoleService();
var attributeService = new AttributeService();
var dvService = new DefinedValueService();
var familyList = new List<Group>();
// Marital statuses: Married, Single, Separated, etc
List<DefinedValue> maritalStatusTypes = dvService.Queryable()
.Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS ) ).ToList();
// Connection statuses: Member, Visitor, Attendee, etc
List<DefinedValue> connectionStatusTypes = dvService.Queryable()
.Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ) ).ToList();
// Record status reasons: No Activity, Moved, Deceased, etc
List<DefinedValue> recordStatusReasons = dvService.Queryable()
.Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON ) ).ToList();
// Record statuses: Active, Inactive, Pending
int? statusActiveId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ) ).Id;
int? statusInactiveId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;
int? statusPendingId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_PENDING ) ).Id;
// Record type: Person
int? personRecordTypeId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ) ).Id;
// Suffix type: Dr., Jr., II, etc
List<DefinedValue> suffixTypes = dvService.Queryable()
.Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_SUFFIX ) ).ToList();
// Title type: Mr., Mrs. Dr., etc
List<DefinedValue> titleTypes = dvService.Queryable()
.Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_TITLE ) ).ToList();
// Note type: Comment
int noteCommentTypeId = new NoteTypeService().Get( new Guid( "7E53487C-D650-4D85-97E2-350EB8332763" ) ).Id;
// Group roles: Adult, Child, others
int adultRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
int childRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;
// Group type: Family
int familyGroupTypeId = GroupTypeCache.GetFamilyGroupType().Id;
// Look up additional Person attributes (existing)
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
// Cached F1 attributes: IndividualId, HouseholdId, PreviousChurch, Position, Employer, School
var individualIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" ) );
var householdIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" ) );
var previousChurchAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "PreviousChurch" ) );
var employerAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Employer" ) );
var positionAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Position" ) );
var firstVisitAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "FirstVisit" ) );
var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "School" ) );
var membershipDateAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "MembershipDate" ) );
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Checking person import ({0:N0} found, {1:N0} already exist).", totalRows, ImportedPeople.Count() ) );
foreach ( var groupedRows in tableData.GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
{
var familyGroup = new Group();
var householdCampusList = new List<string>();
foreach ( var row in groupedRows )
{
int? individualId = row["Individual_ID"] as int?;
int? householdId = row["Household_ID"] as int?;
if ( GetPersonId( individualId, householdId ) == null )
{
var person = new Person();
person.FirstName = row["First_Name"] as string;
person.MiddleName = row["Middle_Name"] as string;
person.NickName = row["Goes_By"] as string ?? person.FirstName;
person.LastName = row["Last_Name"] as string;
person.BirthDate = row["Date_Of_Birth"] as DateTime?;
person.CreatedByPersonAliasId = ImportPersonAlias.Id;
person.RecordTypeValueId = personRecordTypeId;
int groupRoleId = adultRoleId;
var gender = row["Gender"] as string;
if ( gender != null )
{
person.Gender = (Gender)Enum.Parse( typeof( Gender ), gender );
}
string prefix = row["Prefix"] as string;
if ( prefix != null )
{
prefix = prefix.RemoveSpecialCharacters().Trim();
person.TitleValueId = titleTypes.Where( s => prefix == s.Name.RemoveSpecialCharacters() )
//.........这里部分代码省略.........
示例10: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
/// <exception cref="System.NotImplementedException"></exception>
protected void btnSave_Click( object sender, EventArgs e )
{
var rockContext = new RockContext();
var financialPledgeService = new FinancialPledgeService( rockContext );
var financialAccountService = new FinancialAccountService( rockContext );
var definedValueService = new DefinedValueService( rockContext );
var person = FindPerson( rockContext );
FinancialPledge financialPledge = new FinancialPledge();
financialPledge.PersonId = person.Id;
var financialAccount = financialAccountService.Get( GetAttributeValue( "Account" ).AsGuid() );
if ( financialAccount != null )
{
financialPledge.AccountId = financialAccount.Id;
}
financialPledge.TotalAmount = tbTotalAmount.Text.AsDecimal();
var pledgeFrequencySelection = DefinedValueCache.Read( bddlFrequency.SelectedValue.AsInteger() );
if ( pledgeFrequencySelection != null )
{
financialPledge.PledgeFrequencyValueId = pledgeFrequencySelection.Id;
}
financialPledge.StartDate = drpDateRange.LowerValue ?? DateTime.MinValue;
financialPledge.EndDate = drpDateRange.UpperValue ?? DateTime.MaxValue;
if ( sender != btnConfirm )
{
var duplicatePledges = financialPledgeService.Queryable()
.Where( a => a.PersonId == person.Id )
.Where( a => a.AccountId == financialPledge.AccountId )
.Where( a => a.StartDate == financialPledge.StartDate )
.Where( a => a.EndDate == financialPledge.EndDate ).ToList();
if ( duplicatePledges.Any() )
{
pnlAddPledge.Visible = false;
pnlConfirm.Visible = true;
nbDuplicatePledgeWarning.Text = "The following pledges have already been entered for you:";
nbDuplicatePledgeWarning.Text += "<ul>";
foreach ( var pledge in duplicatePledges.OrderBy( a => a.StartDate ).ThenBy( a => a.Account.Name ) )
{
nbDuplicatePledgeWarning.Text += string.Format( "<li>{0} {1} {2}</li>", pledge.Account, pledge.PledgeFrequencyValue, pledge.TotalAmount );
}
nbDuplicatePledgeWarning.Text += "</ul>";
return;
}
}
financialPledgeService.Add( financialPledge );
rockContext.SaveChanges();
// populate account so that Liquid can access it
financialPledge.Account = financialAccount;
// populate PledgeFrequencyValue so that Liquid can access it
financialPledge.PledgeFrequencyValue = definedValueService.Get( financialPledge.PledgeFrequencyValueId ?? 0 );
var mergeObjects = new Dictionary<string, object>();
mergeObjects.Add( "Person", person );
mergeObjects.Add( "FinancialPledge", financialPledge );
mergeObjects.Add( "PledgeFrequency", pledgeFrequencySelection );
mergeObjects.Add( "Account", financialAccount );
lReceipt.Text = GetAttributeValue( "ReceiptText" ).ResolveMergeFields( mergeObjects );
// show liquid help for debug
if ( GetAttributeValue( "EnableDebug" ).AsBooleanOrNull() ?? false )
{
StringBuilder debugInfo = new StringBuilder();
debugInfo.Append( "<p /><div class='alert alert-info'><h4>Debug Info</h4>" );
debugInfo.Append( "<pre>" );
debugInfo.Append( "<p /><strong>Liquid Data</strong> <br>" );
debugInfo.Append( mergeObjects.LiquidHelpText() + "</pre>" );
debugInfo.Append( "</div>" );
lReceipt.Text += debugInfo.ToString();
}
lReceipt.Visible = true;
pnlAddPledge.Visible = false;
pnlConfirm.Visible = false;
// if a ConfirmationEmailTemplate is configured, send an email
var confirmationEmailTemplateGuid = GetAttributeValue( "ConfirmationEmailTemplate" ).AsGuidOrNull();
if ( confirmationEmailTemplateGuid.HasValue )
{
//.........这里部分代码省略.........
示例11: rGridValue_Delete
/// <summary>
/// Handles the Delete event of the rGridValue control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void rGridValue_Delete( object sender, RowEventArgs e )
{
var valueService = new DefinedValueService();
DefinedValue value = valueService.Get( (int)rGridValue.DataKeys[e.RowIndex]["id"] );
if ( value != null )
{
valueService.Delete( value, CurrentPersonId );
valueService.Save( value, CurrentPersonId );
}
rGridValue_Bind( hfIdType.Value );
}
示例12: btnSaveValue_Click
/// <summary>
/// Handles the Click event of the btnSaveValue control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSaveValue_Click( object sender, EventArgs e )
{
using ( new Rock.Data.UnitOfWorkScope() )
{
DefinedValueService valueService = new DefinedValueService();
DefinedValue definedValue;
int valueId = ( ( hfIdValue.Value ) != null && hfIdValue.Value != String.Empty ) ? Int32.Parse( hfIdValue.Value ) : 0;
if ( valueId == 0 )
{
definedValue = new DefinedValue();
definedValue.IsSystem = false;
definedValue.DefinedTypeId = Int32.Parse( hfIdType.Value );
valueService.Add( definedValue, CurrentPersonId );
}
else
{
Rock.Web.Cache.AttributeCache.Flush( valueId );
definedValue = valueService.Get( valueId );
}
definedValue.Name = tbValueName.Text;
definedValue.Description = tbValueDescription.Text;
/*
Parse attribute values from controls list
*/
if ( phAttrControl.Controls.Count > 0 )
{
}
valueService.Save( definedValue, CurrentPersonId );
}
rGridValue_Bind( hfIdType.Value );
modalValues.Hide();
pnlValues.Visible = true;
}
示例13: OnLoad
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( Page.IsPostBack )
{
var definedValueService = new DefinedValueService();
foreach ( RepeaterItem item in rptrValues.Items )
{
var hfValue = item.FindControl( "hfValue" ) as HiddenField;
var cbValue = item.FindControl( "cbValue" ) as CheckBox;
if ( hfValue != null && cbValue != null )
{
var value = definedValueService.Get( hfValue.ValueAsInt() );
if ( value != null )
{
Helper.LoadAttributes( value );
value.SetAttributeValue( attributeKey, cbValue.Checked.ToString() );
Helper.SaveAttributeValues( value, CurrentPersonId );
DefinedValueCache.Flush( value.Id );
}
}
}
}
ShowList();
if (Page.IsPostBack && pnlContent.Visible == false)
{
// If last item was just checked (postback and visible == false),
// do a redirect back to the same page. This is needed to hide
// the pre/post content which is outside of this controls update panel.
Response.Redirect( CurrentPageReference.BuildUrl(), false );
}
}
示例14: dlgLink_SaveClick
/// <summary>
/// Handles the SaveClick event of the dlgLink control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void dlgLink_SaveClick( object sender, EventArgs e )
{
DefinedValue definedValue = null;
using ( var rockContext = new RockContext() )
{
var service = new DefinedValueService( rockContext );
int? definedValueId = hfDefinedValueId.Value.AsIntegerOrNull();
if ( definedValueId.HasValue )
{
definedValue = service.Get( definedValueId.Value );
}
if ( definedValue == null )
{
definedValue = new DefinedValue { Id = 0 };
definedValue.DefinedTypeId = _definedType.Id;
definedValue.IsSystem = false;
var orders = service.Queryable()
.Where( d => d.DefinedTypeId == _definedType.Id )
.Select( d => d.Order )
.ToList();
definedValue.Order = orders.Any() ? orders.Max() + 1 : 0;
}
definedValue.Value = tbTitle.Text;
definedValue.Description = tbLink.Text;
definedValue.LoadAttributes();
definedValue.SetAttributeValue( "IsLink", ( rblLinkType.SelectedValue == "Link" ).ToString() );
rockContext.WrapTransaction( () =>
{
if ( definedValue.Id.Equals( 0 ) )
{
service.Add( definedValue );
}
rockContext.SaveChanges();
definedValue.SaveAttributeValues( rockContext );
} );
Rock.Web.Cache.DefinedTypeCache.Flush( definedValue.DefinedTypeId );
Rock.Web.Cache.DefinedValueCache.Flush( definedValue.Id );
}
HideDialog();
BindGrid();
}