Beispiel #1
0
        private Report method_4(string fileName, HttpRequest request, string args)
        {
            Report report = null;
            string key    = request["cacheid"];

            if ((key != null) && (key.Trim().Length > 0))
            {
                report = (Report)CachedReportPool.get(key);
            }
            if (report == null)
            {
                Env env = null;
                try
                {
                    ReportDefine rd = null;
                    if (request["fromdb"] != "yes")
                    {
                        rd = new ReportDefine(fileName);
                    }
                    else
                    {
                        string content = ToDatabase.Load(request, _operator, request["spath"]);
                        if (content == "")
                        {
                            throw new Exception("从数据库中读出的报表内容为空");
                        }
                        rd = new ReportDefine(content, 1);
                    }
                    env = new Env(rd)
                    {
                        Request = request,
                        Session = _sessionState
                    };
                    prepareEnv(args, env, rd);
                    report = new Engine(env).calc();
                }
                catch (FileNotFoundException exception)
                {
                    throw exception;
                }
                catch (Exception exception2)
                {
                    throw exception2;
                }
                finally
                {
                    method_9(env);
                }
            }
            method_6(request["pageset"], report);
            return(report);
        }
Beispiel #2
0
        public string loadFile()
        {
            string str = cn.com.fcsoft.util.Tools.demoAction(this.httpRequest_0);

            if (str != "")
            {
                throw new Exception(str);
            }
            Logger.debug("开始打开文件:");
            string str2 = "";

            if (CellNo.sVersionNo == "3")
            {
                str2 = CellNo.sCustomerName + "\n" + CellNo.sProjectName;
            }
            string sFileName = this.httpRequest_0.Params["spath"];

            if (this.httpRequest_0.Params["fromdb"] == "yes")
            {
                str2 = str2 + ToDatabase.Load(this.httpRequest_0, this.dboperator_0, sFileName);
            }
            else
            {
                sFileName = PathTool.getRealPath(this.httpRequest_0, FileAction.basePath + sFileName);
                StringBuilder builder = new StringBuilder();
                try
                {
                    StreamReader reader = new StreamReader(sFileName, Encoding.Default);
                    for (string str5 = reader.ReadLine(); str5 != null; str5 = reader.ReadLine())
                    {
                        builder.Append(str5);
                    }
                    reader.Close();
                    str2 = str2 + builder.ToString();
                }
                catch (Exception exception)
                {
                    str2 = exception.Message;
                }
            }
            return(str2.Replace("<fc />", "").Replace("<fc></fc>", ""));
        }
Beispiel #3
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);
        }
Beispiel #4
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());
        }