using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Util;
using System;
using System.ComponentModel;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;
using System.Net;
namespace King.dee.ZC02
{
/// <summary>
/// </summary>
[Description("【单据列表插件】菜单应用"), HotUpdate]
public class MenuBillPlugIn : AbstractListPlugIn
{
/// <summary>
/// 主菜单点击事件
/// </summary>
/// <param name="e"></param>
public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey == "RRMP_tbButton_3")
{
GetDataFromApiAsync();
}
}
private void GetDataFromApiAsync()
{
// 目标GET接口的URL
string url = "http://localhost:9092/findFlowlist";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
// 接收报错信息
HttpWebResponse resp;
try
{
resp = (HttpWebResponse)req.GetResponse();
this.View.ShowMessage("result:" + resp);
}
catch (WebException ex)
{
resp = ex.Response as HttpWebResponse;
}
if (resp.StatusCode == HttpStatusCode.OK)
{
Stream stream = resp.GetResponseStream();
//获取内容
using (StreamReader reader = new StreamReader(stream))
{
string result = reader.ReadToEnd();// 请求结果
}
}
else
{
throw new Exception("连接不到服务器!");
}
}
}
}
推荐阅读
您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!
请选择打赏金币数 *