public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { var mc = new MiniClient(Utils.EvalExpression(this.GetString("content"), input).Trim(), 60000); var data = mc.Get(""); hasMore = cut = false; return Map.FromJsonObject(data); }
public Modifica(ServerFacade sf, Map map) { this.Copy(map); if (this.IsModificaAnagrafica || this.IsModificaProfilo) { Map anagrafica = Utils.Read(sf, "SELECT * FROM anagrafico a, profilo p WHERE a.id = @_iKey_int AND p.idUtilizzatore = a.id AND p.dataInizio < @_dtAdesso AND (p.DataFine IS NULL OR p.DataFine > @_dtAdesso)", this); this["anagrafica"] = anagrafica; this["ufficio"] = Utils.Read(sf, "SELECT * FROM UnitaPianta WHERE id = @_iIdUfficioVisitato", anagrafica); } else if (this.IsModificaImmagine) { Map anagrafica = Utils.Read(sf, "SELECT * FROM anagrafico a, profilo p WHERE a.id = @_iKey_int AND p.idUtilizzatore = a.id AND p.dataInizio < @_dtAdesso AND (p.DataFine IS NULL OR p.DataFine > @_dtAdesso)", this); Image img = Utils.ReadImageFile(anagrafica.GetString("imgdip")); if (img != null) { this["immagine"] = Utils.ResizeImage(img, 200, 200); this["immaginethumb"] = Utils.ResizeImage(img, 80, 80); } } else if (this.IsModificaVisite) { Map visita = Utils.Read(sf, "SELECT * FROM visite WHERE codicebadge = @Key_char AND datainiziobadge = @_dtKey_date", this); Map anagrafica = Utils.Read(sf, "SELECT a.*, p.* FROM badge b, anagrafico a, profilo p WHERE b.codicebadge = @Key_char AND b.datainiziobadge = @_dtKey_date AND b.idUtilizzatore = a.id AND p.idUtilizzatore = a.id AND p.dataInizio < @_dtAdesso AND (p.DataFine IS NULL OR p.DataFine > @_dtAdesso)", this); this["visita"] = visita; this["anagrafica"] = anagrafica; this["visitato"] = Utils.Read(sf, "SELECT * FROM anagrafico a, profilo p WHERE a.id = @_iIdVisitato AND p.idUtilizzatore = a.id AND p.dataInizio < @_dtAdesso AND (p.DataFine IS NULL OR p.DataFine > @_dtAdesso)", visita); this["ufficio"] = Utils.Read(sf, "SELECT * FROM UnitaPianta WHERE id = @_iIdUfficioVisitato", anagrafica); } else if (this.IsModificaTimbratura) { this["presenti"] = Utils.ReadValue(sf.InstanceExecuteReader("SELECT MAX(id) FROM PresentiPerArea", new Map()), 0); } else if (this.IsModificaUtenti) { this["utente"] = Utils.Read(sf, "SELECT * FROM Utenti WHERE id = @_iKey_int", this); } }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = false; var text = this.GetString("content"); var cached = this["cached"] as ScriptEngine; if (cached == null) { var script = new ScriptEngine(); script.References("Solari.Core.dll"); script.Using("Solari.Core"); script.DeclareGlobal("sf", typeof(ServerFacade), sf); script.DeclareGlobal("cfg", typeof(Map), cfg.Data); script.DeclareGlobal("context", typeof(Map), this); try { script.SetCode("public bool Filter(Map input) { " + text + " ; return false; }"); script.Compile(); this["cached"] = script; cut = !(bool)script.Execute("Filter", input); return input; } catch (Exception ex) { throw new ScriptingException(ex); } } else { var script = cached; try { cut = !(bool)script.Execute("Filter", input); return input; } catch (Exception ex) { throw new ScriptingException(ex); } } }
private Map ExecuteUnit(UnitOfWork unit, Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { try { return unit.Execute(input, sf, cfg, out hasMore, out cut); } catch (Exception ex) { _logger.Log(string.Format("Errore nell'esecuzione della unit {0}", unit.Label), ex); throw; } }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = false; cut = false; string testo; if (VelocityHelper.RenderStringTemplateToString(this.GetString("content"), input, out testo) && testo.Length > 0) SendMail(input, cfg.Data); return input; }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = cut = false; var fields = this.GetString("fields").Split(','); var data = Utils.SelectValues(input, this.GetString("path")); if (data != null) using (TextWriter tw = new StreamWriter(Utils.EvalExpression(this.GetString("outfile"), input))) { foreach (Map map in data) WriteCsvMap(tw, map, fields); } return input; }
public void Execute(ServerFacade sf, ConfigHelper cfg) { _logger.Log(string.Format("Inizia l'esecuzione di {0} {1} units", _id, _units.Count)); if (_units.Count == 0) return; _logger.Debug(PrettyPrinter.PrettyPrint(_units)); try { InternalExecute(_units, new Map(), sf, cfg); } catch (Exception e) { _logger.Log("Esecuzione interrotta", e); } _logger.Log(string.Format("Terminata l'esecuzione di {0} {1} units", _id, _units.Count)); }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { var vett = Utils.SelectValues(input, this.GetString("path")); var ret = new Map(); var idx = -1; if (vett != null) { idx = this.GetInt("__IDX__", 0); this["__IDX__"] = idx + 1; if (idx < vett.Count) ret = vett[idx] as Map; } hasMore = vett != null && idx < vett.Count - 1; cut = false; return ret; }
private void InternalExecute(ArrayList units, Map input, ServerFacade sf, ConfigHelper cfg) { if (units.Count == 0) return; var unit = PluginHelper.GetUnitOfWork(units[0] as Map); _logger.Log(string.Format("Inizia l'esecuzione della unit {0}", unit.Label)); // _logger.Debug(PrettyPrinter.PrettyPrint(input)); bool more; do { bool cut; var tempData = input.DeepCopy(); tempData = ExecuteUnit(unit, tempData, sf, cfg, out more, out cut); if (!cut) InternalExecute(new ArrayList(units.GetRange(1, units.Count - 1)), tempData, sf, cfg); if (more) _logger.Log(string.Format("Continua l'esecuzione della unit {0}", unit.Label)); } while (more); }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = false; if (!this.ContainsKey("__DATA__")) { var text = this.GetString("content"); this["__DATA__"] = Utils.List(sf, text, input); } var vett = this.GetArray("__DATA__"); var ret = new Map(); var idx = -1; if (vett != null) { idx = this.GetInt("__IDX__", 0); this["__IDX__"] = idx + 1; if (idx < vett.Count) ret = vett[idx] as Map; } hasMore = vett != null && idx < vett.Count - 1; cut = false; return ret; }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = cut = false; var text = this.GetString("content"); var cached = this["cached"] as ScriptEngine; if (cached == null) { System.Diagnostics.Debug.WriteLine("Compila script per " + this.Uid); var script = new ScriptEngine(); script.References("Solari.Core.dll"); script.Using("Solari.Core"); script.DeclareGlobal("sf", typeof (ServerFacade), sf); script.DeclareGlobal("cfg", typeof (Map), cfg.Data); script.DeclareGlobal("context", typeof (Map), this); script.DeclareGlobal("hasMore", typeof (bool), false); try { script.SetCode("public Map DoExecute(Map input) { hasMore = false; " + text + " ; return input; }"); script.Compile(); this["cached"] = script; var ret = script.Execute("DoExecute", input) as Map; hasMore = (bool) script.GlobalGet("hasMore"); return ret; } catch (Exception ex) { throw new ScriptingException(ex); } } else { System.Diagnostics.Debug.WriteLine("Trova in cache script per " + this.Uid); var script = cached; try { var ret = script.Execute("DoExecute", input) as Map; hasMore = (bool)script.GlobalGet("hasMore"); return ret; } catch (Exception ex) { throw new ScriptingException(ex); } } }
public static ArrayList List(ServerFacade sf, string query, Map parms) { var ret = new ArrayList(); using (var rdr = sf.InstanceExecuteReader(query, parms)) { while (rdr != null && rdr.Read()) { var map = new Map(); DbHelper.FillHashtable(rdr, map); ret.Add(map); } } return ret; }
public static void CaricaDati(ServerFacade sf, out ArrayList ret, out int idPresenti) { ret = new ArrayList(); idPresenti = 0; foreach (Map map in Utils.List(sf, "SELECT * FROM coda_escape ORDER BY ID", new Map())) { Modifica m = new Modifica(sf, map); ret.Add(m); if (m.IsModificaTimbratura && idPresenti == 0) idPresenti = m.GetInt("presenti.id"); } }
public SfCommand(ServerFacade sf, string sql) { _originalText = sql; if (_originalText != "") PreProcess(sf); }
private void PreProcess(ServerFacade sf) { foreach (string singleCommand in _originalText.Split(';')) { string modified = singleCommand; CommandType ct = CommandType.Text; string[] parms= sf.PrepareParameters(ref modified, ref ct); _modifiedText.Add(modified); _commandType.Add(ct); _params.Add(parms); } }
public abstract Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut);
public FinderBase Finder(System.Type t, ServerFacade sf) { t = GetOverrider(t); return (FinderBase)PluginHelper.Instance.CreateInstance(t.Assembly.GetName().Name, t.FullName + "Finder", new object[] { t, sf }); }
public override Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut) { hasMore = cut = false; var strData = File.ReadAllText(this.GetString("infile")); return Map.FromXmlObject(strData).GetMap(this.GetString("path")); }
public FinderBase(System.Type t, ServerFacade sf) { _baseType = t; _sf = sf; }
public static Map Read(ServerFacade sf, string query, Map parms) { using (var rdr = sf.InstanceExecuteReader(query, parms)) { if (rdr != null && rdr.Read()) { var ret = new Map(); DbHelper.FillHashtable(rdr, ret); return ret; } } return null; }