Fix calcolo datetime invariante su lingua...

This commit is contained in:
Samuele E. Locatelli
2018-12-05 23:47:16 +01:00
parent 9b672839cc
commit e0fc47a141
+17 -4
View File
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Web;
namespace SteamWare
@@ -229,8 +230,15 @@ namespace SteamWare
{
// se è in cache
if (isInCacheObject("lastUpdateAppConf"))
{
answ = Convert.ToDateTime(objCacheObj("lastUpdateAppConf"));
{
// faccio SEMPRE calcolo esatto sennò sbaglia...
CultureInfo provider = CultureInfo.InvariantCulture;
string format = "yyyy-MM-dd HH:mm:ss";
answ = DateTime.ParseExact(objCacheObj("lastUpdateAppConf").ToString(), format, provider);
#if false
// mi aspetto formato standard...
answ = Convert.ToDateTime(objCacheObj("lastUpdateAppConf"));
#endif
}
}
catch (Exception exc)
@@ -241,7 +249,12 @@ namespace SteamWare
}
set
{
setCacheVal("lastUpdateAppConf", value, true);
// faccio SEMPRE calcolo esatto sennò sbaglia...
CultureInfo provider = CultureInfo.InvariantCulture;
string format = "yyyy-MM-dd HH:mm:ss";
string valore = value.ToString(format, provider);
// ora salvo!
setCacheVal("lastUpdateAppConf", valore, true);
}
}
@@ -1179,7 +1192,7 @@ namespace SteamWare
answ = redVal != null && redVal != "";
}
}
catch(Exception exc)
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Errore in verifica isInCacheObject REDIS per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc));
}