Commit b9095f86 authored by Anthony Mochel's avatar Anthony Mochel
Browse files

fix(log): disposable context

parent b8e53fc7
......@@ -75,17 +75,7 @@ namespace BeeWeatherPollenTracker
catch (Exception e)
{
logs.WriteInFile(e);
if (string.IsNullOrEmpty(pollenJson))
{
try
{
File.WriteAllText($"pollen_{DateTime.Now.ToString()}.json", pollenJson);
}
catch (Exception inner)
{
logs.WriteInFile(inner);
}
}
logs.WriteBackup(LoggerManager.DataForcastType.POLL, pollenJson);
}
#endregion Pollen
......
......@@ -88,14 +88,17 @@ namespace BeeWeatherPollenTracker
try
{
// Entity context
var context = new delmeEntities1();
using (var context = new delmeEntities1())
{
// Add weather forecast to context
foreach (var item in this._weather_forecast_list)
context.beehive_weather_forecast.Add(item);
// Push data in databse
context.SaveChanges();
}
}
catch (Exception ex)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment