Esempio n. 1
0
        public ReportConfig(string reportName, DB db = null)
        {
            this.ReportName = reportName;
            this.Db         = db;
            this.XmlConfig  = AllReportConfig.Elements("Rep").FirstOrDefault(q => q.Attribute("key").Value == ReportName);

            if (XmlConfig == null)
            {
                throw new Exception("xml没有相关配置");
            }
        }
Esempio n. 2
0
        public ReportHelper(string reportName)
        {
            this.ReportName = reportName;
            this.Db         = MySqlHelper.GetInstance();
            var st = new Stopwatch();

            st.Start();
            this.XmlConfig = AllReportConfig.Elements("Rep").FirstOrDefault(q => q.Attribute("key").Value == ReportName);
            st.Stop();
            var t = st.Elapsed;

            if (XmlConfig == null)
            {
                throw new Exception("xml没有相关配置");
            }
        }
Esempio n. 3
0
        private Dictionary <string, object> ProcessDynamicParams(SqlParams sqlParams, ref string reportsql, ref string prepareSql, ref string totalSql)
        {
            var parameters = new Dictionary <string, object>();
            var elements   = XmlConfig.Elements("Dynamic");

            if (XmlConfig.Attribute("BaseType") != null)
            {
                var baseConfig = AllReportConfig.Elements("Rep").FirstOrDefault(q => q.Attribute("key").Value == XmlConfig.Attribute("BaseType").Value);
                if (baseConfig != null)
                {
                    foreach (var item in baseConfig.Elements("Dynamic"))
                    {
                        var property = elements.FirstOrDefault(p => p.Attribute("property").Value == item.Attribute("property").Value);
                        if (property != null)
                        {
                            property.Add(item.Elements());
                        }
                    }
                }
            }

            foreach (var itemEle in elements)
            {
                Dictionary <string, object> dataRes;
                List <ReportWhereEntity>    list = FillReportWhereEntity(itemEle);
                string dynamicStr = GetDynamicStr(list, sqlParams.Where, out dataRes);
                string dyProperty = itemEle.Attribute("property").Value;

                if (!string.IsNullOrEmpty(reportsql))
                {
                    reportsql = reportsql.Replace(dyProperty, dynamicStr);
                }
                //if (!string.IsNullOrEmpty(footerSql))
                //    footerSql = footerSql.Replace(dyProperty, dynamicStr);
                if (!string.IsNullOrEmpty(prepareSql))
                {
                    prepareSql = prepareSql.Replace(dyProperty, dynamicStr);
                }
                if (!string.IsNullOrEmpty(totalSql))
                {
                    totalSql = totalSql.Replace(dyProperty, dynamicStr);
                }

                if (dataRes != null)
                {
                    foreach (var item in dataRes)
                    {
                        if (parameters.All(p => p.Key != item.Key.ToLower()))
                        {
                            parameters.Add(item.Key.ToLower(), item.Value);
                        }
                    }
                }
            }

            foreach (var item in sqlParams.Where)
            {
                if (parameters.All(p => p.Key != item.Key.ToLower()))
                {
                    parameters.Add(item.Key.ToLower(), item.Value);
                }
            }
            return(parameters);
        }