本文整理汇总了C#中Rock.Model.LocationService.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# LocationService.Verify方法的具体用法?C# LocationService.Verify怎么用?C# LocationService.Verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.LocationService
的用法示例。
在下文中一共展示了LocationService.Verify方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Job that updates the JobPulse setting with the current date/time.
/// This will allow us to notify an admin if the jobs stop running.
///
/// Called by the <see cref="IScheduler" /> when a
/// <see cref="ITrigger" /> fires that is associated with
/// the <see cref="IJob" />.
/// </summary>
public virtual void Execute(IJobExecutionContext context)
{
// get the job map
JobDataMap dataMap = context.JobDetail.JobDataMap;
int maxRecords = Int32.Parse( dataMap.GetString( "MaxRecordsPerRun" ) );
int throttlePeriod = Int32.Parse( dataMap.GetString( "ThrottlePeriod" ) );
int retryPeriod = Int32.Parse( dataMap.GetString( "RetryPeriod" ) );
DateTime retryDate = DateTime.Now.Subtract(new TimeSpan(retryPeriod, 0, 0, 0));
var rockContext = new Rock.Data.RockContext();
LocationService locationService = new LocationService(rockContext);
var addresses = locationService.Queryable()
.Where( l => (
(l.IsGeoPointLocked == null || l.IsGeoPointLocked == false) // don't ever try locked address
&& (l.IsActive == true && l.Street1 != null && l.PostalCode != null) // or incomplete addresses
&& (
(l.GeocodedDateTime == null && (l.GeocodeAttemptedDateTime == null || l.GeocodeAttemptedDateTime < retryDate)) // has not been attempted to be geocoded since retry date
||
(l.StandardizedDateTime == null && (l.StandardizeAttemptedDateTime == null || l.StandardizeAttemptedDateTime < retryDate)) // has not been attempted to be standardize since retry date
)
))
.Take( maxRecords ).ToList();
foreach ( var address in addresses )
{
locationService.Verify( address, false ); // currently not reverifying
rockContext.SaveChanges();
System.Threading.Thread.Sleep( throttlePeriod );
}
}
示例2: btnStandardize_Click
/// <summary>
/// Handles the Click event of the btnStandardize 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 btnStandardize_Click( object sender, EventArgs e )
{
int locationId = hfLocationId.Value.AsInteger();
var rockContext = new RockContext();
var service = new LocationService( rockContext );
var location = service.Get( locationId );
if (location == null)
{
// if they are adding a new named location, there won't be a location record yet, so just make a new one for the verification
location = new Location();
}
acAddress.GetValues( location );
service.Verify( location, true );
acAddress.SetValues( location );
geopPoint.SetValue( location.GeoPoint );
lStandardizationUpdate.Text = String.Format( "<div class='alert alert-info'>Standardization Result: {0}<br/>Geocoding Result: {1}</div>",
location.StandardizeAttemptedResult.IfEmpty( "No Result" ),
location.GeocodeAttemptedResult.IfEmpty( "No Result" ) );
}
示例3: 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 )
{
Campus campus;
var rockContext = new RockContext();
var campusService = new CampusService( rockContext );
var locationService = new LocationService( rockContext );
var locationCampusValue = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.LOCATION_TYPE_CAMPUS.AsGuid());
int campusId = int.Parse( hfCampusId.Value );
if ( campusId == 0 )
{
campus = new Campus();
campusService.Add( campus);
}
else
{
campus = campusService.Get( campusId );
}
campus.Name = tbCampusName.Text;
campus.IsActive = cbIsActive.Checked;
campus.Description = tbDescription.Text;
campus.Url = tbUrl.Text;
campus.PhoneNumber = tbPhoneNumber.Text;
if ( campus.Location == null )
{
var location = locationService.Queryable()
.Where( l =>
l.Name.Equals( campus.Name, StringComparison.OrdinalIgnoreCase ) &&
l.LocationTypeValueId == locationCampusValue.Id )
.FirstOrDefault();
if (location == null)
{
location = new Location();
locationService.Add( location );
}
campus.Location = location;
}
campus.Location.Name = campus.Name;
campus.Location.LocationTypeValueId = locationCampusValue.Id;
string preValue = campus.Location.GetFullStreetAddress();
acAddress.GetValues( campus.Location );
string postValue = campus.Location.GetFullStreetAddress();
campus.ShortCode = tbCampusCode.Text;
var personService = new PersonService( rockContext );
var leaderPerson = personService.Get( ppCampusLeader.SelectedValue ?? 0 );
campus.LeaderPersonAliasId = leaderPerson != null ? leaderPerson.PrimaryAliasId : null;
campus.ServiceTimes = kvlServiceTimes.Value;
campus.LoadAttributes( rockContext );
Rock.Attribute.Helper.GetEditValues( phAttributes, campus );
if ( !campus.IsValid && campus.Location.IsValid)
{
// Controls will render the error messages
return;
}
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
campus.SaveAttributeValues( rockContext );
if (preValue != postValue && !string.IsNullOrWhiteSpace(campus.Location.Street1))
{
locationService.Verify(campus.Location, true);
}
} );
Rock.Web.Cache.CampusCache.Flush( campus.Id );
NavigateToParentPage();
}
示例4: rptrAddresses_ItemCommand
void rptrAddresses_ItemCommand( object source, RepeaterCommandEventArgs e )
{
int locationId = int.MinValue;
if ( int.TryParse( e.CommandArgument.ToString(), out locationId ) )
{
var rockContext = new RockContext();
var service = new LocationService( rockContext );
var location = service.Get( locationId );
switch ( e.CommandName )
{
case "verify":
service.Verify( location, true );
break;
}
rockContext.SaveChanges();
}
BindFamilies();
}
示例5: btnStandardize_Click
/// <summary>
/// Handles the Click event of the btnStandardize 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 btnStandardize_Click( object sender, EventArgs e )
{
int locationId = int.Parse( hfLocationId.Value );
var rockContext = new RockContext();
var service = new LocationService( rockContext );
var location = service.Get( locationId );
acAddress.GetValues( location );
service.Verify( location, true );
acAddress.SetValues( location );
geopPoint.SetValue( location.GeoPoint );
lStandardizationUpdate.Text = String.Format( "<div class='alert alert-info'>Standardization Result: {0}<br/>Geocoding Result: {1}</div>",
location.StandardizeAttemptedResult.IfEmpty( "No Result" ),
location.GeocodeAttemptedResult.IfEmpty( "No Result" ) );
}
示例6: Execute
/// <summary>
/// Job that updates the JobPulse setting with the current date/time.
/// This will allow us to notify an admin if the jobs stop running.
///
/// Called by the <see cref="IScheduler" /> when a
/// <see cref="ITrigger" /> fires that is associated with
/// the <see cref="IJob" />.
/// </summary>
public virtual void Execute(IJobExecutionContext context)
{
// get the job map
JobDataMap dataMap = context.JobDetail.JobDataMap;
int maxRecords = Int32.Parse( dataMap.GetString( "MaxRecordsPerRun" ) );
int throttlePeriod = Int32.Parse( dataMap.GetString( "ThrottlePeriod" ) );
int retryPeriod = Int32.Parse( dataMap.GetString( "RetryPeriod" ) );
DateTime retryDate = DateTime.Now.Subtract(new TimeSpan(retryPeriod, 0, 0, 0));
var rockContext = new Rock.Data.RockContext();
LocationService locationService = new LocationService(rockContext);
var addresses = locationService.Queryable()
.Where( l =>
(
( l.IsGeoPointLocked == null || l.IsGeoPointLocked == false ) &&// don't ever try locked address
l.IsActive == true &&
l.Street1 != null &&
l.Street1 != "" &&
l.City != null &&
l.City != "" &&
(
( l.GeocodedDateTime == null && ( l.GeocodeAttemptedDateTime == null || l.GeocodeAttemptedDateTime < retryDate ) ) || // has not been attempted to be geocoded since retry date
( l.StandardizedDateTime == null && ( l.StandardizeAttemptedDateTime == null || l.StandardizeAttemptedDateTime < retryDate ) ) // has not been attempted to be standardize since retry date
)
) )
.Take( maxRecords ).ToList();
int attempts = 0;
int successes = 0;
foreach ( var address in addresses )
{
attempts++;
if ( locationService.Verify( address, true ) )
{
successes++;
}
rockContext.SaveChanges();
System.Threading.Thread.Sleep( throttlePeriod );
}
context.Result = string.Format( "{0:N0} address verifications attempted; {1:N0} successfully verified", attempts, successes );
}
示例7: rptrAddresses_ItemCommand
/// <summary>
/// Handles the ItemCommand event of the rptrAddresses control.
/// </summary>
/// <param name="source">The source of the event.</param>
/// <param name="e">The <see cref="RepeaterCommandEventArgs"/> instance containing the event data.</param>
protected void rptrAddresses_ItemCommand( object source, RepeaterCommandEventArgs e )
{
int locationId = int.MinValue;
if ( int.TryParse( e.CommandArgument.ToString(), out locationId ) )
{
using ( var rockContext = new RockContext() )
{
var service = new LocationService( rockContext );
var location = service.Get( locationId );
if ( location != null )
{
switch ( e.CommandName )
{
case "verify":
{
service.Verify( location, true );
rockContext.SaveChanges();
break;
}
case "settings":
{
NavigateToLinkedPage( "LocationDetailPage",
new Dictionary<string, string> { { "LocationId", location.Id.ToString() }, { "PersonId", Person.Id.ToString() } } );
break;
}
}
}
}
}
BindGroups();
}