本文整理汇总了C#中List.AsDelimited方法的典型用法代码示例。如果您正苦于以下问题:C# List.AsDelimited方法的具体用法?C# List.AsDelimited怎么用?C# List.AsDelimited使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.AsDelimited方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 names = new List<string>();
foreach ( string guidValue in value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
{
Guid guid = Guid.Empty;
if ( Guid.TryParse( guidValue, out guid ) )
{
var definedValue = Rock.Web.Cache.DefinedValueCache.Read( guid );
if ( definedValue != null )
{
names.Add( definedValue.Name );
}
}
}
formattedValue = names.AsDelimited( ", " );
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例2: SetValue
/// <summary>
/// Sets the value.
/// </summary>
/// <param name="metricCategory">The metric category.</param>
public void SetValue( MetricCategory metricCategory )
{
if ( metricCategory != null )
{
ItemId = metricCategory.Id.ToString();
var parentCategoryIds = new List<string>();
var parentCategory = metricCategory.Category;
while ( parentCategory != null )
{
if ( !parentCategoryIds.Contains( parentCategory.Id.ToString() ) )
{
parentCategoryIds.Insert( 0, parentCategory.Id.ToString() );
}
else
{
// infinite recursion
break;
}
parentCategory = parentCategory.ParentCategory;
}
InitialItemParentIds = parentCategoryIds.AsDelimited( "," );
ItemName = metricCategory.Name;
}
else
{
ItemId = Constants.None.IdValue;
ItemName = Constants.None.TextHtml;
}
}
示例3: 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;
var names = new List<string>();
if ( !string.IsNullOrWhiteSpace( value ) )
{
var selectedGuids = new List<Guid>();
value.SplitDelimitedValues().ToList().ForEach( v => selectedGuids.Add( Guid.Parse( v ) ) );
foreach( Guid guid in selectedGuids)
{
var entityType = EntityTypeCache.Read( guid );
if ( entityType != null )
{
names.Add( entityType.FriendlyName );
}
}
}
formattedValue = names.AsDelimited( ", " );
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例4: SetValue
/// <summary>
/// Sets the value.
/// </summary>
/// <param name="location">The location.</param>
public void SetValue( Rock.Model.Location location )
{
if ( location != null )
{
ItemId = location.Id.ToString();
List<int> parentLocationIds = new List<int>();
var parentLocation = location.ParentLocation;
while ( parentLocation != null )
{
if ( parentLocationIds.Contains( parentLocation.Id ) )
{
// infinite recursion
break;
}
parentLocationIds.Insert( 0, parentLocation.Id ); ;
parentLocation = parentLocation.ParentLocation;
}
InitialItemParentIds = parentLocationIds.AsDelimited( "," );
ItemName = location.ToString();
}
else
{
ItemId = Constants.None.IdValue;
ItemName = Constants.None.TextHtml;
}
}
示例5: 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( System.Web.UI.Control control, Dictionary<string, ConfigurationValue> configurationValues )
{
List<string> values = new List<string>();
if ( control != null && control is RockCheckBoxList )
{
RockCheckBoxList cbl = (RockCheckBoxList)control;
foreach ( ListItem li in cbl.Items )
if ( li.Selected )
values.Add( li.Value );
return values.AsDelimited<string>( "," );
}
return null;
}
示例6: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
Guid? workflowGuid = GetAttributeValue( action, "Workflow", true ).AsGuidOrNull();
if ( workflowGuid.HasValue )
{
using ( var newRockContext = new RockContext() )
{
var workflowService = new WorkflowService( newRockContext );
var workflow = workflowService.Get( workflowGuid.Value );
if ( workflow != null )
{
string status = GetAttributeValue( action, "Status" ).ResolveMergeFields( GetMergeFields( action ) );
workflow.Status = status;
workflow.AddLogEntry( string.Format( "Status set to '{0}' by another workflow: {1}", status, action.Activity.Workflow ) );
newRockContext.SaveChanges();
action.AddLogEntry( string.Format( "Set Status to '{0}' on another workflow: {1}", status, workflow ) );
bool processNow = GetAttributeValue( action, "ProcessNow" ).AsBoolean();
if ( processNow )
{
var processErrors = new List<string>();
if ( !workflowService.Process( workflow, out processErrors ) )
{
action.AddLogEntry( "Error(s) occurred processing target workflow: " + processErrors.AsDelimited( ", " ) );
}
}
return true;
}
}
action.AddLogEntry( "Could not find selected workflow." );
}
else
{
action.AddLogEntry( "Workflow attribute was not set." );
return true; // Continue processing in this case
}
return false;
}
示例7: 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;
var names = new List<string>();
if ( !string.IsNullOrWhiteSpace( value ) )
{
int entityTypeId = int.MinValue;
if ( int.TryParse( value, out entityTypeId ) )
{
var entityType = EntityTypeCache.Read( entityTypeId );
if ( entityType != null )
{
names.Add( entityType.FriendlyName );
}
}
}
formattedValue = names.AsDelimited( ", " );
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例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 )
{
ParseControls( true );
var rockContext = new RockContext();
var service = new WorkflowTypeService( rockContext );
WorkflowType workflowType = null;
int? workflowTypeId = hfWorkflowTypeId.Value.AsIntegerOrNull();
if ( workflowTypeId.HasValue )
{
workflowType = service.Get( workflowTypeId.Value );
}
if ( workflowType == null )
{
workflowType = new WorkflowType();
}
var validationErrors = new List<string>();
// check for unique prefix
string prefix = tbNumberPrefix.UntrimmedText;
if ( !string.IsNullOrWhiteSpace( prefix ) &&
prefix.ToUpper() != ( workflowType.WorkflowIdPrefix ?? string.Empty ).ToUpper() )
{
if ( service.Queryable().AsNoTracking()
.Any( w =>
w.Id != workflowType.Id &&
w.WorkflowIdPrefix == prefix ) )
{
validationErrors.Add( "Workflow Number Prefix is already being used by another workflow type. Please use a unique prefix." );
}
else
{
workflowType.WorkflowIdPrefix = prefix;
}
}
else
{
workflowType.WorkflowIdPrefix = prefix;
}
workflowType.IsActive = cbIsActive.Checked;
workflowType.Name = tbName.Text;
workflowType.Description = tbDescription.Text;
workflowType.CategoryId = cpCategory.SelectedValueAsInt();
workflowType.WorkTerm = tbWorkTerm.Text;
workflowType.ModifiedByPersonAliasId = CurrentPersonAliasId;
workflowType.ModifiedDateTime = RockDateTime.Now;
int? mins = tbProcessingInterval.Text.AsIntegerOrNull();
if ( mins.HasValue )
{
workflowType.ProcessingIntervalSeconds = mins.Value * 60;
}
else
{
workflowType.ProcessingIntervalSeconds = null;
}
workflowType.IsPersisted = cbIsPersisted.Checked;
workflowType.LoggingLevel = ddlLoggingLevel.SelectedValueAsEnum<WorkflowLoggingLevel>();
workflowType.IconCssClass = tbIconCssClass.Text;
workflowType.SummaryViewText = ceSummaryViewText.Text;
workflowType.NoActionMessage = ceNoActionMessage.Text;
if ( validationErrors.Any() )
{
nbValidationError.Text = string.Format( "Please Correct the Following<ul><li>{0}</li></ul>",
validationErrors.AsDelimited( "</li><li>" ) );
nbValidationError.Visible = true;
return;
}
if ( !Page.IsValid || !workflowType.IsValid )
{
return;
}
foreach(var activityType in ActivityTypesState)
{
if (!activityType.IsValid)
{
return;
}
foreach(var actionType in activityType.ActionTypes)
{
if ( !actionType.IsValid )
{
return;
}
}
//.........这里部分代码省略.........
示例9: btnCopy_Click
//.........这里部分代码省略.........
foreach ( var actionType in activityType.ActionTypes )
{
var newActionType = actionType.Clone( false );
newActionType.ActivityTypeId = 0;
newActionType.WorkflowFormId = 0;
newActionType.Id = 0;
newActionType.Guid = Guid.NewGuid();
newActivityType.ActionTypes.Add( newActionType );
if ( actionType.CriteriaAttributeGuid.HasValue &&
guidXref.ContainsKey( actionType.CriteriaAttributeGuid.Value ) )
{
newActionType.CriteriaAttributeGuid = guidXref[actionType.CriteriaAttributeGuid.Value];
}
Guid criteriaAttributeGuid = actionType.CriteriaValue.AsGuid();
if ( !criteriaAttributeGuid.IsEmpty() &&
guidXref.ContainsKey( criteriaAttributeGuid ) )
{
newActionType.CriteriaValue = guidXref[criteriaAttributeGuid].ToString();
}
if ( actionType.WorkflowForm != null )
{
var newWorkflowForm = actionType.WorkflowForm.Clone( false );
newWorkflowForm.Id = 0;
newWorkflowForm.Guid = Guid.NewGuid();
var newActionButtons = new List<string>();
foreach ( var actionButton in actionType.WorkflowForm.Actions.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ) )
{
var details = actionButton.Split( new char[] { '^' } );
if ( details.Length > 2 )
{
Guid oldGuid = details[2].AsGuid();
if (!oldGuid.IsEmpty() && guidXref.ContainsKey(oldGuid))
{
details[2] = guidXref[oldGuid].ToString();
}
}
newActionButtons.Add( details.ToList().AsDelimited("^") );
}
newWorkflowForm.Actions = newActionButtons.AsDelimited( "|" );
if ( actionType.WorkflowForm.ActionAttributeGuid.HasValue &&
guidXref.ContainsKey( actionType.WorkflowForm.ActionAttributeGuid.Value ) )
{
newWorkflowForm.ActionAttributeGuid = guidXref[actionType.WorkflowForm.ActionAttributeGuid.Value];
}
newActionType.WorkflowForm = newWorkflowForm;
foreach ( var formAttribute in actionType.WorkflowForm.FormAttributes )
{
if ( guidXref.ContainsKey( formAttribute.Attribute.Guid ) )
{
var newFormAttribute = formAttribute.Clone( false );
newFormAttribute.WorkflowActionFormId = 0;
newFormAttribute.Id = 0;
newFormAttribute.Guid = Guid.NewGuid();
newFormAttribute.AttributeId = 0;
newFormAttribute.Attribute = new Rock.Model.Attribute
{
Guid = guidXref[formAttribute.Attribute.Guid],
Name = formAttribute.Attribute.Name
};
newWorkflowForm.FormAttributes.Add( newFormAttribute );
}
}
}
newActionType.LoadAttributes( rockContext );
if ( actionType.Attributes != null && actionType.Attributes.Any() )
{
foreach ( var attributeKey in actionType.Attributes.Select( a => a.Key ) )
{
string value = actionType.GetAttributeValue( attributeKey );
Guid guidValue = value.AsGuid();
if ( !guidValue.IsEmpty() && guidXref.ContainsKey( guidValue ) )
{
newActionType.SetAttributeValue( attributeKey, guidXref[guidValue].ToString() );
}
else
{
newActionType.SetAttributeValue( attributeKey, value );
}
}
}
}
}
workflowType = newWorkflowType;
AttributesState = newAttributesState;
ActivityTypesState = newActivityTypesState;
ActivityAttributesState = newActivityAttributesState;
hfWorkflowTypeId.Value = workflowType.Id.ToString();
ShowEditDetails( workflowType, rockContext );
}
}
示例10: OnLoad
//.........这里部分代码省略.........
if ( group != null )
{
_groupId = group.Id.ToString();
string redirectUrl = string.Empty;
// redirect so that the group treeview has the first node selected right away and group detail shows the group
if ( hfPageRouteTemplate.Value.IndexOf( "{groupId}", StringComparison.OrdinalIgnoreCase ) >= 0 )
{
redirectUrl = "~/" + hfPageRouteTemplate.Value.ReplaceCaseInsensitive( "{groupId}", _groupId.ToString() );
}
else
{
redirectUrl = this.Request.Url + "?GroupId=" + _groupId.ToString();
}
this.Response.Redirect( redirectUrl, false );
Context.ApplicationInstance.CompleteRequest();
}
}
}
}
if ( !string.IsNullOrWhiteSpace( _groupId ) )
{
hfInitialGroupId.Value = _groupId;
hfSelectedGroupId.Value = _groupId;
string key = string.Format( "Group:{0}", _groupId );
Group group = RockPage.GetSharedItem( key ) as Group;
if ( group == null )
{
int id = _groupId.AsInteger();
group = new GroupService( new RockContext() ).Queryable( "GroupType" )
.Where( g => g.Id == id )
.FirstOrDefault();
RockPage.SaveSharedItem( key, group );
}
if ( group != null )
{
// show the Add button if the selected Group's GroupType can have children
lbAddGroupChild.Enabled = canEditBlock && group.GroupType.ChildGroupTypes.Count > 0;
}
else
{
// hide the Add Button when adding a new Group
lbAddGroupChild.Enabled = false;
}
// get the parents of the selected item so we can tell the treeview to expand those
int? rootGroupId = GetAttributeValue( "RootGroup" ).AsIntegerOrNull();
List<string> parentIdList = new List<string>();
while ( group != null )
{
if ( group.Id == rootGroupId )
{
// stop if we are at the root group
group = null;
}
else
{
group = group.ParentGroup;
}
if ( group != null )
{
parentIdList.Insert( 0, group.Id.ToString() );
}
}
// also get any additional expanded nodes that were sent in the Post
string postedExpandedIds = this.Request.Params["ExpandedIds"];
if ( !string.IsNullOrWhiteSpace( postedExpandedIds ) )
{
var postedExpandedIdList = postedExpandedIds.Split( ',' ).ToList();
foreach ( var id in postedExpandedIdList )
{
if ( !parentIdList.Contains( id ) )
{
parentIdList.Add( id );
}
}
}
hfInitialGroupParentIds.Value = parentIdList.AsDelimited( "," );
}
else
{
// let the Add button be visible if there is nothing selected (if authorized)
lbAddGroupChild.Enabled = canEditBlock;
}
// disable add child group if no group is selected
int selectedGroupId = hfSelectedGroupId.ValueAsInt();
if ( selectedGroupId == 0 )
{
lbAddGroupChild.Enabled = false;
}
}
示例11: FormatFeeCost
/// <summary>
/// Formats the fee cost.
/// </summary>
/// <param name="value">The value.</param>
/// <returns></returns>
protected string FormatFeeCost( string value )
{
var values = new List<string>();
string[] nameValues = value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
foreach ( string nameValue in nameValues )
{
string[] nameAndValue = nameValue.Split( new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries );
if ( nameAndValue.Length == 2 )
{
values.Add( string.Format( "{0}-{1}", nameAndValue[0], nameAndValue[1].AsDecimal().FormatAsCurrency() ) );
}
else
{
values.Add( string.Format( "{0}", nameValue.AsDecimal().FormatAsCurrency() ) );
}
}
return values.AsDelimited( ", " );
}
示例12: 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 names = new List<string>();
foreach ( Guid guid in value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).AsGuidList() )
{
var attribute = AttributeCache.Read( guid );
if ( attribute != null )
{
names.Add( attribute.Name );
}
}
formattedValue = names.AsDelimited( ", " );
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例13: ProcessPaymentInfo
//.........这里部分代码省略.........
if ( Gateway.SplitNameOnCard )
{
if ( string.IsNullOrWhiteSpace( txtCardFirstName.Text ) || string.IsNullOrWhiteSpace( txtCardLastName.Text ) )
{
errorMessages.Add( "Make sure to enter a valid first and last name as it appears on your credit card" );
}
}
else
{
if ( string.IsNullOrWhiteSpace( txtCardName.Text ) )
{
errorMessages.Add( "Make sure to enter a valid name as it appears on your credit card" );
}
}
if ( string.IsNullOrWhiteSpace( txtCreditCard.Text ) )
{
errorMessages.Add( "Make sure to enter a valid credit card number" );
}
var currentMonth = DateTime.Today;
currentMonth = new DateTime( currentMonth.Year, currentMonth.Month, 1 );
if ( !mypExpiration.SelectedDate.HasValue || mypExpiration.SelectedDate.Value.CompareTo( currentMonth ) < 0 )
{
errorMessages.Add( "Make sure to enter a valid credit card expiration date" );
}
if ( string.IsNullOrWhiteSpace( txtCVV.Text ) )
{
errorMessages.Add( "Make sure to enter a valid credit card security code" );
}
}
}
if ( errorMessages.Any() )
{
errorMessage = errorMessages.AsDelimited( "<br/>" );
return false;
}
using ( new UnitOfWorkScope() )
{
FinancialScheduledTransaction scheduledTransaction = null;
if ( ScheduledTransactionId.HasValue )
{
scheduledTransaction = new FinancialScheduledTransactionService().Get( ScheduledTransactionId.Value );
}
if ( scheduledTransaction == null )
{
errorMessage = "There was a problem getting the transaction information";
return false;
}
if ( scheduledTransaction.AuthorizedPerson == null )
{
errorMessage = "There was a problem determining the person associated with the transaction";
return false;
}
PaymentInfo paymentInfo = GetPaymentInfo( new PersonService(), scheduledTransaction );
if ( paymentInfo != null )
{
tdName.Description = paymentInfo.FullName;
tdTotal.Description = paymentInfo.Amount.ToString( "C" );
if (paymentInfo.CurrencyTypeValue != null)
{
tdPaymentMethod.Description = paymentInfo.CurrencyTypeValue.Description;
tdPaymentMethod.Visible = true;
}
else
{
tdPaymentMethod.Visible = false;
}
if (string.IsNullOrWhiteSpace(paymentInfo.MaskedNumber))
{
tdAccountNumber.Visible = false;
}
else
{
tdAccountNumber.Visible = true;
tdAccountNumber.Description = paymentInfo.MaskedNumber;
}
tdWhen.Description = string.Format( "{0} starting on {1}", howOften, when.ToShortDateString());
}
}
rptAccountListConfirmation.DataSource = SelectedAccounts.Where( a => a.Amount != 0 );
rptAccountListConfirmation.DataBind();
string nextDate = dtpStartDate.SelectedDate.HasValue ? dtpStartDate.SelectedDate.Value.ToShortDateString() : "?";
string frequency = DefinedValueCache.Read( btnFrequency.SelectedValueAsInt() ?? 0 ).Description;
tdWhen.Description = frequency + " starting on " + nextDate;
return true;
}
示例14: BindGrid
//.........这里部分代码省略.........
if ( attributeGuid.HasValue )
{
var attribute = AttributeCache.Read( attributeGuid.Value );
selectedAttributes.Add( columnIndex, attribute );
BoundField boundField;
if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.BOOLEAN.AsGuid() ) )
{
boundField = new BoolField();
}
else
{
boundField = new BoundField();
}
boundField.DataField = string.Format( "Attribute_{0}_{1}", attribute.Id, columnIndex );
boundField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? attribute.Name : reportField.ColumnHeaderText;
boundField.SortExpression = null;
if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.INTEGER.AsGuid() ) ||
attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.DATE.AsGuid() ) )
{
boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
}
boundField.Visible = reportField.ShowInGrid;
// NOTE: Additional formatting for attributes is done in the gReport_RowDataBound event
gReport.Columns.Add( boundField );
}
}
else if ( reportField.ReportFieldType == ReportFieldType.DataSelectComponent )
{
selectedComponents.Add( columnIndex, reportField );
DataSelectComponent selectComponent = DataSelectContainer.GetComponent( reportField.DataSelectComponentEntityType.Name );
if ( selectComponent != null )
{
DataControlField columnField = selectComponent.GetGridField( entityType, reportField.Selection );
if ( columnField is BoundField )
{
( columnField as BoundField ).DataField = string.Format( "Data_{0}_{1}", selectComponent.ColumnPropertyName, columnIndex );
}
columnField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? selectComponent.ColumnHeaderText : reportField.ColumnHeaderText;
columnField.SortExpression = null;
columnField.Visible = reportField.ShowInGrid;
gReport.Columns.Add( columnField );
}
}
}
// if no fields are specified, show the default fields (Previewable/All) for the EntityType
var dataColumns = gReport.Columns.OfType<object>().Where(a => a.GetType() != typeof(SelectField));
if (dataColumns.Count() == 0)
{
// show either the Previewable Columns or all (if there are no previewable columns)
bool showAllColumns = !entityFields.Any( a => a.FieldKind == FieldKind.Property && a.IsPreviewable );
foreach ( var entityField in entityFields.Where(a => a.FieldKind == FieldKind.Property) )
{
columnIndex++;
selectedEntityFields.Add( columnIndex, entityField );
BoundField boundField;
if ( entityField.DefinedTypeGuid.HasValue )
{
boundField = new DefinedValueField();
}
else
{
boundField = Grid.GetGridField( entityField.PropertyType );
}
boundField.DataField = string.Format( "Entity_{0}_{1}", entityField.Name, columnIndex );
boundField.HeaderText = entityField.Name;
boundField.SortExpression = entityField.Name;
boundField.Visible = showAllColumns || entityField.IsPreviewable;
gReport.Columns.Add( boundField );
}
}
try
{
gReport.ExportFilename = report.Name;
gReport.DataSource = report.GetDataSource( new RockContext(), entityType, selectedEntityFields, selectedAttributes, selectedComponents, gReport.SortProperty, out errors );
gReport.DataBind();
}
catch ( Exception ex )
{
errors.Add( ex.Message );
}
if ( errors.Any() )
{
nbEditModeMessage.Text = "INFO: There was a problem with one or more of the report's data components...<br/><br/> " + errors.AsDelimited( "<br/>" );
}
}
}
示例15: SetAllowedGroupTypes
/// <summary>
/// Sets the allowed group types.
/// </summary>
private void SetAllowedGroupTypes()
{
// limit GroupType selection to what Block Attributes allow
hfGroupTypesInclude.Value = string.Empty;
List<Guid> groupTypeIncludeGuids = GetAttributeValue( "GroupTypes" ).SplitDelimitedValues().AsGuidList();
if ( groupTypeIncludeGuids.Any() )
{
var groupTypeIdIncludeList = new List<int>();
foreach ( Guid guid in groupTypeIncludeGuids )
{
var groupType = GroupTypeCache.Read( guid );
if ( groupType != null )
{
groupTypeIdIncludeList.Add( groupType.Id );
}
}
hfGroupTypesInclude.Value = groupTypeIdIncludeList.AsDelimited( "," );
}
hfGroupTypesExclude.Value = string.Empty;
List<Guid> groupTypeExcludeGuids = GetAttributeValue( "GroupTypesExclude" ).SplitDelimitedValues().AsGuidList();
if ( groupTypeExcludeGuids.Any() )
{
var groupTypeIdExcludeList = new List<int>();
foreach ( Guid guid in groupTypeExcludeGuids )
{
var groupType = GroupTypeCache.Read( guid );
if ( groupType != null )
{
groupTypeIdExcludeList.Add( groupType.Id );
}
}
hfGroupTypesExclude.Value = groupTypeIdExcludeList.AsDelimited( "," );
}
}