private PDCacheEntry TryReloadProcessDef(ProcessDef pd) { string ckey = pd.ShortDefinitionId.ToLower(); var errs = new List <string>(); if (!ValidateProcessDef(pd, errs)) { throw new Exception("Process definition invalid: " + string.Join(";\n", errs)); } string script = ProcessBooScriptGenerator.GenerateScriptString(pd); string surl = "PScript_" + Guid.NewGuid().ToString("N"); _storage.AddScript(surl, script); try { var t = _dsl.TryRecompile(surl, RD.CompilationMode.Compile); var cd = new PDCacheEntry { Process = pd, ReadDate = DateTime.Now, ScriptUrl = surl }; return(cd); } catch (Exception) { _storage.Invalidate(surl); throw; } }
public void GenerateScript(ProcessDef pd) { WriteLine("#########"); WriteLine("# this script is generated by an automatic tool. Do not modify it because your changes might be overwritten"); WriteLine("#########"); WriteCompositeTask(pd.Body); }
public static string GenerateScriptString(ProcessDef pd) { var sw = new StringWriter(); GenerateScript(pd, sw); return(sw.ToString()); }
public static void GenerateScript(ProcessDef pd, TextWriter output) { var gd = new ProcessBooScriptGenerator(output); gd.GenerateScript(pd); output.Flush(); }
public static string Serialize(ProcessDef pd) { var sw = new StringWriter(); Serialize(pd, sw); return(sw.ToString()); }
public static void SerializeToFile(ProcessDef pd, string fileName) { using (var sw = new StreamWriter(fileName, false, Encoding.UTF8)) { Serialize(pd, sw); } }
public static void GenerateScript(ProcessDef pd, string outputDirectory) { string fn = Path.Combine(outputDirectory, string.Format("{0}.{1}.boo", pd.ProcessName, pd.Version)); using (var sw = new StreamWriter(fn, false, Encoding.UTF8)) { GenerateScript(pd, sw); } }
public void Implement(IAlgorithmBuilder builder) { if (ProcessDef == null) { throw new InvalidOperationException("No valid process definition"); } ProcessDef.Implement(builder); }
public virtual void Activate(ITaskExecutionContext ctx, ProcessDef processDef, IProcessScriptRuntime scriptRuntime) { Context = ctx; ProcessDefinition = processDef; TaskDefinition = processDef.GetRequiredTask(this.TaskId); ScriptRuntime = scriptRuntime; if (TaskDefinition == null) { throw new Exception("Task not found in process definition: " + this.TaskId); } }
private bool ValidateProcessDef(ProcessDef pd, List <string> errors = null, List <string> warnings = null) { if (!pd.Validate(errors)) { return(false); } var script = ProcessBooScriptGenerator.GenerateScriptString(pd); if (!_dsl.CheckSyntax(script, errors, warnings)) { return(false); } return(true); }
/// <summary> /// Attempts to update process definition. If the attempt fails current definition will not /// be modified. /// </summary> /// <param name="pd"></param> /// <param name="errors"></param> /// <returns></returns> public bool TryUpdateProcess(ProcessDef pd) { EnsureProcessesLoaded(); var ce = TryReloadProcessDef(pd); string fn = Path.Combine(BaseDir, pd.ShortDefinitionId + ".npd"); log.Info("Saving process file {0}", fn); using (var sw = new StreamWriter(fn, false, Encoding.UTF8)) { ProcessDefJsonSerializer.Serialize(ce.Process, sw); } ce.ReadDate = DateTime.Now; _processCache.AddOrUpdate(ce.Process.ShortDefinitionId.ToLower(), ce, (id, oc) => ce); return(true); }
public bool ValidateAndSaveProcessDefinition(ProcessDef pd, bool save, out List <string> errors, out List <string> warnings) { EnsureProcessesLoaded(); errors = new List <string>(); warnings = new List <string>(); if (!ValidateProcessDef(pd, errors, warnings)) { return(false); } if (save) { if (!TryUpdateProcess(pd)) { return(false); } } return(true); }
public ProcessDef GetProcessDef() { _curProcessDef = new ProcessDef(); string name = this.GetType().FullName; int idx = name.LastIndexOf('.'); if (idx < 0) { throw new Exception("Invalid type name"); } _curProcessDef.PackageName = Package == null ? null : Package.Name; _curProcessDef.ProcessName = name.Substring(0, idx); _curProcessDef.Version = Int32.Parse(name.Substring(idx + 1)); _curProcessDef.Version = 1; _curProcessDef.DataTypes = new TypeSet(); _currentCompositeTask = new CompositeTaskDef { Id = _curProcessDef.ProcessName }; _curProcessDef.Body = _currentCompositeTask; Prepare(); _curProcessDef.FinishModelBuild(); return(_curProcessDef); }
public int Process(ProcessDef strategy) { return(strategy(data)); }
public void Initialize(ProcessDef pd, BooProcessPackage pp) { ProcessDefinition = pd; Package = pp; Prepare(); }
internal BooProcessScriptRuntime(ProcessRuntimeDSLBase pd) { _pd = pd; _def = pd.ProcessDefinition; }
protected void GenerateScript(ProcessDef pd) { GenerateScript(pd.Body); }
public static void Serialize(ProcessDef pd, TextWriter output) { _ser.Serialize(new JsonTextWriter(output), pd); }
internal BooDslProcessRuntime(ProcessDefDSLBase pd) { _pd = pd; _def = pd.GetProcessDef(); }
public int Process(ProcessDef strategy) { //todo:ellenörzés return(strategy(data)); }
public JsonResult SaveProcessDefine() { AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed, PromptMsg = "操作失败" }; try { string json = Request.Form["processDefContent"]; ProcessDefine processDefine = JsonConvert.DeserializeObject<ProcessDefine>(json, new ActivityConvert()); string processDefContent = processDefine.ToXml(); string name = Request.Form["Name"]; string text = Request.Form["text"]; string version = Request.Form["version"]; string description = Request.Form["description"]; string startor = Request.Form["startor"]; string isActive = Request.Form["isActive"]; string categoryID = Request.Form["categoryID"]; string currentFlag = Request.Form["currentFlag"]; string currentStatus = Request.Form["currentStatus"]; string processDefID = Request.Form["processDefID"]; if (!string.IsNullOrEmpty(processDefContent)) { string ID = IdGenerator.NewGuid().ToString(); if (!string.IsNullOrEmpty(processDefID)) { ID = processDefID; } ProcessDef proDef = repository.Query<ProcessDef>().Where(p => p.ID != processDefID && p.Name == processDefine.ID && p.Version == processDefine.Version).FirstOrDefault(); if (proDef != null) { ajaxResult.RetValue = false; ajaxResult.Result = DoResult.Success; ajaxResult.PromptMsg = "操作失败,该流程已经存在,选择该流程修改"; } else { ProcessDef processDef = new ProcessDef() { ID = ID, Name = name, Text = text, Version = version, Description = description, CreateTime = DateTime.Now, Creator = workContext.User.LoginName, Startor = startor, IsActive = isActive.ToShort(), CurrentFlag = currentFlag.ToShort(), CurrentState = currentStatus.ToShort(), Content = processDefContent, CategoryID = categoryID, }; repository.SaveOrUpdate(processDef); ajaxResult.RetValue = processDef; ajaxResult.Result = DoResult.Success; ajaxResult.PromptMsg = "操作成功"; CacheManager.Remove(ID); } } } catch (Exception ex) { log.Error("创建工作流失败" + ex.Message); ajaxResult.RetValue = false; ajaxResult.Result = DoResult.Failed; ajaxResult.PromptMsg = "操作失败"; } return Json(ajaxResult); }
public static void GenerateScript(ProcessDef pd, TextWriter output) { new BooProcessScriptGenerator(output).GenerateScript(pd); output.Flush(); }