/// <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);
        }
        /// <summary>
        /// 准备报表数据
        /// </summary>
        private void PrepairReportData(MobileReportDownloadTask task)
        {
            //_loginInfo = TokenTransfer.GetLoginInfo(task.Token);
            MobileReportEngine engine = new MobileReportEngine(task, _loginInfo);

            _mobileReport = engine.GetAllReport(null, task.Condition);
        }
 /// <summary>
 /// 销毁当前任务
 /// </summary>
 internal void DestroyTask()
 {
     PrepairReportDataError(this._task, this._loginInfo);
     this._loginInfo    = null;
     this._mobileReport = null;
     this._task         = null;
     this.Busy          = false;
 }
        /// <summary>
        ///     在分页加载时,通过移动前端传递过来的列头信息构造数据字符串
        /// </summary>
        /// <param name="columnsInfoString">移动前端传递过来的列头信息字符串</param>
        /// <param name="report">MobileReport对象</param>
        /// <returns>结果DSL串</returns>
        internal static string TransferToRowData(string columnsInfoString, MobileReport report)
        {
            var rowBuilder = new StringBuilder();
            var semirows   = new SemiRows();

            if (report != null)
            {
                semirows = report.SemiRows;
            }
            string[] columns = columnsInfoString.Split(',');
            foreach (SemiRow semiRow in semirows)
            {
                rowBuilder.Append("<row>");
                if (semiRow.SectionType == SectionType.ReportSummary)
                // 如果当前行是总计行
                {
                    rowBuilder.Append(@"<column>总计</column>");
                    for (int i = 0; i < columns.Length; i++)
                    {
                        if (i == 0)
                        {
                            continue;
                        }
                        rowBuilder.Append(string.Format(@"<column>{0}</column>", semiRow[columns[i]]));
                    }
                }
                else
                // 如果当前行是普通数据行
                {
                    foreach (string t in columns)
                    {
                        rowBuilder.Append(string.Format(@"<column>{0}</column>", semiRow[t]));
                    }
                }
                rowBuilder.Append("</row>");
            }
            return(rowBuilder.ToString());
        }
Example #5
0
        internal static void SaveMobileReport(MobileReport mobileReport, ref string filePath)
        {
            #region 1.将报表格式信息存入数据库中
            string tableSchema   = DslTransfer.TransferToTableSchema(mobileReport);
            string root          = GetU8Path();
            var    directoryPath = Path.Combine(root, @"U8AuditWebSite/MobileReport");
            string guid          = Guid.NewGuid().ToString();
            string fileName      = string.Format("ReportData{0}.db", guid);
            var    cachePath     = Path.Combine(root, string.Format(@"U8AuditWebSite/MobileReport/ReportData{0}.db", guid));
            Directory.CreateDirectory(directoryPath);
            SQLiteConnection.CreateFile(cachePath);

            //连接数据库
            var conn    = new SQLiteConnection();
            var connstr = new SQLiteConnectionStringBuilder
            {
                DataSource = cachePath
            };
            conn.ConnectionString = connstr.ToString();
            conn.Open();
            //创建表
            var    cmd = new SQLiteCommand();
            string sql = "drop table if exists TableSchema";
            cmd.CommandText = sql;
            cmd.Connection  = conn;
            cmd.ExecuteNonQuery();
            sql             = "CREATE TABLE TableSchema(tableSchema varchar(10000))";
            cmd.CommandText = sql;
            cmd.Connection  = conn;
            cmd.ExecuteNonQuery();
            //插入数据
            sql             = string.Format("INSERT INTO TableSchema VALUES('{0}')", tableSchema);
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
            #endregion

            #region 2.报表数据存入数据库中
            // 创建报表格式表
            var       cellList       = new List <Cell>();
            bool      isMutiReport   = false;
            Hashtable ht             = new Hashtable();
            Report    report         = mobileReport.Report;
            var       supperCellList = new List <Cell>();
            var       childCellList  = new List <Cell>();
            if (mobileReport != null)
            {
                Section section = report.Sections[SectionType.PageTitle];
                foreach (object gridDetailCell in section.Cells)
                {
                    var cell = gridDetailCell as Cell;
                    if (cell == null || !cell.Visible)
                    {
                        continue;
                    }
                    if (cell is SuperLabel)
                    {
                        isMutiReport = true; //如果列头存在superLable类型,则为多列头格式报表
                        supperCellList.Add(cell);
                    }
                    cellList.Add(gridDetailCell as Cell);
                }
                if (isMutiReport)
                {
                    cellList = new List <Cell>();
                    section  = report.Sections[SectionType.Detail];
                    foreach (object gridDetailCell in section.Cells)
                    {
                        var cell = gridDetailCell as Cell;
                        if (cell != null && cell.Visible)
                        {
                            cellList.Add(gridDetailCell as Cell);
                            childCellList.AddRange(from superCell in supperCellList
                                                   where (cell.Super != null && cell.Super.Name == superCell.Name)
                                                   select cell);
                        }
                    }
                }
                // 这里取pageTitle的一个对象来组成报表标题区域的值
                //var section = report.Sections[SectionType.PageTitle];
                //foreach (var gridDetailCell in section.Cells)
                //{
                //    var cell = gridDetailCell as Cell;
                //    if (cell != null && cell.Visible)
                //    {
                //        cellList.Add(gridDetailCell as Cell);
                //    }
                //}
            }
            // 应手机端开发人员要求,这里要通过后台设置各个列的次序等信息,采用f0,f1,f2,f3...等定位列头。
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < cellList.Count; i++)
            {
                sb.Append("f" + i);
                sb.Append(" varchar(50)");
                sb.Append(",");
            }
            //foreach (var cell in cellList)
            //{
            //    sb.Append(cell.Name);
            //    sb.Append(" varchar(50)");
            //    sb.Append(",");
            //}
            sb.Remove(sb.Length - 1, 1);
            sql             = "drop table if exists ReportData";
            cmd.CommandText = sql;
            cmd.Connection  = conn;
            cmd.ExecuteNonQuery();
            sql             = string.Format("CREATE TABLE ReportData({0})", sb);
            cmd.CommandText = sql;
            cmd.Connection  = conn;
            cmd.ExecuteNonQuery();

            if (!isMutiReport)
            {
                // 将reportData第一行添加报表中文名称等信息。
                sb = new StringBuilder();
                sb.Append("insert into ReportData VALUES(");
                foreach (var cell in cellList)
                {
                    sb.Append(string.Format("'{0}',", cell.Caption));
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append(")");
                sql             = sb.ToString();
                cmd.CommandText = sql;
                cmd.Connection  = conn;
                cmd.ExecuteNonQuery();
            }
            else //如果该报表属于多列头报表,首先从Detail中取得子列,并对列头进行特殊处理
            {
                // 将reportData前两行添加报表中文名称等信息。
                sb = new StringBuilder();
                sb.Append("insert into ReportData VALUES(");
                foreach (var cell in cellList)
                {
                    sb.Append(string.Format("'{0}',", childCellList.Contains(cell) ? cell.Super.Caption : cell.Caption));
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append(")");
                sql             = sb.ToString();
                cmd.CommandText = sql;
                cmd.Connection  = conn;
                cmd.ExecuteNonQuery();
                sb = new StringBuilder();
                sb.Append("insert into ReportData VALUES(");
                foreach (var cell in cellList)
                {
                    sb.Append(string.Format("'{0}',", cell.Caption));
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append(")");
                sql             = sb.ToString();
                cmd.CommandText = sql;
                cmd.Connection  = conn;
                cmd.ExecuteNonQuery();
            }


            // 插入报表数据
            DbTransaction trans = conn.BeginTransaction(); // <--加入事务控制
            try
            {
                foreach (SemiRow semiRow in mobileReport.SemiRows)
                {
                    sb = new StringBuilder();
                    sb.Append("insert into ReportData VALUES(");
                    foreach (var cell in cellList)
                    {
                        string value;
                        if (semiRow[cell.Name] == null)
                        {
                            value = "";
                        }
                        else
                        {
                            value = semiRow[cell.Name].ToString();
                        }
                        if (value == "'")
                        {
                            value = "''";
                        }
                        sb.Append(string.Format("'{0}',", value));
                    }
                    sb.Remove(sb.Length - 1, 1);
                    sb.Append(")");
                    sql             = sb.ToString();
                    cmd.CommandText = sql;
                    cmd.Connection  = conn;
                    cmd.ExecuteNonQuery();
                }
                trans.Commit(); // <--提交事务
            }
            catch (Exception exception)
            {
                trans.Rollback(); // <--失败则回滚
                throw exception;
            }
            filePath = Path.ChangeExtension(fileName, ".txt");
            var filePath1 = Path.ChangeExtension(cachePath, ".txt");
            File.Copy(cachePath, filePath1);
            //File.Move(cachePath, filePath1);
            #endregion
        }
        /// <summary>
        ///     在分页加载时,通过移动前端传递过来的列头信息构造数据字符串
        /// </summary>
        /// <param name="columnsInfoString">移动前端传递过来的列头信息字符串</param>
        /// <param name="report">MobileReport对象</param>
        /// <returns>结果DSL串</returns>
        internal static string TransferToRowDataJson(string columnsInfoString, MobileReport report)
        {
            var rowBuilder = new StringBuilder();
            var semirows   = new SemiRows();

            if (report != null)
            {
                semirows = report.SemiRows;
            }
            string[] columns = columnsInfoString.Split(',');
            rowBuilder.Append("\"data\":[");
            int j = 0;

            foreach (SemiRow semiRow in semirows)
            {
                rowBuilder.Append("{\"RowNumber\":");
                rowBuilder.Append(string.Format("\"{0}\",", j.ToString()));
                //rowBuilder.Append(string.Format("{\"RowNumber\":\"{0}\"", j.ToString()));
                if (semiRow.SectionType == SectionType.ReportSummary)
                // 如果当前行是总计行
                {
                    rowBuilder.Append("\"level\":\"0\",");
                    for (int i = 0; i < columns.Length; i++)
                    {
                        rowBuilder.Append(string.Format("\"{0}\":", columns[i].ToString()));
                        if (i == 0)
                        {
                            rowBuilder.Append("\"总计\",");
                            continue;
                        }
                        if (semiRow.Contains(columns[i]))
                        {
                            rowBuilder.Append(string.Format("\"{0}\",", (semiRow[columns[i]].ToString()).Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\"", "")));
                        }
                        else
                        {
                            rowBuilder.Append("\"\",");
                        }
                        //rowBuilder.Append(string.Format("\"{0}\":\"{1}\"", columns[i].ToString(), semiRow[columns[i]]));
                    }
                    rowBuilder.Remove(rowBuilder.Length - 1, 1);
                    rowBuilder.Append("},");
                }
                else
                // 如果当前行是普通数据行
                {
                    foreach (string t in columns)
                    {
                        if (semiRow.Contains(t))
                        {
                            rowBuilder.Append(string.Format("\"{0}\":\"{1}\",", t, semiRow[t].ToString().Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\"", "\\\"")));
                        }
                        else
                        {
                            rowBuilder.Append(string.Format("\"{0}\":\"{1}\",", t, ""));
                        }
                    }

                    rowBuilder.Remove(rowBuilder.Length - 1, 1);
                    rowBuilder.Append("},");
                }
                //rowBuilder.Append("}");
                j++;
            }
            if (semirows.Count != 0)
            {
                rowBuilder.Remove(rowBuilder.Length - 1, 1);
            }
            rowBuilder.Append("]}");
            return(rowBuilder.ToString());
        }
Example #7
0
        /// <summary>
        /// 打开一张报表
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="filterString">下载时使用,直接传入过滤字符串</param>
        /// <param name="isGetAllDate">是否获取所有报表数据,为true则为被下载时调用</param>
        /// <returns></returns>
        public MobileReport OpenReport(Dictionary <string, string> parameters = null, string filterString = null, bool isGetAllDate = false)
        {
            var time = DateTime.Now;

            #region 1.LoadFormat 读取报表结构
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->LoadFormat TaskID: " + _loginInfo.TaskID + "  Start:" + time.ToString());
            var reportEngine = new ReportEngine(this._loginInfo, ReportStates.Browse);
            //reportEngine.LoadFormat(null, this._viewId, null, null, null, null, null);
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->LoadFormat TaskID: " + _loginInfo.TaskID + "  End:" + System.DateTime.Now.ToString());
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->LoadFormat TaskID: " + _loginInfo.TaskID + "  Use Time " + (DateTime.Now - time).ToString());

            #endregion 1.LoadFormat 读取报表结构


            #region 2.GetSql 与习文过滤交互,获取过滤对象

            time = System.DateTime.Now;
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->GetSql TaskID: " + _loginInfo.TaskID + "  Start:" + time.ToString());
            // 调用习文的FilterSrv方法,构建FilterArgs的RawFilter部分
            FilterSrv objfilter = new FilterSrvClass();
            object    err       = null;
            objfilter.InitSolutionID = _solutionId;
            // 构建Filter对象_filter
            _filter = new FilterArgs(this._reportId, this._filterClass, this._loginInfo);
            this.InitFilter(ref _filter, this._loginInfo);
            //if (!isGetAllDate)
            //    this.InitFilter2(ref _filter, this._loginInfo);
            _filter.RawFilter = objfilter;
            var filter1 = _filter.RawFilter as FilterSrv;
            // 创建业务组的自定义行为对象,传给过滤控件
            if (!string.IsNullOrEmpty(_filter.FilterClass))
            {
                var oComObj = Activator.CreateInstance(
                    Type.GetTypeFromProgID(_filter.FilterClass));
                filter1.BehaviorObject = oComObj;
            }
            filter1.FilterArgs.Add(_filter.Args["ufreportarg"], "ufreportarg");
            bool flag = filter1.OpenFilter(this._loginInfo.U8Login, _filterId, null, null, ref err, true);
            if (flag)
            {
                UFGeneralFilter.FilterItemsClass filterItems = filter1.FilterList as FilterItemsClass;
                for (int i = 1; i < filterItems.Count + 1; i++)
                {
                    ReportFilterService.FilterItem item = new ReportFilterService.FilterItem(filterItems[i].Key, filterItems[i].varValue);
                    _filter.FltDAESrv.Add(item);
                    _filter.FltSrv.Add(item);
                    if (!String.IsNullOrEmpty(filterItems[i].DAEexpression1))
                    {
                        ReportFilterService.FilterItem item1 = new ReportFilterService.FilterItem(filterItems[i].DAEexpression1, filterItems[i].varValue);
                        _filter.FltDAESrv.Add(item1);
                        _filter.FltSrv.Add(item);
                    }
                }
                //1.初始化一个reportEngine对象
                if (parameters == null) //下载时逻辑,直接传入
                {
                    _filter.DataSource.FilterString = this.FillCustomFilterString(objfilter, filterString);
                }
                else //界面打开时
                {
                    _filter.ViewID = this._viewId;
                    _filter.DataSource.FilterString = this.FillCustomFilterString(objfilter, parameters);
                    //_filter.DataSource.FilterString = JsonTransfer.VTransfer(_filter.DataSource.FilterString);
                    //_filter.DataSource.FilterString = "1=1";
                }
            }
            else
            {
                string errorInfo = err.ToString();
                throw new InvalidEnumArgumentException("该报表有必输过滤项目没有设置默认值,请设置默认值重新查询!" + errorInfo);
            }

            // 从习文的过滤对象中取得值赋值给报表过滤对象
            this.InitFilterArgsAfterOpenFilter(ref _filter, filter1.InitSolutionID);
            #endregion 2.GetSql 与习文过滤交互,获取过滤对象
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->GetSql TaskID: " + _loginInfo.TaskID + "  End:" + System.DateTime.Now.ToString());
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->GetSql TaskID: " + _loginInfo.TaskID + "  Use Time " + (DateTime.Now - time).ToString());

            #region 3.OpenReport 调用业务组getSql方法获取数据源,打开一张报表
            time = System.DateTime.Now;
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->OpenReport TaskID: " + _loginInfo.TaskID + "  Start:" + time.ToString());
            var engineAdapter = new MobileReportEngineAdapter(this._loginInfo);
            //这里有个GetSql()方法。
            this._filterFlag = this.GetfilterFlag();

            engineAdapter.OpenReport(_filter, _filterFlag, null, null, null, _baseTableName);

            // 参照BS的GetMessage,循环调用拉取数据
            this._mobileReport = engineAdapter.GetReport();

            // 如果是第一次打开新的报表

            while (!this._mobileReport.PageEnd)
            {
                engineAdapter.GetMessage();
            }
            this._mobileReport = engineAdapter.GetReport();

            if (isGetAllDate)// 如果是下载全部报表数据,这里采用pageTo方法获取所有报表数据.
            {
                this._mobileReport.SemiRows = new SemiRows();
                var mobileReport = this.PageTo(this._mobileReport.Report.CacheID, -1, -1);
                this._mobileReport.SemiRows = mobileReport.SemiRows;
            }
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->OpenReport TaskID: " + _loginInfo.TaskID + "  End:" + System.DateTime.Now.ToString());
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->OpenReport TaskID: " + _loginInfo.TaskID + "  Use Time " + (DateTime.Now - time).ToString());
            return(this._mobileReport);

            #endregion 3.OpenReport 调用业务组getSql方法获取数据源,打开一张报表
        }
Example #8
0
        /// <summary>
        /// 下载时使用,获取全部报表数据
        /// </summary>
        /// <param name="o"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public MobileReport GetAllReport(Dictionary <string, string> parameters = null, string condition = null)
        {
            MobileReport report = this.OpenReport(parameters, condition, true);

            return(report);
        }
        /// <summary>
        /// 新增供U易联调用的接口
        /// </summary>
        /// <param name="login"></param>
        /// <param name="actionType"></param>
        /// <param name="parameters"></param>
        /// <param name="responseXml"></param>
        /// <returns></returns>
        public string Execute(U8LoginInfor login, string actionType, Dictionary <string, string> parameters,
                              ref string responseXml)
        {
            string result   = "";
            bool   is4chart = false;

            if (parameters.ContainsKey("is4chart"))
            {
                is4chart = Boolean.Parse(parameters["is4chart"]);
            }
            this._loginInfo   = login;
            this._responseXml = responseXml;
            if (!this.CheckReportExist(parameters))
            {
                result = "该查询方案不存在,可能已经取消发布到移动端,请确认!";
                throw new Exception("该查询方案不存在,可能已经取消发布到移动端,请确认!");
            }
            try
            {
                MobileReportEngine engine = new MobileReportEngine(this._loginInfo, actionType, parameters, ref responseXml);
                int startLine             = Convert.ToInt32(this.GetInformationByKey("startline", parameters));
                this._columnsStr = this.GetInformationByKey("columnsstring", parameters);
                int pageRowCount = 25;
                if (this.GetInformationByKey("count", parameters) != null)
                {
                    pageRowCount = Convert.ToInt32(this.GetInformationByKey("count", parameters));
                }

                engine.SetReportPageRowCount(pageRowCount);
                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 = RetrieveRowData2Json.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(this.GetInformationByKey("currentpage", parameters));
                        //pageIndex = Convert.ToInt32(parameters["currentpage"].ToString());
                    }
                    int totalpage = Convert.ToInt32(this.GetCacheInfoFromSession(responseXml, "totalpage"));
                    if (totalpage == 0)
                    {
                        totalpage       = Convert.ToInt32(this.GetInformationByKey("totalpage", parameters));
                        this._totolPage = totalpage.ToString();
                    }
                    if (pageIndex + 1 > totalpage)
                    {
                        result = null;
                        return(result);
                    }
                    else
                    {
                        string cacheId = GetCacheInfoFromSession(responseXml, "cacheid");
                        if (string.IsNullOrEmpty(cacheId))
                        {
                            cacheId       = this.GetInformationByKey("cacheid", parameters);
                            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)
                {
                    int pageIndex = Convert.ToInt32(this.GetCacheInfoFromSession(responseXml, "currentpage"));
                    if (pageIndex == 0)
                    {
                        if (parameters.ContainsKey("currentpage"))
                        {
                            pageIndex = Convert.ToInt32(this.GetInformationByKey("currentpage", parameters));
                        }
                    }
                    // 由于CS端每页都需要显示总计行,这里需要将不是最后一页的总计行删除掉
                    //if (!bLastPage(pageIndex, _mobileReport.Report) && this._mobileReport.Report.Sections[SectionType.ReportSummary] != null)
                    //{
                    //    _mobileReport.SemiRows.RemoveAt(_mobileReport.SemiRows.Count - 1);
                    //}
                    // 如果是请求图表数据
                    if (is4chart)
                    {
                        var report = _mobileReport.Report;
                        engine.InitMobileReportChartSchema(report);
                        ChartService chartservice = new ChartService(report);
                        ChartSchemas css          = report.ChartSchemas;
                        if (css.CurrentGroupChart.Items != null && css.CurrentGroupChart.Items.Count > 0)
                        {
                            ChartSchemaItem groupCharts = css.CurrentGroupChart.Items[1] as ChartSchemaItem;
                            if (groupCharts != null)
                            {
                                foreach (ChartSchemaItemAmong among in groupCharts.Items.Values)
                                {
                                    UltraChart  designChart = MobileChartHelper.CreateAchartByDesignTime(among);
                                    var         dataTable1  = chartservice.GetDataSource(groupCharts.Level, among.ID, null, designChart.ChartType);
                                    MobileChart mobileChart = new MobileChart(designChart.ChartType, dataTable1);
                                    string      result1     = MobileChartHelper.TransferDataTableToString(mobileChart);
                                    MobileChartHelper.Desrialize <MobileChart>(mobileChart, result1);
                                    return(result1);
                                }
                            }
                        }
                    }
                    System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ParseReport TaskID: " + _loginInfo.TaskID + "  Start:" + System.DateTime.Now.ToString());
                    result = ULinkParse(this._mobileReport);
                    System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ParseReport TaskID: " + _loginInfo.TaskID + "  End:" + System.DateTime.Now.ToString());
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("无法将类型为“U8Login.clsLoginClass”的 COM 对象强制转换为接口类型“U8Login._clsLogin”") && !parameters.ContainsKey("AAA"))
                {
                    parameters.Add("AAA", "1");
                    return(Execute(this._loginInfo, actionType, parameters, ref responseXml));
                }
                else
                {
                    throw ex;
                }
            }
            System.Diagnostics.Trace.WriteLine("<<<<<<<<<<MobileReportTest>>>>>>>>>>OpenReport-->ExecuteOpenReport TaskID: " + this._loginInfo.UserToken + "  End:" + System.DateTime.Now.ToString());
            return(result);
        }
        private string ULinkParse(MobileReport report)
        {
            string tableSchema = string.Empty;
            string reportStr;
            string rowData;

            if (report.Page == 0) //第一页
            {
                //tableSchema = JsonTransfer.TransferToTableSchema(report);
                //byte[] bytes = Encoding.Default.GetBytes(tableSchema);
                //tableSchema = Convert.ToBase64String(bytes);
                rowData = RetrieveRowData2Json.TransferToRowData(report);
                StringBuilder sb = new StringBuilder();
                sb.Append("{");
                sb.Append("\"resresult\":{");
                sb.Append("\"flag\": \"0\",");

                sb.Append("\"currentpage\": \"");
                sb.Append(string.IsNullOrEmpty(this._currentPage) ? "" : this._currentPage + "\",");

                sb.Append("\"totalpage\": \"");
                sb.Append(string.IsNullOrEmpty(this._totolPage) ? "" : this._totolPage + "\",");

                sb.Append("\"columnsstring\": \"");
                sb.Append(string.IsNullOrEmpty(this._columnsStr) ? "" : this._columnsStr + "\",");

                sb.Append("\"cacheid\": \"");
                sb.Append(string.IsNullOrEmpty(this._cacheid) ? "" : this._cacheid + "\",");

                sb.Append("\"desc\": \"查询报表详情成功!\",");
                sb.Append("\"resdata\": ");
                sb.Append(string.Format("{0}", rowData));
                sb.Append("}}");
                reportStr = sb.ToString();
                //reportStr = string.Format("<report><tableSchema>{0}</tableSchema>{1}</report>", tableSchema, rowData);
            }
            else
            {
                if (report.SemiRows != null)
                {
                    string columnstr = this.GetCacheInfoFromSession(this._responseXml, "columnsString");
                    try
                    {
                        byte[] bytes = Convert.FromBase64String(columnstr);
                        columnstr = Encoding.Default.GetString(bytes);
                    }
                    catch
                    {
                        columnstr = this._columnsStr;
                    }
                    rowData = RetrieveRowData2Json.TransferToRowDataJson(columnstr, report);
                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    sb.Append("\"resresult\":{");
                    sb.Append("\"flag\": \"0\",");

                    sb.Append("\"currentpage\": \"");
                    sb.Append(string.IsNullOrEmpty(this._currentPage) ? "" : this._currentPage + "\",");

                    sb.Append("\"totalpage\": \"");
                    sb.Append(string.IsNullOrEmpty(this._totolPage) ? "" : this._totolPage + "\",");

                    sb.Append("\"columnsstring\": \"");
                    sb.Append(string.IsNullOrEmpty(this._columnsStr) ? "" : this._columnsStr + "\",");

                    sb.Append("\"cacheid\": \"");
                    sb.Append(string.IsNullOrEmpty(this._cacheid) ? "" : this._cacheid + "\",");

                    sb.Append("\"desc\": \"查询报表详情成功!\",");
                    sb.Append("\"resdata\":{");
                    sb.Append(string.Format("{0}", rowData));
                    sb.Append("}}");
                    reportStr = sb.ToString();
                    //reportStr = string.Format("<report>{0}</report>", rowData);
                }
                else
                {
                    reportStr = null;
                }
            }
            return(reportStr);
        }
        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);
        }