ECGPrint/1200Gxml心电图绘制/ConfigHelper.cs
2024-12-25 17:24:22 +08:00

1003 lines
34 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _1200Gxml心电图绘制
{
public class ConfigHelper
{
/// <summary>
/// 是否有远程判读服务
/// </summary>
public static bool RemoteServcie;
/// <summary>
/// 是否自动上传数据
/// </summary>
public static bool UploadServcie;
/// <summary>
/// <summary>
/// 远程判读URL
/// </summary>
private static string UrlDistance = string.Empty;
/// <summary>
/// 远程申请判读地址URL
/// </summary>
private static string UrlApplication = "/api/RestEcg/Create";
/// <summary>
/// 远程只申请不判读URL用于统计
/// </summary>
private static string UrlApplicationNo = "/api/dataservice/upload";
/// <summary>
/// 获取远程判读结果地址URL
/// </summary>
private static string UrlReturn = "/api/RestEcg/Result";
/// <summary>
/// 获取远程修正结果地址URL
/// </summary>
private static string UrlNewReturn = "/api/RestEcg/NewResult";
/// <summary>
/// 通知远程端收到修正结果的地址URL
/// </summary>
private static string UrlChangeState = "/api/RestEcg/ChangeState";
/// <summary>
/// 获取远程判读医生签名
/// </summary>
private static string UrlGraph = "/api/RestEcg/Graph";
/// <summary>
/// 远程验证用户名
/// </summary>
public static string UrlUserName = string.Empty;
/// <summary>
/// 远程验证密码
/// </summary>
public static string UrlPassWord = string.Empty;
/// <summary>
/// 从HIS系统中获取过来的患者有多少未执行过
/// </summary>
public static List<string> ProjectIds = new List<string>();
public static DataTable NoSignatureDoctor;
/// <summary>
/// 缓存远程电子签章的容器
/// </summary>
public static Dictionary<string, Image> RemoteDocImages = new Dictionary<string, Image>();
/// <summary>
/// 网络版数据库连接字符串
/// </summary>
private static string LocalConStr = string.Empty;
/// <summary>
/// 社区机构编号
/// </summary>
private static readonly string OrgID = string.Empty;
/// <summary>
/// 提交到几级判读设置
/// </summary>
private static string InptLevel = "1";
/// <summary>
/// 0:Access 1:SqlServer
/// </summary>
public static int DbSign;
//0远程1急诊
public static int LongDistanceType = 1;
/// <summary>
/// 设置分页的
/// </summary>
public static int PageSize = 20;
/// <summary>
/// 默认采集时间设置
/// </summary>
public static int CaiSJ = 10;
/// <summary>
/// 打印采样点设置
/// </summary>
public static int PrintSampleRate = 1000;
/// <summary>
/// 远程结果是否需要闪烁
/// </summary>
public static bool IsNeedBland = false;
/// <summary>
/// 是否需要隐藏
/// </summary>
public static bool IsShowFlag;
/// <summary>
/// 地区
/// </summary>
public static string Area = string.Empty;
/// <summary>
/// 是否有服务端修正的结果
/// </summary>
public static bool HasCorrectResult = false;
/// <summary>
/// E100命令端口
/// </summary>
public static string CommandComPort = "COM4";
/// <summary>
/// E100数据端口
/// </summary>
public static string EcgDataComPort = "COM3";
/// <summary>
/// BlueTooth命令端口
/// </summary>
public static string CommandComPortBlueTooth = "COM6";
/// <summary>
/// BlueTooth数据端口
/// </summary>
public static string EcgDataComPortBlueTooth = "COM5";
/// <summary>
/// 尿液分析仪数据和命令端口
/// </summary>
public static string EcgDataOrCommandPortUrine = "COM7";
/// <summary>
/// 波形颜色
/// </summary>
public static Color WaveColor = Color.Black;
/// <summary>
/// 波形网格颜色
/// </summary>
public static Color WaveGridColor = Color.LightCoral;
/// <summary>
/// 波形背景色
/// </summary>
public static Color WaveBackColor = Color.White;
/// <summary>
/// 4*3+1导联默认显示
/// </summary>
public static int SingleLead = 1;
/// <summary>
/// 打印波形线条粗细
/// </summary>
public static float WaveSize = 2.0f;
/// <summary>
/// 是否自动采集
/// </summary>
public static bool IsAutoCollect = true;
/// <summary>
/// 0关闭1株洲2体检
/// </summary>
public static int EcgPrintMode;
/// <summary>
/// 是否进行采集
/// </summary>
public static bool IsRecordEcg = false;
/// <summary>
/// 是否网络版还是单机版
/// </summary>
public static string VersionType;
/// <summary>
/// 是否打印危险提醒
/// </summary>
public static bool IsPrintQuickResponse = false;
/// <summary>
/// 皮肤名称
/// </summary>
public static string SkinName = "Caramel";
/// <summary>
/// 打印类型比如普通打印B5打印热敏打印
/// </summary>
public static string PrintType = "A4";
/// <summary>
/// 是否有HIS
/// </summary>
public static bool HasHis;
/// <summary>
/// 心电图报告模式
/// </summary>
public static CbItemObj[] ReportModel = null;
/// <summary>
/// 心电图测量方向
/// </summary>
public static CbItemObj[] Measure = null;
/// <summary>
/// 心电图类型
/// </summary>
public static CbItemObj[] ProjectTypes = null;
/// <summary>
/// 心电图判读状态
/// </summary>
public static CbItemObj[] EcgStates = null;
/// <summary>
/// 性别选项
/// </summary>
public static CbItemObj[] GenderItems = null;
/// <summary>
/// 缓存的病室信息
/// </summary>
public static DataTable PatientRooms = null;
/// <summary>
/// 缓存的病床信息
/// </summary>
public static DataTable PatientBeds = null;
/// <summary>
/// 本地报告地址
/// </summary>
public static string LocalAddress = string.Empty;
/// <summary>
/// 判读是否有返回结果
/// </summary>
public static bool IsNeedBlandOk = false;
/// <summary>
/// 是否获取远程报告名称
/// </summary>
public static bool IsGetAddress; //false为不获取远端报告名称
public static bool IsPrintEcg = true; //默认是否打印纸质报告
public static bool IsShowPrint; //默认不显示是否打印纸质报告
/// <summary>
/// 采集界面记录按钮 快捷键
/// </summary>
public static string KeysCode = "F1";
/// <summary>
/// 是否Ctrl+组合
/// </summary>
public static bool CtrlBool;
/// <summary>
/// 是否Alt+组合
/// </summary>
public static bool AltBool;
/// <summary>
/// 是否Shift+组合
/// </summary>
public static bool ShiftBool;
/// <summary>
/// 打印背景网格线是实线还虚线
/// </summary>
public static bool IsDashOrSolid;
/// <summary>
/// 是否显示远程医生签名
/// </summary>
public static bool IsDistalSign = true;
/// <summary>
/// 基线
/// </summary>
public static int BaseOff = 0x00000001;
public static int Base005Hz = 0x00000002;
public static int Base05Hz = 0x00000004;
public static int Base075Hz = 0x00000008;
/// <summary>
/// 肌电
/// </summary>
public static int McOff = 0x00000100;
public static int Mc25Hz = 0x00000200;
public static int Mc35Hz = 0x00000400;
public static int Mc45Hz = 0x00000800;
/// <summary>
/// 工频
/// </summary>
public static int AcOff = 0x00010000;
public static int Ac50Hz = 0x00020000;
public static int Ac60Hz = 0x00040000;
/// <summary>
/// 低通
/// </summary>
public static int LpOff = 0x01000000;
public static int Lp75Hz = 0x02000000;
public static int Lp100Hz = 0x04000000;
public static int Lp150Hz = 0x08000000;
/// <summary>
/// 基线变量参数
/// </summary>
public static int BaseHz = Base075Hz;
/// <summary>
/// 肌电变量参数
/// </summary>
public static int McHz = Mc35Hz;
/// <summary>
/// 工频变量参数
/// </summary>
public static int AcHz = Ac50Hz;
/// <summary>
/// 低通变量参数
/// </summary>
public static int LpHz = Lp75Hz;
/// <summary>
/// 是否允许自动下载的标志
/// </summary>
public static volatile bool CanDownLoadPackage = true;
public static string EcgReportTitle = "本报告仅供临床参考,不作证明之用。";
/// <summary>
/// 是否第一次检查系统是64位还是32位
/// </summary>
public static bool IsFirstLoad = true;
/// <summary>
/// 接收数据的字节数据默认24个字节 原始数据中的实际字节数 III avr avf avl 这四个导联都是算出来的
/// </summary>
public static int SourceLeadCount = 24;
/// <summary>
/// 导联数
/// </summary>
public static int LeadCounts = 12;
/// <summary>
/// 采集界面显示行数 12导 6*2排列。15导 7*2排列。18导 9*2 排列
/// </summary>
public static int ShowLeadCount = 6;
/// <summary>
/// 采集到的数据实际导联数12导实际导8导。15导实际导11导18导实际导14导。
/// </summary>
public static int FactLeadNum = 8;
public static List<int> LeadInfo = new List<int>
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; //导联信息
public static string[] LeadNameArray =
{
"I", "II", "III", "aVR", "aVL", "aVF", "V1", "V2", "V3", "V4", "V5", "V6", "V3R", "V4R", "V5R", "V7", "V8",
"V9"
}; //导联类别
/// <summary>
/// 申请令牌
/// </summary>
public static CommonVerifyUrlResult Cvur;
/// <summary>
/// 本地医生ID
/// </summary>
public static string LocalDoctorId = string.Empty;
/// <summary>
/// 本地医生名称
/// </summary>
public static string LocalDoctorName = string.Empty;
/// <summary>
/// 本地医生科室
/// </summary>
public static string LocalDoctorDept = string.Empty;
/// <summary>
/// 本地医生签名
/// </summary>
public static byte[] LocalDoctorElectronicSignature;
/// <summary>
/// 项目类型,比如:十二导---0十五导V3R,V4R,V5R----1或V7,V8,V9----2十八导---3
/// </summary>
public static int EcgProjectType;
/// <summary>
/// 是否有微信支付
/// </summary>
public static bool WxIsPay;
/*百度翻译*/
public static string BdTransBaseAddr { get; private set; }
public static string BdTransKey { get; private set; }
public static string BdTransSecret { get; private set; }
/// <summary>
/// 用户接口
/// </summary>
public static string WebApi { get; private set; } = "http://localhost:15873/";
static ConfigHelper()
{
if (string.IsNullOrEmpty(UrlDistance))
{
var ds = new DataSet();
var sr = new StreamReader(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", Encoding.UTF8);
var str = DesEncrypt.Decrypt(sr.ReadToEnd());
var ms = new MemoryStream(Encoding.UTF8.GetBytes(str));
ds.ReadXml(ms);
ms.Close();
sr.Close();
LocalConStr = ds.Tables[0].Rows[0]["LocalConnectionString"].ToString().Trim();
UrlDistance = ds.Tables[0].Rows[0]["UrlDistanceString"].ToString().Trim();
DbSign = Convert.ToInt32(ds.Tables[0].Rows[0]["DB_SIGN"].ToString().Trim());
UrlUserName = ds.Tables[0].Rows[0]["UrlUserName"].ToString();
UrlPassWord = ds.Tables[0].Rows[0]["UrlPassWord"].ToString();
RemoteServcie = bool.Parse(ds.Tables[0].Rows[0]["RemoteServcie"].ToString());
UploadServcie = bool.Parse(ds.Tables[0].Rows[0]["UploadServcie"].ToString());
IsShowFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["ShowFlag"].ToString().Trim()) != 0;
PageSize = Convert.ToInt32(ds.Tables[0].Rows[0]["PAGE_SIZE"].ToString().Trim());
LongDistanceType = Convert.ToInt32(ds.Tables[0].Rows[0]["LongDistanceType"].ToString().Trim());
InptLevel = ds.Tables[0].Rows[0]["InterpretationLevel"].ToString().Trim();
Area = ds.Tables[0].Rows[0]["AREA"].ToString();
OrgID = ds.Tables[0].Rows[0]["ORGID"].ToString();
var isEx = ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsFirstLoad");
if (isEx)
{
IsFirstLoad = ds.Tables[0].Rows[0]["IsFirstLoad"] == null ||
bool.Parse(ds.Tables[0].Rows[0]["IsFirstLoad"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "PrintType")) isEx = true;
if (isEx)
{
PrintType = ds.Tables[0].Rows[0]["PrintType"] != null
? ds.Tables[0].Rows[0]["PrintType"].ToString()
: "A4";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "DashOrSolid")) isEx = true;
if (isEx)
{
IsDashOrSolid = ds.Tables[0].Rows[0]["DashOrSolid"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["DashOrSolid"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsDistalSign")) isEx = true;
if (isEx)
{
IsDistalSign = ds.Tables[0].Rows[0]["IsDistalSign"] == null ||
bool.Parse(ds.Tables[0].Rows[0]["IsDistalSign"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "CaiSJ")) isEx = true;
if (isEx)
{
CaiSJ = ds.Tables[0].Rows[0]["CaiSJ"] != null
? int.Parse(ds.Tables[0].Rows[0]["CaiSJ"].ToString())
: 12;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "EcgProjectType")) isEx = true;
if (isEx)
{
EcgProjectType = ds.Tables[0].Rows[0]["EcgProjectType"] != null
? int.Parse(ds.Tables[0].Rows[0]["EcgProjectType"].ToString())
: 0;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "KeysCode")) isEx = true;
if (isEx)
{
KeysCode = ds.Tables[0].Rows[0]["KeysCode"] != null
? ds.Tables[0].Rows[0]["KeysCode"].ToString()
: "F1";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "CtrlBool")) isEx = true;
if (isEx)
{
CtrlBool = ds.Tables[0].Rows[0]["CtrlBool"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["CtrlBool"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "AltBool")) isEx = true;
if (isEx)
{
AltBool = ds.Tables[0].Rows[0]["AltBool"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["AltBool"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "ShiftBool")) isEx = true;
if (isEx)
{
ShiftBool = ds.Tables[0].Rows[0]["ShiftBool"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["ShiftBool"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "PrintSampleRate")) isEx = true;
if (isEx)
{
PrintSampleRate = ds.Tables[0].Rows[0]["PrintSampleRate"] != null
? int.Parse(ds.Tables[0].Rows[0]["PrintSampleRate"].ToString())
: 250;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WaveColor")) isEx = true;
if (isEx)
{
WaveColor = ds.Tables[0].Rows[0]["WaveColor"] != null
? Color.FromArgb(int.Parse(ds.Tables[0].Rows[0]["WaveColor"].ToString()))
: Color.Black;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WaveGridColor")) isEx = true;
if (isEx)
{
WaveGridColor = ds.Tables[0].Rows[0]["WaveGridColor"] != null
? Color.FromArgb(int.Parse(ds.Tables[0].Rows[0]["WaveGridColor"].ToString()))
: Color.LightCoral;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WaveBackColor")) isEx = true;
if (isEx)
{
WaveBackColor = ds.Tables[0].Rows[0]["WaveBackColor"] != null
? Color.FromArgb(int.Parse(ds.Tables[0].Rows[0]["WaveBackColor"].ToString()))
: Color.White;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "SingleLead")) isEx = true;
if (isEx)
{
SingleLead = ds.Tables[0].Rows[0]["SingleLead"] != null
? int.Parse(ds.Tables[0].Rows[0]["SingleLead"].ToString())
: 1;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WaveSize")) isEx = true;
if (isEx)
{
WaveSize = ds.Tables[0].Rows[0]["WaveSize"] != null
? float.Parse(ds.Tables[0].Rows[0]["WaveSize"].ToString())
: 2.0f;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsAutoCollect")) isEx = true;
if (isEx)
{
IsAutoCollect = ds.Tables[0].Rows[0]["IsAutoCollect"] == null ||
bool.Parse(ds.Tables[0].Rows[0]["IsAutoCollect"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "EcgPrintMode")) isEx = true;
if (isEx)
{
EcgPrintMode = ds.Tables[0].Rows[0]["EcgPrintMode"] != null
? int.Parse(ds.Tables[0].Rows[0]["EcgPrintMode"].ToString())
: 0;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "HasHIS")) isEx = true;
if (isEx)
{
HasHis = ds.Tables[0].Rows[0]["HasHIS"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["HasHIS"].ToString());
isEx = false;
}
//WebApi
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WebApi")) isEx = true;
if (isEx)
{
WebApi = ds.Tables[0].Rows[0]["WebApi"] != null ? ds.Tables[0].Rows[0]["WebApi"].ToString() : "";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "EcgReportTitle")) isEx = true;
if (isEx)
{
EcgReportTitle = ds.Tables[0].Rows[0]["EcgReportTitle"] != null
? ds.Tables[0].Rows[0]["EcgReportTitle"].ToString()
: "";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsGetAddress")) isEx = true;
if (isEx)
{
IsGetAddress = ds.Tables[0].Rows[0]["IsGetAddress"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["IsGetAddress"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsPrintEcg")) isEx = true;
if (isEx)
{
IsPrintEcg = ds.Tables[0].Rows[0]["IsPrintEcg"] == null ||
bool.Parse(ds.Tables[0].Rows[0]["IsPrintEcg"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "IsShowPrint")) isEx = true;
if (isEx)
{
IsShowPrint = ds.Tables[0].Rows[0]["IsShowPrint"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["IsShowPrint"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "WxIsPay")) isEx = true;
if (isEx)
{
WxIsPay = ds.Tables[0].Rows[0]["WxIsPay"] != null &&
bool.Parse(ds.Tables[0].Rows[0]["WxIsPay"].ToString());
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == nameof(BdTransBaseAddr))) isEx = true;
if (isEx)
{
BdTransBaseAddr = ds.Tables[0].Rows[0][nameof(BdTransBaseAddr)] != null ?
ds.Tables[0].Rows[0][nameof(BdTransBaseAddr)].ToString() : "http://api.fanyi.baidu.com/api/trans/vip/translate";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == nameof(BdTransKey))) isEx = true;
if (isEx)
{
BdTransKey = ds.Tables[0].Rows[0][nameof(BdTransKey)] != null ? ds.Tables[0].Rows[0][nameof(BdTransKey)].ToString() : "";
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == nameof(BdTransSecret))) isEx = true;
if (isEx)
{
BdTransSecret = ds.Tables[0].Rows[0][nameof(BdTransSecret)] != null ? ds.Tables[0].Rows[0][nameof(BdTransSecret)].ToString() : string.Empty;
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "BASE_HZ")) isEx = true;
if (isEx)
{
switch (ds.Tables[0].Rows[0]["BASE_HZ"].ToString().Trim())
{
case "关":
BaseHz = BaseOff;
break;
case "0.05":
BaseHz = Base005Hz;
break;
case "0.5":
BaseHz = Base05Hz;
break;
case "0.75":
BaseHz = Base075Hz;
break;
}
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "MC_HZ")) isEx = true;
if (isEx)
{
switch (ds.Tables[0].Rows[0]["MC_HZ"].ToString().Trim())
{
case "关":
McHz = McOff;
break;
case "25":
McHz = Mc25Hz;
break;
case "35":
McHz = Mc35Hz;
break;
case "45":
McHz = Mc45Hz;
break;
}
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "AC_HZ")) isEx = true;
if (isEx)
{
switch (ds.Tables[0].Rows[0]["AC_HZ"].ToString().Trim())
{
case "关":
AcHz = AcOff;
break;
case "50":
AcHz = Ac50Hz;
break;
case "60":
AcHz = Ac60Hz;
break;
}
isEx = false;
}
if (ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == "LP_HZ")) isEx = true;
if (isEx)
switch (ds.Tables[0].Rows[0]["LP_HZ"].ToString().Trim())
{
case "关":
LpHz = LpOff;
break;
case "75":
LpHz = Lp75Hz;
break;
case "100":
LpHz = Lp100Hz;
break;
case "150":
LpHz = Lp150Hz;
break;
}
ds.Dispose();
}
try
{
var addrPath = Application.StartupPath + "\\LOCAL_INFOMATION.INFO";
if (File.Exists(addrPath))
{
var sr = new StreamReader(addrPath);
var cnt = sr.ReadToEnd();
sr.Close();
LocalAddress = cnt;
}
else
{
const string addr = "北京市亦庄经济技术开发区宏达北路16号1楼202室";
var fs = new FileStream(addrPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
var sw = new StreamWriter(fs);
sw.Write(addr);
sw.Close();
fs.Close();
LocalAddress = addr;
}
}
catch (Exception)
{
// ignored
}
}
/// <summary>
/// 获取本地网络连接字符串
/// </summary>
public static string LocalConnectionStr
{
get => LocalConStr;
set => LocalConStr = value;
}
/// <summary>
/// 远程判读URL
/// </summary>
public static string UrlDistanceString
{
get => UrlDistance;
set => UrlDistance = value;
}
/// <summary>
/// 远程申请判读地址URL
/// </summary>
/// <returns></returns>
public static string UrlApplicationString
{
get => UrlApplication;
set => UrlApplication = value;
}
/// <summary>
/// 只申请不判读地址URL
/// </summary>
/// <returns></returns>
public static string UrlApplicationStringNo
{
get => UrlApplicationNo;
set => UrlApplicationNo = value;
}
/// <summary>
/// 获得远程判读结果URL
/// </summary>
/// <returns></returns>
public static string UrlReturnString
{
get => UrlReturn;
set => UrlReturn = value;
}
/// <summary>
/// 获得远程判读修正结果URL
/// </summary>
/// <returns></returns>
public static string UrlNewReturnString
{
get => UrlNewReturn;
set => UrlNewReturn = value;
}
/// <summary>
/// 通知远程判读结果收到URL
/// </summary>
/// <returns></returns>
public static string UrlChangeStateString
{
get => UrlChangeState;
set => UrlChangeState = value;
}
/// <summary>
/// 获取远程判读医生签名URL
/// </summary>
public static string UrlGraphString
{
get => UrlGraph;
set => UrlGraph = value;
}
/// <summary>
/// 获得社区机构编号
/// </summary>
/// <returns></returns>
public static string ORGID => OrgID;
/// <summary>
/// 获取提交判读等级
/// </summary>
public static string InterpretationLevel
{
get => InptLevel;
set => InptLevel = value;
}
/// <summary>
/// 保存配置文件
/// </summary>
/// <param name="columnName">列名</param>
/// <param name="value">值</param>
public static void SaveConfig(string columnName, string value)
{
try
{
var ds = new DataSet();
var sr = new StreamReader(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", Encoding.UTF8);
var str = DesEncrypt.Decrypt(sr.ReadToEnd());
var ms = new MemoryStream(Encoding.UTF8.GetBytes(str));
ds.ReadXml(ms);
var isEx = ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == columnName);
if (!isEx) ds.Tables[0].Columns.Add(new DataColumn(columnName, typeof(string)));
ds.Tables[0].Rows[0][columnName] = value;
ms.Close();
sr.Close();
var msm = new MemoryStream();
ds.Tables[0].WriteXml(msm);
var s = Encoding.UTF8.GetString(msm.ToArray()).Insert(0, "<?xml version=\"1.0\" standalone=\"yes\" ?>");
File.WriteAllText(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", DesEncrypt.Encrypt(s),
Encoding.UTF8);
msm.Close();
ds.Dispose();
}
catch (Exception)
{
}
}
/// <summary>
/// 保存多个配置文件节点
/// </summary>
/// <param name="config">配置字符串</param>
public static void SaveConfig(Dictionary<string, string> config)
{
try
{
var ds = new DataSet();
var sr = new StreamReader(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", Encoding.UTF8);
var str = DesEncrypt.Decrypt(sr.ReadToEnd());
var ms = new MemoryStream(Encoding.UTF8.GetBytes(str));
ds.ReadXml(ms);
if (config != null)
foreach (var kvp in config)
{
var isEx = ds.Tables[0].Columns.Cast<DataColumn>().Any(dc => dc.ColumnName == kvp.Key);
if (!isEx) ds.Tables[0].Columns.Add(new DataColumn(kvp.Key, typeof(string)));
ds.Tables[0].Rows[0][kvp.Key] = kvp.Value;
}
ms.Close();
sr.Close();
var msm = new MemoryStream();
ds.Tables[0].WriteXml(msm);
var s = Encoding.UTF8.GetString(msm.ToArray()).Insert(0, "<?xml version=\"1.0\" standalone=\"yes\" ?>");
File.WriteAllText(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", DesEncrypt.Encrypt(s),
Encoding.UTF8);
msm.Close();
ds.Dispose();
}
catch (Exception)
{
}
}
}
}