本文整理汇总了C#中FinancialAccountService.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# FinancialAccountService.Contains方法的具体用法?C# FinancialAccountService.Contains怎么用?C# FinancialAccountService.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FinancialAccountService
的用法示例。
在下文中一共展示了FinancialAccountService.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpression
/// <summary>
/// Gets the expression.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="serviceInstance">The service instance.</param>
/// <param name="parameterExpression">The parameter expression.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override Expression GetExpression( Type entityType, IService serviceInstance, ParameterExpression parameterExpression, string selection )
{
var rockContext = (RockContext)serviceInstance.Context;
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length < 3 )
{
return null;
}
DateTime? startDate = selectionValues[0].AsDateTime();
DateTime? endDate = selectionValues[1].AsDateTime();
var accountGuids = selectionValues[2].Split( ',' ).Select( a => a.AsGuid() ).ToList();
var accountIdList = new FinancialAccountService( (RockContext)serviceInstance.Context ).GetByGuids( accountGuids ).Select( a => a.Id ).ToList();
int transactionTypeContributionId = Rock.Web.Cache.DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid() ).Id;
var financialTransactionsQry = new FinancialTransactionService( rockContext ).Queryable()
.Where( xx => xx.TransactionTypeValueId == transactionTypeContributionId );
if ( accountIdList.Any() )
{
if ( accountIdList.Count == 1 )
{
int accountId = accountIdList.First();
financialTransactionsQry = financialTransactionsQry.Where( xx => xx.TransactionDetails.Any( a => a.AccountId == accountId ) );
}
else
{
financialTransactionsQry = financialTransactionsQry.Where( xx => xx.TransactionDetails.Any( a => accountIdList.Contains( a.AccountId ) ) );
}
}
var firstContributionDateQry = financialTransactionsQry
.GroupBy( xx => xx.AuthorizedPersonAlias.PersonId )
.Select( ss => new
{
PersonId = ss.Key,
FirstTransactionDateTime = ss.Min( a => a.TransactionDateTime )
} );
if ( startDate.HasValue )
{
firstContributionDateQry = firstContributionDateQry.Where( xx => xx.FirstTransactionDateTime >= startDate.Value );
}
if ( endDate.HasValue )
{
firstContributionDateQry = firstContributionDateQry.Where( xx => xx.FirstTransactionDateTime < endDate );
}
var innerQry = firstContributionDateQry.Select( xx => xx.PersonId ).AsQueryable();
var qry = new PersonService( rockContext ).Queryable()
.Where( p => innerQry.Any( xx => xx == p.Id ) );
Expression extractedFilterExpression = FilterExpressionExtractor.Extract<Rock.Model.Person>( qry, parameterExpression, "p" );
return extractedFilterExpression;
}
示例2: BindGrid
/// <summary>
/// Binds the grid.
/// </summary>
private void BindGrid()
{
var rockContext = new RockContext();
var pledgeService = new FinancialPledgeService( rockContext );
var sortProperty = gPledges.SortProperty;
var pledges = pledgeService.Queryable();
Person person = null;
if ( TargetPerson != null )
{
person = TargetPerson;
}
else
{
int? personId = gfPledges.GetUserPreference( "Person" ).AsIntegerOrNull();
if ( personId.HasValue && ppFilterPerson.Visible )
{
person = new PersonService( rockContext ).Get( personId.Value );
}
}
if ( person != null )
{
// if a person is specified, get pledges for that person ( and also anybody in their GivingUnit )
pledges = pledges.Where( p => p.PersonAlias.Person.GivingId == person.GivingId );
}
// get the accounts and make sure they still exist by checking the database
var accountIds = gfPledges.GetUserPreference( "Accounts" ).Split( ',' ).AsIntegerList();
accountIds = new FinancialAccountService( rockContext ).GetByIds( accountIds ).Select( a => a.Id ).ToList();
if ( accountIds.Any() && apFilterAccount.Visible )
{
pledges = pledges.Where( p => p.AccountId.HasValue && accountIds.Contains( p.AccountId.Value ) );
}
// Date Range
var drp = new DateRangePicker();
drp.DelimitedValues = gfPledges.GetUserPreference( "Date Range" );
var filterStartDate = drp.LowerValue ?? DateTime.MinValue;
var filterEndDate = drp.UpperValue ?? DateTime.MaxValue;
if (filterEndDate != DateTime.MaxValue)
{
filterEndDate = filterEndDate.AddDays( 1 );
}
/****
* Include any pledges whose Start/EndDates overlap with the Filtered Date Range
*
* * Pledge1 Range 1/1/2011 - 12/31/2011
* * Pledge2 Range 1/1/0000 - 1/1/9999
* * Pledge3 Range 6/1/2011 - 6/1/2012
*
* Filter1 Range 1/1/2010 - 1/1/2013
* * * All Pledges should show
* Filter1 Range 1/1/2012 - 1/1/2013
* * * Pledge2 and Pledge3 should show
* Filter2 Range 5/1/2012 - 5/2/2012
* * * Pledge2 and Pledge3 should show
* Filter3 Range 5/1/2012 - 1/1/9999
* * * Pledge2 and Pledge3 should show
* Filter4 Range 5/1/2010 - 5/1/2010
* * * Pledge2 should show
***/
// exclude pledges that start after the filter's end date or end before the filter's start date
if ( drpDates.Visible )
{
pledges = pledges.Where( p => !(p.StartDate > filterEndDate) && !(p.EndDate < filterStartDate) );
}
// Last Modified
drp.DelimitedValues = gfPledges.GetUserPreference( "Last Modified" );
filterStartDate = drp.LowerValue ?? DateTime.MinValue;
filterEndDate = drp.UpperValue ?? DateTime.MaxValue;
if (filterEndDate != DateTime.MaxValue)
{
filterEndDate = filterEndDate.AddDays( 1 );
}
if ( drpLastModifiedDates.Visible )
{
pledges = pledges.Where( p => !(p.ModifiedDateTime >= filterEndDate) && !(p.ModifiedDateTime <= filterStartDate) );
}
gPledges.DataSource = sortProperty != null ? pledges.Sort( sortProperty ).ToList() : pledges.OrderBy( p => p.AccountId ).ToList();
gPledges.DataBind();
}
示例3: GetExpression
/// <summary>
/// Gets the expression.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="serviceInstance">The service instance.</param>
/// <param name="parameterExpression">The parameter expression.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override Expression GetExpression( Type entityType, IService serviceInstance, ParameterExpression parameterExpression, string selection )
{
var rockContext = (RockContext)serviceInstance.Context;
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length < 3 )
{
return null;
}
DateRange dateRange;
if ( selectionValues.Length >= 4 )
{
string slidingDelimitedValues = selectionValues[3].Replace( ',', '|' );
dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( slidingDelimitedValues );
}
else
{
// if converting from a previous version of the selection
DateTime? startDate = selectionValues[0].AsDateTime();
DateTime? endDate = selectionValues[1].AsDateTime();
dateRange = new DateRange( startDate, endDate );
if ( dateRange.End.HasValue )
{
// the DateRange picker doesn't automatically add a full day to the end date
dateRange.End.Value.AddDays( 1 );
}
}
var accountGuids = selectionValues[2].Split( ',' ).Select( a => a.AsGuid() ).ToList();
var accountIdList = new FinancialAccountService( (RockContext)serviceInstance.Context ).GetByGuids( accountGuids ).Select( a => a.Id ).ToList();
int transactionTypeContributionId = Rock.Web.Cache.DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid() ).Id;
var financialTransactionsQry = new FinancialTransactionService( rockContext ).Queryable()
.Where( xx => xx.TransactionTypeValueId == transactionTypeContributionId );
if ( accountIdList.Any() )
{
if ( accountIdList.Count == 1 )
{
int accountId = accountIdList.First();
financialTransactionsQry = financialTransactionsQry.Where( xx => xx.TransactionDetails.Any( a => a.AccountId == accountId ) );
}
else
{
financialTransactionsQry = financialTransactionsQry.Where( xx => xx.TransactionDetails.Any( a => accountIdList.Contains( a.AccountId ) ) );
}
}
var firstContributionDateQry = financialTransactionsQry
.GroupBy( xx => xx.AuthorizedPersonAlias.PersonId )
.Select( ss => new
{
PersonId = ss.Key,
FirstTransactionSundayDate = ss.Min( a => a.SundayDate )
} );
if ( dateRange.Start.HasValue )
{
firstContributionDateQry = firstContributionDateQry.Where( xx => xx.FirstTransactionSundayDate >= dateRange.Start.Value );
}
if ( dateRange.End.HasValue )
{
firstContributionDateQry = firstContributionDateQry.Where( xx => xx.FirstTransactionSundayDate < dateRange.End.Value );
}
var innerQry = firstContributionDateQry.Select( xx => xx.PersonId ).AsQueryable();
var qry = new PersonService( rockContext ).Queryable()
.Where( p => innerQry.Any( xx => xx == p.Id ) );
Expression extractedFilterExpression = FilterExpressionExtractor.Extract<Rock.Model.Person>( qry, parameterExpression, "p" );
return extractedFilterExpression;
}