本文整理汇总了C#中FinancialAccountService类的典型用法代码示例。如果您正苦于以下问题:C# FinancialAccountService类的具体用法?C# FinancialAccountService怎么用?C# FinancialAccountService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FinancialAccountService类属于命名空间,在下文中一共展示了FinancialAccountService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="accountId">The account identifier.</param>
public void ShowDetail( int accountId )
{
FinancialAccount account = null;
bool editAllowed = UserCanEdit;
if ( !accountId.Equals( 0 ) )
{
account = new FinancialAccountService( new RockContext() ).Get( accountId );
editAllowed = editAllowed || account.IsAuthorized( Authorization.EDIT, CurrentPerson );
pdAuditDetails.SetEntity( account, ResolveRockUrl( "~" ) );
}
if ( account == null )
{
account = new FinancialAccount { Id = 0, IsActive = true };
// hide the panel drawer that show created and last modified dates
pdAuditDetails.Visible = false;
}
hfAccountId.Value = account.Id.ToString();
nbEditModeMessage.Text = string.Empty;
if (editAllowed)
{
ShowEditDetails(account);
}
else
{
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(FinancialAccount.FriendlyTypeName);
ShowReadonlyDetails(account);
}
}
示例2: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
public void LoadDropDowns()
{
// get accounts that are both allowed by the BlockSettings and also in the personal AccountList setting
var rockContext = new RockContext();
var accountGuidList = GetAttributeValue( "Accounts" ).SplitDelimitedValues().Select( a => a.AsGuid() );
string keyPrefix = string.Format( "transaction-matching-{0}-", this.BlockId );
var personalAccountGuidList = ( this.GetUserPreference( keyPrefix + "account-list" ) ?? string.Empty ).SplitDelimitedValues().Select( a => a.AsGuid() ).ToList();
var accountQry = new FinancialAccountService( rockContext ).Queryable();
// no accounts specified means "all"
if ( accountGuidList.Any() )
{
accountQry = accountQry.Where( a => accountGuidList.Contains( a.Guid ) );
}
// no personal accounts specified means "all(that are allowed in block settings)"
if ( personalAccountGuidList.Any() )
{
accountQry = accountQry.Where( a => personalAccountGuidList.Contains( a.Guid ) );
}
rptAccounts.DataSource = accountQry.OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();
rptAccounts.DataBind();
}
示例3: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="itemKey">The item key.</param>
/// <param name="itemKeyValue">The item key value.</param>
public void ShowDetail( string itemKey, int itemKeyValue )
{
pnlDetails.Visible = false;
if ( !itemKey.Equals( "accountId" ) )
{
return;
}
bool editAllowed = true;
FinancialAccount account = null;
if ( !itemKeyValue.Equals( 0 ) )
{
account = new FinancialAccountService( new RockContext() ).Get( itemKeyValue );
editAllowed = account.IsAuthorized( Authorization.EDIT, CurrentPerson );
}
else
{
account = new FinancialAccount { Id = 0, IsActive = true };
}
if ( account == null )
{
return;
}
pnlDetails.Visible = true;
hfAccountId.Value = account.Id.ToString();
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( FinancialAccount.FriendlyTypeName );
}
if ( readOnly )
{
ShowReadonlyDetails( account );
}
else
{
ShowEditDetails( account );
}
}
示例4: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
var guids = value.SplitDelimitedValues();
var accounts = new FinancialAccountService().Queryable().Where( a => guids.Contains( a.Guid.ToString() ) );
if ( accounts.Any() )
{
formattedValue = string.Join( ", ", ( from account in accounts select account.PublicName ).ToArray() );
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例5: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( value ) )
{
var service = new FinancialAccountService( new RockContext() );
var account = service.Get( new Guid( value ) );
if ( account != null )
{
formattedValue = account.PublicName;
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例6: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
Guid? guid = value.AsGuidOrNull();
if ( guid.HasValue )
{
var service = new FinancialAccountService( new RockContext() );
var account = service.Get( guid.Value );
if ( account != null )
{
formattedValue = account.PublicName;
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例7: GetEditValue
/// <summary>
/// Reads new values entered by the user for the field
/// returns Account.Guid
/// </summary>
/// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
/// <param name="configurationValues">The configuration values.</param>
/// <returns></returns>
public override string GetEditValue( Control control, Dictionary<string, ConfigurationValue> configurationValues )
{
var picker = control as AccountPicker;
string result = null;
if ( picker != null )
{
var guid = Guid.Empty;
var id = picker.ItemId.AsIntegerOrNull();
var account = new FinancialAccountService( new RockContext() ).Get( id ?? 0 );
if ( account != null )
{
guid = account.Guid;
}
result = guid.ToString();
}
return result;
}
示例8: GetEditValue
/// <summary>
/// Reads new values entered by the user for the field
/// </summary>
/// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
/// <param name="configurationValues">The configuration values.</param>
/// <returns></returns>
public override string GetEditValue( Control control, Dictionary<string, ConfigurationValue> configurationValues )
{
var picker = control as AccountPicker;
string result = null;
if ( picker != null )
{
var guids = new List<Guid>();
var ids = picker.SelectedValuesAsInt();
var accounts = new FinancialAccountService().Queryable().Where( a => ids.Contains( a.Id ) );
if ( accounts.Any() )
{
guids = accounts.Select( a => a.Guid ).ToList();
}
result = string.Join( ",", guids );
}
return result;
}
示例9: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="accountId">The account identifier.</param>
public void ShowDetail( int accountId )
{
FinancialAccount account = null;
bool editAllowed = UserCanEdit;
if ( !accountId.Equals( 0 ) )
{
account = new FinancialAccountService( new RockContext() ).Get( accountId );
editAllowed = editAllowed || account.IsAuthorized( Authorization.EDIT, CurrentPerson );
}
if ( account == null )
{
account = new FinancialAccount { Id = 0, IsActive = true };
}
hfAccountId.Value = account.Id.ToString();
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !editAllowed || !editAllowed )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( FinancialAccount.FriendlyTypeName );
}
if ( readOnly )
{
ShowReadonlyDetails( account );
}
else
{
ShowEditDetails( account );
}
}
示例10: btnFilter_Click
/// <summary>
/// Handles the Click event of the btnFilter 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 btnFilter_Click( object sender, EventArgs e )
{
string keyPrefix = string.Format( "transaction-matching-{0}-", this.BlockId );
var personalAccountGuidList = ( this.GetUserPreference( keyPrefix + "account-list" ) ?? string.Empty ).SplitDelimitedValues().Select( a => a.AsGuid() ).ToList();
var personalAccountList = new FinancialAccountService( new RockContext() ).GetByGuids( personalAccountGuidList ).ToList();
apPersonalAccounts.SetValues( personalAccountList );
mdAccountsPersonalFilter.Show();
}
示例11: SetSelection
/// <summary>
/// Sets the selection.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="controls">The controls.</param>
/// <param name="selection">The selection.</param>
public override void SetSelection( Type entityType, Control[] controls, string selection )
{
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 3 )
{
var accountPicker = controls[0] as AccountPicker;
var dateRangePicker = controls[1] as DateRangePicker;
dateRangePicker.LowerValue = selectionValues[0].AsDateTime();
dateRangePicker.UpperValue = selectionValues[1].AsDateTime();
var accountGuids = selectionValues[2].Split( ',' ).Select( a => a.AsGuid() ).ToList();
var accounts = new FinancialAccountService( new RockContext() ).GetByGuids( accountGuids );
if ( accounts != null && accounts.Any() )
{
accountPicker.SetValues( accounts );
}
}
}
示例12: BindGrid
//.........这里部分代码省略.........
qry = qry.Where( t => t.SourceTypeValueId == sourceTypeId );
}
// Campus
if ( this.ContextEntity() == null )
{
var campus = CampusCache.Read( gfTransactions.GetUserPreference( "Campus" ).AsInteger() );
if ( campus != null )
{
qry = qry.Where( b => b.Batch != null && b.Batch.CampusId == campus.Id );
}
}
}
SortProperty sortProperty = gTransactions.SortProperty;
if ( sortProperty != null )
{
if ( sortProperty.Property == "TotalAmount" )
{
if ( sortProperty.Direction == SortDirection.Ascending )
{
qry = qry.OrderBy( t => t.TransactionDetails.Sum( d => (decimal?)d.Amount ) ?? 0.00M );
}
else
{
qry = qry.OrderByDescending( t => t.TransactionDetails.Sum( d => (decimal?)d.Amount ) ?? 0.0M );
}
}
else
{
qry = qry.Sort( sortProperty );
}
}
else
{
// Default sort by Id if the transations are seen via the batch,
// otherwise sort by descending date time.
if ( ContextTypesRequired.Any( e => e.Id == batchEntityTypeId ) )
{
qry = qry.OrderBy( t => t.Id );
}
else
{
qry = qry.OrderByDescending( t => t.TransactionDateTime ).ThenByDescending( t => t.Id );
}
}
var lTransactionImageField = gTransactions.ColumnsOfType<RockLiteralField>().FirstOrDefault( a => a.ID == "lTransactionImage" );
var summaryField = gTransactions.ColumnsOfType<RockBoundField>().FirstOrDefault( a => a.DataField == "Summary" );
var showImages = bddlOptions.SelectedValue.AsIntegerOrNull() == 1;
if ( lTransactionImageField != null)
{
lTransactionImageField.Visible = showImages;
}
if ( summaryField != null )
{
summaryField.Visible = !showImages;
}
if ( showImages )
{
qry = qry.Include( a => a.Images );
}
_isExporting = isExporting;
gTransactions.SetLinqDataSource( qry.AsNoTracking() );
gTransactions.DataBind();
_isExporting = false;
if ( _batch == null &&
_scheduledTxn == null &&
_registration == null &&
_person == null )
{
pnlSummary.Visible = true;
// No context - show account summary
var qryTransactionDetails = qry.SelectMany( a => a.TransactionDetails );
var qryFinancialAccount = new FinancialAccountService( rockContext ).Queryable();
var accountSummaryQry = qryTransactionDetails.GroupBy( a => a.AccountId ).Select( a => new
{
AccountId = a.Key,
TotalAmount = (decimal?)a.Sum( d => d.Amount )
} ).Join( qryFinancialAccount, k1 => k1.AccountId, k2 => k2.Id, ( td, fa ) => new { td.TotalAmount, fa.Name, fa.Order } )
.OrderBy( a => a.Order );
var summaryList = accountSummaryQry.ToList();
var grandTotalAmount = ( summaryList.Count > 0 ) ? summaryList.Sum( a => a.TotalAmount ?? 0 ) : 0;
lGrandTotal.Text = grandTotalAmount.FormatAsCurrency();
rptAccountSummary.DataSource = summaryList.Select( a => new { a.Name, TotalAmount = a.TotalAmount.FormatAsCurrency() } ).ToList();
rptAccountSummary.DataBind();
}
else
{
pnlSummary.Visible = false;
}
}
示例13: gfTransactions_DisplayFilterValue
/// <summary>
/// Handles the filter display for each saved user value
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
/// <exception cref="System.NotImplementedException"></exception>
protected void gfTransactions_DisplayFilterValue( object sender, Rock.Web.UI.Controls.GridFilter.DisplayFilterValueArgs e )
{
switch ( e.Key )
{
case "Row Limit":
// row limit filter was removed, so hide it just in case
e.Value = null;
break;
case "Date Range":
e.Value = DateRangePicker.FormatDelimitedValues( e.Value );
break;
case "Amount Range":
e.Value = NumberRangeEditor.FormatDelimitedValues( e.Value, "N2" );
break;
case "Account":
var accountIds = e.Value.SplitDelimitedValues().AsIntegerList().Where(a => a > 0 ).ToList();
if ( accountIds.Any())
{
var service = new FinancialAccountService( new RockContext() );
var accountNames = service.GetByIds( accountIds ).OrderBy( a => a.Order ).OrderBy( a => a.Name ).Select( a => a.Name ).ToList().AsDelimited( ", ", " or " );
e.Value = accountNames;
}
else
{
e.Value = string.Empty;
}
break;
case "Transaction Type":
case "Currency Type":
case "Credit Card Type":
case "Source Type":
int definedValueId = 0;
if ( int.TryParse( e.Value, out definedValueId ) )
{
var definedValue = DefinedValueCache.Read( definedValueId );
if ( definedValue != null )
{
e.Value = definedValue.Value;
}
}
break;
case "Campus":
var campus = CampusCache.Read( e.Value.AsInteger() );
if ( campus != null )
{
e.Value = campus.Name;
}
else
{
e.Value = string.Empty;
}
break;
}
}
示例14: ProcessPayments
/// <summary>
/// Processes the payments.
/// </summary>
/// <param name="gateway">The gateway.</param>
/// <param name="batchNamePrefix">The batch name prefix.</param>
/// <param name="payments">The payments.</param>
/// <param name="batchUrlFormat">The batch URL format.</param>
/// <returns></returns>
public static string ProcessPayments( FinancialGateway gateway, string batchNamePrefix, List<Payment> payments, string batchUrlFormat = "" )
{
int totalPayments = 0;
int totalAlreadyDownloaded = 0;
int totalNoScheduledTransaction = 0;
int totalAdded = 0;
var batches = new List<FinancialBatch>();
var batchSummary = new Dictionary<Guid, List<Payment>>();
var initialControlAmounts = new Dictionary<Guid, decimal>();
var allBatchChanges = new Dictionary<Guid, List<string>>();
var allTxnChanges = new Dictionary<Guid, List<string>>();
var txnPersonNames = new Dictionary<Guid, string>();
using ( var rockContext = new RockContext() )
{
var accountService = new FinancialAccountService( rockContext );
var txnService = new FinancialTransactionService( rockContext );
var batchService = new FinancialBatchService( rockContext );
var scheduledTxnService = new FinancialScheduledTransactionService( rockContext );
var contributionTxnType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid() );
var defaultAccount = accountService.Queryable()
.Where( a =>
a.IsActive &&
!a.ParentAccountId.HasValue &&
( !a.StartDate.HasValue || a.StartDate.Value <= RockDateTime.Now ) &&
( !a.EndDate.HasValue || a.EndDate.Value >= RockDateTime.Now )
)
.OrderBy( a => a.Order )
.FirstOrDefault();
var batchTxnChanges = new Dictionary<Guid, List<string>>();
var batchBatchChanges = new Dictionary<Guid, List<string>>();
foreach ( var payment in payments.Where( p => p.Amount > 0.0M ) )
{
totalPayments++;
// Only consider transactions that have not already been added
if ( txnService.GetByTransactionCode( payment.TransactionCode ) == null )
{
var scheduledTransaction = scheduledTxnService.GetByScheduleId( payment.GatewayScheduleId );
if ( scheduledTransaction != null )
{
scheduledTransaction.IsActive = payment.ScheduleActive;
var txnChanges = new List<string>();
var transaction = new FinancialTransaction();
transaction.FinancialPaymentDetail = new FinancialPaymentDetail();
transaction.Guid = Guid.NewGuid();
allTxnChanges.Add( transaction.Guid, txnChanges );
txnChanges.Add( "Created Transaction (Downloaded from Gateway)" );
transaction.TransactionCode = payment.TransactionCode;
History.EvaluateChange( txnChanges, "Transaction Code", string.Empty, transaction.TransactionCode );
transaction.TransactionDateTime = payment.TransactionDateTime;
History.EvaluateChange( txnChanges, "Date/Time", null, transaction.TransactionDateTime );
transaction.ScheduledTransactionId = scheduledTransaction.Id;
transaction.AuthorizedPersonAliasId = scheduledTransaction.AuthorizedPersonAliasId;
History.EvaluateChange( txnChanges, "Person", string.Empty, scheduledTransaction.AuthorizedPersonAlias.Person.FullName );
txnPersonNames.Add( transaction.Guid, scheduledTransaction.AuthorizedPersonAlias.Person.FullName );
transaction.FinancialGatewayId = gateway.Id;
History.EvaluateChange( txnChanges, "Gateway", string.Empty, gateway.Name );
transaction.TransactionTypeValueId = contributionTxnType.Id;
History.EvaluateChange( txnChanges, "Type", string.Empty, contributionTxnType.Value );
var currencyTypeValue = payment.CurrencyTypeValue;
var creditCardTypevalue = payment.CreditCardTypeValue;
if ( scheduledTransaction.FinancialPaymentDetail != null )
{
if ( currencyTypeValue == null && scheduledTransaction.FinancialPaymentDetail.CurrencyTypeValueId.HasValue )
{
currencyTypeValue = DefinedValueCache.Read( scheduledTransaction.FinancialPaymentDetail.CurrencyTypeValueId.Value );
}
if ( creditCardTypevalue == null && scheduledTransaction.FinancialPaymentDetail.CreditCardTypeValueId.HasValue )
{
creditCardTypevalue = DefinedValueCache.Read( scheduledTransaction.FinancialPaymentDetail.CreditCardTypeValueId.Value );
}
transaction.FinancialPaymentDetail.AccountNumberMasked = scheduledTransaction.FinancialPaymentDetail.AccountNumberMasked;
//.........这里部分代码省略.........
示例15: GetAccounts
/// <summary>
/// Gets the accounts.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <returns></returns>
private IQueryable<FinancialAccount> GetAccounts( RockContext rockContext )
{
var accountService = new FinancialAccountService( rockContext );
SortProperty sortProperty = rGridAccount.SortProperty;
var accountQuery = accountService.Queryable();
string accountNameFilter = rAccountFilter.GetUserPreference( "Account Name" );
if ( !string.IsNullOrEmpty( accountNameFilter ) )
{
accountQuery = accountQuery.Where( account => account.Name.Contains( accountNameFilter ) );
}
int campusId = int.MinValue;
if ( int.TryParse( rAccountFilter.GetUserPreference( "Campus" ), out campusId ) )
{
accountQuery = accountQuery.Where( account => account.Campus.Id == campusId );
}
string publicFilter = rAccountFilter.GetUserPreference( "Public" );
if ( !string.IsNullOrWhiteSpace( publicFilter ) )
{
accountQuery = accountQuery.Where( account => ( account.IsPublic ?? false ) == ( publicFilter == "Yes" ) );
}
string activeFilter = rAccountFilter.GetUserPreference( "Active" );
if ( !string.IsNullOrWhiteSpace( activeFilter ) )
{
accountQuery = accountQuery.Where( account => account.IsActive == ( activeFilter == "Yes" ) );
}
string taxDeductibleFilter = rAccountFilter.GetUserPreference( "Tax Deductible" );
if ( !string.IsNullOrWhiteSpace( taxDeductibleFilter ) )
{
accountQuery = accountQuery.Where( account => account.IsTaxDeductible == ( taxDeductibleFilter == "Yes" ) );
}
accountQuery = accountQuery.OrderBy( a => a.Order );
return accountQuery;
}