|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using System;
|
using System.Data;
|
using Newtonsoft.Json.Linq;
|
using System.IO;
|
|
namespace Gs.DevApp.DevFrm.Rpt
|
{
|
public partial class RptPreview : DevExpress.XtraEditors.XtraForm
|
{
|
private string _rptService;
|
public RptPreview(string rptService)
|
{
|
_rptService = rptService;
|
InitializeComponent();
|
this.Text = _rptService + "报表查看:";
|
getRptData();
|
}
|
|
/// <summary>
|
/// 读取报表数据列表
|
/// </summary>
|
private void getRptData()
|
{
|
var _obj = new
|
{
|
reportType = this._rptService,
|
sortName = "a.userName asc,a.roleName asc,menuActionPath ",
|
sortOrder = "asc",
|
keyWhere = ""
|
};
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", "Report/" + _rptService, JsonConvert.SerializeObject(_obj));
|
JObject _job = JObject.Parse(strJson);
|
string rtnCode = _job["rtnCode"].ToString();
|
if (int.Parse(rtnCode) > 0)
|
{
|
JArray array = new JArray();
|
foreach (var a in _job["rtnData"]["listM1"])
|
{
|
array.Add(a);
|
}
|
DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
|
DataSet ds = new DataSet();
|
dt.TableName = "Table2";
|
ds.Tables.Add(dt);
|
FastReport.Report report = new FastReport.Report();
|
byte[] buffer = (byte[])_job["rtnData"]["reportData"];
|
using (MemoryStream Stream = new MemoryStream(buffer))
|
{
|
report.Load(Stream);
|
}
|
report.RegisterData(ds);
|
report.Preview = previewControl1;
|
report.Prepare();
|
report.ShowPrepared();
|
}
|
else
|
{
|
ToolBox.MsgHelper.Warning("提示:" + _job["rtnMsg"].ToString());
|
}
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
}
|
}
|