using MaterialTraceability.Business; using MaterialTraceability.Entity.DTO; using MaterialTraceabilityUI.Common; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace MaterialTraceabilityUI { /// /// ConfigInfo.xaml 的交互逻辑 /// public partial class ConfigInfo : UserControl { /// /// INIFile配置文件 /// private IniFileHelper inifile = new IniFileHelper(System.Environment.CurrentDirectory + "/MesConfig/App.InI"); private IniFileHelper inifile2 = new IniFileHelper(System.Environment.CurrentDirectory + "/App.InI"); private IniFileHelper plcIniFile = new IniFileHelper(System.Environment.CurrentDirectory + "/PlcConfig/App.InI"); private AppConfigDto appConfig = AppConfigDto.Instance; private string iniSection = ""; public ConfigInfo() { InitializeComponent(); switch(appConfig.processId) { case "TB": iniSection = "TBPLcAddress"; break; case "LY_A": iniSection = "LYPLcAddress"; break; case "MQ_A": iniSection = "MQPLcAddress"; break; case "AB": iniSection = "ABPLcAddress"; break; default: break; } } private void SaveConfigInfo_Click(object sender, RoutedEventArgs e) { try { // 通过Rfid获取sfc ProcessLotServiceWSServiceParam节点 inifile.IniWriteValue("ProcessLotServiceWSServiceParam", "url", this.ProcessLotServiceWSServiceParamUrl.Text); inifile.IniWriteValue("ProcessLotServiceWSServiceParam", "site", this.ProcessLotServiceWSServiceParamSite.Text); inifile.IniWriteValue("ProcessLotServiceWSServiceParam", "user", this.ProcessLotServiceWSServiceParamUser.Text); inifile.IniWriteValue("ProcessLotServiceWSServiceParam", "loginUser", this.ProcessLotServiceWSServiceParamLoginUser.Text); inifile.IniWriteValue("ProcessLotServiceWSServiceParam", "password", this.ProcessLotServiceWSServiceParamPassword.Text); // 新自动完工接口,Z_PR591调整数量, AdujustQtyParam节点 inifile.IniWriteValue("AdujustQtyParam", "url", this.AdujustQtyParamUrl.Text); inifile.IniWriteValue("AdujustQtyParam", "site", this.AdujustQtyParamSite.Text); inifile.IniWriteValue("AdujustQtyParam", "operationRevision", this.AdujustQtyParamOperationRevision.Text); inifile.IniWriteValue("AdujustQtyParam", "user", this.AdujustQtyParamUser.Text); inifile.IniWriteValue("AdujustQtyParam", "activity", this.AdujustQtyParamActivity.Text); inifile.IniWriteValue("AdujustQtyParam", "password", this.AdujustQtyParamPassword.Text); // 新自动完工接口,Z_PR571拆分, SplitSfcParam节点 inifile.IniWriteValue("SplitSfcParam", "url", this.SplitSfcParamUrl.Text); inifile.IniWriteValue("SplitSfcParam", "site", this.SplitSfcParamSite.Text); inifile.IniWriteValue("SplitSfcParam", "operationRevision", this.SplitSfcParamOperationRevision.Text); inifile.IniWriteValue("SplitSfcParam", "user", this.SplitSfcParamUser.Text); inifile.IniWriteValue("SplitSfcParam", "password", this.SplitSfcParamPassword.Text); inifile.IniWriteValue("SplitSfcParam", "activity", this.SplitSfcParamActivity.Text); inifile.IniWriteValue("HandSplitSfcParam", "user", this.HandSplitSfcParamUser.Text); inifile.IniWriteValue("HandSplitSfcParam", "password", this.HandSplitSfcParamPwd.Text); // 首工序获取SFC接口、自动入账接口、卷绕自动上料接口,MiFirstOperationForsfcServiceServiceParam节点 inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "url", this.MiFirstOperationForsfcServiceServiceParamUrl.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "site", this.MiFirstOperationForsfcServiceServiceParamSite.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "operationRevision", this.MiFirstOperationForsfcServiceServiceParamOperationRevision.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "user", this.MiFirstOperationForsfcServiceServiceParamUser.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "password", this.MiFirstOperationForsfcServiceServiceParamPassword.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "activity", this.MiFirstOperationForsfcServiceServiceParamActivity.Text); inifile.IniWriteValue("MiFirstOperationForsfcServiceServiceParam", "modeProcessSfc", this.MiFirstOperationForsfcServiceServiceParamModeProcessSfc.Text); // 涂布工单下达,MiReleaseSfcWithActivityServiceServiceParam节点 inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "url", this.MiReleaseSfcWithActivityServiceServiceParamUrl.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "site", this.MiReleaseSfcWithActivityServiceServiceParamSite.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "operationRevision", this.MiReleaseSfcWithActivityServiceServiceParamOperationRevision.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "user", this.MiReleaseSfcWithActivityServiceServiceParamUser.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "activity", this.MiReleaseSfcWithActivityServiceServiceParamActivity.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "loginUser", this.MiReleaseSfcWithActivityServiceServiceParamLoginUser.Text); inifile.IniWriteValue("MiReleaseSfcWithActivityServiceServiceParam", "password", this.MiReleaseSfcWithActivityServiceServiceParamPassword.Text); // 获取SFC数量 ,MiSFCQueryQtyServiceServiceParam节点 inifile.IniWriteValue("MiSFCQueryQtyServiceServiceParam", "url", this.MiSFCQueryQtyServiceServiceParamUrl.Text); inifile.IniWriteValue("MiSFCQueryQtyServiceServiceParam", "site", this.MiSFCQueryQtyServiceServiceParamSite.Text); inifile.IniWriteValue("MiSFCQueryQtyServiceServiceParam", "loginUser", this.MiSFCQueryQtyServiceServiceParamloginUser.Text); inifile.IniWriteValue("MiSFCQueryQtyServiceServiceParam", "password", this.MiSFCQueryQtyServiceServiceParamPassword.Text); // 注销接口, MiSignOffSFCsServiceServiceParam节点 inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "url", this.MiSignOffSFCsServiceServiceParamUrl.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "site", this.MiSignOffSFCsServiceServiceParamSite.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "operationRevision", this.MiSignOffSFCsServiceServiceParamOperationRevision.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "user", this.MiSignOffSFCsServiceServiceParamUser.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "activityId", this.MiSignOffSFCsServiceServiceParamActivityId.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "amount", this.MiSignOffSFCsServiceServiceParamAmount.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "loginUser", this.MiSignOffSFCsServiceServiceParamloginUser.Text); inifile.IniWriteValue("MiSignOffSFCsServiceServiceParam", "password", this.MiSignOffSFCsServiceServiceParampassword.Text); // 获取工单数量,FindShopRequestParam节点 inifile.IniWriteValue("FindShopRequestParam", "url", this.FindShopRequestParamUrl.Text); inifile.IniWriteValue("FindShopRequestParam", "site", this.FindShopRequestParamSite.Text); inifile.IniWriteValue("FindShopRequestParam", "loginUser", this.FindShopRequestParamloginUser.Text); inifile.IniWriteValue("FindShopRequestParam", "password", this.FindShopRequestParampassword.Text); // 物料特征数据上传接口,MachineIntegrationServiceParam接口 inifile.IniWriteValue("MachineIntegrationServiceParam", "url", this.MachineIntegrationServiceParamUrl.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "site", this.MachineIntegrationServiceParamSite.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "operationRevision", this.MachineIntegrationServiceParamOperationRevision.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "activityId", this.MachineIntegrationServiceParamActivityId.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "dcGroupRevision", this.MachineIntegrationServiceParamDcGroupRevision.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "dcGroup", this.MachineIntegrationServiceParamDcGroup.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "loginUser", this.MachineIntegrationServiceParamloginUser.Text); inifile.IniWriteValue("MachineIntegrationServiceParam", "password", this.MachineIntegrationServiceParampassword.Text); // 获取Mes数据,TBParametricValueParam节点 inifile.IniWriteValue("TBParametricValueParam", "url", this.TBParametricValueParamUrl.Text); inifile.IniWriteValue("TBParametricValueParam", "site", this.TBParametricValueParamSite.Text); inifile.IniWriteValue("TBParametricValueParam", "loginUser", this.TBParametricValueParamloginUser.Text); inifile.IniWriteValue("TBParametricValueParam", "password", this.TBParametricValueParampassword.Text); // 系统参数配置,SystemConfig节点 inifile2.IniWriteValue("SystemConfig", "plcAddress", this.AppConfigParamPlcAddress.Text); inifile2.IniWriteValue("SystemConfig", "machineId", this.AppConfigParamMachineID.Text); inifile2.IniWriteValue("SystemConfig", "processId", this.AppConfigParamProcessID.Text); inifile2.IniWriteValue("SystemConfig", "resource", this.AppConfigParamResource.Text); inifile2.IniWriteValue("SystemConfig", "operation", this.AppConfigParamOperation.Text); inifile2.IniWriteValue("SystemConfig", "operationByA", this.AppConfigParamOperationByA.Text); inifile2.IniWriteValue("SystemConfig", "operationByB", this.AppConfigParamOperationByB.Text); inifile2.IniWriteValue("SystemConfig", "isMesFlag", this.AppConfigParamIsMesFlag.Text); inifile2.IniWriteValue("SystemConfig", "plcSingalReadTime", this.AppConfigParamPlcSingalReadTime.Text); inifile2.IniWriteValue("SystemConfig", "MesWebServiceTimeOut", this.AppConfigParamMesWebServiceTimeOut.Text); ComboBoxItem ccdUploadIsFlag = (ComboBoxItem)this.ccdUploadIsFlagCombox.SelectedItem; if(ccdUploadIsFlag != null) { inifile2.IniWriteValue("SystemConfig", "ccdUploadIsFlag", ccdUploadIsFlag.Content.ToString()); } else { inifile2.IniWriteValue("SystemConfig", "ccdUploadIsFlag", "否"); } List plcParamValues = this.PlcParamValue.ItemsSource as List; foreach(ParamValueDto item in plcParamValues) { plcIniFile.IniWriteValue(iniSection, item.paramName,item.paramValue); } MessageBox.Show("更新成功,重启生效"); } catch(Exception ex) { LogHelperBusiness.LogError("配置信息保存异常", ex); MessageBox.Show("配置信息保存异常"); } } private void UserControl_Loaded(object sender, RoutedEventArgs e) { // 通过Rfid获取sfc ProcessLotServiceWSServiceParam节点 this.ProcessLotServiceWSServiceParamUrl.Text = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"); this.ProcessLotServiceWSServiceParamSite.Text = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"); this.ProcessLotServiceWSServiceParamUser.Text = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "user"); this.ProcessLotServiceWSServiceParamLoginUser.Text = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"); this.ProcessLotServiceWSServiceParamPassword.Text = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password"); // 新自动完工接口,Z_PR591调整数量, AdujustQtyParam节点 this.AdujustQtyParamUrl.Text = inifile.IniReadValue("AdujustQtyParam", "url"); this.AdujustQtyParamSite.Text = inifile.IniReadValue("AdujustQtyParam", "site"); this.AdujustQtyParamOperationRevision.Text = inifile.IniReadValue("AdujustQtyParam", "operationRevision"); this.AdujustQtyParamUser.Text = inifile.IniReadValue("AdujustQtyParam", "user"); this.AdujustQtyParamActivity.Text = inifile.IniReadValue("AdujustQtyParam", "activity"); this.AdujustQtyParamPassword.Text = inifile.IniReadValue("AdujustQtyParam", "password"); // 新自动完工接口,Z_PR571拆分, SplitSfcParam节点 this.SplitSfcParamUrl.Text = inifile.IniReadValue("SplitSfcParam", "url"); this.SplitSfcParamSite.Text = inifile.IniReadValue("SplitSfcParam", "site"); this.SplitSfcParamOperationRevision.Text = inifile.IniReadValue("SplitSfcParam", "operationRevision"); this.SplitSfcParamUser.Text = inifile.IniReadValue("SplitSfcParam", "user"); this.SplitSfcParamPassword.Text = inifile.IniReadValue("SplitSfcParam", "password"); this.SplitSfcParamActivity.Text = inifile.IniReadValue("SplitSfcParam", "activity"); this.HandSplitSfcParamUser.Text = inifile.IniReadValue("HandSplitSfcParam", "user"); this.HandSplitSfcParamPwd.Text = inifile.IniReadValue("HandSplitSfcParam", "password"); // 首工序获取SFC接口、自动入账接口、卷绕自动上料接口,MiFirstOperationForsfcServiceServiceParam节点 this.MiFirstOperationForsfcServiceServiceParamUrl.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "url"); this.MiFirstOperationForsfcServiceServiceParamSite.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "site"); this.MiFirstOperationForsfcServiceServiceParamOperationRevision.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "operationRevision"); this.MiFirstOperationForsfcServiceServiceParamUser.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "user"); this.MiFirstOperationForsfcServiceServiceParamPassword.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "password"); this.MiFirstOperationForsfcServiceServiceParamActivity.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "activity"); this.MiFirstOperationForsfcServiceServiceParamModeProcessSfc.Text = inifile.IniReadValue("MiFirstOperationForsfcServiceServiceParam", "modeProcessSfc"); // 涂布工单下达,MiReleaseSfcWithActivityServiceServiceParam节点 this.MiReleaseSfcWithActivityServiceServiceParamUrl.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "url"); this.MiReleaseSfcWithActivityServiceServiceParamSite.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "site"); this.MiReleaseSfcWithActivityServiceServiceParamOperationRevision.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "operationRevision"); this.MiReleaseSfcWithActivityServiceServiceParamUser.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "user"); this.MiReleaseSfcWithActivityServiceServiceParamActivity.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "activity"); this.MiReleaseSfcWithActivityServiceServiceParamLoginUser.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "loginUser"); this.MiReleaseSfcWithActivityServiceServiceParamPassword.Text = inifile.IniReadValue("MiReleaseSfcWithActivityServiceServiceParam", "password"); // 获取SFC数量 ,MiSFCQueryQtyServiceServiceParam节点 this.MiSFCQueryQtyServiceServiceParamUrl.Text = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "url"); this.MiSFCQueryQtyServiceServiceParamSite.Text = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "site"); this.MiSFCQueryQtyServiceServiceParamloginUser.Text = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "loginUser"); this.MiSFCQueryQtyServiceServiceParamPassword.Text = inifile.IniReadValue("MiSFCQueryQtyServiceServiceParam", "password"); // 注销接口, MiSignOffSFCsServiceServiceParam节点 this.MiSignOffSFCsServiceServiceParamUrl.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "url"); this.MiSignOffSFCsServiceServiceParamSite.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "site"); this.MiSignOffSFCsServiceServiceParamOperationRevision.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "operationRevision"); this.MiSignOffSFCsServiceServiceParamUser.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "user"); this.MiSignOffSFCsServiceServiceParamActivityId.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "activityId"); this.MiSignOffSFCsServiceServiceParamAmount.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "amount"); this.MiSignOffSFCsServiceServiceParamloginUser.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "loginUser"); this.MiSignOffSFCsServiceServiceParampassword.Text = inifile.IniReadValue("MiSignOffSFCsServiceServiceParam", "password"); // 获取工单数量,FindShopRequestParam节点 this.FindShopRequestParamUrl.Text = inifile.IniReadValue("FindShopRequestParam", "url"); this.FindShopRequestParamSite.Text = inifile.IniReadValue("FindShopRequestParam", "site"); this.FindShopRequestParamloginUser.Text = inifile.IniReadValue("FindShopRequestParam", "loginUser"); this.FindShopRequestParampassword.Text = inifile.IniReadValue("FindShopRequestParam", "password"); // 物料特征数据上传接口,MachineIntegrationServiceParam接口 this.MachineIntegrationServiceParamUrl.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "url"); this.MachineIntegrationServiceParamSite.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "site"); this.MachineIntegrationServiceParamOperationRevision.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "operationRevision"); this.MachineIntegrationServiceParamActivityId.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "activityId"); this.MachineIntegrationServiceParamDcGroupRevision.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroupRevision"); this.MachineIntegrationServiceParamDcGroup.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "dcGroup"); this.MachineIntegrationServiceParamloginUser.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "loginUser"); this.MachineIntegrationServiceParampassword.Text = inifile.IniReadValue("MachineIntegrationServiceParam", "password"); // 获取Mes数据,TBParametricValueParam节点 this.TBParametricValueParamUrl.Text = inifile.IniReadValue("TBParametricValueParam", "url"); this.TBParametricValueParamSite.Text = inifile.IniReadValue("TBParametricValueParam", "site"); this.TBParametricValueParamloginUser.Text = inifile.IniReadValue("TBParametricValueParam", "loginUser"); this.TBParametricValueParampassword.Text = inifile.IniReadValue("TBParametricValueParam", "password"); // 系统参数配置,SystemConfig节点 this.AppConfigParamPlcAddress.Text = inifile2.IniReadValue("SystemConfig", "plcAddress"); this.AppConfigParamMachineID.Text = inifile2.IniReadValue("SystemConfig", "machineId"); this.AppConfigParamProcessID.Text = inifile2.IniReadValue("SystemConfig", "processId"); this.AppConfigParamIsMesFlag.Text = inifile2.IniReadValue("SystemConfig", "isMesFlag"); this.AppConfigParamPlcSingalReadTime.Text = inifile2.IniReadValue("SystemConfig", "plcSingalReadTime"); this.AppConfigParamResource.Text = inifile2.IniReadValue("SystemConfig", "resource"); this.AppConfigParamOperation.Text = inifile2.IniReadValue("SystemConfig", "operation"); this.AppConfigParamOperationByA.Text = inifile2.IniReadValue("SystemConfig", "operationByA"); this.AppConfigParamOperationByB.Text = inifile2.IniReadValue("SystemConfig", "operationByB"); this.AppConfigParamMesWebServiceTimeOut.Text = inifile2.IniReadValue("SystemConfig", "MesWebServiceTimeOut"); this.ccdUploadIsFlagCombox.Text = inifile2.IniReadValue("SystemConfig", "ccdUploadIsFlag"); //获取PLC配置 List plcParamValues = plcIniFile.ReadKeys(iniSection); List paramValues = new List(); foreach(string item in plcParamValues) { ParamValueDto paramValueDto = new ParamValueDto(); paramValueDto.paramName = item; paramValueDto.paramValue = plcIniFile.IniReadValue(iniSection, item); paramValues.Add(paramValueDto); } this.PlcParamValue.ItemsSource = paramValues; } } }