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; } }
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); }
private IEnumerable <PDCacheEntry> InitialProcessLoad() { List <PDCacheEntry> entries = new List <PDCacheEntry>(); foreach (string file in Directory.GetFiles(BaseDir, "*.npd")) { try { log.Info("Loading process from {0}", file); var pd = LoadPDFromFile(file); var err = new List <string>(); if (!this.ValidateProcessDef(pd, err)) { log.Warn("Process {0} in {1} is invalid: {2}", pd.DefinitionId, file, string.Join("|", err)); continue; } var script = ProcessBooScriptGenerator.GenerateScriptString(pd); string surl = "PScript_" + Guid.NewGuid().ToString("N"); _storage.AddScript(surl, script); var cd = new PDCacheEntry { Process = pd, ReadDate = DateTime.Now, ScriptUrl = surl }; entries.Add(cd); } catch (Exception ex) { log.Warn("Error loading process file {0}: {1}", file, ex); continue; } } var all = _dsl.CreateAll(); return(entries); }