예제 #1
0
파일: Http.cs 프로젝트: mariocosmi/Worker
 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);
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
파일: Where.cs 프로젝트: mariocosmi/Worker
 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);
         }
     }
 }
예제 #4
0
파일: Job.cs 프로젝트: mariocosmi/Worker
 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;
     }
 }
예제 #5
0
파일: Mail.cs 프로젝트: mariocosmi/Worker
        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;
        }
예제 #6
0
 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;
 }
예제 #7
0
파일: Job.cs 프로젝트: mariocosmi/Worker
 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));
 }
예제 #8
0
 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;
 }
예제 #9
0
파일: Job.cs 프로젝트: mariocosmi/Worker
 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);
 }
예제 #10
0
파일: Select.cs 프로젝트: mariocosmi/Worker
 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;
 }
예제 #11
0
파일: Script.cs 프로젝트: mariocosmi/Worker
 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);
         }
     }
 }
예제 #12
0
파일: Utils.cs 프로젝트: mariocosmi/Worker
 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;
 }
예제 #13
0
 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");
     }
 }
예제 #14
0
 public SfCommand(ServerFacade sf, string sql)
 {
     _originalText = sql;
     if (_originalText != "")
         PreProcess(sf);
 }
예제 #15
0
 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);
     }
 }
예제 #16
0
 public abstract Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut);
예제 #17
0
 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 });
 }
예제 #18
0
 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"));
 }
예제 #19
0
 public FinderBase(System.Type t, ServerFacade sf)
 {
     _baseType = t;
     _sf = sf;
 }
예제 #20
0
파일: Utils.cs 프로젝트: mariocosmi/Worker
 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;
 }