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 { /// /// 是否有远程判读服务 /// public static bool RemoteServcie; /// /// 是否自动上传数据 /// public static bool UploadServcie; /// /// /// 远程判读URL /// private static string UrlDistance = string.Empty; /// /// 远程申请判读地址URL /// private static string UrlApplication = "/api/RestEcg/Create"; /// /// 远程只申请不判读URL用于统计 /// private static string UrlApplicationNo = "/api/dataservice/upload"; /// /// 获取远程判读结果地址URL /// private static string UrlReturn = "/api/RestEcg/Result"; /// /// 获取远程修正结果地址URL /// private static string UrlNewReturn = "/api/RestEcg/NewResult"; /// /// 通知远程端收到修正结果的地址URL /// private static string UrlChangeState = "/api/RestEcg/ChangeState"; /// /// 获取远程判读医生签名 /// private static string UrlGraph = "/api/RestEcg/Graph"; /// /// 远程验证用户名 /// public static string UrlUserName = string.Empty; /// /// 远程验证密码 /// public static string UrlPassWord = string.Empty; /// /// 从HIS系统中获取过来的患者有多少未执行过 /// public static List ProjectIds = new List(); public static DataTable NoSignatureDoctor; /// /// 缓存远程电子签章的容器 /// public static Dictionary RemoteDocImages = new Dictionary(); /// /// 网络版数据库连接字符串 /// private static string LocalConStr = string.Empty; /// /// 社区机构编号 /// private static readonly string OrgID = string.Empty; /// /// 提交到几级判读设置 /// private static string InptLevel = "1"; /// /// 0:Access 1:SqlServer /// public static int DbSign; //0远程1急诊 public static int LongDistanceType = 1; /// /// 设置分页的 /// public static int PageSize = 20; /// /// 默认采集时间设置 /// public static int CaiSJ = 10; /// /// 打印采样点设置 /// public static int PrintSampleRate = 1000; /// /// 远程结果是否需要闪烁 /// public static bool IsNeedBland = false; /// /// 是否需要隐藏 /// public static bool IsShowFlag; /// /// 地区 /// public static string Area = string.Empty; /// /// 是否有服务端修正的结果 /// public static bool HasCorrectResult = false; /// /// E100命令端口 /// public static string CommandComPort = "COM4"; /// /// E100数据端口 /// public static string EcgDataComPort = "COM3"; /// /// BlueTooth命令端口 /// public static string CommandComPortBlueTooth = "COM6"; /// /// BlueTooth数据端口 /// public static string EcgDataComPortBlueTooth = "COM5"; /// /// 尿液分析仪数据和命令端口 /// public static string EcgDataOrCommandPortUrine = "COM7"; /// /// 波形颜色 /// public static Color WaveColor = Color.Black; /// /// 波形网格颜色 /// public static Color WaveGridColor = Color.LightCoral; /// /// 波形背景色 /// public static Color WaveBackColor = Color.White; /// /// 4*3+1导联默认显示 /// public static int SingleLead = 1; /// /// 打印波形线条粗细 /// public static float WaveSize = 2.0f; /// /// 是否自动采集 /// public static bool IsAutoCollect = true; /// /// 0关闭;1株洲;2体检 /// public static int EcgPrintMode; /// /// 是否进行采集 /// public static bool IsRecordEcg = false; /// /// 是否网络版还是单机版 /// public static string VersionType; /// /// 是否打印危险提醒 /// public static bool IsPrintQuickResponse = false; /// /// 皮肤名称 /// public static string SkinName = "Caramel"; /// /// 打印类型,比如:普通打印,B5打印,热敏打印 /// public static string PrintType = "A4"; /// /// 是否有HIS /// public static bool HasHis; /// /// 心电图报告模式 /// public static CbItemObj[] ReportModel = null; /// /// 心电图测量方向 /// public static CbItemObj[] Measure = null; /// /// 心电图类型 /// public static CbItemObj[] ProjectTypes = null; /// /// 心电图判读状态 /// public static CbItemObj[] EcgStates = null; /// /// 性别选项 /// public static CbItemObj[] GenderItems = null; /// /// 缓存的病室信息 /// public static DataTable PatientRooms = null; /// /// 缓存的病床信息 /// public static DataTable PatientBeds = null; /// /// 本地报告地址 /// public static string LocalAddress = string.Empty; /// /// 判读是否有返回结果 /// public static bool IsNeedBlandOk = false; /// /// 是否获取远程报告名称 /// public static bool IsGetAddress; //false为不获取远端报告名称 public static bool IsPrintEcg = true; //默认是否打印纸质报告 public static bool IsShowPrint; //默认不显示是否打印纸质报告 /// /// 采集界面记录按钮 快捷键 /// public static string KeysCode = "F1"; /// /// 是否Ctrl+组合 /// public static bool CtrlBool; /// /// 是否Alt+组合 /// public static bool AltBool; /// /// 是否Shift+组合 /// public static bool ShiftBool; /// /// 打印背景网格线是实线还虚线 /// public static bool IsDashOrSolid; /// /// 是否显示远程医生签名 /// public static bool IsDistalSign = true; /// /// 基线 /// public static int BaseOff = 0x00000001; public static int Base005Hz = 0x00000002; public static int Base05Hz = 0x00000004; public static int Base075Hz = 0x00000008; /// /// 肌电 /// public static int McOff = 0x00000100; public static int Mc25Hz = 0x00000200; public static int Mc35Hz = 0x00000400; public static int Mc45Hz = 0x00000800; /// /// 工频 /// public static int AcOff = 0x00010000; public static int Ac50Hz = 0x00020000; public static int Ac60Hz = 0x00040000; /// /// 低通 /// public static int LpOff = 0x01000000; public static int Lp75Hz = 0x02000000; public static int Lp100Hz = 0x04000000; public static int Lp150Hz = 0x08000000; /// /// 基线变量参数 /// public static int BaseHz = Base075Hz; /// /// 肌电变量参数 /// public static int McHz = Mc35Hz; /// /// 工频变量参数 /// public static int AcHz = Ac50Hz; /// /// 低通变量参数 /// public static int LpHz = Lp75Hz; /// /// 是否允许自动下载的标志 /// public static volatile bool CanDownLoadPackage = true; public static string EcgReportTitle = "本报告仅供临床参考,不作证明之用。"; /// /// 是否第一次检查系统是64位还是32位 /// public static bool IsFirstLoad = true; /// /// 接收数据的字节数据,默认24个字节 原始数据中的实际字节数 III avr avf avl 这四个导联都是算出来的 /// public static int SourceLeadCount = 24; /// /// 导联数 /// public static int LeadCounts = 12; /// /// 采集界面显示行数 12导 6*2排列。15导 7*2排列。18导 9*2 排列 /// public static int ShowLeadCount = 6; /// /// 采集到的数据实际导联数,12导实际导8导。15导实际导11导,18导实际导14导。 /// public static int FactLeadNum = 8; public static List LeadInfo = new List { 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" }; //导联类别 /// /// 申请令牌 /// public static CommonVerifyUrlResult Cvur; /// /// 本地医生ID /// public static string LocalDoctorId = string.Empty; /// /// 本地医生名称 /// public static string LocalDoctorName = string.Empty; /// /// 本地医生科室 /// public static string LocalDoctorDept = string.Empty; /// /// 本地医生签名 /// public static byte[] LocalDoctorElectronicSignature; /// /// 项目类型,比如:十二导---0,十五导(V3R,V4R,V5R----1或V7,V8,V9----2),十八导---3 /// public static int EcgProjectType; /// /// 是否有微信支付 /// 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; } /// /// 用户接口 /// 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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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().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 } } /// /// 获取本地网络连接字符串 /// public static string LocalConnectionStr { get => LocalConStr; set => LocalConStr = value; } /// /// 远程判读URL /// public static string UrlDistanceString { get => UrlDistance; set => UrlDistance = value; } /// /// 远程申请判读地址URL /// /// public static string UrlApplicationString { get => UrlApplication; set => UrlApplication = value; } /// /// 只申请不判读地址URL /// /// public static string UrlApplicationStringNo { get => UrlApplicationNo; set => UrlApplicationNo = value; } /// /// 获得远程判读结果URL /// /// public static string UrlReturnString { get => UrlReturn; set => UrlReturn = value; } /// /// 获得远程判读修正结果URL /// /// public static string UrlNewReturnString { get => UrlNewReturn; set => UrlNewReturn = value; } /// /// 通知远程判读结果收到URL /// /// public static string UrlChangeStateString { get => UrlChangeState; set => UrlChangeState = value; } /// /// 获取远程判读医生签名URL /// public static string UrlGraphString { get => UrlGraph; set => UrlGraph = value; } /// /// 获得社区机构编号 /// /// public static string ORGID => OrgID; /// /// 获取提交判读等级 /// public static string InterpretationLevel { get => InptLevel; set => InptLevel = value; } /// /// 保存配置文件 /// /// 列名 /// 值 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().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, ""); File.WriteAllText(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", DesEncrypt.Encrypt(s), Encoding.UTF8); msm.Close(); ds.Dispose(); } catch (Exception) { } } /// /// 保存多个配置文件节点 /// /// 配置字符串 public static void SaveConfig(Dictionary 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().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, ""); File.WriteAllText(Application.StartupPath + @"\MedicalCloudPlatform.exe.yjl", DesEncrypt.Encrypt(s), Encoding.UTF8); msm.Close(); ds.Dispose(); } catch (Exception) { } } } }