コード例 #1
0
        /// <summary>
        /// 将报表对象转换为DSL串
        /// </summary>
        /// <param name="report"></param>
        /// <returns></returns>
        private string Parse(MobileReport report)
        {
            string tableSchema = string.Empty;
            string reportStr;
            string rowData;

            if (report.Page == 0) //第一页
            {
                tableSchema = DslTransfer.TransferToTableSchema(report);
                //Logger logger = Logger.GetLogger("DSLTransfer");
                //logger.Info(tableSchema);
                //logger.Close();
                byte[] bytes = Encoding.Default.GetBytes(tableSchema);
                tableSchema = Convert.ToBase64String(bytes);
                rowData     = RetrieveRowData.TransferToRowData(report);
                reportStr   = string.Format("<report><tableSchema>{0}</tableSchema>{1}</report>", tableSchema, rowData);
            }
            else
            {
                if (report.SemiRows != null)
                {
                    string columnstr = this.GetCacheInfoFromSession(this._responseXml, "columnsString");
                    byte[] bytes     = Convert.FromBase64String(columnstr);
                    columnstr = Encoding.Default.GetString(bytes);
                    rowData   = RetrieveRowData.TransferToRowData(columnstr, report);
                    reportStr = string.Format("<report>{0}</report>", rowData);
                }
                else
                {
                    reportStr = null;
                }
            }
            return(reportStr);
        }
コード例 #2
0
        public override ActionResult Execute(string token, string actionType, Dictionary <string, string> parameters,
                                             ref string responseXml)
        {
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ExecuteOpenReport TaskID: " + token + "  Start:" + System.DateTime.Now.ToString());
            this.Init(token, actionType, parameters, ref responseXml);
            this._responseXml = responseXml;
            var result = new ActionResult()
            {
                Action      = actionType,
                Flag        = 1,
                Description = "调用失败",
                ResultData  = null
            };

            if (!this.CheckReportExist(parameters))
            {
                result.Description = "该查询方案不存在,可能已经取消发布到移动端,请确认!";
                return(result);
            }
            try
            {
                var engine    = new MobileReportEngine(token, actionType, parameters, ref responseXml);
                int startLine = Convert.ToInt32(this.GetInformationByKey("startline", parameters));
                if (startLine == 1) //请求第一页数据
                {
                    this._mobileReport  = engine.OpenReport(parameters);
                    this._pageRowsCount = engine.GetReportPageRowCount();
                    //this._mobileReport = this.OpenReport(this._loginInfo, parameters);
                    this._mobileReport.Page = 0;
                    int    totalpage         = this._mobileReport.Report.RowsCount / this._pageRowsCount + 1;
                    string reportCacheString = RetrieveRowData.GetColumnsInfoString(this._mobileReport);
                    this.SetCacheInfoIntoSession(ref responseXml, "currentpage", "1");
                    this.SetCacheInfoIntoSession(ref responseXml, "totalpage", totalpage.ToString());
                    byte[] bytes = Encoding.Default.GetBytes(reportCacheString);
                    reportCacheString = Convert.ToBase64String(bytes);
                    this.SetCacheInfoIntoSession(ref responseXml, "columnsString", reportCacheString);
                    this.SetCacheInfoIntoSession(ref responseXml, "cacheid", this._mobileReport.Report.CacheID);
                }
                else
                {
                    int pageIndex = Convert.ToInt32(this.GetCacheInfoFromSession(responseXml, "currentpage"));
                    if (pageIndex == 0)
                    {
                        pageIndex = Convert.ToInt32(parameters["currentpage"].ToString());
                    }
                    int totalpage = Convert.ToInt32(this.GetCacheInfoFromSession(responseXml, "totalpage"));
                    if (totalpage == 0)
                    {
                        totalpage       = Convert.ToInt32(parameters["totalpage"].ToString());
                        this._totolPage = totalpage.ToString();
                    }
                    if (pageIndex + 1 > totalpage)
                    {
                        result.ResultData = null;
                        result.Flag       = 0;
                        return(result);
                    }
                    else
                    {
                        string cacheId = GetCacheInfoFromSession(responseXml, "cacheid");
                        if (string.IsNullOrEmpty(cacheId))
                        {
                            cacheId       = parameters["cacheid"].ToString();
                            this._cacheid = cacheId;
                        }
                        int lastIndex = -1;
                        //this._mobileReport = this.PageTo(cacheId, pageIndex, lastIndex);
                        this._mobileReport = engine.PageTo(cacheId, pageIndex, lastIndex);
                        this.SetCacheInfoIntoSession(ref responseXml, "currentpage", (pageIndex + 1).ToString());
                        this._mobileReport.Page = pageIndex + 1;
                    }
                }

                if (_mobileReport != null)
                {
                    System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ParseReport TaskID: " + _loginInfo.TaskID + "  Start:" + System.DateTime.Now.ToString());
                    result.ResultData = Parse(this._mobileReport);
                    System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ParseReport TaskID: " + _loginInfo.TaskID + "  End:" + System.DateTime.Now.ToString());
                    result.Flag        = 0;
                    result.Description = "获取报表成功";
                }
            }
            catch (Exception ex)
            {
                result.Flag        = 1;
                result.Description = "获取报表数据失败:" + ex.Message;

                if (ex.Message.Contains("无法将类型为“U8Login.clsLoginClass”的 COM 对象强制转换为接口类型“U8Login._clsLogin”") && !parameters.ContainsKey("AAA"))
                {
                    parameters.Add("AAA", "1");
                    return(Execute(token, actionType, parameters, ref responseXml));
                }
            }
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ExecuteOpenReport TaskID: " + token + "  End:" + System.DateTime.Now.ToString());
            return(result);
        }