public void ReceivePosts(IEnumerable <Post> posts) { foreach (var post in posts) { Log.Info(string.Format("Received new post {0}", post.Id)); try { _savingPlugin.Save(post); } catch (Exception ex) { Log.Error(string.Format("Error while saving post in plugin {0}", _savingPlugin.Name), ex); } } try { _savingPlugin.Flush(); } catch (Exception ex) { Log.Error(string.Format("Error while flushing plugin {0}", _savingPlugin.Name), ex); } PostUtils.ResetPageContentStore(); Publish(); }
private void btnAddCottageAdd_Click(object sender, EventArgs e) { //Add a cottage to the database, gets data from form components try { PostUtils.CheckPostal(tbAddCottagePostNum.Text, tbAddCottagePostRegion.Text); string query = "START TRANSACTION; " + "INSERT INTO mokki(mokki_id,toimintaalue_id,postinro,mokkinimi,katuosoite,kuvaus,henkilomaara,varustelu,hinta) " + "VALUES(default," + RegionUtils.RegionNameToIndex(cbAddCottageRegion.Text) + ",'" + TextBoxUtils.ModifyInput(tbAddCottagePostNum.Text, 5) + "','" + TextBoxUtils.ModifyInput(tbAddCottageName.Text, 45) + "','" + TextBoxUtils.ModifyInput(tbAddCottageStreet.Text, 45) + "','" + TextBoxUtils.ModifyInput(tbAddCottageDescription.Text, 500) + "'," + (int)nudAddCottageCapacity.Value + ",'" + TextBoxUtils.ModifyInput(cbAddCottageEquipment.Text, 100) + "'," + (double)nudAddCottagePrice.Value + "); " + "COMMIT;"; try { ConnectionUtils.OpenConnection(); MySqlCommand command = new MySqlCommand(query, ConnectionUtils.connection); command.ExecuteNonQuery(); ConnectionUtils.CloseConnection(); this.Close(); } catch (Exception ex) { //Incase of connction problems ConnectionUtils.CloseConnection(); MessageBox.Show("Virhe tietojen syöttämisessä tietokantaan. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString()); } } catch (Exception ex) { //Incase of exceptions in variable conversion ConnectionUtils.CloseConnection(); MessageBox.Show("Virhe tietojen muuntamisessa. Tarkista kenttien tiedot. Lisätietoja: " + ex.Message.ToString()); } }