private void btnExportSetting_Click(object sender, EventArgs e) { if (MessageBox.Show("是否需要导出参数?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } try { string path = System.IO.Path.Combine(Application.StartupPath, "MySetting.xml"); POS.Model.MySetting mysetting = new Model.MySetting(); UserSetting us = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <UserSetting>(); if (us != null) { SetValue(mysetting, us); } KeySetting ks = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <KeySetting>(); if (ks != null) { SetValue(mysetting, ks); } TariffSetting ts = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <TariffSetting>(); if (ts != null) { SetValue(mysetting, ts); } HolidaySetting hs = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <HolidaySetting>(); if (hs != null) { SetValue(mysetting, hs); } List <OperatorInfo> opts = (new OperatorBll(AppSettings.CurrentSetting.ParkConnect)).GetAllOperators().QueryObjects; if (opts != null) { SetValue(mysetting, opts); } XmlSerializer ser = new XmlSerializer(typeof(POS.Model.MySetting)); using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) { ser.Serialize(stream, mysetting); } string remote = @"FlashDisk\RalidPos\MySetting.xml"; OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI(); if (rapi.DevicePresent) { rapi.Connect(); rapi.CopyFileToDevice(path, remote, true); rapi.Disconnect(); } ShowMessage("导出参数成功,手持机上的收费软件需要重启后参数才会生效", Color.Black); } catch (Exception ex) { ShowMessage(ex.Message, Color.Red); Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } }
private void btnExportSetting_Click(object sender, EventArgs e) { if (MessageBox.Show(Resource1.FrmMain_ExportConfig, Resource1.FrmMain_Query, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } try { string path = System.IO.Path.Combine(Application.StartupPath, "MySetting.xml"); POS.Model.MySetting mysetting = new Model.MySetting(); FrmWorkstationSelection frm = new FrmWorkstationSelection(); if (frm.ShowDialog() == DialogResult.OK) { mysetting.StationID = frm.SelectedWorkstation; UserSetting us = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <UserSetting>(); if (us != null) { SetValue(mysetting, us); } KeySetting ks = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <KeySetting>(); if (ks != null) { SetValue(mysetting, ks); } TariffSetting ts = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <TariffSetting>(); if (ts != null) { SetValue(mysetting, ts); } HolidaySetting hs = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <HolidaySetting>(); if (hs != null) { SetValue(mysetting, hs); } List <OperatorInfo> opts = (new OperatorBll(AppSettings.CurrentSetting.ParkConnect)).GetAllOperators().QueryObjects; if (opts != null) { SetValue(mysetting, opts); } XmlSerializer ser = new XmlSerializer(typeof(POS.Model.MySetting)); using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) { ser.Serialize(stream, mysetting); } string remote = @"FlashDisk\RalidPos\MySetting.xml"; OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI(); if (rapi.DevicePresent) { rapi.Connect(); if (!rapi.Connected) { ShowMessage(Resource1.FrmMain_ConnectHandsetFail, Color.Red); return; } rapi.CopyFileToDevice(path, remote, true); rapi.Disconnect(); ShowMessage(Resource1.FrmMain_ExportConfigSuccess, Color.Black); } else { ShowMessage(Resource1.FrmMain_FindnotHandet, Color.Red); } } } catch (Exception ex) { ShowMessage(ex.Message, Color.Red); Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } }