This commit is contained in:
2018-12-11 00:37:17 +00:00
parent 2926981028
commit d1faf35a66
3 changed files with 57 additions and 53 deletions

View File

@@ -282,9 +282,11 @@ namespace AyaNova.Biz
//So this is the core date time to work off of
DateTime RelativeToday = DateTime.Today;
DateTime RelativeNow = DateTime.Now;
// ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria");
// log.LogInformation("RelativeToday (before adjustment):");
// log.LogInformation(RelativeToday.ToString());
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria");
log.LogInformation("RelativeToday (before adjustment):");
log.LogInformation(RelativeToday.ToString());
log.LogInformation("RelativeNow (before adjustment):");
log.LogInformation(RelativeNow.ToString());
if (sValue.StartsWith("{[") && sValue.EndsWith("]}"))
@@ -301,13 +303,15 @@ namespace AyaNova.Biz
RelativeToday = RelativeToday.AddHours(TimeZoneAdjustment);//flip the sign to adjust towards UTC
RelativeNow = RelativeNow.AddHours(TimeZoneAdjustment);//flip the sign to adjust towards UTC
// //TESTING:
// //LOG THE CRIT AND QUERY
// // ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria");
// log.LogInformation("RelativeToday (adjusted):");
// log.LogInformation(RelativeToday.ToString());
// log.LogInformation("Offset used:");
// log.LogInformation(u.tz.ToString());
//TESTING:
//LOG THE CRIT AND QUERY
// ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("FilterSqlCriteriaBuilder::DataFilterToColumnCriteria");
log.LogInformation("RelativeToday (adjusted):");
log.LogInformation(RelativeToday.ToString());
log.LogInformation("RelativeNow (adjusted):");
log.LogInformation(RelativeNow.ToString());
log.LogInformation("Offset used:");
log.LogInformation(u.tz.ToString());
#region Build criteria for date RANGE TOKEN specified
//Used as the basis point
@@ -473,14 +477,14 @@ namespace AyaNova.Biz
case FilterSpecialToken.Past:
//Forever up to Now
dtAfter = new DateTime(1753, 1, 2, 00, 00, 00);
dtBefore = RelativeNow;
dtBefore = DateTime.UtcNow;
BuildBetweenTwoDatesFragment(sColumn, sb, dtAfter, dtBefore);
break;
case FilterSpecialToken.Future:
//From Now to forever (999 years from now)
dtAfter = RelativeNow;
dtBefore = RelativeNow.AddYears(999);
dtAfter = DateTime.UtcNow;
dtBefore = DateTime.UtcNow.AddYears(999);
BuildBetweenTwoDatesFragment(sColumn, sb, dtAfter, dtBefore);
break;
@@ -502,9 +506,9 @@ namespace AyaNova.Biz
case FilterSpecialToken.InTheLast3Months:
//From Now minus 3 months
dtAfter = RelativeNow.AddMonths(-3);//relative now is already adjusted for time zone so no need to adjust it again
dtAfter = DateTime.UtcNow.AddMonths(-3);
//To Now
dtBefore = RelativeNow;
dtBefore = DateTime.UtcNow;
BuildBetweenTwoDatesFragment(sColumn, sb, dtAfter, dtBefore);
break;
@@ -842,18 +846,18 @@ namespace AyaNova.Biz
}
//This is only used by the token date query code above and that code doesn't convert to UTC time to match the DB so this function will handle that
//This is only used by the token date query code above and that code does convert to UTC time to match the DB so this function will not need to handle that
//The other non tokenized date criteria builders are all working with dates that come from the client in UTC already and they don't use this method
//so nothing required there
private static void BuildBetweenTwoDatesFragment(string sColumn, StringBuilder sb, DateTime dtAfter, DateTime dtBefore)
{
sb.Append(">'");
sb.Append(PostgresDateFormat(dtAfter.ToUniversalTime()));
sb.Append(PostgresDateFormat(dtAfter));
sb.Append("' AND ");
sb.Append(sColumn);
sb.Append(" ");
sb.Append("<'");
sb.Append(PostgresDateFormat(dtBefore.ToUniversalTime()));
sb.Append(PostgresDateFormat(dtBefore));
sb.Append("'");
}

View File

@@ -188,14 +188,14 @@ namespace AyaNova.Biz
//BUILD WHERE AND APPEND IT
q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), UserId);
// //TESTING:
// //TODO: remove this from production build
// //LOG THE CRIT AND QUERY
// ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("WidgetBiz::GetManyAsync");
// log.LogInformation("Filter criteria:");
// log.LogInformation(TheFilter.Filter);
// log.LogInformation("Generated SQL:");
// log.LogInformation(q);
//TESTING:
//TODO: remove this from production build
//LOG THE CRIT AND QUERY
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("WidgetBiz::GetManyAsync");
log.LogInformation("Filter criteria:");
log.LogInformation(TheFilter.Filter);
log.LogInformation("Generated SQL:");
log.LogInformation(q);
}
//BUILD ORDER BY AND APPEND IT

View File

@@ -1647,9 +1647,9 @@ namespace raven_integration
//Excluded widget
w.name = Util.Uniquify(WidgetNameStart);
//8 days ago will be outside the 14 day window
w.startDate = DateTime.Now.AddDays(-8).ToUniversalTime();
w.endDate = DateTime.Now.AddDays(-8).AddHours(1).ToUniversalTime();
//9 days ago will be outside the 14 day window
w.startDate = DateTime.Now.AddDays(-9).ToUniversalTime();
w.endDate = DateTime.Now.AddDays(-9).AddHours(1).ToUniversalTime();
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
@@ -2154,8 +2154,8 @@ namespace raven_integration
dynamic w = new JObject();
w.name = Util.Uniquify(WidgetNameStart);
//####
w.startDate = DateTime.Now.AddMonths(-3).AddMinutes(5).ToUniversalTime();
w.endDate = DateTime.Now.AddMonths(-3).AddMinutes(5).AddHours(1).ToUniversalTime();
w.startDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(5);
w.endDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(5).AddHours(1);
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a);
@@ -2164,8 +2164,8 @@ namespace raven_integration
//Excluded widget
w.name = Util.Uniquify(WidgetNameStart);
//####
w.startDate = DateTime.Now.AddMonths(-3).AddMinutes(-5).ToUniversalTime();
w.endDate = DateTime.Now.AddMonths(-3).AddMinutes(-5).AddHours(1).ToUniversalTime();
w.startDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(-5);
w.endDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(-5).AddHours(1);
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
Util.ValidateDataReturnResponseOk(a);