【Stimulsoft Reports Server教程】创建报表快照

发布时间 : 2019-01-14 11:10:01.000|阅读 503 次

概述:此示例项目显示如何创建报表shapshot项目。为此,您可以使用reportsnapshots REST命令。作为参数,您需要指定命令缩进,报表快照名称和报表shapshot说明。这些参数可以作为请求发布数据传递。

相关链接:

下载Stimulsoft Reports Flex最新版本

此示例项目显示如何创建报表shapshot项目。为此,您可以使用reportsnapshots REST命令。作为参数,您需要指定命令缩进,报表快照名称和报表shapshot说明。这些参数可以作为请求发布数据传递。

#region Create Snapshot
url = "http://localhost:40010/1/reportsnapshots";
var requestCreateSnapshot = WebRequest.Create(url);
requestCreateSnapshot.Method = "POST";
requestCreateSnapshot.ContentType = "application/x-www-form-urlencoded";
requestCreateSnapshot.Headers.Add("x-sti-SessionKey", sessionKey);
 
postData = "{'Ident': 'ReportSnapshotItem', 'Name': 'ReportSnapshot01', 'Description': ''}";
Request(requestCreateSnapshot, postData);
// Check Result
var s = GetResponseResult(requestCreateSnapshot);
json = JObject.Parse(s);
var items = ((JArray)json["Items"]);
#endregion

您可以使用以下方法向服务器发送请求并获取请求的结果。

private void Request(WebRequest request, string postData)
{
    var bytesCreateSnapshot = Encoding.GetEncoding(1251).GetBytes(postData);
    request.ContentLength = bytesCreateSnapshot.Length;
    using (Stream ws = request.GetRequestStream())
    {
        ws.Write(bytesCreateSnapshot, 0, bytesCreateSnapshot.Length);
        ws.Flush();
    }
}
 
private string GetResponseResult(WebRequest request)
{
    var resp = request.GetResponse();
    var respStream = resp.GetResponseStream();
    if (respStream != null)
    {
        using (var stream1 = new StreamReader(respStream))
        {
            var s = stream1.ReadToEnd();
            return s;
        }
    }
    return null;
}

下面的屏幕截图中,您可以看到示例代码的结果。

Stimulsoft

Stimulsoft

下载示例

购买Stimulsoft正版授权,请点击“咨询在线客服”哟!

Stimulsoft资源合集专题页

在线
客服
微信
QQ 电话
023-68661681
返回
顶部