/// <summary> /// Reset table WeatherFileDownload to default values. /// </summary> /// <returns>Status of table reset</returns> public bool ResetFileDownloadTable() { bool isReset = false; try { connection.DeleteAll <WeatherFileDownloadEntity>(); foreach (Region region in Enum.GetValues(typeof(Region))) { foreach (ClimateType ct in Enum.GetValues(typeof(ClimateType))) { WeatherFileDownloadEntity wfd = new WeatherFileDownloadEntity() { Region = region, ClimateType = ct, TimeStamp = DateTime.Now.AddDays(-50), Filename = FileDownloadHelper.getDBFileName(ct, region) }; connection.Insert(wfd); } } isReset = true; Log.Information("File download table is reset"); } catch (Exception e) { Log.Error(e, " : error"); } return(isReset); }
/// <summary> /// Get the timestamp of the file name from the table - WeatherFileDownload /// </summary> /// <param name="filename">name of the file which the timestamp is needed</param> /// <returns>time stamp for the file name</returns> public DateTime getFileTimeStamp(string filename) { string sql = @"SELECT TOP 1 * FROM WeatherFileDownload WHERE filename = '" + filename + "'"; WeatherFileDownloadEntity dt = connection.QuerySingle <WeatherFileDownloadEntity>(sql); var fileDate = dt.TimeStamp.Date; return(fileDate); }