Example #1
0
        public override object calculate()
        {
            SubReportList subRptList = base.cs.Env.SubRptList;

            if (subRptList == null)
            {
                throw new ReportError("当前报表没有引入子报表,不能进行子报表运算");
            }
            if ((base.paramList.Count < 3) || (base.paramList.Count > 4))
            {
                throw new ReportError("子报表运算函数的参数格式应为subreport(rpt, List1, List2) 或者 subreport(rpt, List1, List2,importOrEmbed)");
            }
            ExpParse parse4 = (ExpParse)base.paramList[0];

            if (parse4 == null)
            {
                throw new ReportError("子报表运算函数出现无效参数");
            }
            object obj2 = ConvertTool.getValue(parse4.calculate());
            int    num  = 0;

            if (base.paramList.Count == 4)
            {
                ExpParse parse3 = (ExpParse)base.paramList[3];
                if (parse3 == null)
                {
                    throw new ReportError("子报表运算函数出现无效参数");
                }
                object obj6 = ConvertTool.getValue(parse3.calculate());
                try
                {
                    num = (int)obj6;
                }
                catch (Exception)
                {
                    num = 0;
                }
            }
            if (!(obj2 is string))
            {
                throw new ReportError("子报表运算函数第一个参数应为引入的子报表名");
            }
            string       str    = subRptList.getAddress((string)obj2);
            string       str2   = subRptList.getType((string)obj2);
            ReportDefine define = this.method_0(str, str2);
            ExpParse     parse  = (ExpParse)base.paramList[1];
            ExpParse     parse2 = (ExpParse)base.paramList[2];

            if ((parse != null) && (parse2 != null))
            {
                object obj5 = ConvertTool.getValue(parse.calculate());
                object obj4 = ConvertTool.getValue(parse2.calculate());
                if ((obj5 is ArrayList) && (obj4 is ArrayList))
                {
                    return(this.method_1(define, (ArrayList)obj5, (ArrayList)obj4, num));
                }
                return(this.method_1(define, null, null, num));
            }
            return(this.method_1(define, null, null, num));
        }
Example #2
0
        public static void calcRpt(ReportDefine rDef, bool ifCoverUserDataSet, CellExt1 ecs)
        {
            Env env = ecs.Env;

            if (env.AutoCalcDataSet)
            {
                string str      = null;
                string rootPath = null;
                if (env.Request != null)
                {
                    str      = env.Request["e_setdataset"];
                    rootPath = env.Request.PhysicalApplicationPath;
                }
                else
                {
                    str      = env.getParameter("e_setdataset");
                    rootPath = FileAction.rootPath;
                }
                if ((str != null) && (str.Length > 0))
                {
                    Type type = Assembly.LoadFrom(rootPath + @"bin\LoadEbiao.dll").GetType("LoadEbiao.IDataSet");
                    if (type != null)
                    {
                        object[]     objArray3 = new object[0];
                        object       obj2      = Activator.CreateInstance(type, objArray3);
                        MethodInfo   method    = type.GetMethod("setDataSetConfigs");
                        BindingFlags flags     = (BindingFlags)20;
                        object[]     objArray  = new object[] { env, rDef.DataSetConfigs };
                        try
                        {
                            object obj3 = method.Invoke(obj2, flags, Type.DefaultBinder, objArray, null);
                            rDef.DataSetConfigs = (DataSetHelper)obj3;
                        }
                        catch (Exception exception)
                        {
                            throw new Exception(exception.InnerException.Message);
                        }
                    }
                }
                DataSetHelper dataSetConfigs = rDef.DataSetConfigs;
                string[]      dataSetNames   = dataSetConfigs.DataSetNames;
                for (int i = 0; i < dataSetNames.Length; i++)
                {
                    if ((env.getDataSet(dataSetNames[i]) == null) || ifCoverUserDataSet)
                    {
                        env.putDataSet(dataSetNames[i], dataSetConfigs.calcDataSet(env, dataSetNames[i], ecs));
                    }
                }
            }
            Logger.debug("取数完毕,开始计算......");
            ecs.calculate();
        }
Example #3
0
        private object method_1(ReportDefine reportDefine_0, ArrayList arrayList_0, ArrayList arrayList_1, int int_1)
        {
            Env env  = new Env(reportDefine_0);
            Env env2 = base.cs.Env;

            env.setConnection(env2.getConnection());
            env.Request = env2.Request;
            if ((arrayList_0 != null) && (arrayList_1 != null))
            {
                if (arrayList_0.Count != arrayList_1.Count)
                {
                    throw new ReportError("子报表参数名列表和参数表达式列表个数不一致");
                }
                for (int i = 0; i < arrayList_0.Count; i++)
                {
                    string paramName  = (string)arrayList_0[i];
                    object paramValue = arrayList_1[i];
                    if (paramName != null)
                    {
                        env.putParam(paramName, paramValue);
                    }
                }
            }
            CellExt1 ecs = new CellExt1(env);

            if (int_1 != 0)
            {
                ecs.SubRptType = CellExt1.SRT_IMPORT;
            }
            else
            {
                ecs.SubRptType = CellExt1.SRT_EMBED;
            }
            ecs.read(reportDefine_0.CellSet);
            CalcReport.calcRpt(reportDefine_0, true, ecs);
            return(ecs);
        }
Example #4
0
        private ReportDefine method_0(string string_0, string string_1)
        {
            ReportDefine define = null;

            if (!"绝对路径".ToUpper().Equals(string_1.ToUpper()))
            {
                if (!"库中报表名".ToUpper().Equals(string_1.ToUpper()))
                {
                    if (!"相对路径".ToUpper().Equals(string_1.ToUpper()))
                    {
                        if (!"url".ToUpper().Equals(string_1.ToUpper()))
                        {
                            return(define);
                        }
                        Uri uri = null;
                        try
                        {
                            uri = new Uri(string_0);
                        }
                        catch (UriFormatException)
                        {
                            throw new ReportError("子报表的url格式不正确");
                        }
                        try
                        {
                            return(new ReportDefine(WebRequest.Create(uri).GetResponse().GetResponseStream()));
                        }
                        catch (IOException)
                        {
                            throw new ReportError("子报表的url访问被拒绝或出错");
                        }
                        catch (Exception exception)
                        {
                            throw new ReportError("从子报表的url读入并创建报表定义的时候出错:" + exception.Message.ToString().ToString());
                        }
                    }
                    string str = PathTool.getRootPath(base.cs.Env.Request);
                    try
                    {
                        return(new ReportDefine(str + string_0));
                    }
                    catch (Exception exception2)
                    {
                        throw new ReportError("从子报表指定目录下的文件创建报表定义时出错:" + exception2.Message.ToString().ToString());
                    }
                }
                string sContent = ToDatabase.Load(base.cs.Env.Request, base.cs.Env.getConnection().ConnectionString, string_0);
                if (sContent != "")
                {
                    try
                    {
                        return(new ReportDefine(sContent, 1));
                    }
                    catch (Exception exception3)
                    {
                        throw new ReportError("从子报表指定目录下的文件创建报表定义时出错:" + exception3.Message.ToString().ToString());
                    }
                }
                throw new Exception("从数据库中读出的子报表内容为空");
            }
            try
            {
                define = new ReportDefine(string_0);
            }
            catch (Exception exception4)
            {
                throw new ReportError("从子报表指定目录下的文件创建报表定义时出错:" + exception4.Message.ToString().ToString());
            }
            return(define);
        }