public PluginExecutionResult Execute(PluginExecutionData executionData) { if (!_setupDone) { Setup(executionData); _setupDone = true; } try { _activityData = executionData.GetMetadata <TopCatActivityData>(new[] { new TopCatActivityDataConverter() }); //since we cannot have multiple topcat instances running on the machine, we will use lock var action = new Action(() => { TopCatExecutionController topcatExecution = new TopCatExecutionController(_activityData.Script); if (!_activityData.RunOnce) { topcatExecution.ExecuteTopCatTest(); } ReadResult(topcatExecution.GetResultFilePath(executionData.Environment.PluginSettings["DomainAdminUserName"])); }); ExecutionServices.CriticalSection.Run(new Framework.Synchronization.LocalLockToken($"TopCat Execution:{_activityData.Script.ScriptName}", new TimeSpan(0, 2, 0), new TimeSpan(0, 5, 0)), action); return(new PluginExecutionResult(PluginResult.Passed)); } catch (Exception genericException) { ExecutionServices.SystemTrace.LogDebug(genericException.Message); return(new PluginExecutionResult(PluginResult.Failed, "Activity Failed :", genericException.Message)); } }
/// <summary> /// Performs any teardown activities for plugin which implements this interface /// </summary> public void Teardown() { var action = new Action(() => { _configureScript = new TopCatScript(Path.Combine(Path.GetTempPath(), "TopCatScript", "CustomPrintSettings.tcx"), "CustomPrintSettings"); TopCatExecutionController topCatExecutionController = new TopCatExecutionController(_configureScript); topCatExecutionController.Cleanup(); }); var token = new LocalLockToken(_defaultPrintQueue.FullName, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); ExecutionServices.CriticalSection.Run(token, action); }
public void Setup(PluginExecutionData executionData) { _activityData = executionData.GetMetadata <TopCatActivityData>(new[] { new TopCatActivityDataConverter() }); if (_activityData.Script == null) { ExecutionServices.SystemTrace.LogWarn("No scripts were provided, returning"); return; } if (!string.IsNullOrEmpty(_activityData.SetupFileName)) { ProcessUtil.Execute(CopyInstaller(_activityData.SetupFileName, _activityData.CopyDirectory), string.Empty); } TopCatExecutionController topcatExecution = new TopCatExecutionController(_activityData.Script); topcatExecution.InstallPrerequisites(executionData.Environment.PluginSettings["TopCatSetup"]); if (_activityData.RunOnce) { topcatExecution.ExecuteTopCatTest(); } }