Пример #1
0
 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;
     }
 }
Пример #2
0
 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));
 }
Пример #3
0
 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);
 }
Пример #4
0
 public void Execute(ConfigHelper cfg)
 {
     using (var sf = ServerFacade.Create(cfg.ModelloDatabase, cfg.StringaDiConnessione)) {
         try {
             sf.BeginTransaction();
             foreach (var job in _jobs)
                 if (job.CanExecute)
                     job.Execute(sf, cfg);
             sf.Commit();
         } catch (Exception e) {
             if (sf.Transaction != null)
                 sf.Rollback();
             _logger.Log("Errore in onTimer", e);
         }
     }
 }
Пример #5
0
 public abstract Map Execute(Map input, ServerFacade sf, ConfigHelper cfg, out bool hasMore, out bool cut);
Пример #6
0
 public void StartServer(MainForm frm)
 {
     _mainForm = frm;
     try {
         log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Utils.GetMainFolder(), "log4net.config")));
     } catch (Exception e) {
         this.Log(string.Format("Impossibile accedere alla cartella {0}: {1}", Utils.GetMainFolder(), e.Message), true);
         this.Log("Verificare di avere i permessi di scrittura sulla cartella");
         this.Log("Oppure ripetere l'installazione indicando una cartella diversa");
         return;
     }
     try {
         _cfg = new ConfigHelper(Path.Combine(Utils.GetMainFolder(), "Web.xml"));
         if (_cfg.ModelloDatabase == "") {
             this.Log("Mancano le informazioni per accedere al db", true);
             return;
         }
         Log(_cfg.StringaDiConnessione);
         Utils.CheckDatabase(_cfg.ModelloDatabase, _cfg.StringaDiConnessione, out _dbAvviato, out _dbMessage);
         if (!_dbAvviato) {
             this.Log("Impossibile accedere al db: " + _dbMessage, true);
             return;
         }
         PluginHelper.Initialize();
         _timerInterval = _cfg.MainTimer;
         _timer = new Timer(new TimerCallback(this.OnTimer), this, 0, _timerInterval * 1000);
         this.Log(string.Format("Servizio avviato - connessione a database {0} ok; refresh ogni {1} secondi", _cfg.ModelloDatabase, _cfg.MainTimer), true);
     } catch (Exception e) {
         this.Log("Impossibile avviare il servizio", e);
     }
 }