public Tuple <ExecutionResult, StepRuntime> Execute(StepRuntime rt, IProcessRuntimeEnvironment env) { var result = _real.Execute(rt, env); _persistenceService.OnExecute(_real, result, env); return(result); }
/// <summary> /// Unfreeze the process /// </summary> /// <param name="processRuntimeId"></param> /// <param name="runtime"></param> /// <param name="nextStep"></param> /// <param name="collection"></param> /// <returns></returns> public override bool TryUnfreeze(Guid processRuntimeId, out IProcessRuntime runtime, out StepRuntime nextStep, out IPropertySetCollection collection) { runtime = null; collection = null; nextStep = null; using (var ctx = new ProcessDbContext()) { var rtp = ctx.Process.Find(processRuntimeId); if (rtp == null) { return(false); } var definition = JsonConvert.DeserializeObject <ProcessDefinition>(rtp.ProcessDefinition.JsonProcessDefinition); definition.Id = rtp.ProcessDefinition.Id; collection = rtp.PropertyCollection.Deserialize(); if (!string.IsNullOrEmpty(rtp.NextStepId)) { StepDefinition stepDef = definition.Steps.Single(s => s.StepId == rtp.NextStepId); StepDefinitionId sid = new StepDefinitionId(stepDef.Id, stepDef.StepId); LinkDefinition[] links = definition.Links.Where(l => l.Source == sid).ToArray(); nextStep = new StepRuntime(stepDef, links.Select(l => new LinkRuntime(l)).ToArray()); } runtime = Create(rtp.Id, definition, rtp.SuspendedStepId, (ProcessStateEnum)rtp.Status); } return(true); }
// Run the step internal StepResult processStep(StepRuntime step) { // setup var stepResult = new StepResult(); Screenshot before = null, after = null; stepResult.StartingUrl = WebDriver.Url; // ensure it has a step if (string.IsNullOrEmpty(step.StepID)) { step.StepID = Guid.NewGuid().ToString(); } Script.Logger.Log($"******* Step: {step.StepName} ({step.StepID})***********", MessageTypes.General); // take screenshot before actions taken if (step.BeforeScreenshot) { before = takeSnapshot(step.StepID + "_before.png", "Before"); } // user "before" logging userLogging(step.BeforeLog); // do the actions stepResult.ActionResults.AddRange(executeActions(step.Actions)); // check if it did what you expected stepResult.ExpectResults.AddRange(checkExpectations(step.Expectations)); // save value from webpage getValues(step.Getters); // user "after" logging userLogging(step.AfterLog); // take a snapshot after the actions if (step.AfterScreenshot) { after = takeSnapshot(step.StepID + "_after.png", "After"); } // compare before/after screenshots if (step.DiffScreenshot) { snapshotDiff(before, after, step.StepID); } stepResult.EndingUrl = WebDriver.Url; return(stepResult); }
/// <summary> /// Un-freeze the runtime process /// </summary> /// <param name="processRuntimeId"></param> /// <param name="runtime"></param> /// <param name="nextStep"></param> /// <param name="collection"></param> /// <returns></returns> public override bool TryUnfreeze(Guid processRuntimeId, out IProcessRuntime runtime, out StepRuntime nextStep, out IPropertySetCollection collection) { runtime = null; nextStep = null; collection = null; var filter = Builders <MongoProcessRuntimePersistence> .Filter.Eq(r => r.Id, processRuntimeId); MongoProcessRuntimePersistence rtp = _collection.Find(filter).SingleOrDefault(); if (rtp == null) { return(false); } var defFilter = Builders <ProcessDefinitionPersistence> .Filter.And( Builders <ProcessDefinitionPersistence> .Filter.Eq(r => r.FlowId, rtp.DefinitionFlowId), Builders <ProcessDefinitionPersistence> .Filter.Eq(r => r.Md5, rtp.DefinitionMd5) ); ProcessDefinition definition; ProcessDefStatusEnum status; AccountData[] accounts; if (!_processDefinitionService.TryFind(defFilter, out definition, out status, out accounts)) { return(false); } collection = rtp.PropertyCollection.Deserialize(); if (!string.IsNullOrEmpty(rtp.NextStepId)) { StepDefinition stepDef = definition.Steps.SingleOrDefault(s => s.StepId == rtp.NextStepId); StepDefinitionId sid = new StepDefinitionId(stepDef.Id, stepDef.StepId); LinkDefinition[] links = definition.Links.Where(l => l.Source == sid).ToArray(); nextStep = new StepRuntime(stepDef, links.Select(l => new LinkRuntime(l)).ToArray()); } runtime = Create(rtp.Id, definition, rtp.SuspendedStepId, (ProcessStateEnum)rtp.Status); return(true); }