public async Task Delete(string domain) { string connectionString = await _connectionInfoAsync.GetConnectionStringAsync(); await MySqlHelper.ExecuteNonQueryAsync(connectionString, SpfEntityDaoResouces.DeleteSpfEntity, new MySqlParameter("domain", domain)); }
public async Task Delete(string domain) { string connectionString = await _connectionInfo.GetConnectionStringAsync(); await MySqlHelper.ExecuteNonQueryAsync(connectionString, DkimSchedulerDaoResources.DeleteDkimRecord, new MySqlParameter("id", domain)); }
public async Task <string> GetDkimHistory(string domain) { string connectionString = await _connectionInfo.GetConnectionStringAsync(); string history = (string)await MySqlHelper.ExecuteScalarAsync( connectionString, DkimApiDaoResources.GetDkimHistory, new MySqlParameter("domain", domain)); return(history); }
public async Task <EntityDkimEntityState> GetDkimSelectors(string domain) { string connectionString = await _connectionInfo.GetConnectionStringAsync(); string serializedDkim = (string)await MySqlHelper.ExecuteScalarAsync( connectionString, DkimApiDaoResources.GetDkimResult, new MySqlParameter("domain", domain)); return(serializedDkim == null ? null : JsonConvert.DeserializeObject <EntityDkimEntityState>(serializedDkim, _serializerSettings)); }
public async Task <DkimHistoryEntityState> Get(string domain) { string connectionString = await _connectionInfoAsync.GetConnectionStringAsync(); string state = (string)await MySqlHelper.ExecuteScalarAsync(connectionString, DkimEntityHistoryDaoResouces.SelectDkimEntityHistory, new MySqlParameter("domain", domain)); return(state == null ? null : JsonConvert.DeserializeObject <DkimHistoryEntityState>(state)); }
public async Task <DkimSchedulerState> Get(string domain) { string connectionString = await _connectionInfo.GetConnectionStringAsync(); string id = (string)await MySqlHelper.ExecuteScalarAsync(connectionString, DkimSchedulerDaoResources.SelectDkimRecord, new MySqlParameter("domain", domain)); return(id == null ? null : new DkimSchedulerState(id)); }
public async Task <SpfSchedulerState> Get(string domain) { string id = (string)await MySqlHelper.ExecuteScalarAsync( await _connectionInfo.GetConnectionStringAsync(), SpfSchedulerDaoResources.SelectSpfRecord, new MySqlParameter("id", domain)); return(id == null ? null : new SpfSchedulerState(id)); }
public async Task Save(SpfSchedulerState state) { int numberOfRowsAffected = await MySqlHelper.ExecuteNonQueryAsync( await _connectionInfo.GetConnectionStringAsync(), SpfSchedulerDaoResources.InsertSpfRecord, new MySqlParameter("id", state.Id.ToLower())); if (numberOfRowsAffected == 0) { throw new InvalidOperationException($"Didn't save duplicate {nameof(SpfSchedulerState)} for {state.Id}"); } }
public async Task Save(DkimHistoryEntityState state) { string connectionString = await _connectionInfoAsync.GetConnectionStringAsync(); string serializedState = JsonConvert.SerializeObject(state, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); await MySqlHelper.ExecuteNonQueryAsync(connectionString, DkimEntityHistoryDaoResouces.InsertDkimEntityHistory, new MySqlParameter("domain", state.Id), new MySqlParameter("state", serializedState)); }
public async Task WriteHistory(List <SpfEntityState> spfEntityStates) { string commandStart = "INSERT INTO `spf_entity_history`\r\n(`entity_id`,\r\n`state`)\r\nVALUES"; string parameterNames = string.Join(",", spfEntityStates.Select((v, i) => $"(@domain{i}, @state{i})")); string command = $"{commandStart} {parameterNames};"; MySqlParameter[] parameters = spfEntityStates.Select((v, i) => new List <MySqlParameter> { new MySqlParameter($"domain{i}", v.Id), new MySqlParameter($"state{i}", JsonConvert.SerializeObject(v)) }).SelectMany(_ => _).ToArray(); await MySqlHelper.ExecuteNonQueryAsync(_connectionInfo.ConnectionString, command, parameters); }
public async Task Save(TlsRptEntityState state) { string connectionString = await _connectionInfoAsync.GetConnectionStringAsync(); string serializedState = JsonConvert.SerializeObject(state); int rowsAffected = await MySqlHelper.ExecuteNonQueryAsync(connectionString, TlsRptEntityDaoResouces.InsertTlsRptEntity, new MySqlParameter("domain", state.Id), new MySqlParameter("version", state.Version), new MySqlParameter("state", serializedState)); if (rowsAffected == 0) { throw new InvalidOperationException( $"Didn't update TlsRptEntityState because version {state.Version} has already been persisted."); } }
public async Task Save(DkimEntityState state) { string connectionString = await _connectionInfoAsync.GetConnectionStringAsync(); string serializedState = JsonConvert.SerializeObject(state, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); int rowsAffected = await MySqlHelper.ExecuteNonQueryAsync(connectionString, DkimEntityDaoResources.InsertDkimEntity, new MySqlParameter("domain", state.Id), new MySqlParameter("version", state.Version), new MySqlParameter("state", serializedState)); if (rowsAffected == 0) { throw new InvalidOperationException( $"Didn't update DkimEntityState because version {state.Version} has already been persisted."); } }
private Task TruncateDatabase() => MySqlHelper.ExecuteNonQueryAsync(ConnectionString, "DELETE FROM spf_scheduled_records;");
private async Task <DateTime> GetLastChecked(string domain) => (DateTime)await MySqlHelper.ExecuteScalarAsync(ConnectionString, $"SELECT last_checked FROM spf_scheduled_records WHERE id = @domain", new MySqlParameter("domain", domain));
private Task Insert(string domain, DateTime lastChecked) => MySqlHelper.ExecuteNonQueryAsync(ConnectionString, @"INSERT INTO spf_scheduled_records (id, last_checked) VALUES (@domain, @last_checked)", new MySqlParameter("domain", domain), new MySqlParameter("last_checked", lastChecked));
private Task Insert(string domain) => MySqlHelper.ExecuteNonQueryAsync(ConnectionString, @"INSERT INTO spf_scheduled_records (id, last_checked) VALUES (@domain, UTC_TIMESTAMP())", new MySqlParameter("domain", domain));