杭州市民卡医保改造,使用动态库调取医保电子凭证方法
作者:互联网
杭州市民卡医保改造,使用动态库调取医保电子凭证方法。
先将动态库ICCInter_HZ.dll,及其它动态库和配置文件,全部拷至程序根目录下。
一,新建类
/// <summary> /// 使用ICCInter_HZ.dll动态库,调用国家医保电子凭证 /// </summary> public class HZ_DZPZ { /// <summary> /// 获取动态库版本 /// </summary> /// <param name="outdata"></param> /// <returns></returns> [DllImport("ICCInter_HZ.dll", EntryPoint = "GetVer", SetLastError = false)] public static extern int GetVer(StringBuilder outdata); /// <summary> /// 交易函数(1125-扫电子凭证获取卡片基本信息(只扫一次二维码)) /// </summary> [DllImport("ICCInter_HZ.dll", EntryPoint = "ICC_Transaction", SetLastError = false)] public static extern int ICC_Transaction(int TransNum, string DataIn, StringBuilder DataOut); /// <summary> /// 电子凭证医保信息获取(根据二维码ID获取凭证令牌) /// </summary> [DllImport("ICCInter_HZ.dll", EntryPoint = "ICC_GetDZPZ_Info", SetLastError = false)] public static extern int ICC_GetDZPZ_Info(string DataIn, StringBuilder DataOut); }
二,测试获取动态库版本
//获取动态库版本 StringBuilder dataOutVer = new StringBuilder(4096); GetVer(dataOutVer); Console.WriteLine("读取动态库版本:" + dataOutVer.ToString());
三,用1125交易,根据二维码获取二维码ID
//解析手机二维码,获取二维码ID int TransNum = 1125; string dataIn = ""; StringBuilder dataOut = new StringBuilder(4096); int n = ICC_Transaction(TransNum, dataIn, dataOut); Console.WriteLine(n); Console.WriteLine("根据二维码读取二维码的ID:" + dataOut.ToString());//提取字符串 string codeID = PT.common.SearchHtml.Get_DZPZ_ID(dataOut.ToString()); Console.WriteLine("提取二维码的ID:" + codeID);
四,用ICC_GetDZPZ_Info函数,根据二维码ID读取国家电子凭证令牌。
//二维码ID读取电子凭证令牌 string myid = codeID; StringBuilder dataOutL = new StringBuilder(4096); n = ICC_GetDZPZ_Info(myid, dataOutL); Console.WriteLine(n); Console.WriteLine("国家电子凭证令牌:" + dataOutL.ToString()); //提取字符串 string DZPZ_ID = PT.common.SearchHtml.Get_DZPZ(dataOutL.ToString()); Console.WriteLine("提取国家电子凭证令牌:" + DZPZ_ID);
标签:凭证,ICC,StringBuilder,医保,ID,二维码,WriteLine,调取 来源: https://www.cnblogs.com/yisheng163/p/15881831.html