本文整理汇总了C#中Rock.Data.RockContext类的典型用法代码示例。如果您正苦于以下问题:C# RockContext类的具体用法?C# RockContext怎么用?C# RockContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RockContext类属于Rock.Data命名空间,在下文中一共展示了RockContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified workflow action.
/// </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? personAliasGuid = GetAttributeValue( action, "Person" ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Queryable( "Person" )
.Where( a => a.Guid.Equals( personAliasGuid.Value ) )
.FirstOrDefault();
if (personAlias != null)
{
action.Activity.AssignedPersonAlias = personAlias;
action.Activity.AssignedPersonAliasId = personAlias.Id;
action.Activity.AssignedGroup = null;
action.Activity.AssignedGroupId = null;
action.AddLogEntry( string.Format( "Assigned activity to '{0}' ({1})", personAlias.Person.FullName, personAlias.Person.Id ) );
return true;
}
}
return false;
}
示例2: Execute
/// <summary>
/// Execute method to write transaction to the database.
/// </summary>
public void Execute()
{
using ( var rockContext = new RockContext() )
{
var docTypeService = new SignatureDocumentTemplateService( rockContext );
var docService = new SignatureDocumentService( rockContext );
var document = docService.Get( SignatureDocumentId );
if ( document != null )
{
var status = document.Status;
int? binaryFileId = document.BinaryFileId;
string folderPath = System.Web.Hosting.HostingEnvironment.MapPath( "~/App_Data/Cache/SignNow" );
var updateErrorMessages = new List<string>();
if ( docTypeService.UpdateDocumentStatus( document, folderPath, out updateErrorMessages ) )
{
if ( status != document.Status || !binaryFileId.Equals( document.BinaryFileId ) )
{
rockContext.SaveChanges();
}
}
}
}
}
示例3: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
private void LoadDropDowns()
{
ddlEntityType.Items.Clear();
var rockContext = new RockContext();
new EntityTypeService( rockContext ).GetEntityListItems().ForEach( l => ddlEntityType.Items.Add( l ) );
ddlWorkflowType.Items.Clear();
ddlWorkflowType.Items.Add( new ListItem( string.Empty, string.Empty));
foreach ( var workflowType in new WorkflowTypeService( rockContext ).Queryable().OrderBy( w => w.Name ) )
{
if ( workflowType.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
ddlWorkflowType.Items.Add( new ListItem( workflowType.Name, workflowType.Id.ToString() ) );
}
}
rblTriggerType.Items.Clear();
Type type = typeof(WorkflowTriggerType);
foreach ( var value in Enum.GetValues( type ) )
{
rblTriggerType.Items.Add( new ListItem( Enum.GetName( type, value ).SplitCase().Replace( " ", "-" ), Convert.ToInt32( value ).ToString() ) );
}
}
示例4: NotifyAdmins
/// <summary>
/// Notifies the admins.
/// </summary>
/// <param name="subject">The subject.</param>
/// <param name="message">The message.</param>
/// <param name="appRoot">The application root.</param>
/// <param name="themeRoot">The theme root.</param>
/// <param name="createCommunicationHistory">if set to <c>true</c> [create communication history].</param>
/// <exception cref="System.Exception">Error sending System Email: Could not read Email Medium Entity Type</exception>
public static void NotifyAdmins( string subject, string message, string appRoot = "", string themeRoot = "", bool createCommunicationHistory = true )
{
try
{
List<string> recipients = null;
Guid adminGroup = Rock.SystemGuid.Group.GROUP_ADMINISTRATORS.AsGuid();
using ( var rockContext = new RockContext() )
{
recipients = new GroupMemberService( rockContext ).Queryable()
.Where( m =>
m.Group.Guid.Equals( adminGroup ) &&
m.GroupMemberStatus == GroupMemberStatus.Active &&
m.Person.Email != null &&
m.Person.Email != "" )
.Select( m => m.Person.Email )
.ToList();
}
Email.Send(GlobalAttributesCache.Value("OrganizationEmail"), subject, recipients, message, appRoot, themeRoot, null, createCommunicationHistory );
}
catch ( Exception ex )
{
ExceptionLogService.LogException( ex, HttpContext.Current );
}
}
示例5: gBinaryFile_Delete
/// <summary>
/// Handles the Delete event of the gBinaryFile control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gBinaryFile_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
BinaryFile binaryFile = binaryFileService.Get( e.RowKeyId );
if ( binaryFile != null )
{
string errorMessage;
if ( !binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
Guid guid = binaryFile.Guid;
bool clearDeviceCache = binaryFile.BinaryFileType.Guid.Equals( Rock.SystemGuid.BinaryFiletype.CHECKIN_LABEL.AsGuid() );
binaryFileService.Delete( binaryFile );
rockContext.SaveChanges();
if ( clearDeviceCache )
{
Rock.CheckIn.KioskDevice.FlushAll();
Rock.CheckIn.KioskLabel.Flush( guid );
}
}
BindGrid();
}
示例6: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
foreach ( var family in checkInState.CheckIn.GetFamilies( true ) )
{
foreach ( var person in family.People )
{
foreach ( var kioskGroupType in checkInState.Kiosk.ActiveGroupTypes( checkInState.ConfiguredGroupTypes ) )
{
if ( kioskGroupType.KioskGroups.SelectMany( g => g.KioskLocations ).Any( l => l.IsCheckInActive && l.IsActiveAndNotFull ) )
{
if ( !person.GroupTypes.Any( g => g.GroupType.Id == kioskGroupType.GroupType.Id ) )
{
var checkinGroupType = new CheckInGroupType();
checkinGroupType.GroupType = kioskGroupType.GroupType;
person.GroupTypes.Add( checkinGroupType );
}
}
}
}
}
return true;
}
return false;
}
示例7: LoadDropDownItems
/// <summary>
/// Loads the drop down items.
/// </summary>
private void LoadDropDownItems()
{
this.Items.Clear();
if ( _entityTypeId.HasValue )
{
// add Empty option first
this.Items.Add( new ListItem() );
using ( var rockContext = new RockContext() )
{
var allEntityFilters = new DataViewFilterService( rockContext )
.Queryable().AsNoTracking()
.Where( f => f.EntityTypeId == _entityTypeId )
.ToList();
foreach ( var dataView in new DataViewService( rockContext )
.GetByEntityTypeId( _entityTypeId.Value )
.Include( "EntityType" )
.Include( "Category" )
.Include( "DataViewFilter" )
.AsNoTracking() )
{
var currentPerson = HttpContext.Current.Items["CurrentPerson"] as Person;
if ( dataView.IsAuthorized( Authorization.VIEW, currentPerson ) &&
dataView.DataViewFilter.IsAuthorized( Authorization.VIEW, currentPerson, allEntityFilters ) )
{
this.Items.Add( new ListItem( dataView.Name, dataView.Id.ToString() ) );
}
}
}
}
}
示例8: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
foreach ( var family in checkInState.CheckIn.Families.ToList() )
{
foreach ( var person in family.People.ToList() )
{
if ( person.GroupTypes.Count == 0 )
{
family.People.Remove( person );
}
else if ( person.GroupTypes.All( t => t.ExcludedByFilter ) )
{
person.ExcludedByFilter = true;
}
}
}
return true;
}
return false;
}
示例9: mdEdit_SaveClick
/// <summary>
/// Handles the SaveClick event of the mdEdit 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 mdEdit_SaveClick( object sender, EventArgs e )
{
var rockContext = new RockContext();
EntityTypeService entityTypeService = new EntityTypeService( rockContext );
EntityType entityType = entityTypeService.Get( int.Parse( hfEntityTypeId.Value ) );
if ( entityType == null )
{
entityType = new EntityType();
entityType.IsEntity = true;
entityType.IsSecured = true;
entityTypeService.Add( entityType );
}
entityType.Name = tbName.Text;
entityType.FriendlyName = tbFriendlyName.Text;
entityType.IsCommon = cbCommon.Checked;
rockContext.SaveChanges();
EntityTypeCache.Flush( entityType.Id );
hfEntityTypeId.Value = string.Empty;
HideDialog();
BindGrid();
}
示例10: gGroupType_Delete
/// <summary>
/// Handles the Delete event of the gGroupType control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gGroupType_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
GroupType groupType = groupTypeService.Get( e.RowKeyId );
if ( groupType != null )
{
int groupTypeId = groupType.Id;
if ( !groupType.IsAuthorized( "Administrate", CurrentPerson ) )
{
mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
return;
}
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
groupType.ParentGroupTypes.Clear();
groupType.ChildGroupTypes.Clear();
groupTypeService.Delete( groupType );
rockContext.SaveChanges();
GroupTypeCache.Flush( groupTypeId );
}
BindGrid();
}
示例11: SQLLoggingStart
/// <summary>
/// Starts logging all EF SQL Calls to the Debug Output Window as T-SQL Blocks
/// </summary>
/// <param name="rockContext">The rock context to limit the output to. Leave blank to show output for all rockContexts.</param>
public static void SQLLoggingStart( RockContext rockContext = null )
{
_callCounts = 0;
SQLLoggingStop();
_debugLoggingDbCommandInterceptor.RockContext = rockContext;
DbInterception.Add( _debugLoggingDbCommandInterceptor );
}
示例12: LaunchTheWorkflow
/// <summary>
/// Launch the workflow
/// </summary>
protected void LaunchTheWorkflow(string workflowName)
{
Guid workflowTypeGuid = Guid.NewGuid();
if ( Guid.TryParse( workflowName, out workflowTypeGuid ) )
{
var rockContext = new RockContext();
var workflowTypeService = new WorkflowTypeService(rockContext);
var workflowType = workflowTypeService.Get( workflowTypeGuid );
if ( workflowType != null )
{
var workflow = Rock.Model.Workflow.Activate( workflowType, workflowName );
List<string> workflowErrors;
if ( workflow.Process( rockContext, out workflowErrors ) )
{
if ( workflow.IsPersisted || workflowType.IsPersisted )
{
var workflowService = new Rock.Model.WorkflowService(rockContext);
workflowService.Add( workflow );
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
}
}
}
}
}
示例13: 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 guid = GetAttributeValue( action, "Attribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = GetAttributeValue( action, "Value" );
value = value.ResolveMergeFields( GetMergeFields( action ) );
if ( attribute.EntityTypeId == new Rock.Model.Workflow().TypeId )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, value ) );
}
else if ( attribute.EntityTypeId == new Rock.Model.WorkflowActivity().TypeId )
{
action.Activity.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, value ) );
}
}
}
return true;
}
示例14: Execute
/// <summary>
/// Executes this instance.
/// </summary>
public void Execute()
{
using ( var rockContext = new RockContext() )
{
var gateway = new FinancialGatewayService( rockContext ).Get( GatewayId );
if ( gateway != null )
{
var gatewayComponent = gateway.GetGatewayComponent();
if ( gatewayComponent != null )
{
var scheduledTxnService = new FinancialScheduledTransactionService( rockContext );
foreach( var txnId in ScheduledTransactionIds )
{
var scheduledTxn = scheduledTxnService.Get( txnId );
if ( scheduledTxn != null )
{
string statusMsgs = string.Empty;
gatewayComponent.GetScheduledPaymentStatus( scheduledTxn, out statusMsgs );
rockContext.SaveChanges();
}
}
}
}
}
}
示例15: BindPackageGrid
/// <summary>
/// Binds the package grid.
/// </summary>
public void BindPackageGrid()
{
using ( var rockContext = new RockContext() )
{
var definedValues = new DefinedValueService( rockContext )
.GetByDefinedTypeGuid( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() )
.ToList();
foreach( var definedValue in definedValues )
{
definedValue.LoadAttributes( rockContext );
}
gDefinedValues.DataSource = definedValues.Select( v => new
{
v.Id,
v.Value,
v.Description,
PackageName = v.GetAttributeValue( "PMMPackageName" ),
DefaultCounty = v.GetAttributeValue( "DefaultCounty" ),
SendAddressCounty = v.GetAttributeValue( "SendHomeCounty" ).AsBoolean(),
DefaultState = v.GetAttributeValue( "DefaultState" ),
SendAddressState = v.GetAttributeValue( "SendHomeState" ).AsBoolean(),
MVRJurisdication = v.GetAttributeValue("MVRJurisdiction"),
SendAddressStateMVR = v.GetAttributeValue( "SendHomeStateMVR" ).AsBoolean()
} )
.ToList();
gDefinedValues.DataBind();
}
}