コード例 #1
0
        public string GenerateDataSource <T>() where T : ReportModel
        {
            var          source = RdlcXmlTemplates.DataSourceTemplate;
            DataSetModel ds     = new DataSetModel
            {
                Name = typeof(T).Name
            };

            return(Service.FillStringParameters(source, ds));
        }
コード例 #2
0
        public string GenerateDataSets <T>() where T : ReportModel
        {
            var field   = RdlcXmlTemplates.FieldTemplate;
            var dataSet = RdlcXmlTemplates.DataSetTemplate;

            var props = typeof(T).GetProperties();

            string ret = "";

            foreach (var p in props)
            {
                if (p.PropertyType.Implements(typeof(IEnumerable)) && p.PropertyType != typeof(string))
                {
                    var t = p.PropertyType.GetGenericArguments();
                    if (t.Length > 0)
                    {
                        DataSetModel ds = new DataSetModel
                        {
                            DataSourceName = typeof(T).Name,
                            Name           = p.Name,
                            Fields         = ""
                        };
                        var inProps = t[0].GetProperties();
                        foreach (var inP in inProps)
                        {
                            FieldModel f = new FieldModel
                            {
                                Name = inP.Name,
                                Type = inP.PropertyType.ToString()
                            };
                            ds.Fields += Service.FillStringParameters(field, f);
                        }
                        ret += Service.FillStringParameters(dataSet, ds);
                    }
                }
            }

            return(ret);
        }