public override bool Execute(RockContext rockContext, WorkflowAction action, Object entity, out List <string> errorMessages) { errorMessages = new List <string>(); var JobGuid = GetAttributeValue(action, "Job").AsGuid(); if (!JobGuid.IsEmpty()) { ServiceJob Job = new ServiceJobService(rockContext).Get(JobGuid); if (Job != null) { var transaction = new Rock.Transactions.RunJobNowTransaction(Job.Id); // Process the transaction on another thread System.Threading.Tasks.Task.Run(() => transaction.Execute()); action.AddLogEntry(string.Format("The '{0}' job has been started.", Job.Name)); return(true); } } errorMessages.Add("The specified Job could not be found"); return(false); }
/// <summary> /// Handles the SaveClick event of the mdRunNcoa control. This is the Start NCOA dialog. Save = Start /// </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 mdRunNcoa_SaveClick(object sender, EventArgs e) { Ncoa ncoa = new Ncoa(); var sparkDataConfig = Ncoa.GetSettings(); sparkDataConfig.NcoaSettings.PersonFullName = CurrentPerson != null ? CurrentPerson.FullName : null; sparkDataConfig.NcoaSettings.CurrentReportStatus = "Start"; Ncoa.SaveSettings(sparkDataConfig); using (RockContext rockContext = new RockContext()) { ServiceJob job = new ServiceJobService(rockContext).Get(Rock.SystemGuid.ServiceJob.GET_NCOA.AsGuid()); if (job != null) { var transaction = new Rock.Transactions.RunJobNowTransaction(job.Id); // Process the transaction on another thread System.Threading.Tasks.Task.Run(() => transaction.Execute()); mdGridWarning.Show(string.Format("The '{0}' job has been started.", job.Name), ModalAlertType.Information); lbStartNcoa.Enabled = false; } } mdRunNcoa.Hide(); }
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages ) { errorMessages = new List<string>(); var JobGuid = GetAttributeValue( action, "Job" ).AsGuid(); if ( !JobGuid.IsEmpty() ) { ServiceJob Job = new ServiceJobService( rockContext ).Get( JobGuid ); if ( Job != null ) { var transaction = new Rock.Transactions.RunJobNowTransaction( Job.Id ); // Process the transaction on another thread System.Threading.Tasks.Task.Run( () => transaction.Execute() ); action.AddLogEntry( string.Format( "The '{0}' job has been started.", Job.Name ) ); return true; } } errorMessages.Add("The specified Job could not be found"); return false; }
/// <summary> /// Rebuild the streak type and enrollment data /// </summary> private void RebuildData() { var rockContext = GetRockContext(); var streakType = GetStreakType(); if (!streakType.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson)) { mdDeleteWarning.Show("You are not authorized to rebuild this item.", ModalAlertType.Information); return; } var job = new ServiceJobService(rockContext).Get(Rock.SystemGuid.ServiceJob.REBUILD_STREAK.AsGuid()); if (job == null) { ShowBlockError(nbEditModeMessage, "The streak type rebuild job could not be found."); } var jobData = new Dictionary <string, string> { { Rock.Jobs.RebuildStreakMaps.DataMapKey.StreakTypeId, streakType.Id.ToString() } }; var transaction = new Rock.Transactions.RunJobNowTransaction(job.Id, jobData); System.Threading.Tasks.Task.Run(() => transaction.Execute()); ShowBlockSuccess(nbEditModeMessage, "The streak type rebuild has been started. Check the Rock Jobs page for the status."); }
/// <summary> /// Handles the RunNow event of the gScheduledJobs 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 gScheduledJobs_RunNow(object sender, RowEventArgs e) { var job = new ServiceJobService(new RockContext()).Get(e.RowKeyId); if (job != null) { var transaction = new Rock.Transactions.RunJobNowTransaction(job.Id); // Process the transaction on another thread System.Threading.Tasks.Task.Run(() => transaction.Execute()); mdGridWarning.Show(string.Format("The '{0}' job has been started.", job.Name), ModalAlertType.Information); // wait a split second for the job to start so that the grid will show the status (if it changed) System.Threading.Thread.Sleep(250); } BindGrid(); }
/// <summary> /// Handles the RunNow event of the gScheduledJobs 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 gScheduledJobs_RunNow( object sender, RowEventArgs e ) { var job = new ServiceJobService( new RockContext() ).Get( e.RowKeyId ); if ( job != null ) { var transaction = new Rock.Transactions.RunJobNowTransaction( job.Id ); // Process the transaction on another thread System.Threading.Tasks.Task.Run( () => transaction.Execute() ); mdGridWarning.Show( string.Format( "The '{0}' job has been started.", job.Name ), ModalAlertType.Information ); // wait a split second for the job to start so that the grid will show the status (if it changed) System.Threading.Thread.Sleep( 250 ); } BindGrid(); }