1 Star 0 Fork 2

智锋科技/PIP_Demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
FormTest.cs 22.73 KB
一键复制 编辑 原始数据 按行查看 历史
李涛 提交于 2019-10-23 12:21 . 重构
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using System.Net;
using System.IO;
using System.Configuration;
//using Oracle.ManagedDataAccess.Client;
using System.Text.RegularExpressions;
using System.Web.Services.Description;
namespace HIS.EHC
{
public partial class FormTest : Form
{
public FormTest()
{
InitializeComponent();
}
/// <summary>
/// 消息推送
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void onepush_Click(object sender, EventArgs e)
{
string url = tb_sendURL.Text.ToString(); //GetAppConfig("onepushUrl");
//string url = "http://hefei12320.com:8090/ehc-portal-push/sms/send";
string indata = rtb_in.Text.Trim().ToString();
Helper.SaveLog("消息推送入参:" + "url:" + url + "\r\n" + "indata:" + indata.ToString());
StringBuilder outdata = new StringBuilder();
rtb_out.Text = Helper.TransPush(url, indata, outdata) + "\n" + outdata.ToString();
Helper.SaveLog("消息推送出参:" + outdata.ToString());
}
/// <summary>
/// 注册电子健康卡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void sign_Click(object sender, EventArgs e)
{
string mode = tb_display_mode.Text.ToString().Trim();
int intA;
int.TryParse(mode, out intA);
Helper.Set_QRflow_Mode(intA);
string indata = rtb_in.Text.Trim().ToString();
//var jsonObjin = WEISHENG.COMM.Helper.JsonHelper.DeserializeJSON<JavaScriptObject>(indata);
var jsonObjin = JsonConvert.DeserializeObject(indata);
//JavaScriptObject jsonObjin = JavaScriptConvert.DeserializeObject<JavaScriptObject>(indata);
string url = tb_ehcURL.Text.ToString().Trim();//GetAppConfig("ehcUrl");
Helper.SaveLog("注册电子健康卡入参:" + "url:" + url + "\r\n" + "indata:" + indata.ToString());
//string url = "http://hefei12320.com:8070/ehcService/gateway.do";
Byte[] outdata = new Byte[2048];
IntPtr a = Helper.VirtualCardTrans(url, indata, ref outdata[0]);
string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
string strRet = Marshal.PtrToStringAnsi(a);
rtb_out.Text = strRet + "\n" + strGet.TrimEnd('\0');
Helper.SaveLog("注册电子健康卡出参:" + strRet + "\n" + strGet.TrimEnd('\0'));
#region 单独调用打印
//JavaScriptObject jsonObjout = JavaScriptConvert.DeserializeObject<JavaScriptObject>(strGet);
//string ehealthid = jsonObjout["ehealth_code"].ToString();
//string name = jsonObjout["user_name"].ToString();
//string cardNo = jsonObjout["card_no"].ToString();
//EhealthID_Print(ehealthid, cardNo, name);
//例子
//string jsonText = "{\"beijing\":{\"zone\":\"海淀\",\"zone_en\":\"haidian\"}}";
//JObject jo = (JObject)JsonConvert.DeserializeObject(jsonText);
//string zone = jo["beijing"]["zone"].ToString();
//string zone_en = jo["beijing"]["zone_en"].ToString();
//string content = jsonObjin["biz_content"].ToString();
//JavaScriptObject jsonObj = JavaScriptConvert.DeserializeObject<JavaScriptObject>(content);
//if(jsonObj.ContainsKey("QRprint")&&jsonObj["QRprint"]=="Y")
//{
#endregion
}
/// <summary>
/// 电子健康卡验证
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void versign_Click(object sender, EventArgs e)
{
string trace = DateTime.Now.ToString("yyyyMMddhhmmss");
string indata = "{\"app_id\":\"" + tb_AppId.Text.Trim().ToString() + "\",\"biz_content\":{\"ehealth_code\":\"" + tb_cardID.Text.Trim().ToString() + "\",\"operator_id\":\"9527\",\"operator_name\":\"admin\",\"out_verify_no\":\"" + trace.Trim().ToString() + "\",\"out_verify_time\":\"20180516000058\",\"treatment_code\":\"010105\"},\"enc_type\":\"AES\",\"key\":\"" + tb_key.Text.Trim().ToString() + "\",\"method\":\"ehc.ehealthcode.verify\",\"sign\":\"\",\"sign_type\":\"MD5\",\"term_id\":\"" + tb_term_id.Text.Trim().ToString() + "\",\"timestamp\":\"20180516000058\",\"version\":\"X.M.0.1\"}";
string url = tb_ehcURL.Text.ToString().Trim(); //GetAppConfig("ehcUrl");
Helper.SaveLog("电子健康卡验证入参:" + "url:" + url + "\r\n" + "indata:" + indata.ToString());
//string url = "http://hefei12320.com:8070/ehcService/gateway.do";//"http://120.42.37.94:1301/ehcService/gateway.do";
Byte[] outdata = new Byte[2048];
IntPtr a = Helper.VirtualCardTrans(url, indata, ref outdata[0]);
string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
string strRet = Marshal.PtrToStringAnsi(a);
rtb_out.Text = strGet.TrimEnd('\0');
Helper.SaveLog("电子健康卡验证出参:" + strRet + "\n" + strGet.TrimEnd('\0'));
}
/// <summary>
/// 主扫授权
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void authurl_Click(object sender, EventArgs e)
{
//string trace = DateTime.Now.ToString("yyyyMMddhhmmss");
//string indata = "{\"app_id\":\"1BQA48ETK000A718A8C000001FFAA482\",\"enc_type\":\"AES\",\"biz_content\":{\"out_authorize_no\":\"" + trace.Trim().ToString() + "\",\"out_authorize_time\":\"20171117123001\",\"operator_id\":\"\",\"operator_name\":\"\",\"treatment_code\":\"\"},\"sign\": \"\",\"sign_type\": \"MD5\",\"timestamp\": \"20171113092820\",\"method\": \"ehc.ehealthcard.authurl\",\"term_id\": \"35020010001\",\"version\": \"X.M.0.1\",\"key\": \"1BQA48ETK001A718A8C00000FE996B9B\"}";
//string url = tb_ehcURL.Text.ToString().Trim();// GetAppConfig("ehcUrl");
//string mode = tb_display_mode.Text.ToString().Trim();
//int intA;
//int.TryParse(mode, out intA);
//Helper.Set_QRflow_Mode(intA);
////string url = "http://hefei12320.com:8070/ehcService/gateway.do";//"http://120.42.37.94:1301/ehcService/gateway.do";
//IntPtr a = Helper.Trans(indata);
//rtb_out.Text = strRet + "\n" + strGet.TrimEnd('\0');
//rtb_in.Text = trace.Trim().ToString();
////string indata1 = "{\"app_id\": \"1BQA48ETK000A718A8C000001FFAA482\",\"enc_type\": \"AES\",\"biz_content\": {\"out_authorize_no\": \"" + trace.Trim().ToString() + "\",\"out_authorize_time\":\"20171117123001\"},\"sign\": \"\",\"sign_type\": \"MD5\",\"timestamp\": \"20171113092820\",\"method\": \"ehc.ehealthcard.auth.query\",\"term_id\": \"35020010001\",\"version\": \"X.M.0.1\",\"key\": \"1BQA48ETK001A718A8C00000FE996B9B\"}";
////string url1 = GetAppConfig("ehcUrl");
////Helper.SaveLog("查询用户用卡授权结果:" + "url1:" + url1 + "\r\n" + "indata1:" + indata1.ToString());
//////string url = "http://hefei12320.com:8070/ehcService/gateway.do";//"http://120.42.37.94:1301/ehcService/gateway.do";
////Byte[] outdata1 = new Byte[2048];
////IntPtr a1 = VirtualCardTrans(url1, indata1, ref outdata1[0]);
////string strGet1 = System.Text.Encoding.Default.GetString(outdata1, 0, outdata1.Length);
////string strRet1 = Marshal.PtrToStringAnsi(a);
////rtb_out.Text = strRet1 + "\n" + strGet1.TrimEnd('\0');
////Helper.SaveLog("查询用户用卡授权结果:" + strGet1.TrimEnd('\0'));
}
/// <summary>
/// 卡管交易测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
string indata = rtb_in.Text.Trim().ToString();
string url = tb_ehcURL.Text.ToString().Trim(); //GetAppConfig("ehcUrl");
//string url = "http://hefei12320.com:8070/ehcService/gateway.do";
Helper.SaveLog("卡管交易测试入参:" + "url:" + url + "\r\n" + "indata:" + indata.ToString());
Byte[] outdata = new Byte[2048];
IntPtr a = Helper.VirtualCardTrans(url, indata, ref outdata[0]);
string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
string strRet = Marshal.PtrToStringAnsi(a);
rtb_out.Text = strGet.TrimEnd('\0');
Helper.SaveLog("卡管交易测试出参:" + strGet.TrimEnd('\0'));
}
/// <summary>
/// 打印静态二维码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void print_Click(object sender, EventArgs e)
{
//string strGet = rtb_out.Text.Trim().ToString();
//JavaScriptObject jsonObjout = JavaScriptConvert.DeserializeObject<JavaScriptObject>(strGet);
//string ehealthid = jsonObjout["ehealth_card_id"].ToString();
//string name = jsonObjout["user_name"].ToString();
//string cardNo = jsonObjout["card_no"].ToString();
//EhealthID_Print(ehealthid, cardNo, name);
}
/// <summary>
/// 窗口退费函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void windowsback_Click(object sender, EventArgs e)
{
string url = tb_refundURL.Text.ToString().Trim();//GetAppConfig("winRefundUrl");//"http://hefei12320.com:8060/onepay-web/hfey/traderefundservice?";
var request = (HttpWebRequest)WebRequest.Create(url);
string postData = rtb_in.Text.ToString();
Helper.SaveLog("窗口退费测试入参:" + "url:" + url + "\r\n" + "indata:" + postData.ToString());
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
rtb_out.Text = responseString;
Helper.SaveLog("窗口退费测试出参:" + responseString);
}
/// <summary>
///测试oracle连接
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void orcl_Click(object sender, EventArgs e)
{
rtb_out.Text = "oracle数据库连接状态:" + ConnectOracle();
Helper.SaveLog("oracle数据库连接状态:" + ConnectOracle());
}
/// <summary>
/// 读取配置文件
/// </summary>
/// <param name="strKey"></param>
/// <returns></returns>
public static string GetAppConfig(string strKey)
{
string file = System.Windows.Forms.Application.ExecutablePath;
Configuration config = ConfigurationManager.OpenExeConfiguration(file);
foreach (string key in config.AppSettings.Settings.AllKeys)
{
if (key == strKey)
{
return config.AppSettings.Settings[strKey].Value.ToString();
}
}
return null;
}
/// <summary>
/// 修改AppSettings中配置
/// </summary>
/// <param name="key">key值</param>
/// <param name="value">相应值</param>
public static bool SetConfigValue(string key, string value)
{
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] != null)
config.AppSettings.Settings[key].Value = value;
else
config.AppSettings.Settings.Add(key, value);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
return true;
}
catch
{
return false;
}
}
/// <summary>
/// 连接oracle数据库
/// </summary>
/// <returns></returns>
public static string ConnectOracle()
{
//try
//{
// string connString = GetAppConfig("oraclestr");// "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=onepay)));Persist Security Info=True;User ID=system;Password=onepay;";
// OracleConnection con = new OracleConnection(connString);
// con.Open();
// MessageBox.Show(con.State.ToString());
// return string.Empty;
// return con.State.ToString();
//}
//catch (Exception ex)
//{
// return ex.ToString();
//}
return "";
}
private void authQuery_Click_1(object sender, EventArgs e)
{
string trace = rtb_in.Text.ToString(); //DateTime.Now.ToString("yyyyMMddhhmmss");
string indata = "{\"app_id\": \"1BQA48ETK000A718A8C000001FFAA482\",\"enc_type\": \"AES\",\"biz_content\": {\"out_authorize_no\": \"" + trace.Trim().ToString() + "\",\"out_authorize_time\":\"20171117123001\"},\"sign\": \"\",\"sign_type\": \"MD5\",\"timestamp\": \"20171113092820\",\"method\": \"ehc.ehealthcard.auth.query\",\"term_id\": \"35020010001\",\"version\": \"X.M.0.1\",\"key\": \"1BQA48ETK001A718A8C00000FE996B9B\"}";
string url = GetAppConfig("ehcUrl");
Helper.SaveLog("查询用户用卡授权结果:" + "url:" + url + "\r\n" + "indata:" + indata.ToString());
//string url = "http://hefei12320.com:8070/ehcService/gateway.do";//"http://120.42.37.94:1301/ehcService/gateway.do";
Byte[] outdata = new Byte[2048];
IntPtr a = Helper.VirtualCardTrans(url, indata, ref outdata[0]);
string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
string strRet = Marshal.PtrToStringAnsi(a);
rtb_out.Text = strRet + "\n" + strGet.TrimEnd('\0');
Helper.SaveLog("查询用户用卡授权结果:" + strGet.TrimEnd('\0'));
}
private void checkBill_Click(object sender, EventArgs e)
{
try
{
string url = rtb_in.Text.ToString();
Helper.SaveLog("his接口日志入参:" + url);
//"https://bp.winning-health.com.cn:15574/winbx/p?action=GETHISZD&ksrq=20181115&zflb=1&yydm=0019-03&randnum=8bfba9be-ab7a-43a0-b899-c5779d8182fb&timestamp=20180730131906&accesskey=98B9A8472BD06DA1CD740EE85541951FC2370FBF64253A6CBF27A349AD447B37F1D9AC0D24BBC7435878E12D65D2FFCF1CB09D57F51A95E07E35E71F0C20F14B";
//"https://bp.winning-health.com.cn:15574/winbx/p?action=HELLO&yydm=0019-03&randnum=12312321312a321313&timestamp=20180730131906&accesskey=98B9A8472BD06DA1CD740EE85541951FC2370FBF64253A6CBF27A349AD447B37F1D9AC0D24BBC7435878E12D65D2FFCF1CB09D57F51A95E07E35E71F0C20F14B";// "https://bp.winning-health.com.cn:15574/winbx/p";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string jsonStr = responseString.ReadToEnd();
//DataTable dt = JsonToDataTable(jsonStr);
//dgv1.DataSource = dt;
rtb_out.Text = jsonStr.ToString();
responseString.Close();
response.Close();
Helper.SaveLog("his接口日志出参:" + responseString);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
rtb_out.Text = ex.ToString();
}
//string url = "https://bp.winning-health.com.cn:15574/winbx/p";
////"https://bp.winning-health.com.cn:15574/winbx/p?action=HELLO&yydm=0019-03&randnum=12312321312a321313&timestamp=20180730131906&accesskey=98B9A8472BD06DA1CD740EE85541951FC2370FBF64253A6CBF27A349AD447B37F1D9AC0D24BBC7435878E12D65D2FFCF1CB09D57F51A95E07E35E71F0C20F14B";// "https://bp.winning-health.com.cn:15574/winbx/p";
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//string postData ="action=HELLO&yydm=0019-03&randnum=12312321312a321313&timestamp=20180730131906&accesskey=98B9A8472BD06DA1CD740EE85541951FC2370FBF64253A6CBF27A349AD447B37F1D9AC0D24BBC7435878E12D65D2FFCF1CB09D57F51A95E07E35E71F0C20F14B";//"https://IP:port/winbx/p?action=GETHISZD&ksrq=&zflb&czyh&yydm&randnum&timestamp&accesskey";
//Helper.SaveLog("对账单:" + "url:" + url + "\r\n" + "indata:" + postData.ToString());
//byte[] data = Encoding.UTF8.GetBytes(postData);
//request.Method = "POST";
//request.ContentType = "application/json;charset=utf-8";
//request.ContentLength = data.Length;
//Stream stream = request.GetRequestStream();
//stream.Write(data, 0, data.Length);
//stream.Close();
//HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//StreamReader responseString = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
//rtb_out.Text = responseString.ReadToEnd();
//responseString.Close();
//response.Close();
////stream.Close();
//Helper.SaveLog("对账单:" + responseString.ReadToEnd());
}
#region json转换为DataTable
/// <summary>
/// 将json转换为DataTable
/// </summary>
/// <param name="strJson">得到的json</param>
/// <returns></returns>
private DataTable JsonToDataTable(string strJson)
{
//转换json格式
strJson = strJson.Replace(",\"", "*\"").Replace("\":", "\"#").ToString();
//取出表名
var rg = new Regex(@"(?<={)[^:]+(?=:\[)", RegexOptions.IgnoreCase);
string strName = rg.Match(strJson).Value;
DataTable tb = null;
//去除表名
strJson = strJson.Substring(strJson.IndexOf("[") + 1);
strJson = strJson.Substring(0, strJson.IndexOf("]"));
//获取数据
rg = new Regex(@"(?<={)[^}]+(?=})");
MatchCollection mc = rg.Matches(strJson);
for (int i = 0; i < mc.Count; i++)
{
string strRow = mc[i].Value;
string[] strRows = strRow.Split('*');
//创建表
if (tb == null)
{
tb = new DataTable();
tb.TableName = strName;
foreach (string str in strRows)
{
var dc = new DataColumn();
string[] strCell = str.Split('#');
if (strCell[0].Substring(0, 1) == "\"")
{
int a = strCell[0].Length;
dc.ColumnName = strCell[0].Substring(1, a - 2);
}
else
{
dc.ColumnName = strCell[0];
}
tb.Columns.Add(dc);
}
tb.AcceptChanges();
}
//增加内容
DataRow dr = tb.NewRow();
for (int r = 0; r < strRows.Length; r++)
{
dr[r] = strRows[r].Split('#')[1].Trim().Replace(",", ",").Replace(":", ":").Replace("\"", "");
}
tb.Rows.Add(dr);
tb.AcceptChanges();
}
return tb;
}
#endregion
/// <summary>
/// 获取检验报告单查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void QueryReportInfo_Click(object sender, EventArgs e)
{
//PayClient.WebReference.TechLisWebService pdfWeb = new PayClient.WebReference.TechLisWebService();
//string reportId = "14516879";//"14279606";
//string type = "2";
//string pdf = pdfWeb.QueryReportInfo(reportId, type);
//rtb_out.Text = pdf.ToString().Trim();
}
/// <summary>
/// 获取检查报告单查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void getRis_Click(object sender, EventArgs e)
{
//PayClient.riswebservice.TechLisWebService risweb = new PayClient.riswebservice.TechLisWebService();
//string reportId = "6781540";//"6780980";
//string type = "1";
//string pdf = risweb.QueryReportInfo(reportId,type);
//rtb_out.Text = pdf.ToString().Trim();
}
//[DllImport("E:\\易惠项目\\0项目\\合肥二院接口测试\\合肥二院测试\\合肥二院测试\\bin\\发布dll\\onepush.dll")]
//public static extern IntPtr TransPush(string url, string indata, ref byte outdata);
///// <summary>
///// 消息推送
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void onepush_Click(object sender, EventArgs e)
//{
// string url = "http://hefei12320.com:8090/ehc-portal-push/sms/send";
// string indata = rtb_in.Text;
// //StringBuilder outdata = new StringBuilder();
// Byte[] outdata = new Byte[2048];
// IntPtr a = TransPush(url, indata, ref outdata[0]);
// string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
// string strRet = Marshal.PtrToStringAnsi(a);
//}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/elfbobo_admin/PIP_Demo.git
git@gitee.com:elfbobo_admin/PIP_Demo.git
elfbobo_admin
PIP_Demo
PIP_Demo
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385