/// <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); }