本文整理汇总了C#中Dictionary.lavaDebugInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.lavaDebugInfo方法的具体用法?C# Dictionary.lavaDebugInfo怎么用?C# Dictionary.lavaDebugInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.lavaDebugInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the specified writer.
/// </summary>
/// <param name="badge">The badge.</param>
/// <param name="writer">The writer.</param>
public override void Render( PersonBadgeCache badge, System.Web.UI.HtmlTextWriter writer )
{
string displayText = GetAttributeValue( badge, "DisplayText" );
if ( Person != null )
{
Dictionary<string, object> mergeValues = new Dictionary<string, object>();
mergeValues.Add( "Person", Person );
displayText = displayText.ResolveMergeFields( mergeValues );
if ( GetAttributeValue( badge, "EnableDebug" ).AsBoolean() )
{
string debugInfo = string.Format( @"
<small><a data-toggle='collapse' data-parent='#accordion' href='#badge-debug'><i class='fa fa-eye'></i></a></small>
<div id='badge-debug' class='collapse well badge-debug'>
{0}
</div>
", mergeValues.lavaDebugInfo() );
displayText += debugInfo;
}
}
writer.Write( displayText );
}
示例2: LoadContent
public void LoadContent()
{
// get opportunity id
int opportunityId = -1;
if ( !string.IsNullOrWhiteSpace( PageParameter( "OpportunityId" ) ) )
{
opportunityId = Convert.ToInt32( PageParameter( "OpportunityId" ) );
}
if ( opportunityId > 0 )
{
RockContext rockContext = new RockContext();
ConnectionOpportunityService connectionOpportunityService = new ConnectionOpportunityService( rockContext );
bool enableDebug = GetAttributeValue( "EnableDebug" ).AsBoolean();
var qry = connectionOpportunityService
.Queryable()
.Where( g => g.Id == opportunityId );
if ( !enableDebug )
{
qry = qry.AsNoTracking();
}
var opportunity = qry.FirstOrDefault();
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "Opportunity", opportunity );
// add linked pages
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "SignupPage", LinkedPageUrl( "SignupPage", null ) );
mergeFields.Add( "LinkedPages", linkedPages );
mergeFields.Add( "CurrentPerson", CurrentPerson );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
if ( GetAttributeValue( "SetPageTitle" ).AsBoolean() )
{
string pageTitle = opportunity.PublicName;
RockPage.PageTitle = pageTitle;
RockPage.BrowserTitle = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
RockPage.Header.Title = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
}
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}
}
示例3: 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 )
{
RockContext rockContext = new RockContext();
Group group = null;
Guid personGuid = Guid.Empty;
// get group from url
if ( Request["GroupId"] != null || Request["GroupGuid"] != null )
{
if ( Request["GroupId"] != null )
{
int groupId = 0;
if ( Int32.TryParse( Request["GroupId"], out groupId ) )
{
group = new GroupService( rockContext ).Queryable().Where( g => g.Id == groupId ).FirstOrDefault();
}
}
else
{
Guid groupGuid = Request["GroupGuid"].AsGuid();
group = new GroupService( rockContext ).Queryable().Where( g => g.Guid == groupGuid ).FirstOrDefault();
}
}
else
{
Guid groupGuid = Guid.Empty;
if ( Guid.TryParse( GetAttributeValue( "DefaultGroup" ), out groupGuid ) ) {
group = new GroupService( rockContext ).Queryable().Where( g => g.Guid == groupGuid ).FirstOrDefault(); ;
}
}
if ( group == null )
{
lAlerts.Text = "Could not determine the group to add to.";
return;
}
// get person
Person person = null;
if ( !string.IsNullOrWhiteSpace(Request["PersonGuid"]) )
{
person = new PersonService( rockContext ).Get( Request["PersonGuid"].AsGuid() );
}
if ( person == null )
{
lAlerts.Text += "A person could not be found for the identifier provided.";
return;
}
// hide alert
divAlert.Visible = false;
// get status
var groupMemberStatus = this.GetAttributeValue( "GroupMemberStatus" ).ConvertToEnum<GroupMemberStatus>( GroupMemberStatus.Active );
// load merge fields
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "Group", group );
mergeFields.Add( "Person", person );
mergeFields.Add( "CurrentPerson", CurrentPerson );
// show debug info?
bool enableDebug = GetAttributeValue( "EnableDebug" ).AsBoolean();
if ( enableDebug && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
var groupMemberService = new GroupMemberService(rockContext);
var groupMemberList = groupMemberService.Queryable()
.Where( m => m.GroupId == group.Id && m.PersonId == person.Id )
.ToList();
if (groupMemberList.Count > 0 )
{
foreach(var groupMember in groupMemberList )
{
if ( GetAttributeValue( "Inactivate" ).AsBoolean() )
{
groupMember.GroupMemberStatus = GroupMemberStatus.Inactive;
}
else
{
groupMemberService.Delete( groupMember );
}
rockContext.SaveChanges();
//.........这里部分代码省略.........
示例4: ListGroups
private void ListGroups()
{
RockContext rockContext = new RockContext();
var qry = new GroupMemberService(rockContext)
.Queryable("Group")
.Where( m => m.PersonId == CurrentPersonId
&& m.GroupMemberStatus == GroupMemberStatus.Active
&& m.Group.IsActive == true);
List<Guid> includeGroupTypeGuids = GetAttributeValue( "IncludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( includeGroupTypeGuids.Count > 0 )
{
qry = qry.Where( t => includeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
}
List<Guid> excludeGroupTypeGuids = GetAttributeValue( "ExcludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( excludeGroupTypeGuids.Count > 0 )
{
qry = qry.Where( t => !excludeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
}
var groups = qry.Select( m => new GroupInvolvementSummary { Group = m.Group, Role = m.GroupRole.Name, IsLeader = m.GroupRole.IsLeader, GroupType = m.Group.GroupType.Name } ).ToList();
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "Groups", groups );
mergeFields.Add( "CurrentPerson", CurrentPerson );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "DetailPage", LinkedPageUrl( "DetailPage", null ) );
mergeFields.Add( "LinkedPages", linkedPages );
string template = GetAttributeValue( "LavaTemplate" );
// show debug info
bool enableDebug = GetAttributeValue( "EnableDebug" ).AsBoolean();
if ( enableDebug && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
lContent.Text = template.ResolveMergeFields( mergeFields );
}
示例5: ShowContent
// helper functional methods (like BindGrid(), etc.)
private void ShowContent()
{
List<Dictionary<string, object>> scheduleSummaries = new List<Dictionary<string, object>>();
// get scheduled transactions for current user
if ( CurrentPerson != null )
{
var rockContext = new RockContext();
FinancialScheduledTransactionService transactionService = new FinancialScheduledTransactionService( rockContext );
var schedules = transactionService.Queryable( "ScheduledTransactionDetails.Account" )
.Where( s => s.AuthorizedPersonAlias.Person.GivingId == CurrentPerson.GivingId && s.IsActive == true );
foreach ( FinancialScheduledTransaction schedule in schedules )
{
string errorMsgs = string.Empty;
transactionService.GetStatus( schedule, out errorMsgs );
decimal totalAmount = 0;
Dictionary<string, object> scheduleSummary = new Dictionary<string, object>();
scheduleSummary.Add("Id", schedule.Id);
scheduleSummary.Add("Guid", schedule.Guid);
scheduleSummary.Add("StartDate", schedule.StartDate);
scheduleSummary.Add("EndDate", schedule.EndDate);
scheduleSummary.Add("NextPaymentDate", schedule.NextPaymentDate);
if ( schedule.NextPaymentDate.HasValue )
{
scheduleSummary.Add( "DaysTillNextPayment", (schedule.NextPaymentDate.Value - DateTime.Now).Days );
}
else
{
scheduleSummary.Add( "DaysTillNextPayment", null );
}
DateTime? lastPaymentDate = schedule.Transactions.Max(t => t.TransactionDateTime);
scheduleSummary.Add("LastPaymentDate", lastPaymentDate);
if ( lastPaymentDate.HasValue )
{
scheduleSummary.Add("DaysSinceLastPayment", (DateTime.Now - lastPaymentDate.Value).Days);
}
else
{
scheduleSummary.Add( "DaysSinceLastPayment", null );
}
scheduleSummary.Add("CurrencyType", ( schedule.FinancialPaymentDetail != null && schedule.FinancialPaymentDetail.CurrencyTypeValue != null ) ? schedule.FinancialPaymentDetail.CurrencyTypeValue.Value : "" );
scheduleSummary.Add( "CreditCardType", ( schedule.FinancialPaymentDetail != null && schedule.FinancialPaymentDetail.CreditCardTypeValue != null) ? schedule.FinancialPaymentDetail.CreditCardTypeValue.Value : "" );
scheduleSummary.Add("UrlEncryptedKey", schedule.UrlEncodedKey);
scheduleSummary.Add("Frequency", schedule.TransactionFrequencyValue.Value);
scheduleSummary.Add("FrequencyDescription", schedule.TransactionFrequencyValue.Description);
List<Dictionary<string, object>> summaryDetails = new List<Dictionary<string,object>>();
foreach ( FinancialScheduledTransactionDetail detail in schedule.ScheduledTransactionDetails )
{
Dictionary<string, object> detailSummary = new Dictionary<string,object>();
detailSummary.Add("AccountId", detail.Id);
detailSummary.Add("AccountName", detail.Account.Name);
detailSummary.Add("Amount", detail.Amount);
detailSummary.Add("Summary", detail.Summary);
summaryDetails.Add( detailSummary );
totalAmount += detail.Amount;
}
scheduleSummary.Add("ScheduledAmount", totalAmount);
scheduleSummary.Add( "TransactionDetails", summaryDetails );
scheduleSummaries.Add( scheduleSummary );
}
rockContext.SaveChanges();
}
// added linked pages to mergefields
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "ManageScheduledTransactionsPage", LinkedPageRoute( "ManageScheduledTransactionsPage" ) );
linkedPages.Add( "TransactionHistoryPage", LinkedPageRoute( "TransactionHistoryPage" ) );
linkedPages.Add( "TransactionEntryPage", LinkedPageRoute( "TransactionEntryPage" ) );
var scheduleValues = new Dictionary<string, object>();
scheduleValues.Add( "ScheduledTransactions", scheduleSummaries.ToList() );
scheduleValues.Add( "LinkedPages", linkedPages );
// TODO: When support for "Person" is not supported anymore (should use "CurrentPerson" instead), remove this line
scheduleValues.Add( "Person", CurrentPerson );
scheduleValues.Add( "CurrentPerson", CurrentPerson );
string content = GetAttributeValue( "Template" ).ResolveMergeFields( scheduleValues );
// show merge fields if needed
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
// TODO: When support for "Person" is not supported anymore (should use "CurrentPerson" instead), remove this line
scheduleValues.Remove( "Person" );
content += scheduleValues.lavaDebugInfo();
//.........这里部分代码省略.........
示例6: LoadContent
/// <summary>
/// Loads the content.
/// </summary>
protected void LoadContent()
{
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "CurrentPerson", CurrentPerson );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
RockContext rockContext = new RockContext();
var prayerRequestService = new PrayerRequestService( rockContext );
var qryPrayerRequests = prayerRequestService.Queryable();
// filter out expired
if ( !GetAttributeValue( "Show Expired" ).AsBoolean() )
{
qryPrayerRequests = qryPrayerRequests.Where( r => r.ExpirationDate >= RockDateTime.Now );
}
// filter by date range
var requestDateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( GetAttributeValue( "DateRange" ) ?? "-1||" );
if ( requestDateRange.Start != null && requestDateRange.End != null )
{
qryPrayerRequests = qryPrayerRequests.Where( r => r.EnteredDateTime >= requestDateRange.Start && r.EnteredDateTime <= requestDateRange.End );
}
var categoryGuids = ( GetAttributeValue( "Category" ) ?? string.Empty ).SplitDelimitedValues().AsGuidList();
if ( categoryGuids.Any() )
{
qryPrayerRequests = qryPrayerRequests.Where( a => a.CategoryId.HasValue && ( categoryGuids.Contains( a.Category.Guid ) || ( a.Category.ParentCategoryId.HasValue && categoryGuids.Contains( a.Category.ParentCategory.Guid ) ) ) );
}
// filter by status
int? statusFilterType = GetAttributeValue( "ApprovalStatus" ).AsIntegerOrNull();
if ( statusFilterType.HasValue )
{
switch ( statusFilterType.Value )
{
case 1:
{
qryPrayerRequests = qryPrayerRequests.Where( a => a.IsApproved == true );
break;
}
case 2:
{
qryPrayerRequests = qryPrayerRequests.Where( a => a.IsApproved == false );
break;
}
}
}
int sortBy = GetAttributeValue( "Sortby" ).AsInteger();
switch ( sortBy )
{
case 0: qryPrayerRequests = qryPrayerRequests.OrderBy( a => a.EnteredDateTime );
break;
case 1: qryPrayerRequests = qryPrayerRequests.OrderByDescending( a => a.EnteredDateTime );
break;
case 2: qryPrayerRequests = qryPrayerRequests.OrderBy( a => a.Text );
break;
default: qryPrayerRequests = qryPrayerRequests.OrderBy( a => a.EnteredDateTime );
break;
}
int? maxResults = GetAttributeValue( "MaxResults" ).AsIntegerOrNull();
if ( maxResults.HasValue && maxResults > 0 )
{
qryPrayerRequests = qryPrayerRequests.Take( maxResults.Value );
}
mergeFields.Add( "PrayerRequestItems", qryPrayerRequests );
var queryParams = new Dictionary<string, string>();
queryParams.Add( "PrayerRequestId", "_PrayerRequestIdParam_" );
string url = LinkedPageUrl( "PrayerRequestDetailPage", queryParams );
if ( !string.IsNullOrWhiteSpace( url ) )
{
url = url.Replace( "_PrayerRequestIdParam_", "[Id]" );
}
mergeFields.Add( "LinkUrl", url );
string template = GetAttributeValue( "LavaTemplate" );
lContent.Text = template.ResolveMergeFields( mergeFields );
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}
示例7: ShowDetails
/// <summary>
/// Shows the details.
/// </summary>
private void ShowDetails()
{
_rockContext = _rockContext ?? new RockContext();
if ( _group != null )
{
// Show lava content
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "Group", _group );
bool showDebug = UserCanEdit && GetAttributeValue( "EnableDebug" ).AsBoolean();
lLavaOutputDebug.Visible = showDebug;
if ( showDebug )
{
lLavaOutputDebug.Text = mergeFields.lavaDebugInfo( _rockContext );
}
string template = GetAttributeValue( "LavaTemplate" );
lLavaOverview.Text = template.ResolveMergeFields( mergeFields );
// Set visibility based on selected mode
if ( IsFullWithSpouse )
{
pnlCol1.RemoveCssClass( "col-md-12" ).AddCssClass( "col-md-6" );
}
else
{
pnlCol1.RemoveCssClass( "col-md-6" ).AddCssClass( "col-md-12" );
}
pnlCol2.Visible = IsFullWithSpouse;
pnlHomePhone.Visible = !IsSimple;
pnlCellPhone.Visible = !IsSimple;
acAddress.Visible = !IsSimple;
if ( CurrentPersonId.HasValue && _autoFill )
{
var personService = new PersonService( _rockContext );
Person person = personService
.Queryable( "PhoneNumbers.NumberTypeValue" ).AsNoTracking()
.FirstOrDefault( p => p.Id == CurrentPersonId.Value );
tbFirstName.Text = CurrentPerson.FirstName;
tbLastName.Text = CurrentPerson.LastName;
tbEmail.Text = CurrentPerson.Email;
if ( !IsSimple )
{
Guid homePhoneType = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid();
var homePhone = person.PhoneNumbers
.FirstOrDefault( n => n.NumberTypeValue.Guid.Equals( homePhoneType ) );
if ( homePhone != null )
{
pnHome.Text = homePhone.Number;
}
Guid cellPhoneType = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid();
var cellPhone = person.PhoneNumbers
.FirstOrDefault( n => n.NumberTypeValue.Guid.Equals( cellPhoneType ) );
if ( cellPhone != null )
{
pnCell.Text = cellPhone.Number;
cbSms.Checked = cellPhone.IsMessagingEnabled;
}
var homeAddress = person.GetHomeLocation();
if ( homeAddress != null )
{
acAddress.SetValues( homeAddress );
}
if ( IsFullWithSpouse )
{
var spouse = person.GetSpouse( _rockContext );
if ( spouse != null )
{
tbSpouseFirstName.Text = spouse.FirstName;
tbSpouseLastName.Text = spouse.LastName;
tbSpouseEmail.Text = spouse.Email;
var spouseCellPhone = spouse.PhoneNumbers
.FirstOrDefault( n => n.NumberTypeValue.Guid.Equals( cellPhoneType ) );
if ( spouseCellPhone != null )
{
pnSpouseCell.Text = spouseCellPhone.Number;
cbSpouseSms.Checked = spouseCellPhone.IsMessagingEnabled;
}
}
}
}
}
if ( GetAttributeValue( "PreventOvercapacityRegistrations" ).AsBoolean() )
{
int openGroupSpots = 2;
int openRoleSpots = 2;
//.........这里部分代码省略.........
示例8: ShowSuccess
/// <summary>
/// Shows the success panel
/// </summary>
private void ShowSuccess( int registrationId )
{
decimal currentStep = ( FormCount * RegistrationState.RegistrantCount ) + ( Using3StepGateway ? 3 : 2 );
PercentComplete = ( currentStep / ProgressBarSteps ) * 100.0m;
pnlSuccessProgressBar.Visible = GetAttributeValue( "DisplayProgressBar" ).AsBoolean();
lSuccessTitle.Text = "Congratulations";
lSuccess.Text = "You have successfully completed this registration.";
try
{
var rockContext = new RockContext();
var registration = new RegistrationService( rockContext )
.Queryable( "RegistrationInstance.RegistrationTemplate" )
.FirstOrDefault( r => r.Id == registrationId );
if ( registration != null &&
registration.RegistrationInstance != null &&
registration.RegistrationInstance.RegistrationTemplate != null )
{
var template = registration.RegistrationInstance.RegistrationTemplate;
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "CurrentPerson", CurrentPerson );
mergeFields.Add( "RegistrationInstance", registration.RegistrationInstance );
mergeFields.Add( "Registration", registration );
if ( template != null && !string.IsNullOrWhiteSpace( template.SuccessTitle ) )
{
lSuccessTitle.Text = template.SuccessTitle.ResolveMergeFields( mergeFields );
}
else
{
lSuccessTitle.Text = "Congratulations";
}
if ( template != null && !string.IsNullOrWhiteSpace( template.SuccessText ) )
{
lSuccess.Text = template.SuccessText.ResolveMergeFields( mergeFields );
}
else
{
lSuccess.Text = "You have successfully completed this " + RegistrationTerm.ToLower();
}
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && UserCanEdit )
{
lSuccessDebug.Visible = true;
lSuccessDebug.Text = mergeFields.lavaDebugInfo();
}
}
if ( nbAmountPaid.Visible = true &&
nbAmountPaid.Text.AsDecimalOrNull().HasValue &&
nbAmountPaid.Text.AsDecimalOrNull().Value > 0.0M &&
( rblSavedCC.Items.Count == 0 || ( rblSavedCC.SelectedValueAsId() ?? 0 ) == 0 ) )
{
cbSaveAccount.Visible = true;
pnlSaveAccount.Visible = true;
txtSaveAccount.Visible = true;
// If current person does not have a login, have them create a username and password
phCreateLogin.Visible = !new UserLoginService( rockContext ).GetByPersonId( CurrentPersonId ).Any();
}
else
{
pnlSaveAccount.Visible = false;
}
}
catch ( Exception ex )
{
ExceptionLogService.LogException( ex, Context, this.RockPage.PageId, this.RockPage.Site.Id, CurrentPersonAlias );
}
SetPanel( 4 );
}
示例9: DisplayDetails
private void DisplayDetails()
{
int eventItemOccurrenceId = 0;
RockContext rockContext = new RockContext();
// get the calendarItem id
if ( !string.IsNullOrWhiteSpace( PageParameter( "EventOccurrenceId" ) ) )
{
eventItemOccurrenceId = Convert.ToInt32( PageParameter( "EventOccurrenceId" ) );
}
if ( eventItemOccurrenceId > 0 )
{
var eventItemOccurrenceService = new EventItemOccurrenceService( rockContext );
var qry = eventItemOccurrenceService
.Queryable( "EventItem, EventItem.Photo, Campus, Linkages" )
.Where( i => i.Id == eventItemOccurrenceId );
var eventItemOccurrence = qry.FirstOrDefault();
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "RegistrationPage", LinkedPageRoute( "RegistrationPage" ) );
var campusEntityType = EntityTypeCache.Read( "Rock.Model.Campus" );
var contextCampus = RockPage.GetCurrentContext( campusEntityType ) as Campus;
if ( contextCampus != null )
{
mergeFields.Add( "CampusContext", contextCampus );
}
// determine if the registration is full
var maxRegistrantCount = 0;
var currentRegistrationCount = 0;
var linkage = eventItemOccurrence.Linkages.FirstOrDefault();
if (linkage != null )
{
if (linkage.RegistrationInstance != null )
{
if ( linkage.RegistrationInstance.MaxAttendees != 0 )
{
maxRegistrantCount = linkage.RegistrationInstance.MaxAttendees;
}
}
if ( maxRegistrantCount != 0 )
{
currentRegistrationCount = new RegistrationRegistrantService( rockContext ).Queryable().AsNoTracking()
.Where( r =>
r.Registration.RegistrationInstanceId == linkage.RegistrationInstanceId
&& r.OnWaitList == false )
.Count();
}
}
mergeFields.Add( "RegistrationStatusLabel", (maxRegistrantCount - currentRegistrationCount > 0) ? "Register" : "Join Wait List");
mergeFields.Add( "EventItemOccurrence", eventItemOccurrence );
mergeFields.Add( "Event", eventItemOccurrence != null ? eventItemOccurrence.EventItem : null );
mergeFields.Add( "CurrentPerson", CurrentPerson );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
if ( GetAttributeValue( "SetPageTitle" ).AsBoolean() )
{
string pageTitle = eventItemOccurrence != null ? eventItemOccurrence.EventItem.Name : "Event";
RockPage.PageTitle = pageTitle;
RockPage.BrowserTitle = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
RockPage.Header.Title = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
}
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}
else
{
lOutput.Text = "<div class='alert alert-warning'>No event was available from the querystring.</div>";
}
}
示例10: ProcessRequest
//.........这里部分代码省略.........
requestObjects.Add( "Host", request.Url.Host );
requestObjects.Add( "Authority", request.Url.Authority );
requestObjects.Add( "LocalPath", request.Url.LocalPath );
requestObjects.Add( "AbsoluteUri", request.Url.AbsoluteUri );
requestObjects.Add( "AbsolutePath", request.Url.AbsolutePath );
requestObjects.Add( "Port", request.Url.Port );
requestObjects.Add( "Query", request.Url.Query );
requestObjects.Add( "OriginalString", request.Url.OriginalString );
mergeFields.Add( "Request", requestObjects );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields(null);
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
// check for new rss item limit
if ( request.QueryString["Count"] != null )
{
int.TryParse( request.QueryString["Count"], out rssItemLimit );
}
// get channel items
ContentChannelItemService contentService = new ContentChannelItemService( rockContext );
var content = contentService.Queryable( "ContentChannelType" )
.Where( c => c.ContentChannelId == channel.Id && (c.Status == ContentChannelItemStatus.Approved || c.ContentChannel.RequiresApproval == false) && c.StartDateTime <= RockDateTime.Now )
.OrderByDescending( c => c.StartDateTime )
.Take( rssItemLimit );
if ( channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange )
{
if ( channel.ContentChannelType.IncludeTime )
{
content = content.Where( c => c.ExpireDateTime >= RockDateTime.Now );
}
else
{
content = content.Where( c => c.ExpireDateTime > RockDateTime.Today );
}
}
foreach ( var item in content )
{
item.Content = item.Content.ResolveMergeFields( mergeFields );
// resolve any relative links
var globalAttributes = Rock.Web.Cache.GlobalAttributesCache.Read();
string publicAppRoot = globalAttributes.GetValue( "PublicApplicationRoot" ).EnsureTrailingForwardslash();
item.Content = item.Content.Replace( @" src=""/", @" src=""" + publicAppRoot );
item.Content = item.Content.Replace( @" href=""/", @" href=""" + publicAppRoot );
// get item attributes and add them as elements to the feed
item.LoadAttributes( rockContext );
foreach ( var attributeValue in item.AttributeValues )
{
attributeValue.Value.Value = attributeValue.Value.Value.ResolveMergeFields( mergeFields );
}
}
mergeFields.Add( "Items", content );
mergeFields.Add( "RockVersion", Rock.VersionInfo.VersionInfo.GetRockProductVersionNumber() );
// show debug info
if ( request.QueryString["EnableDebug"] != null )
{
response.Write( mergeFields.lavaDebugInfo() );
response.Write( "<pre>" );
response.Write( WebUtility.HtmlEncode(rssTemplate.ResolveMergeFields( mergeFields )) );
response.Write( "</pre>" );
response.Write( "</body>" );
response.Write( "</html" );
}
else
{
response.Write( rssTemplate.ResolveMergeFields( mergeFields ) );
}
}
else
{
response.Write( "RSS is not enabled for this channel." );
response.StatusCode = 200;
return;
}
}
else
{
response.StatusCode = 200;
response.Write( "Invalid channel id." );
response.StatusCode = 200;
return;
}
}
else
{
response.Write( "A ChannelId is required." );
response.StatusCode = 200;
return;
}
}
示例11: LoadPackages
private void LoadPackages()
{
// get category
int? categoryId = null;
if ( !string.IsNullOrWhiteSpace( GetAttributeValue( "CategoryId" ) ) )
{
categoryId = Convert.ToInt32(GetAttributeValue( "CategoryId" ));
}
else if ( !string.IsNullOrWhiteSpace( PageParameter( "CategoryId" ) ) )
{
categoryId = Convert.ToInt32( PageParameter( "CategoryId" ) );
}
string categoryName = PageParameter( "CategoryName" );
if ( GetAttributeValue( "SetPageTitle" ).AsBoolean() && !string.IsNullOrWhiteSpace(categoryName) )
{
string pageTitle = "Items for " + categoryName;
RockPage.PageTitle = pageTitle;
RockPage.BrowserTitle = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
RockPage.Header.Title = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
}
PackageService packageService = new PackageService();
var packages = packageService.GetAllPackages( categoryId );
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "CurrentPerson", CurrentPerson );
// add link to detail page
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "DetailPage", LinkedPageUrl( "DetailPage", null ) );
mergeFields.Add( "LinkedPages", linkedPages );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
mergeFields.Add( "Packages", packages );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo(); ;
}
}
示例12: LoadCategories
private void LoadCategories()
{
string errorResponse = string.Empty;
PackageCategoryService packageCategoryService = new PackageCategoryService();
var categories = packageCategoryService.GetCategories(out errorResponse);
// check for errors
ErrorCheck( errorResponse );
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "CurrentPerson", CurrentPerson );
var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );
mergeFields.Add( "Categories", categories );
// add link to detail page
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "DetailPage", LinkedPageUrl( "DetailPage", null ) );
mergeFields.Add( "LinkedPages", linkedPages );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:32,代码来源:PackageCategoryListLava.ascx.cs
示例13: DisplayDetails
private void DisplayDetails()
{
int eventItemOccurrenceId = 0;
// get the calendarItem id
if ( !string.IsNullOrWhiteSpace( PageParameter( "EventOccurrenceId" ) ) )
{
eventItemOccurrenceId = Convert.ToInt32( PageParameter( "EventOccurrenceId" ) );
}
if ( eventItemOccurrenceId > 0 )
{
var eventItemOccurrenceService = new EventItemOccurrenceService( new RockContext() );
var qry = eventItemOccurrenceService
.Queryable( "EventItem, EventItem.Photo, Campus, Linkages" )
.Where( i => i.Id == eventItemOccurrenceId );
var eventItemOccurrence = qry.FirstOrDefault();
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "RegistrationPage", LinkedPageUrl( "RegistrationPage", null ) );
var campusEntityType = EntityTypeCache.Read( "Rock.Model.Campus" );
var contextCampus = RockPage.GetCurrentContext( campusEntityType ) as Campus;
if ( contextCampus != null )
{
mergeFields.Add( "CampusContext", contextCampus );
}
mergeFields.Add( "EventItemOccurrence", eventItemOccurrence );
mergeFields.Add( "Event", eventItemOccurrence != null ? eventItemOccurrence.EventItem : null );
mergeFields.Add( "CurrentPerson", CurrentPerson );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
if ( GetAttributeValue( "SetPageTitle" ).AsBoolean() )
{
string pageTitle = eventItemOccurrence != null ? eventItemOccurrence.EventItem.Name : "Event";
RockPage.PageTitle = pageTitle;
RockPage.BrowserTitle = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
RockPage.Header.Title = String.Format( "{0} | {1}", pageTitle, RockPage.Site.Name );
}
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}
else
{
lOutput.Text = "<div class='alert alert-warning'>No event was available from the querystring.</div>";
}
}
示例14: BindData
//.........这里部分代码省略.........
.Any( c => categories.Contains( c.DefinedValueId ) ) );
}
// Get the beginning and end dates
var today = RockDateTime.Today;
var filterStart = FilterStartDate.HasValue ? FilterStartDate.Value : today;
var monthStart = new DateTime( filterStart.Year, filterStart.Month, 1 );
var rangeStart = monthStart.AddMonths( -1 );
var rangeEnd = monthStart.AddMonths( 2 );
var beginDate = FilterStartDate.HasValue ? FilterStartDate.Value : rangeStart;
var endDate = FilterEndDate.HasValue ? FilterEndDate.Value : rangeEnd;
endDate = endDate.AddDays( 1 ).AddMilliseconds( -1 );
// Get the occurrences
var occurrences = qry.ToList();
var occurrencesWithDates = occurrences
.Select( o => new EventOccurrenceDate
{
EventItemOccurrence = o,
Dates = o.GetStartTimes( beginDate, endDate ).ToList()
} )
.Where( d => d.Dates.Any() )
.ToList();
CalendarEventDates = new List<DateTime>();
var eventOccurrenceSummaries = new List<EventOccurrenceSummary>();
foreach ( var occurrenceDates in occurrencesWithDates )
{
var eventItemOccurrence = occurrenceDates.EventItemOccurrence;
foreach ( var datetime in occurrenceDates.Dates )
{
if ( eventItemOccurrence.Schedule.EffectiveEndDate.HasValue && ( eventItemOccurrence.Schedule.EffectiveStartDate != eventItemOccurrence.Schedule.EffectiveEndDate ) )
{
var multiDate = eventItemOccurrence.Schedule.EffectiveStartDate;
while ( multiDate.HasValue && ( multiDate.Value < eventItemOccurrence.Schedule.EffectiveEndDate.Value ))
{
CalendarEventDates.Add( multiDate.Value.Date );
multiDate = multiDate.Value.AddDays( 1 );
}
}
else
{
CalendarEventDates.Add( datetime.Date );
}
if ( datetime >= beginDate && datetime < endDate )
{
eventOccurrenceSummaries.Add( new EventOccurrenceSummary
{
EventItemOccurrence = eventItemOccurrence,
Name = eventItemOccurrence.EventItem.Name,
DateTime = datetime,
Date = datetime.ToShortDateString(),
Time = datetime.ToShortTimeString(),
Campus = eventItemOccurrence.Campus != null ? eventItemOccurrence.Campus.Name : "All Campuses",
Location = eventItemOccurrence.Campus != null ? eventItemOccurrence.Campus.Name : "All Campuses",
LocationDescription = eventItemOccurrence.Location,
Description = eventItemOccurrence.EventItem.Description,
Summary = eventItemOccurrence.EventItem.Summary,
OccurrenceNote = eventItemOccurrence.Note.SanitizeHtml(),
DetailPage = String.IsNullOrWhiteSpace( eventItemOccurrence.EventItem.DetailsUrl ) ? null : eventItemOccurrence.EventItem.DetailsUrl
} );
}
}
}
var eventSummaries = eventOccurrenceSummaries
.OrderBy( e => e.DateTime )
.GroupBy( e => e.Name )
.Select( e => e.ToList() )
.ToList();
eventOccurrenceSummaries = eventOccurrenceSummaries
.OrderBy( e => e.DateTime )
.ThenBy( e => e.Name )
.ToList();
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "TimeFrame", ViewMode );
mergeFields.Add( "DetailsPage", LinkedPageUrl( "DetailsPage", null ) );
mergeFields.Add( "EventItems", eventSummaries );
mergeFields.Add( "EventItemOccurrences", eventOccurrenceSummaries );
mergeFields.Add( "CurrentPerson", CurrentPerson );
lOutput.Text = GetAttributeValue( "LavaTemplate" ).ResolveMergeFields( mergeFields );
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
else
{
lDebug.Visible = false;
lDebug.Text = string.Empty;
}
}
示例15: DisplayResults
//.........这里部分代码省略.........
// make a list of person ids in the giving group
List<int> givingGroupIdsOnly = new List<int>();
foreach ( var x in givingGroup )
{
givingGroupIdsOnly.Add(x.PersonId);
}
string salutation = string.Empty;
if (givingGroup.GroupBy(g => g.LastName).Count() == 1 )
{
salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName ) ) + " " + givingGroup.FirstOrDefault().LastName;
if ( salutation.Contains( "," ) )
{
salutation = salutation.ReplaceLastOccurrence( ",", " &" );
}
}
else
{
salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName + " " + g.LastName ) );
if ( salutation.Contains( "," ) )
{
salutation = salutation.ReplaceLastOccurrence( ",", " &" );
}
}
mergeFields.Add( "Salutation", salutation );
var homeAddress = CurrentPerson.GetHomeLocation();
if ( homeAddress != null )
{
mergeFields.Add( "StreetAddress1", homeAddress.Street1 );
mergeFields.Add( "StreetAddress2", homeAddress.Street2 );
mergeFields.Add( "City", homeAddress.City );
mergeFields.Add( "State", homeAddress.State );
mergeFields.Add( "PostalCode", homeAddress.PostalCode );
mergeFields.Add( "Country", homeAddress.Country );
}
else
{
mergeFields.Add( "StreetAddress1", string.Empty );
mergeFields.Add( "StreetAddress2", string.Empty );
mergeFields.Add( "City", string.Empty );
mergeFields.Add( "State", string.Empty );
mergeFields.Add( "PostalCode", string.Empty );
mergeFields.Add( "Country", string.Empty );
}
mergeFields.Add( "TransactionDetails", qry.ToList() );
mergeFields.Add( "AccountSummary", qry.GroupBy( t => t.Account.Name ).Select( s => new AccountSummary { AccountName = s.Key, Total = s.Sum( a => a.Amount ), Order = s.Max(a => a.Account.Order) } ).OrderBy(s => s.Order ));
// pledge information
var pledges = new FinancialPledgeService( rockContext ).Queryable().AsNoTracking()
.Where(p =>
p.PersonAlias.Person.GivingId == CurrentPerson.GivingId
&& (p.StartDate.Year == statementYear || p.EndDate.Year == statementYear))
.GroupBy(p => p.Account)
.Select(g => new PledgeSummary {
AccountId = g.Key.Id,
AccountName = g.Key.Name,
AmountPledged = g.Sum( p => p.TotalAmount ),
PledgeStartDate = g.Min(p => p.StartDate),
PledgeEndDate = g.Max( p => p.EndDate)
} )
.ToList();
// add detailed pledge information
foreach(var pledge in pledges )
{
var adjustedPedgeEndDate = pledge.PledgeEndDate.Value.Date.AddHours( 23 ).AddMinutes( 59 ).AddSeconds( 59 );
pledge.AmountGiven = new FinancialTransactionDetailService( rockContext ).Queryable()
.Where( t =>
t.AccountId == pledge.AccountId
&& givingGroupIdsOnly.Contains(t.Transaction.AuthorizedPersonAlias.PersonId)
&& t.Transaction.TransactionDateTime >= pledge.PledgeStartDate
&& t.Transaction.TransactionDateTime <= adjustedPedgeEndDate )
.Sum( t => t.Amount );
pledge.AmountRemaining = (pledge.AmountGiven > pledge.AmountPledged) ? 0 : (pledge.AmountPledged - pledge.AmountGiven);
if ( pledge.AmountPledged > 0 )
{
var test = (double)pledge.AmountGiven / (double)pledge.AmountPledged;
pledge.PercentComplete = (int)((pledge.AmountGiven * 100) / pledge.AmountPledged);
}
}
mergeFields.Add( "Pledges", pledges );
var template = GetAttributeValue( "LavaTemplate" );
lResults.Text = template.ResolveMergeFields( mergeFields );
// show debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
}