private void DeployNowTimer(Object state) { if (executing2) { return; } executing2 = true; try { IAMDatabase db = new IAMDatabase(localConfig.SqlServer, localConfig.SqlDb, localConfig.SqlUsername, localConfig.SqlPassword); db.openDB(); DataTable dtS = db.Select("select entity_id, MAX(date) [date] from deploy_now with(nolock) where date < GETDATE() group by entity_id order by MAX(date)"); if ((dtS == null) || (dtS.Rows.Count == 0)) { return; } TextLog.Log("Dispatcher", "Starting deploy now timer"); //Processa um a um dos agendamentos foreach (DataRow dr in dtS.Rows) { try { Int32 count = 0; using (IAMDeploy deploy = new IAMDeploy("Dispatcher", localConfig.SqlServer, localConfig.SqlDb, localConfig.SqlUsername, localConfig.SqlPassword)) { count = deploy.DeployOne((Int64)dr["entity_id"]); if (count == 0) { db.AddUserLog(LogKey.User_Deploy, null, "Deploy", UserLogLevel.Error, 0, 0, 0, 0, 0, (Int64)dr["entity_id"], 0, "Erro on deploy now user: no package sent", deploy.ExecutionLog); } } db.ExecuteNonQuery("delete from deploy_now where entity_id = " + dr["entity_id"], CommandType.Text, null); } catch (Exception ex2) { db.AddUserLog(LogKey.User_Deploy, null, "Deploy", UserLogLevel.Error, 0, 0, 0, 0, 0, (Int64)dr["entity_id"], 0, "Erro on deploy now user: "******"Dispatcher", "\tError on deploy now timer " + ex.Message + ex.StackTrace); } finally { TextLog.Log("Dispatcher", "Finishing deploy now timer"); executing2 = false; } }