488 lines
21 KiB
C#
488 lines
21 KiB
C#
using DevExpress.XtraEditors;
|
||
using HL_FristAidPlatform_DTO;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Reflection;
|
||
using System.Runtime.InteropServices;
|
||
using System.Windows.Forms;
|
||
|
||
namespace HL_FristAidPlatform_Public
|
||
{
|
||
public static class PublicHelp
|
||
{
|
||
#region 判断本机电脑是否能连接外网
|
||
|
||
[DllImport("winInet.dll")]
|
||
private static extern bool InternetGetConnectedState(ref int dwFlag, int dwReserved);
|
||
|
||
private const int INTERNET_CONNECTION_MODEM = 1;
|
||
private const int INTERNET_CONNECTION_LAN = 2;
|
||
|
||
/// <summary>
|
||
/// 判断本机是否联网
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static bool IsConnectNetwork()
|
||
{
|
||
try
|
||
{
|
||
int dwFlag = 0;
|
||
//false表示没有连接到任何网络,true表示已连接到网络上
|
||
if (!InternetGetConnectedState(ref dwFlag, 0))
|
||
{
|
||
//if (!InternetGetConnectedState(ref dwFlag, 0))
|
||
// Console.WriteLine("未连网!");
|
||
//else if ((dwFlag & INTERNET_CONNECTION_MODEM) != 0)
|
||
// Console.WriteLine("采用调治解调器上网。");
|
||
//else if ((dwFlag & INTERNET_CONNECTION_LAN) != 0)
|
||
// Console.WriteLine("采用网卡上网。");
|
||
return false;
|
||
}
|
||
|
||
//判断当前网络是否可用
|
||
IPAddress[] addresslist = Dns.GetHostAddresses("www.baidu.com");
|
||
if (addresslist[0].ToString().Length <= 6)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
#endregion 判断本机电脑是否能连接外网
|
||
|
||
#region 指定用户编号可查询多院区统一数据,默认1,多个用户用#分割 参数105控制
|
||
|
||
/// <summary>
|
||
/// 指定用户是否拥有所有院区权限
|
||
/// 参数105控制
|
||
/// </summary>
|
||
/// <param name="userID">指定用户编号</param>
|
||
/// <returns></returns>
|
||
public static bool IsHaveAllDistrictRight(long userID)
|
||
{
|
||
try
|
||
{
|
||
bool IsHaveAllDistrictRight = false;
|
||
string[] Config105Array = PublicClassForDataBase.Config105.Split('#');
|
||
foreach (string str in Config105Array)
|
||
{
|
||
if (str == userID.ToString())
|
||
{
|
||
IsHaveAllDistrictRight = true;
|
||
break;
|
||
}
|
||
}
|
||
return IsHaveAllDistrictRight;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "指定用户是否拥有所有院区权限:\r\n" + ex);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
#endregion 指定用户编号可查询多院区统一数据,默认1,多个用户用#分割 参数105控制
|
||
|
||
#region 指定用户编号拥有所有系统参数设置权限,默认1,多个用户用#分割 参数111控制
|
||
|
||
/// <summary>
|
||
/// 指定用户编号拥有所有系统参数设置权限,默认1,多个用户用#分割
|
||
/// 参数111控制
|
||
/// </summary>
|
||
/// <param name="userID">指定用户编号</param>
|
||
/// <returns></returns>
|
||
public static bool IsHaveAllDistrictRightForConfigSet(long userID)
|
||
{
|
||
try
|
||
{
|
||
bool IsHaveAllDistrictRight = false;
|
||
string[] Config111Array = PublicClassForDataBase.Config111.Split('#');
|
||
foreach (string str in Config111Array)
|
||
{
|
||
if (str == userID.ToString())
|
||
{
|
||
IsHaveAllDistrictRight = true;
|
||
break;
|
||
}
|
||
}
|
||
return IsHaveAllDistrictRight;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "指定用户编号拥有所有系统参数设置权限:\r\n" + ex);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
#endregion 指定用户编号拥有所有系统参数设置权限,默认1,多个用户用#分割 参数111控制
|
||
|
||
public static List<string> GetParameter(Dictionary<string, string> parameters)
|
||
{
|
||
try
|
||
{
|
||
string summary = Information.Hospital.Ecg_Summary;
|
||
string decodedString = "";
|
||
string parameter = "";
|
||
var dicSort = from objDic in parameters orderby objDic.Key ascending select objDic;
|
||
foreach (var kvp in dicSort)
|
||
{
|
||
decodedString += kvp.Value;
|
||
parameter += "&" + kvp.Key + "=" + kvp.Value;
|
||
}
|
||
decodedString += summary;
|
||
string encryption = Util.Encryption(decodedString);
|
||
List<string> list = new List<string>();
|
||
list.Add(parameter);
|
||
list.Add(encryption);
|
||
return list;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetParameter:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static List<string> GetParameter<T>(string parameters)
|
||
{
|
||
try
|
||
{
|
||
List<string> list = new List<string>();
|
||
string summary = Information.Hospital.Ecg_Summary;
|
||
string decodedString = "";
|
||
string parameter = "";
|
||
T t;
|
||
t = JsonConvert.DeserializeObject<T>(parameters);
|
||
string tStr = string.Empty;
|
||
if (t == null)
|
||
{
|
||
return list;
|
||
}
|
||
PropertyInfo[] properties = t.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||
|
||
if (properties.Length <= 0)
|
||
{
|
||
return list;
|
||
}
|
||
var dicSort = from p in properties orderby p.Name select p;
|
||
foreach (PropertyInfo item in dicSort)
|
||
{
|
||
string name = item.Name;
|
||
object value = item.GetValue(t, null);
|
||
if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String"))
|
||
{
|
||
//if (value.ToString()!="")
|
||
//{
|
||
decodedString += value;
|
||
parameter += "&" + name + "=" + value;
|
||
//}
|
||
}
|
||
}
|
||
decodedString += summary;
|
||
string encryption = Util.Encryption(decodedString);
|
||
list.Add(parameter);
|
||
list.Add(encryption);
|
||
return list;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetParameter:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
#region 心电图接口
|
||
|
||
/// <summary>
|
||
/// 绑定心电设备
|
||
/// </summary>
|
||
public static DataTable BindEquipmentNumber()
|
||
{
|
||
DataTable ResultDT = null;
|
||
try
|
||
{
|
||
if (IsConnectNetwork())
|
||
{
|
||
string summary = Information.Hospital.Ecg_Summary; ;
|
||
string decodedString = "";
|
||
string parameter = "";
|
||
PageInputContext pageInputContext = new PageInputContext();
|
||
pageInputContext.currPageIndex = 1;
|
||
pageInputContext.recordNumPer = Information.Hospital.Ecg_RecordNumPer;
|
||
Dictionary<string, string> eqmtNo = new Dictionary<string, string>();
|
||
eqmtNo.Add("eqmtNo", "");
|
||
eqmtNo.Add("currPageIndex", pageInputContext.currPageIndex.ToString());
|
||
eqmtNo.Add("recordNumPer", pageInputContext.recordNumPer.ToString());
|
||
var dicSort = from objDic in eqmtNo orderby objDic.Key ascending select objDic;
|
||
foreach (var kvp in dicSort)
|
||
{
|
||
decodedString += kvp.Value;
|
||
parameter += "&" + kvp.Key + "=" + kvp.Value;
|
||
}
|
||
decodedString += summary;
|
||
string encryption = Util.Encryption(decodedString);
|
||
string responseString = Util.GetECG(encryption, Util.ServiceCode.GETEQMTLIST.ToString(), parameter);
|
||
ResultDT = DBHelpClass.ECGJsonToDataTable(responseString);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "绑定心电设备:\r\n" + ex);
|
||
return null;
|
||
}
|
||
return ResultDT;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 提交医单
|
||
/// </summary>
|
||
/// <param name="name">姓名</param>
|
||
/// <param name="age">年龄</param>
|
||
/// <param name="sex">性别</param>
|
||
/// <param name="eqmtNo">设备号</param>
|
||
/// <param name="guid">GUID</param>
|
||
/// <returns></returns>
|
||
public static ReturnMedicalForm PostMedicalForm(string name, string age, string sex, string eqmtNo, string guid)
|
||
{
|
||
try
|
||
{
|
||
MedicalForm parameter = new MedicalForm();
|
||
parameter.formId = guid;
|
||
parameter.itemType = "ITEM_TYPE_HEART";
|
||
parameter.itemCode = "ITEM_CODE_HEART_DYNAMIC";
|
||
parameter.itemName = "";
|
||
parameter.dyAdditionalItems = "ITEM_CODE_BLOOD_DYNAMIC";
|
||
parameter.dyAnalyseOption = "0";
|
||
parameter.eqmtTypeNo = "";
|
||
parameter.eqmtNo = eqmtNo;
|
||
parameter.archivesId = guid;
|
||
parameter.ifInHospital = "NOINHOSPITAL";
|
||
parameter.techOfficeNo = "";
|
||
parameter.techOfficeName = "";
|
||
parameter.medCardNo = "";
|
||
parameter.medFormNo = "";
|
||
parameter.billNo = "";
|
||
parameter.userName = name;
|
||
|
||
//M(男)或者 W(女)
|
||
if (sex == "1")
|
||
{
|
||
parameter.sex = "M";
|
||
}
|
||
else if (sex == "2")
|
||
{
|
||
parameter.sex = "W";
|
||
}
|
||
else
|
||
{
|
||
parameter.sex = "";
|
||
}
|
||
|
||
parameter.year = age;
|
||
parameter.birthDay = "";
|
||
parameter.certNo = "";
|
||
parameter.phone = "";
|
||
parameter.serviceBeginTime = PublicClass.DateTimeNow();// "2019-03-25 00:00:00";
|
||
parameter.serviceLength = "1";
|
||
parameter.timeUnite = "DAY";
|
||
parameter.bedNo = "";
|
||
parameter.outPatientNo = "";
|
||
parameter.admNo = "";
|
||
parameter.roomNo = "";
|
||
parameter.treatNo = "";
|
||
parameter.ordNo = "";
|
||
parameter.examNo = "";
|
||
parameter.reportTitle = "";
|
||
parameter.aidFlag = "1";
|
||
parameter.postAction = "POST_CONFIRM";
|
||
parameter.dataFormat = "";
|
||
parameter.data = "";
|
||
parameter.memo = "";
|
||
parameter.reportNotifyUrl = "";
|
||
string paras = JsonConvert.SerializeObject(parameter);
|
||
List<string> list = PublicHelp.GetParameter<MedicalForm>(paras);
|
||
string getserviceorglistString = Util.GetECG(list[1], Util.ServiceCode.POSTMEDICALFORM.ToString(), list[0]);
|
||
var organizeView = JsonConvert.DeserializeObject<ReturnMedicalForm>(getserviceorglistString);
|
||
return organizeView;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog("PublicHelp", "提交医单:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
#endregion 心电图接口
|
||
|
||
#region 反射打开急救综合界面窗体 带指定参数
|
||
|
||
/// <summary>
|
||
/// 反射打开窗体
|
||
/// </summary>
|
||
/// <param name="namespaceName">命名空间</param>
|
||
/// <param name="methodName">窗体名称</param>
|
||
/// <returns></returns>
|
||
public static Form GetReflection(string namespaceName, string methodName)
|
||
{
|
||
try
|
||
{
|
||
//dll组件路径
|
||
string dllPath = string.Format(Application.StartupPath + "\\" + namespaceName + ".dll", System.Environment.CurrentDirectory);
|
||
Assembly assembly = Assembly.LoadFile(dllPath);
|
||
//获得类
|
||
Type type = assembly.GetType(namespaceName + "." + methodName);
|
||
Form form = (Form)Activator.CreateInstance(type);
|
||
return form;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetReflection:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 反射打开窗体带参数
|
||
/// </summary>
|
||
/// <param name="namespaceName">命名空间</param>
|
||
/// <param name="methodName">窗体名称</param>
|
||
/// <returns></returns>
|
||
public static Form GetReflection(string namespaceName, string methodName, string parameter)
|
||
{
|
||
try
|
||
{
|
||
//dll组件路径
|
||
string dllPath = string.Format(Application.StartupPath + "\\" + namespaceName + ".dll", System.Environment.CurrentDirectory);
|
||
Assembly assembly = Assembly.LoadFile(dllPath);
|
||
//获得类
|
||
Type type = assembly.GetType(namespaceName + "." + methodName);
|
||
Form form = (Form)Activator.CreateInstance(type, parameter);
|
||
return form;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetReflection:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 反射打开窗体带参数
|
||
/// </summary>
|
||
/// <param name="namespaceName">命名空间</param>
|
||
/// <param name="methodName">窗体名称</param>
|
||
/// <returns></returns>
|
||
public static Form GetReflection(string namespaceName, string methodName, string parameter1, string parameter2)
|
||
{
|
||
try
|
||
{
|
||
//dll组件路径
|
||
string dllPath = string.Format(Application.StartupPath + "\\" + namespaceName + ".dll", System.Environment.CurrentDirectory);
|
||
Assembly assembly = Assembly.LoadFile(dllPath);
|
||
//获得类
|
||
Type type = assembly.GetType(namespaceName + "." + methodName);
|
||
Form form = (Form)Activator.CreateInstance(type, parameter1, parameter2);
|
||
return form;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetReflection:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 反射打开窗体 带指定参数
|
||
/// </summary>
|
||
/// <param name="namespaceName">命名空间</param>
|
||
/// <param name="methodName">窗体名称</param>
|
||
/// <param name="patientId">患者编号(ID)</param>
|
||
/// <param name="patientGuid">患者编号(GUID)</param>
|
||
/// <param name="patientMainState">窗体初始状态</param>
|
||
/// <param name="_isNeedLoading">是否需要等待窗体</param>
|
||
/// <returns></returns>
|
||
public static Form GetReflection(string namespaceName, string methodName, long patientId, string patientGuid, string hospitalGuid, Enumerate.PatientMainState patientMainState, bool isNeedLoading)
|
||
{
|
||
try
|
||
{
|
||
object[] paras = new object[] { patientId, patientGuid, hospitalGuid, patientMainState, isNeedLoading };
|
||
string dllPath = string.Format(Application.StartupPath + "\\" + namespaceName + ".dll", System.Environment.CurrentDirectory);//dll组件路径
|
||
Assembly pAss = Assembly.LoadFrom(dllPath);//加载组件
|
||
Type pType = pAss.GetType(namespaceName + "." + methodName);//获得类,HL_FristAidPlatform_Apoplexy,Form_PatientMain
|
||
MethodInfo pMtInfo = pType.GetMethod(methodName);//获得方法,Form_PatientMain
|
||
Form form = (Form)Activator.CreateInstance(pType, paras);//创建类实例
|
||
return form;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetReflection:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 反射打开窗体 带指定参数 胸痛综合界面
|
||
/// </summary>
|
||
/// <param name="namespaceName">命名空间</param>
|
||
/// <param name="methodName">窗体名称</param>
|
||
/// <param name="patientId">患者编号(ID)</param>
|
||
/// <param name="patientGuid">患者编号(GUID)</param>
|
||
/// <param name="patientMainState">窗体初始状态</param>
|
||
/// <param name="isNeedLoading">是否需要等待窗体</param>
|
||
/// <param name="diagnosis_Code">当前诊断类型</param>
|
||
/// <param name="give_UP_Treatment">患者自愿放弃后续治疗0:否 1:是</param>
|
||
/// <returns></returns>
|
||
public static Form GetReflection(string namespaceName, string methodName, long patientId, string patientGuid, string hospitalGuid, Enumerate.PatientMainState patientMainState, bool isNeedLoading, string diagnosis_Code, string give_UP_Treatment, string pagetype,int formFlag)
|
||
{
|
||
try
|
||
{
|
||
object[] paras = new object[] { patientId, patientGuid, hospitalGuid, patientMainState, isNeedLoading, diagnosis_Code, give_UP_Treatment, pagetype, formFlag };
|
||
string dllPath = string.Format(Application.StartupPath + "\\" + namespaceName + ".dll", System.Environment.CurrentDirectory);//dll组件路径
|
||
Assembly pAss = Assembly.LoadFrom(dllPath);//加载组件
|
||
Type pType = pAss.GetType(namespaceName + "." + methodName);//获得类,HL_FristAidPlatform_Apoplexy,Form_PatientMain
|
||
MethodInfo pMtInfo = pType.GetMethod(methodName);//获得方法,Form_PatientMain
|
||
Form form = (Form)Activator.CreateInstance(pType, paras);//创建类实例
|
||
return form;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
PublicClass.WriteErrorLog("PublicHelp", "GetReflection:\r\n" + ex);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取本机IP地址
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static string GetLocalIp()
|
||
{
|
||
///获取本地的IP地址
|
||
string AddressIP = string.Empty;
|
||
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
|
||
{
|
||
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
|
||
{
|
||
AddressIP = _IPAddress.ToString();
|
||
}
|
||
}
|
||
return AddressIP;
|
||
}
|
||
|
||
#endregion 反射打开急救综合界面窗体 带指定参数
|
||
}
|
||
} |