本文整理汇总了C#中Location.LoadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Location.LoadAttributes方法的具体用法?C# Location.LoadAttributes怎么用?C# Location.LoadAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.LoadAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowEditDetails
/// <summary>
/// Shows the edit details.
/// </summary>
/// <param name="location">The location.</param>
private void ShowEditDetails( Location location )
{
if ( location.Id == 0 )
{
lReadOnlyTitle.Text = ActionTitle.Add( Location.FriendlyTypeName ).FormatAsHtmlTitle();
hlInactive.Visible = false;
}
else
{
if ( string.IsNullOrWhiteSpace( location.Name ) )
{
lReadOnlyTitle.Text = location.ToString().FormatAsHtmlTitle();
}
else
{
lReadOnlyTitle.Text = location.Name.FormatAsHtmlTitle();
}
}
SetEditMode( true );
imgImage.BinaryFileId = location.ImageId;
imgImage.NoPictureUrl = System.Web.VirtualPathUtility.ToAbsolute( "~/Assets/Images/no-picture.svg?" );
tbName.Text = location.Name;
cbIsActive.Checked = location.IsActive;
acAddress.SetValues( location );
ddlPrinter.SetValue( location.PrinterDeviceId );
geopPoint.SetValue( location.GeoPoint );
geopFence.SetValue( location.GeoFence );
cbGeoPointLocked.Checked = location.IsGeoPointLocked ?? false;
Guid mapStyleValueGuid = GetAttributeValue( "MapStyle" ).AsGuid();
geopPoint.MapStyleValueGuid = mapStyleValueGuid;
geopFence.MapStyleValueGuid = mapStyleValueGuid;
var rockContext = new RockContext();
var locationService = new LocationService( rockContext );
var attributeService = new AttributeService( rockContext );
ddlLocationType.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.LOCATION_TYPE.AsGuid() ), true );
gpParentLocation.Location = location.ParentLocation ?? locationService.Get( location.ParentLocationId ?? 0 );
// LocationType depends on Selected ParentLocation
if ( location.Id == 0 && ddlLocationType.Items.Count > 1 )
{
// if this is a new location
ddlLocationType.SelectedIndex = 0;
}
else
{
ddlLocationType.SetValue( location.LocationTypeValueId );
}
location.LoadAttributes( rockContext );
BuildAttributeEdits( location, true );
}
示例2: ShowReadonlyDetails
/// <summary>
/// Shows the readonly details.
/// </summary>
/// <param name="location">The location.</param>
private void ShowReadonlyDetails( Location location )
{
SetEditMode( false );
hfLocationId.SetValue( location.Id );
if ( string.IsNullOrWhiteSpace( location.Name ) )
{
lReadOnlyTitle.Text = location.ToString().FormatAsHtmlTitle();
}
else
{
lReadOnlyTitle.Text = location.Name.FormatAsHtmlTitle();
}
hlInactive.Visible = !location.IsActive;
if ( location.LocationTypeValue != null )
{
hlType.Text = location.LocationTypeValue.Value;
hlType.Visible = true;
}
else
{
hlType.Visible = false;
}
string imgTag = GetImageTag( location.ImageId, 150, 150 );
if ( location.ImageId.HasValue )
{
string imageUrl = ResolveRockUrl( String.Format( "~/GetImage.ashx?id={0}", location.ImageId.Value ) );
lImage.Text = string.Format( "<a href='{0}'>{1}</a>", imageUrl, imgTag );
}
else
{
lImage.Text = imgTag;
}
DescriptionList descriptionList = new DescriptionList();
if ( location.ParentLocation != null )
{
descriptionList.Add( "Parent Location", location.ParentLocation.Name );
}
if ( location.LocationTypeValue != null )
{
descriptionList.Add( "Location Type", location.LocationTypeValue.Value );
}
if ( location.PrinterDevice != null )
{
descriptionList.Add( "Printer", location.PrinterDevice.Name );
}
string fullAddress = location.GetFullStreetAddress().ConvertCrLfToHtmlBr();
if ( !string.IsNullOrWhiteSpace( fullAddress ) )
{
descriptionList.Add( "Address", fullAddress );
}
lblMainDetails.Text = descriptionList.Html;
location.LoadAttributes();
Rock.Attribute.Helper.AddDisplayControls( location, phAttributes );
phMaps.Controls.Clear();
var mapStyleValue = DefinedValueCache.Read( GetAttributeValue( "MapStyle" ) );
if ( mapStyleValue == null )
{
mapStyleValue = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.MAP_STYLE_ROCK );
}
if ( mapStyleValue != null )
{
string mapStyle = mapStyleValue.GetAttributeValue( "StaticMapStyle" );
if ( !string.IsNullOrWhiteSpace( mapStyle ) )
{
if ( location.GeoPoint != null )
{
string markerPoints = string.Format( "{0},{1}", location.GeoPoint.Latitude, location.GeoPoint.Longitude );
string mapLink = System.Text.RegularExpressions.Regex.Replace( mapStyle, @"\{\s*MarkerPoints\s*\}", markerPoints );
mapLink = System.Text.RegularExpressions.Regex.Replace( mapLink, @"\{\s*PolygonPoints\s*\}", string.Empty );
mapLink += "&sensor=false&size=350x200&zoom=13&format=png";
phMaps.Controls.Add( new LiteralControl ( string.Format( "<div class='group-location-map'><img src='{0}'/></div>", mapLink ) ) );
}
if ( location.GeoFence != null )
{
string polygonPoints = "enc:" + location.EncodeGooglePolygon();
string mapLink = System.Text.RegularExpressions.Regex.Replace( mapStyle, @"\{\s*MarkerPoints\s*\}", string.Empty );
mapLink = System.Text.RegularExpressions.Regex.Replace( mapLink, @"\{\s*PolygonPoints\s*\}", polygonPoints );
mapLink += "&sensor=false&size=350x200&format=png";
phMaps.Controls.Add( new LiteralControl( string.Format( "<div class='group-location-map'><img src='{0}'/></div>", mapLink ) ) );
}
}
//.........这里部分代码省略.........
示例3: ShowReadonlyDetails
/// <summary>
/// Shows the readonly details.
/// </summary>
/// <param name="location">The location.</param>
private void ShowReadonlyDetails( Location location )
{
SetEditMode( false );
hfLocationId.SetValue( location.Id );
if ( string.IsNullOrWhiteSpace( location.Name ) )
{
lReadOnlyTitle.Text = location.ToString().FormatAsHtmlTitle();
}
else
{
lReadOnlyTitle.Text = location.Name.FormatAsHtmlTitle();
}
hlInactive.Visible = !location.IsActive;
if ( location.LocationTypeValue != null )
{
hlType.Text = location.LocationTypeValue.Name;
hlType.Visible = true;
}
else
{
hlType.Visible = false;
}
DescriptionList descriptionList = new DescriptionList();
string fullAddress = location.GetFullStreetAddress();
if ( !string.IsNullOrWhiteSpace( fullAddress ) )
{
descriptionList.Add( "Address", fullAddress );
}
if ( location.ParentLocation != null )
{
descriptionList.Add( "Parent Location", location.ParentLocation.Name );
}
if ( location.PrinterDevice != null)
{
descriptionList.Add( "Printer", location.PrinterDevice.Name );
}
lblMainDetails.Text = descriptionList.Html;
location.LoadAttributes();
Rock.Attribute.Helper.AddDisplayControls( location, phAttributes );
// Get all the location locations and location all those that have a geo-location into either points or polygons
var dict = new Dictionary<string, object>();
if ( location.GeoPoint != null )
{
var pointsDict = new Dictionary<string, object>();
pointsDict.Add( "latitude", location.GeoPoint.Latitude );
pointsDict.Add( "longitude", location.GeoPoint.Longitude );
dict.Add( "point", pointsDict );
}
if ( location.GeoFence != null )
{
var polygonDict = new Dictionary<string, object>();
polygonDict.Add( "polygon_wkt", location.GeoFence.AsText() );
polygonDict.Add( "google_encoded_polygon", location.EncodeGooglePolygon() );
dict.Add( "polygon", polygonDict );
}
phMaps.Controls.Clear();
phMaps.Controls.Add( new LiteralControl( GetAttributeValue( "MapHTML" ).ResolveMergeFields( dict ) ) );
btnSecurity.Visible = location.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
btnSecurity.Title = location.Name;
btnSecurity.EntityId = location.Id;
}