private void ShowAttributeValues() { phViewAttributes.Controls.Clear(); foreach ( var attribute in Workflow.Attributes.OrderBy( a => a.Value.Order ).Select( a => a.Value ) ) { var td = new TermDescription(); td.ID = "tdViewAttribute_" + attribute.Key; td.Term = attribute.Name; string value = Workflow.GetAttributeValue( attribute.Key ); var field = attribute.FieldType.Field; string formattedValue = field.FormatValueAsHtml( phViewAttributes, value, attribute.QualifierValues ); if ( field is Rock.Field.ILinkableFieldType ) { var linkableField = field as Rock.Field.ILinkableFieldType; td.Description = string.Format( "<a href='{0}{1}'>{2}</a>", ResolveRockUrl( "~" ), linkableField.UrlLink( value, attribute.QualifierValues ), formattedValue ); } else { td.Description = formattedValue; } phViewAttributes.Controls.Add( td ); } }
void rptrActivities_ItemDataBound(object sender, RepeaterItemEventArgs e) { var activity = e.Item.DataItem as WorkflowActivity; if (activity != null) { var lblComplete = e.Item.FindControl( "lblComplete" ) as Label; if ( lblComplete != null ) { lblComplete.Visible = activity.CompletedDateTime.HasValue; } var lblActive = e.Item.FindControl( "lblActive" ) as Label; if ( lblActive != null ) { lblActive.Visible = !activity.CompletedDateTime.HasValue; } var tdAssignedToPerson = e.Item.FindControl( "tdAssignedToPerson" ) as TermDescription; if ( tdAssignedToPerson != null && activity.AssignedPersonAliasId.HasValue ) { var person = _personAliasService.Queryable() .Where( a => a.Id == activity.AssignedPersonAliasId.Value ) .Select( a => a.Person ) .FirstOrDefault(); if ( person != null ) { tdAssignedToPerson.Description = string.Format( "<a href='~/Person/{0}'>{1}</a>", person.Id, person.FullName ); } } var tdAssignedToGroup = e.Item.FindControl( "tdAssignedToGroup" ) as TermDescription; if ( tdAssignedToGroup != null && activity.AssignedGroupId.HasValue ) { var group = _groupService.Get( activity.AssignedGroupId.Value); if ( group != null ) { tdAssignedToGroup.Description = group.Name; } } var tdActivated = e.Item.FindControl( "tdActivated" ) as TermDescription; if (tdActivated != null && activity.ActivatedDateTime.HasValue ) { tdActivated.Description = string.Format( "{0} {1} ({2})", activity.ActivatedDateTime.Value.ToShortDateString(), activity.ActivatedDateTime.Value.ToShortTimeString(), activity.ActivatedDateTime.Value.ToRelativeDateString() ); } var tdCompleted = e.Item.FindControl("tdCompleted") as TermDescription; if (tdCompleted != null && activity.CompletedDateTime.HasValue ) { tdCompleted.Description = string.Format( "{0} {1} ({2})", activity.CompletedDateTime.Value.ToShortDateString(), activity.CompletedDateTime.Value.ToShortTimeString(), activity.CompletedDateTime.Value.ToRelativeDateString() ); } var phActivityAttributes = e.Item.FindControl("phActivityAttributes") as PlaceHolder; if (phActivityAttributes != null ) { foreach ( var attribute in activity.Attributes.OrderBy( a => a.Value.Order ).Select( a => a.Value ) ) { var td = new TermDescription(); phActivityAttributes.Controls.Add( td ); td.Term = attribute.Name; string value = activity.GetAttributeValue( attribute.Key ); var field = attribute.FieldType.Field; string formattedValue = field.FormatValueAsHtml( phActivityAttributes, value, attribute.QualifierValues ); if ( field is Rock.Field.ILinkableFieldType ) { var linkableField = field as Rock.Field.ILinkableFieldType; td.Description = string.Format( "<a href='{0}{1}'>{2}</a>", ResolveRockUrl( "~" ), linkableField.UrlLink( value, attribute.QualifierValues ), formattedValue ); } else { td.Description = formattedValue; } phActivityAttributes.Controls.Add( td ); } } var gridActions = e.Item.FindControl("gridActions") as Grid; if ( gridActions != null ) { gridActions.DataSource = activity.Actions.OrderBy( a => a.ActionType.Order ) .Select( a => new { Name = a.ActionType.Name, LastProcessed = a.LastProcessedDateTime.HasValue ? string.Format( "{0} {1} ({2})", a.LastProcessedDateTime.Value.ToShortDateString(), a.LastProcessedDateTime.Value.ToShortTimeString(), a.LastProcessedDateTime.Value.ToRelativeDateString() ) : "", Completed = a.CompletedDateTime.HasValue, CompletedWhen = a.CompletedDateTime.HasValue ? string.Format( "{0} {1} ({2})", a.CompletedDateTime.Value.ToShortDateString(), a.CompletedDateTime.Value.ToShortTimeString(), a.CompletedDateTime.Value.ToRelativeDateString() ) : "" } ) .ToList(); gridActions.DataBind(); } } }