private void SaveBackupEntranceGuardCardInfo(List <EntranceGuardCard> Eclst) { EntranceGuardCardInfoBackupList backUpList = new EntranceGuardCardInfoBackupList(); backUpList.EcList = new List <EntranceGuardCardInfoBackup>(); foreach (var item in Eclst) { EntranceGuardCardInfoBackup Ec = new EntranceGuardCardInfoBackup(); if (item.Abutment_Id != null) { Ec.Abutment_Id = (int)item.Abutment_Id; } else { Ec.Abutment_Id = -1; } Ec.Code = item.Code; Ec.State = item.State; backUpList.EcList.Add(Ec); } string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\部门人员门禁卡信息\\BackupEntranceGuardCardInfo.xml"; XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8); }
/// <summary> /// 生成串口对象 /// </summary> /// <returns></returns> public SerialPort CreateSerialPortObject(string devTag) { // 从配置文件读取串口信息 string filePath = Application.StartupPath + "\\XML\\MySettings.xml"; try { // 打开XML文件 XmlSerializeHelper <SCommItem, SCommXml> .OpenXmlFile(filePath); // 读取XML文件 SCommXml xml = XmlSerializeHelper <SCommItem, SCommXml> .ReadXML(); // 获得指定名称的串口信息 SCommItem item = (SCommItem)xml[devTag]; // 校验位转换 Parity parity = ConvertToParity(item.Parity); // 停止位 StopBits stopBits = ConvertToStopBits(item.StopBits); // 生成串口 return(new SerialPort(item.Name, item.Baud, parity, item.DataBits, stopBits)); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 获取树节点 /// </summary> /// <param name="view">0:基本数据;1:设备信息;2:人员信息;3:设备信息+人员信息</param> /// <returns></returns> public TEntity GetTree(int view) { TEntity tree = null; if (view == 0) { tree = GetTree(); } else if (view == 1) { tree = GetTreeWithDev(); } else if (view == 2) { tree = GetTreeWithPerson(); } else if (view == 3) { var leafNodes = db.DevInfos.ToList(); tree = GetTreeWithPerson(leafNodes.ToTModel()); } if (tree != null) { tree.SetParent(); } string xml = XmlSerializeHelper.GetXmlText(tree); int length = xml.Length; return(tree); }
/// <summary> /// 通过文件导入设备信息 /// </summary> /// <param name="filePath"></param> /// <param name="devBll"></param> /// <returns></returns> public static bool ImportDevInfoFromFile(string filePath, Bll bll) { if (!File.Exists(filePath) || bll == null) { Log.Error("文件不存在:" + filePath); return(false); } var initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath); if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0) { return(false); } var areas = bll.Areas.ToList(); //var devs = bll.DevInfos.Where(i => i.Local_TypeCode != TypeCodes.Archor); //bll.DevInfos.RemoveList(devs);//先清空所有设备 foreach (var devInfo in initInfo.DevList) { if (devInfo.TypeCode == TypeCodes.Archor + "") { continue; } int?parentID = GetAreaIdByPath(devInfo.ParentName, areas); if (parentID != null) { devInfo.ParentId = (int)parentID; AddDevInfo(devInfo, bll.DevInfos); } } return(true); }
public UnitySetting GetUnitySetting() { string path = AppDomain.CurrentDomain.BaseDirectory + "\\UnitySetting.xml"; UnitySetting setting = XmlSerializeHelper.LoadFromFile <UnitySetting>(path); return(setting); }
public void TestSqlSugar() { string ddd = "{\"ORGID\":\"10ADC4A48AB743A2B532AD8D08C4B927\",\"YBCODE\":\"3176\",\"INFID\":\"F9D46DBF812C4F308670693F6431F498\",\"结算编号\":null,\"病人姓名\":\"宋梅\",\"医生姓名\":\"王伟\",\"身份证\":null,\"科室名称\":\"门诊\",\"发票号\":\"202101170012\",\"门诊号\":\"555780231000M202101170012\",\"收费日期\":\"2021-01-19 23:21:23\",\"明细总额\":4,\"经办人\":\"医保接口\"}"; var dataValue = JsonConvert.DeserializeObject <OutpatientPersonBaseJsonDto>(ddd); //var ddd= CommonHelp.GetValue("WebServiceUrl"); StringBuilder ctrXml = new StringBuilder(); ctrXml.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\" ?>"); ctrXml.Append(@"<ROW> <PO_AKC600>1013441659</PO_AKC600> <PO_AAE241>216.91</PO_AAE241> <PO_AAE240>219.7</PO_AAE240> <PO_XJZF>0.0</PO_XJZF> <PO_YAZ725>2.31</PO_YAZ725> <PO_YEZF>0.99</PO_YEZF> <PO_FHZ>1</PO_FHZ> <PO_MSG></PO_MSG> <PO_BXJE>3.30</PO_BXJE> <PO_BXBL>0.7</PO_BXBL> </ROW>"); var iniData = XmlSerializeHelper.DESerializer <ResidentOutpatientPreSettlementXmlDto>(ctrXml.ToString()); //var dataList = _hospitalLogMap.GetList(); //var ccc= _hospitalLogMap._db.Ado.GetDataTable("select * from table"); //_hospitalLogMap.CurrentDb.DeleteById(1); //_sqlSugarRepository.QueryHospitalLog(); }
/// <summary> /// icd10对码 /// </summary> /// <param name="param"></param> public void Icd10PairCode(Icd10PairCodeParam param) { //回参构建 var icd10List = new List <Icd10PairCodeDateXml>(); icd10List.Add(new Icd10PairCodeDateXml() { DiseaseId = param.DiseaseId, DiseaseName = param.ProjectName, DiseaseCoding = param.ProjectCode }); var dd = new Icd10PairCodeDateXml() { DiseaseId = param.DiseaseId, DiseaseName = param.ProjectName, DiseaseCoding = param.ProjectCode }; var xmlData = new Icd10PairCodeXml() { row = icd10List }; var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData); var saveXml = new SaveXmlDataParam() { User = param.User, MedicalInsuranceBackNum = "CXJB002", MedicalInsuranceCode = "91", BusinessId = param.BusinessId, BackParam = strXmlBackParam }; //存基层 _webServiceBasic.SaveXmlData(saveXml); _hisSqlRepository.Icd10PairCode(param); }
/// <summary> /// 获取订单 /// </summary> /// <param name="parameter">参数</param> /// <returns></returns> /// <exception cref="ArgumentNullException">传入的参数是null</exception> /// <exception cref="WeChatPayException">调用微信接口失败时返回的错误信息</exception> public async Task <QueryOrderResponse> GetOrderAsync(QueryOrderRequest parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } parameter.AppId = _appId; parameter.MchId = _mchId; parameter.Sign = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey); string url = "https://api.mch.weixin.qq.com/pay/orderquery"; string body = XmlSerializeHelper.ObjectToXmlString(parameter); string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(), body, "xml/text"); XmlDocument xml = new XmlDocument(); xml.LoadXml(result); var response = XmlSerializeHelper.StringToObject <QueryOrderResponse>(result); Check(response); response.CouponType = Helper.FormatXmlField("coupon_type", xml); response.CouponId = Helper.FormatXmlField("coupon_refund_id", xml); response.SingleCouponAmount = Helper.FormatXmlField("coupon_refund_fee", xml) .Select(x => Convert.ToInt32(x)).ToArray(); return(response); }
/// <summary> /// 获取资金对账单 /// </summary> /// <param name="parameter"></param> /// <returns></returns> /// <exception cref="ArgumentNullException">传入的参数是null</exception> /// <exception cref="WeChatPayException">调用微信接口失败时返回的错误信息</exception> public async Task <OrderTable> GetFundBillAsync(QueryFundBillRequest parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } parameter.AppId = _appId; parameter.MchId = _mchId; parameter.Sign = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey); string url = "https://api.mch.weixin.qq.com/pay/downloadfundflow"; string body = XmlSerializeHelper.ObjectToXmlString(parameter); string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(), body, "xml/text"); if (result.Contains("error_code")) { var xml = new XmlDocument(); xml.Load(result); var nodes = xml.FirstChild; throw new WeChatApiException(nodes["error_code"].InnerText, nodes["return_msg"].InnerText, "下载对账单"); } return(new OrderTable(result)); }
/// <summary> /// 重新下载 代理列表 /// </summary> /// <remarks> /// 调用程序定期调用本方法下载最新的代理列表 /// </remarks> public static void ReDownLoadWebProxyList() { AbstractSpider spider = new ProxycnSpider { BeginPageNumber = 1, EndPageNumber = 30 //下载30页 }; var nList = spider.ResultArticleList; //spider.WriteToTxt(Path.Combine(Directory.GetCurrentDirectory(), // string.Format("{0}-{1}.txt", spider.Site.Name, DateTime.Now.ToShortDateString()))); if (nList == null || nList.Count == 0) { Log.Info("ReDownLoadWebProxyList-NULL"); return; } var cList = CheckAllWebProxy(nList); if (cList.Count > 0) { XmlSerializeHelper.SerializeToXml(s_Config_ProxyIPConfigPath, cList); _webProxyIPList = cList; Log.InfoFormat("ReDownLoadWebProxyList-Checked-UPDATE-Num:{0}", cList.Count); } else { Log.Info("ReDownLoadWebProxyList-Checked-NULL"); } }
/// <summary> /// List all project for certain language /// </summary> /// <returns></returns> public IEnumerable <ProjectDto> ListProjects(string lang) { if (String.IsNullOrEmpty(lang)) { return(null); } // bad practice, better send path from web layer for specified repository only var path = HttpContext.Current.Server.MapPath(String.Format("~/App_Data/Projects_{0}.xml", lang)); if (!File.Exists(path)) { return(null); } try { var text = File.ReadAllText(path); var data = XmlSerializeHelper.Deserialize <ProjectDtoCollection>(text); return(data.Items); } catch (Exception) { // log error return(null); } }
private void SaveBackupEntranceGuardCardInfo(List <EntranceGuardCard> Eclst) { EntranceGuardCardInfoBackupList backUpList = new EntranceGuardCardInfoBackupList(); backUpList.EcList = new List <EntranceGuardCardInfoBackup>(); foreach (var item in Eclst) { EntranceGuardCardInfoBackup Ec = new EntranceGuardCardInfoBackup(); if (item.Abutment_Id != null) { Ec.Abutment_Id = (int)item.Abutment_Id; } else { Ec.Abutment_Id = -1; } Ec.Code = item.Code; Ec.State = item.State; backUpList.EcList.Add(Ec); } string initFile = InitPaths.GetBackupEntranceGuardCardInfo(); XmlSerializeHelper.Save(backUpList, initFile, Encoding.UTF8); }
/// <summary> /// 通过文件导入人员信息 /// </summary> /// <param name="filePath"></param> /// <param name="devBll"></param> /// <returns></returns> public static bool ImportPersonInfoFromFile(string filePath, Bll bll) { if (!File.Exists(filePath) || bll == null) { Log.Error("文件不存在:" + filePath); return(false); } var initInfo = XmlSerializeHelper.LoadFromFile <PersonnelInfoBackupList>(filePath); if (initInfo == null || initInfo.PerList == null || initInfo.PerList.Count == 0) { return(false); } var areas = bll.Areas.ToList(); var deps = bll.Departments.ToList(); foreach (var Per in initInfo.PerList) { var dep = deps.Find(i => i.Id == Per.ParentId); if (dep == null) { dep = deps[Per.ParentId]; Per.ParentId = dep.Id; } else { } AddPersonInfo(Per, bll); } return(true); }
private void index_Load(object sender, EventArgs e) { using (FileStream fs = File.Open("entity\\user.xml", FileMode.Open, FileAccess.Read)) { StreamReader sr = new StreamReader(fs); string text = sr.ReadToEnd(); var list = XmlSerializeHelper.DeSerialize <userList>(text); list.DataSource.ForEach((user) => { Program.userList.Add(user); }); comboBox1.DataSource = list.DataSource; comboBox1.ValueMember = "token"; comboBox1.DisplayMember = "token"; } using (FileStream fs = File.Open("entity\\ip.xml", FileMode.Open, FileAccess.Read)) { StreamReader sr = new StreamReader(fs); string text = sr.ReadToEnd(); var list = XmlSerializeHelper.DeSerialize <IPList>(text); list.DataSource.ForEach((user) => { Program.IPList.Add(user); }); cbiplist.DataSource = list.DataSource; cbiplist.ValueMember = "ip"; cbiplist.DisplayMember = "ip"; } }
public ApiJsonResultData MedicalInsuranceXml([FromUri] MedicalInsuranceXmlUiParam param) { return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y => { var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId); //更新医保信息 var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam(); //回参构建 var xmlData = new HospitalizationRegisterXml() { MedicalInsuranceType = "10", MedicalInsuranceHospitalizationNo = "44116476", }; var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData); var saveXmlData = new SaveXmlData(); saveXmlData.OrganizationCode = userBase.OrganizationCode; saveXmlData.AuthCode = userBase.AuthCode; saveXmlData.BusinessId = param.BusinessId; saveXmlData.TransactionId = Guid.Parse("E67C69F5-5FA8-438A-94EC-85E092CA56E9").ToString("N"); saveXmlData.MedicalInsuranceBackNum = "CXJB002"; saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam); saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam); saveXmlData.MedicalInsuranceCode = "21"; saveXmlData.UserId = userBase.UserId; //存基层 webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData)); })); }
/// <summary> /// 企业付款到零钱 /// </summary> /// <param name="parameter"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public async Task <PayToWalletResponse> PayToWalletAsync(PayToWalletRequest parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } if (string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(_path)) { throw new InvalidOperationException("证书的路径和密码没有填写"); } parameter.AppId = _appId; parameter.MchId = _mchId; string url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"; parameter.Sign = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey); string body = XmlSerializeHelper.ObjectToXmlString(parameter); string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(), body, _path, _password, "xml/text"); var response = XmlSerializeHelper.StringToObject <PayToWalletResponse>(result); Check(response); return(response); }
public ApiJsonResultData OutpatientSettlement([FromBody] UiBaseDataParam param) { return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y => { var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId); userBase.TransKey = param.TransKey; //回参构建88866 var xmlData = new OutpatientDepartmentCostXml() { AccountBalance = 10, MedicalInsuranceOutpatientNo = "88866", CashPayment = 0, SettlementNo = "88866", AllAmount = Convert.ToDecimal(0.07), PatientName = "代美玲", AccountAmountPay = 0, MedicalInsuranceType = "342" }; var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData); var saveXml = new SaveXmlDataParam() { User = userBase, MedicalInsuranceBackNum = "zydj", MedicalInsuranceCode = "48", BusinessId = param.BusinessId, BackParam = strXmlBackParam }; //存基层 webServiceBasic.SaveXmlData(saveXml); })); }
/// <summary> /// 统一下单 /// </summary> /// <param name="parameter">参数</param> /// <returns></returns> /// <exception cref="ArgumentNullException">传入的参数是null</exception> /// <exception cref="WeChatPayException">调用微信接口失败时返回的错误信息</exception> public async Task <UnifiedOrderResponse> UnifiedOrderAsync(UnifiedOrderRequest parameter) { parameter.AppId = _appId; parameter.MchId = _mchId; if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } if (parameter.TradeType == WeChatConstant.JsPay && string.IsNullOrEmpty(parameter.OpenId)) { throw new WeChatPayException("支付方式JsPay OpenId 必须传入"); } if (parameter.TradeType == WeChatConstant.NativePay && string.IsNullOrEmpty(parameter.ProductId)) { throw new WeChatPayException("支付方式NativePay ProductId 必须传入"); } parameter.Sign = WeChatSignHelper.CreateMd5Sign(parameter, _secretKey); string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; string body = XmlSerializeHelper.ObjectToXmlString(parameter); string result = await _client.ExecutePostRequest(url, new Dictionary <string, string>(), body, "xml/text"); var response = XmlSerializeHelper.StringToObject <UnifiedOrderResponse>(result); Check(response); return(response); }
static string WriteLog(params LogMonitorEdm[] model) { if (model == null || model.Length <= 0) { return(""); } try { List <Log_SystemMonitorMQ> list = new List <Log_SystemMonitorMQ>(); foreach (var item in model) { Log_SystemMonitorR cur = new Log_SystemMonitorR() { Remark = item.Remark, PageViewNumR = XmlSerializeHelper.ToSqlXml(item.PagesView), }; Log_SystemMonitorMQ log_SystemMonitorMQ = AutoMapperConfig.GetLog_SystemMonitorMQModel(cur); list.Add(log_SystemMonitorMQ); } appender.WriteLogAndHandFail(list); } catch (Exception ex) { if (ex.InnerException != null) { throw ex.InnerException; } throw ex; } return(""); }
/// <summary> /// 通过文件导入设备信息 /// </summary> /// <param name="filePath"></param> /// <param name="devBll"></param> /// <returns></returns> public static bool ImportFireFightDevInfoFromFile(string filePath, Bll bll) { if (!File.Exists(filePath) || bll == null) { Log.Error("文件不存在:" + filePath); return(false); } var initInfo = XmlSerializeHelper.LoadFromFile <FireFightDevInfoBackupList>(filePath); if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0) { return(false); } var areas = bll.Areas.ToList(); foreach (var devInfo in initInfo.DevList) { if (devInfo.ParentName == "") { continue; } int?parentID = GetAreaIdByPath2(devInfo.ParentName, areas); if (parentID != null) { devInfo.ParentId = Convert.ToString(parentID); AddFireFightDevInfo(devInfo, bll); } } return(true); }
private RefundNotificationRequest RefundParameterCheck(string input, string mchId, string appId, string nonce) { using (MD5 md5 = MD5.Create()) { var base64 = Convert.FromBase64String(input); StringBuilder output = new StringBuilder(); var data = md5.ComputeHash(Encoding.UTF8.GetBytes(_securityKey)); foreach (var b in data) { output.Append(b.ToString("x2")); } string key = output.ToString(); byte[] keyBuffer = Encoding.UTF8.GetBytes(key); byte[] encryptBuffer = base64; RijndaelManaged rDel = new RijndaelManaged { Key = keyBuffer, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 }; ICryptoTransform cTransform = rDel.CreateDecryptor(); byte[] resultBuffer = cTransform.TransformFinalBlock(encryptBuffer, 0, encryptBuffer.Length); string xml = Encoding.UTF8.GetString(resultBuffer); RefundNotificationRequest notification = XmlSerializeHelper.StringToObject <RefundNotificationRequest>(xml); notification.MchId = mchId; notification.AppId = appId; notification.Nonce = nonce; return(notification); } }
public ApiJsonResultData MedicalInsuranceXmlCancelSettlement([FromUri] MedicalInsuranceXmlUiParam param) { return(new ApiJsonResultData(ModelState, new UiInIParam()).RunWithTry(y => { var userBase = webServiceBasicService.GetUserBaseInfo(param.UserId); //更新医保信息 var strXmlIntoParam = XmlSerializeHelper.XmlParticipationParam(); //回参构建 var xmlData = new HospitalSettlementCancelXml() { SettlementNo = param.SettlementNo }; var strXmlBackParam = XmlSerializeHelper.HisXmlSerialize(xmlData); var saveXmlData = new SaveXmlData(); saveXmlData.OrganizationCode = userBase.OrganizationCode; saveXmlData.AuthCode = userBase.AuthCode; saveXmlData.BusinessId = param.BusinessId; saveXmlData.TransactionId = param.TransKey; saveXmlData.MedicalInsuranceBackNum = "CXJB003"; saveXmlData.BackParam = CommonHelp.EncodeBase64("utf-8", strXmlBackParam); saveXmlData.IntoParam = CommonHelp.EncodeBase64("utf-8", strXmlIntoParam); saveXmlData.MedicalInsuranceCode = "42"; saveXmlData.UserId = userBase.UserId; //存基层 webServiceBasic.HIS_InterfaceList("38", JsonConvert.SerializeObject(saveXmlData)); })); }
/// <summary> /// 通过文件导入设备信息 /// </summary> /// <param name="filePath"></param> /// <param name="devBll"></param> /// <returns></returns> public static bool ImportDoorAccessInfoFromFile(string filePath, Bll bll) { if (!File.Exists(filePath) || bll == null) { Log.Error("文件不存在:" + filePath); return(false); } var initInfo = XmlSerializeHelper.LoadFromFile <DoorAccessList>(filePath); if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0) { return(false); } var areas = bll.Areas.ToList(); foreach (var devInfo in initInfo.DevList) { int?parentId = GetAreaIdByPath(devInfo.ParentName, areas); if (parentId != null) { devInfo.ParentId = (int)parentId; AddDoorAccessInfo(devInfo, bll); } } return(true); }
private void InitAuthorizationFromFile(string path) { var aaList = new List <AreaAuthorization>(); var aarList = new List <AreaAuthorizationRecord>(); var tree = XmlSerializeHelper.LoadFromFile <AuthorizationArea>(path); var list = tree.GetAllChildren(null); foreach (var area in list) { if (area.Items != null) { foreach (var aa in area.Items) { aa.CreateTime = DateTime.Now; aa.ModifyTime = DateTime.Now; aaList.Add(aa); } } } bool r1 = AreaAuthorizations.AddRange(aaList); foreach (var area in list) { if (area.Records != null) { foreach (var ar in area.Records) { ar.CreateTime = DateTime.Now; ar.ModifyTime = DateTime.Now; aarList.Add(ar); } } } AreaAuthorizationRecords.AddRange(aarList); }
private void BenzScreenWindowForm_Load(object sender, EventArgs e) { var xmlDoc = new XmlDocument(); xmlDoc.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLConfig.xml")); var model = XmlSerializeHelper.DESerializer <XMLConfig>(xmlDoc.InnerXml); //获取屏幕信息 Screen[] sc; sc = Screen.AllScreens; foreach (var i in model.Nodes) { if (i.Window >= sc.Length) { i.Window = 0; } var from = new BenzScreenWindowWebsiteForm(i, sc[i.Window].Bounds.Left, sc[i.Window].Bounds.Top); if (model.Nodes.IndexOf(i) == model.Nodes.Count() - 1) { from.SetIsLast(); } from.Show(); Thread.Sleep(1000); } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { if (cbxSerialPortNo.Text == "") { MessageUtil.ShowTips("请先选择串口号!"); return; } // 打开系统配置文件,写入串口配置信息 try { // 读XML文件 SCommXml xml = OpenSCommXml(); // 读取当前串口配置 SCommItem item = (SCommItem)xml["主控串口"]; // 更新XML中的串口信息 UpdateXmlSerialPortInfo(item); XmlSerializeHelper <SCommItem, SCommXml> .WriteXML(xml); // 更新属性类中的串口信息 UpdatePropertySerialPortInfo(item); if (MessageUtil.ShowTips("串口设置成功!") == DialogResult.OK) { this.Close(); } } catch (Exception ex) { MessageUtil.ShowWarning(ex.Message); } }
public static void XMLDemo2() { CitiesListResponse response = new CitiesListResponse { Result = new Result { Value = "123465", Code = "001" }, CitiesList = new City[] { new City { PinYin = "suzhou", Value = "苏州", HasOutService = "123", Info = "苏州", Population = 123456 }, new City { PinYin = "wuxi", Value = "无锡", HasOutService = "234", Info = "无锡", Population = 234567 }, new City { PinYin = "nanjing", Value = "南京", HasOutService = "456", Info = "南京", Population = 345678 }, } }; string str = XmlSerializeHelper.Serializer(response); Console.WriteLine(str); Console.ReadLine(); XmlSerializer serializer = new XmlSerializer(typeof(CitiesListResponse)); serializer.Serialize(Console.Out, response); Console.Read(); }
private void LoadData() { fileArchorList = ArchorHelper.LoadArchoDevInfo().ArchorList; Group1.Header += " " + fileArchorList.Count; DataGrid1.ItemsSource = fileArchorList; BLL.Bll bll = new BLL.Bll(); dbArchorList = bll.Archors.ToList(); DataGridDb.ItemsSource = dbArchorList; string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\基站信息\\UDPArchorList.xml"; udpArchorList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path); Group2.Header += " " + udpArchorList.Count; DataGrid2.ItemsSource = udpArchorList; var switchAreas = bll.bus_anchor_switch_area.ToList(); var list4 = bll.bus_anchors.ToList(); if (list4 != null) { Group4.Header += " " + list4.Count; DataGrid4.ItemsSource = list4; } areas = bll.Areas.ToList(); Check(); }
private void OnCallback(string data) { try { var response = CultureInfo.InvariantCulture.DoInCulture(() => XmlSerializeHelper.Deserialize(data)); if (!response.IsSuccess) { SendOutError(response.Exception); return; } var type = response.GetType(); this.AddDebugLog(type.Name); var handler = _handlerBunch.TryGetValue(response.GetType()); if (handler != null) { handler(response); } } catch (Exception ex) { SendOutError(ex); } }
public void SaveConfigInfo() { configInfo = new ConfigInfo();//构造当前的信息 string xml = XmlSerializeHelper.Serialize <ConfigInfo>(configInfo); path = Application.dataPath + "/StreamingAssets/configInfo.xml"; if (File.Exists(path)) { File.Delete(path); } FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } StreamWriter sw = new StreamWriter(path); sw.Write(xml); sw.Flush(); sw.Close(); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }