123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Reflection;
- using System.Net;
- using System.Management;
- using System.IO;
- using System.Runtime.InteropServices;
- namespace BJShouXinYB_Demo
- {
- class MedOrdersShareClass
- {
- [DllImport("MedicareCom.dll", EntryPoint = "Open", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- static extern int Open(StringBuilder OutData);
- [DllImport("MedicareCom.dll", EntryPoint = "GetPersonInfo_Multimedia", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- static extern int GetPersonInfo_Multimedia(StringBuilder InData, StringBuilder OutData);
- [DllImport("MedicareCom.dll", EntryPoint = "GetPersonInfoNation_Multimedia", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- static extern int GetPersonInfoNation_Multimedia(StringBuilder InData, StringBuilder OutData);
- [DllImport("MedicareCom.dll", EntryPoint = "NationEcTrans", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
- static extern IntPtr NationEcTrans(StringBuilder strUrl, StringBuilder InData, StringBuilder OutData);
- public int GetMedOrdersShareObj(out System.Type OutComType, out object OutComInstance)
- {
- Object rtnObj = "";
- string progID = "EachCommunicationCom.Outpatient";
- System.Type ComType;
- object ComInstance;
- ComType = Type.GetTypeFromProgID(progID);
- // 创建Com的实例
- if (ComType != null)
- {
- //创建实例
- ComInstance = Activator.CreateInstance(ComType);
- OutComType = ComType;
- OutComInstance = ComInstance;
- return 0;
- }
- else
- {
- OutComType = null;
- OutComInstance = "";
- return -1;
- }
- }
- public void ConnectServer(System.Type ComType, object ComInstance, out string OutPut)
- {
- try
- {
- if (ComInstance == null)
- {
- OutPut = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[1];
- ParamArray[0] = "";
- //ParamArray[1] = input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ComType.InvokeMember("ConnectServer", // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- OutPut = ParamArray[0].ToString();
- MessageBox.Show("ConnectServer输出:" + OutPut);
- return;
- }
- catch (Exception ex)
- {
- OutPut = ex.Message;
- MessageBox.Show("COM加载异常!" + OutPut);
- return;
- }
- }
- public void MedOrdersShareObj(string FunName, string Input, System.Type ComType, object ComInstance, out string OutPut)
- {
- try
- {
- if (ComInstance == null)
- {
- OutPut = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[2];
- ParamArray[0] = Input;
- ParamArray[1] = Input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ParamMods[0][1] = true;
- ComType.InvokeMember(FunName, // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- OutPut = ParamArray[1].ToString();
- return;
- }
- catch (Exception ex)
- {
- OutPut = ex.Message;
- MessageBox.Show("COM加载异常!" + OutPut);
- return;
- }
- }
- }
- class BussniessClass
- {
- public BussniessClass()
- {
- string progID = "MedicareCom.Outpatient";
- System.Type ComType;
- object ComInstance;
- ComType = Type.GetTypeFromProgID(progID);
- // 创建Com的实例
- if (ComType != null)
- {
- //创建实例
- ComInstance = Activator.CreateInstance(ComType);
- }
- }
- public void BussniessObj(string FunName, string input, out string output)
- {
- output = "";
- try
- {
- Type ComType = System.Type.GetTypeFromProgID("MedicareCom.Outpatient");
- if (ComType != null)
- {
- //创建实例,不能再次创建,否则会提示没有初始化
- object ComInstance = System.Activator.CreateInstance(ComType);
- if (ComInstance != null)
- {
- MessageBox.Show(("函数FunName:" + FunName + "\n"
- + "入参:" + input));
- }
- else
- {
- output = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[2];
- ParamArray[0] = input;
- ParamArray[1] = input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ParamMods[0][1] = true;
- ComType.InvokeMember(FunName, // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- output = ParamArray[1].ToString();
- }
- else
- {
- output = "北京首信医保COM加载失败!";
- //MessageBox.Show("COM加载失败!");
- }
- }
- catch (Exception ex)
- {
- output = ex.Message;
- MessageBox.Show("COM加载异常!" + output);
- }
- }
- }
- class ReadCardClass
- {
- public int GetReadCardObj(out System.Type OutComType,out object OutComInstance)
- {
- Object rtnObj = "";
- string progID = "MedicareCom.Outpatient";
- System.Type ComType;
- object ComInstance;
- ComType = Type.GetTypeFromProgID(progID);
- // 创建Com的实例
- if (ComType != null)
- {
- //创建实例
- ComInstance = Activator.CreateInstance(ComType);
- OutComType = ComType;
- OutComInstance = ComInstance;
- return 0;
- }
- else
- {
- OutComType = null;
- OutComInstance = "";
- return -1;
- }
- }
- public void Open(System.Type ComType, object ComInstance,out string OutPut)
- {
- try
- {
- if (ComInstance == null)
- {
- OutPut = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[1];
- ParamArray[0] = "";
- //ParamArray[1] = input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ComType.InvokeMember("open", // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- OutPut = ParamArray[0].ToString();
- MessageBox.Show("Open输出:" + OutPut);
- return;
- }
- catch (Exception ex)
- {
- OutPut = ex.Message;
- MessageBox.Show("COM加载异常!" + OutPut);
- return;
- }
- }
- public void Close(System.Type ComType, object ComInstance, out string OutPut)
- {
- try
- {
- if (ComInstance == null)
- {
- OutPut = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[1];
- ParamArray[0] = "";
- //ParamArray[1] = input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(1); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ComType.InvokeMember("close", // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- OutPut = ParamArray[0].ToString();
- MessageBox.Show("Close输出:" + OutPut);
- return;
- }
- catch (Exception ex)
- {
- OutPut = ex.Message;
- MessageBox.Show("COM加载异常!" + OutPut);
- return;
- }
- }
- public void ReadCardObj(string FunName, string Input, System.Type ComType, object ComInstance, out string OutPut)
- {
- try
- {
- if (ComInstance == null)
- {
- OutPut = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[2];
- ParamArray[0] = Input;
- ParamArray[1] = Input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ParamMods[0][1] = true;
- ComType.InvokeMember(FunName, // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- OutPut = ParamArray[1].ToString();
- return;
- }
- catch (Exception ex)
- {
- OutPut = ex.Message;
- MessageBox.Show("COM加载异常!" + OutPut);
- return;
- }
- }
- public void BussniessObj(string FunName, string input, out string output)
- {
- output = "";
- try
- {
- Type ComType = System.Type.GetTypeFromProgID("MedicareCom.Outpatient");
- if (ComType != null)
- {
- //创建实例,不能再次创建,否则会提示没有初始化
- object ComInstance = System.Activator.CreateInstance(ComType);
- if (ComInstance != null)
- {
- MessageBox.Show(("函数FunName:" + FunName + "\n"
- + "入参:" + input));
- }
- else
- {
- output = "实例不存在!";
- return;
- }
- //GlobalVariables.writeLog("入参infno:" + infno);
- //GlobalVariables.writeLog("入参input:" + input);
- //设置需要设置的参数值
- object[] ParamArray = new object[2];
- ParamArray[0] = input;
- ParamArray[1] = input;
- ParameterModifier[] ParamMods = new ParameterModifier[1];
- ParamMods[0] = new ParameterModifier(2); // 初始化为接口参数的个数
- ParamMods[0][0] = true;
- ParamMods[0][1] = true;
- ComType.InvokeMember(FunName, // 接口函数名
- BindingFlags.Default | BindingFlags.InvokeMethod,
- null,
- ComInstance, // 调用的COM组件
- ParamArray, // 参数数组
- ParamMods, // 指定返回参数的ParameterModifier数组
- null,
- null);
- output = ParamArray[1].ToString();
- }
- else
- {
- output = "北京首信医保COM加载失败!";
- //MessageBox.Show("COM加载失败!");
- }
- }
- catch (Exception ex)
- {
- output = ex.Message;
- MessageBox.Show("COM加载异常!" + output);
- }
- }
- }
- }
|