private WorkflowContext Run(WorkflowProcess process, Dictionary <String, object> processParameters) { var contextData = new WorkflowContextData(process != null ? process.Id : Guid.Empty, UserId); var context = new WorkflowContext(contextData, Provider); context.SetVariables(processParameters); if (process != null) { if (process.StartActivityId == Guid.Empty) { throw new ApplicationException("Для процесса не задан StartActivity"); } ScriptManager.LoadScript(process.Script); context.RunActivity(process.StartActivityId); return(RunActivities(context)); } context.ThrowException("No Process", "Процесс не существует!"); return(context); }
public override void Execute(WorkflowContext context, IAppServiceProvider provider, IDataContext dataContext) { /* * Действие (Execute) StartActivity заключается в том, * что выполняется переход к следующему действию. */ /*var queryTargetId = from l in dataContext.ObjectDefs.OfType<Activity_Link>() * where l.Source_Id == Id //context.ActivityId //&& l.Parent_Id == context.ProcessId * && (l.Deleted == null || l.Deleted == false) * select l.Target_Id;*/ var link = TargetLinks != null?TargetLinks.FirstOrDefault(l => l.UserActionId == null) : null; if (link == null) //(!queryTargetId.Any()) { context.ThrowException("", "Не удалось найти действие для продолжения"); return; } Guid?newGuid = link.TargetId; //queryTargetId.First(); if (!newGuid.HasValue) { context.ThrowException("", "В Activity_Link не указано следующее действие (TargetId)"); return; } context.RunActivity(newGuid.Value); }
private WorkflowContext RunSubProcess(WorkflowProcess process, WorkflowContext context) { if (process != null) { ScriptManager.LoadScript(process.Script); context.RunActivity(process.StartActivityId); return(RunProcessActivities(context)); } context.ThrowException("No Process", "Процесс не существует!"); return(RunProcessActivities(context)); }
public virtual void Execute(WorkflowContext context, IAppServiceProvider provider, IDataContext dataContext) { try { Guid?id = GetNextActivityId(context); if (id != null) { context.RunActivity((Guid)id); } else { context.ThrowException("Unexpected end of process", "Неожиданное завершение процесса"); } } catch (Exception e) { context.ThrowException(e); } }