Beispiel #1
0
        private object GetDefaultValue(Report report, XmlNode node, DataSourceParameterType type)
        {
            string value = ReadAttributeValue(node, "DefaultValue");

            if (string.IsNullOrWhiteSpace(value))
            {
                return(null);
            }

            value = ExpressionHelper.ParseExpression(report.Tenant, value, report.DataSources, ParameterHelper.GetPraParameterInfo(report));
            return(DataSourceParameterHelper.CastValue(value, type));
        }
Beispiel #2
0
        private static object GetParameterValue(string name, DataSourceParameterType type, ParameterInfo info)
        {
            var paramter = info.Parameters.FirstOrDefault(x => x.Name.ToLower().Equals(name.Replace("@", "").ToLower()));

            if (paramter != null)
            {
                return(DataSourceParameterHelper.CastValue(paramter.Value, type));
            }

            foreach (var dataSourceParameter in info.DataSourceParameters)
            {
                if (dataSourceParameter.Name.ToLower().Equals(name.ToLower()))
                {
                    if (dataSourceParameter.DefaultValue != null)
                    {
                        return(dataSourceParameter.DefaultValue);
                    }
                }
            }

            return(null);
        }
        public static object CastValue(object value, DataSourceParameterType type)
        {
            switch (type)
            {
            case DataSourceParameterType.Date:
                double milliseconds = value.To <double>();

                if (milliseconds > 0)
                {
                    value = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
                            .AddMilliseconds(milliseconds)
                            .ToLocalTime()
                            .Date
                            .ToString("d");
                }
                else
                {
                    return(value.To <DateTime>());
                }
                break;

            case DataSourceParameterType.Number:
                return(value.To <long>());

            case DataSourceParameterType.Bool:
                return(value.To <bool>());

            case DataSourceParameterType.Decimal:
                return(value.To <decimal>());

            case DataSourceParameterType.Double:
                return(value.To <double>());
            }

            return(value);
        }
Beispiel #4
0
        private object GetAttributeValue(XmlNode node, string name, DataSourceParameterType type)
        {
            string value = this.ReadAttributeValue(node, name);

            return(DataSourceParameterHelper.CastValue(value, type));
        }