public static void GenerateList() { try { using (NpgsqlConnection connection = SQLjec.getInstance().conn()) { NpgsqlCommand command = connection.CreateCommand(); connection.Open(); command.CommandText = "SELECT * FROM events_xmas"; command.CommandType = CommandType.Text; NpgsqlDataReader data = command.ExecuteReader(); while (data.Read()) { EventXmasModel ev = new EventXmasModel { startDate = (UInt32)data.GetInt64(0), endDate = (UInt32)data.GetInt64(1) }; _events.Add(ev); } command.Dispose(); data.Close(); connection.Dispose(); connection.Close(); } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[EventXmasSyncer] Erro fatal!"); } }
public static EventXmasModel getRunningEvent() { try { uint date = uint.Parse(DateTime.Now.ToString("yyMMddHHmm")); for (int i = 0; i < _events.Count; i++) { EventXmasModel ev = _events[i]; if (ev.startDate <= date && date < ev.endDate) { return(ev); } } } catch (Exception ex) { SaveLog.fatal(ex.ToString()); Printf.b_danger("[EventXmasSyncer] Erro fatal!"); } return(null); }