private static string GetParameterValueFromExpression(ReportParameterViewItem r, DateTime sourceDateTime) { if (!string.IsNullOrEmpty(r.Value) && r.Type == ReportParameterTypeEnum.DateTime) { DateTime?dt = DateTimeExpression.Evaluate(r.Value, sourceDateTime); return(dt.HasValue ? dt.Value.ToString("yyyy-MM-dd") : null); } return(r.Value); }
internal static string _GetActualParameterValue(ReportParameter p, ParameterValue v) { if (v.Value == null) { return(null); } else if (p.Type == ParameterTypeEnum.DateTime) { //extract the date part of the value DateTime?date; try { date = DateTimeExpression.Evaluate(v.Value, DateTime.Now); } catch { //this exception will be thrown later for invalid expressions return(null); } return(date.HasValue ? date.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : null); } else if (p.Type == ParameterTypeEnum.String && p.Name.EndsWith("Time", StringComparison.InvariantCultureIgnoreCase)) { if (string.IsNullOrEmpty(v.Value)) { return(v.Value); } DateTime dt; if (DateTime.TryParseExact(v.Value, Report.TimeFormats, null, DateTimeStyles.None, out dt)) { return(dt.ToString("HH:mm")); } else { return(null); } } else { return(v.Value); } }