Exemplo n.º 1
0
        public string genHtmlFile(HttpRequest req, string sXml)
        {
            var    builder  = new StringBuilder();
            Report report   = null;
            var    document = new XmlDocument();

            if (sXml == null)
            {
                document = method_5(req);
            }
            else
            {
                document.LoadXml(sXml);
            }
            string exptype     = Tools.getXPathValue(document.DocumentElement, "/root/paths/exptype");
            string fromdb      = Tools.getXPathValue(document.DocumentElement, "/root/paths/fromdb");
            string gen         = Tools.getXPathValue(document.DocumentElement, "/root/paths/gen");
            string orderpageno = Tools.getXPathValue(document.DocumentElement, "/root/paths/orderpageno");

            gen = PathTool.getRealPath(req, FileAction.basePath + gen);
            int num4 = 0;
            int num2 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Count;

            for (int i = 0; i < num2; i++)
            {
                string sFileName = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(0).InnerText;
                builder.Append("<reportfile><name>" + sFileName + "</name>");
                if (fromdb != "yes")
                {
                    sFileName = PathTool.getRealPath(req, FileAction.basePath + sFileName);
                }
                string str2 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(1).InnerText;
                Env    env  = null;
                try
                {
                    ReportDefine rd = null;
                    if (fromdb == "yes")
                    {
                        string sContent = ToDatabase.Load(req, _operator, sFileName);
                        if (sContent == "")
                        {
                            throw new Exception("从数据库中读出的报表内容为空");
                        }
                        rd = new ReportDefine(sContent, 1);
                    }
                    else
                    {
                        rd = new ReportDefine(sFileName);
                    }
                    env = new Env(rd)
                    {
                        Request = req,
                        Session = _sessionState
                    };
                    Hashtable collection = new Hashtable();
                    XmlNode   node       = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(2);
                    int       num7       = node.ChildNodes.Count;
                    for (int j = 0; j < num7; j++)
                    {
                        string key      = node.ChildNodes.Item(j).ChildNodes.Item(0).InnerText;
                        string newValue = Escape.unescape(node.ChildNodes.Item(j).ChildNodes.Item(1).InnerText);
                        if (((key != null) && (key.Trim().Length > 0)) && ((newValue != null) && (newValue.Trim().Length > 0)))
                        {
                            if (!(key == "e_setdataset") && !(key == "e_setparammacro"))
                            {
                                SupportClass.PutElement(collection, key, newValue);
                            }
                            else
                            {
                                env.setParameter(key, newValue);
                            }
                        }
                    }
                    float num5 = 1f;
                    try
                    {
                        num5 = Convert.ToSingle(document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(3).InnerText);
                    }
                    catch (Exception)
                    {
                    }
                    preapareArgs(rd, collection, env);
                    prepareDataSource(rd.DataSetConfigs.getDataSourceNames(), env);
                    report = new Engine(env).calc();
                    string str7 = "";
                    try
                    {
                        str7 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(4).InnerText;
                    }
                    catch (Exception)
                    {
                    }
                    string str9 = "";
                    try
                    {
                        str9 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(5).InnerText;
                    }
                    catch (Exception)
                    {
                    }
                    method_6(str9, report);
                    string sFile = gen + str2 + "." + exptype;
                    int    num3  = 1;
                    switch (exptype)
                    {
                    case "htm":
                        if (str2.Length == 0)
                        {
                            str2 = method_11();
                            method_13(gen);
                        }
                        num3 = method_1(report, gen, str2, num5, num4, str7);
                        break;

                    case "pdf":
                        report.exportToPDF(sFile);
                        break;

                    default:
                        if (exptype != "xls")
                        {
                            if (!(exptype == "xlt"))
                            {
                                if (exptype == "*")
                                {
                                    num3  = method_1(report, gen, str2, num5, num4, str7);
                                    sFile = gen + str2 + ".pdf";
                                    report.exportToPDF(sFile);
                                    sFile = gen + str2 + ".xls";
                                    report.exportToExcel(sFile, false);
                                    sFile = gen + str2 + ".xlt";
                                    report.exportToExcel(sFile, true);
                                }
                            }
                            else
                            {
                                report.exportToExcel(sFile, true);
                            }
                        }
                        else
                        {
                            report.exportToExcel(sFile, false);
                        }
                        break;
                    }
                    if ((orderpageno != null) && (orderpageno == "yes"))
                    {
                        num4 += num3;
                    }
                    builder.Append("<pages>" + Convert.ToString(num3) + "</pages><errmsg></errmsg>");
                }
                catch (Exception exception)
                {
                    builder.Append("<pages>0</pages><errmsg>" + exception.Message + "</errmsg>");
                }
                finally
                {
                    method_9(env);
                }
                builder.Append("<genname>" + str2 + "</genname>");
                builder.Append(method_2(report));
                builder.Append("</reportfile>");
            }
            return(builder.ToString());
        }
Exemplo n.º 2
0
        public string run(HttpRequest req)
        {
            string message = Tools.demoAction(req);

            if (message != "")
            {
                throw new Exception(message);
            }
            string str12       = PathTool.getRealPath(req, FileAction.basePath + req["spath"]);
            string s           = req["pageno"];
            string str14       = req["e_fixrowcol"];
            bool   isFixRowCol = false;

            if (((str14 == null) && (s == "-1")) || (str14 == "1"))
            {
                isFixRowCol = true;
            }
            Report report = null;
            string str13  = "";
            string str9   = "";
            string str8   = "";
            string key    = "";
            string str6   = "";
            string str3   = "";
            string str5   = "";

            try
            {
                str6 = method_5(req).DocumentElement.ChildNodes.Item(0).InnerText;
                try
                {
                    report = method_4(str12, req, str6);
                }
                catch (Exception exception3)
                {
                    throw exception3;
                }
                string str11 = PathTool.getRealPath(req, FileAction.basePath + req["tempfilepath"]);
                str5 = req["e_runsavefile"];
                if ((str5 != null) && (str5.Length > 0))
                {
                    method_0(report, str11, str5, _float);
                    report.exportToPDF(str11 + str5 + ".pdf");
                    report.exportToExcel(str11 + str5 + ".xls", false);
                    report.exportToExcel(str11 + str5 + ".xlt", true);
                }
                try
                {
                    str3 = report.exportToHTML(null, _float, int.Parse(s), req, isFixRowCol);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
                try
                {
                    str8 = Convert.ToString(report.pages);
                    str9 = req["cacheid"];
                    if ((s != "-1") && ((str9 == null) || (str9.Trim().Length == 0)))
                    {
                        str9 = CachedReportPool.put(report);
                    }
                    if ((str6 != null) && (str6.Trim().Length > 0))
                    {
                        key = req["e_paramid"];
                        if ((key != null) && (key.Trim().Length > 0))
                        {
                            key = CachedParamsPool.put(key, str6);
                        }
                        else
                        {
                            key = CachedParamsPool.put(str6);
                        }
                    }
                }
                catch (Exception exception2)
                {
                    throw exception2;
                }
            }
            catch (Exception exception4)
            {
                str13 = exception4.Message;
            }
            string str2 = str9 + ",,," + str8 + ",,," + str13 + ",,," + key + ",,,";

            if ((str5 == null) || (str5.Length <= 0))
            {
                return(str2 + "html,,," + str3);
            }
            return(str2 + "save,,," + _builder.ToString());
        }