using Autofac; using Bro.Common.Factory; using Bro.Common.Helper; using Bro.Common.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace Bro.Common.Model.Forms { public partial class FrmOpConfigEdit : Form { public string MethodCode { get; set; } public IOperationConfig BackupConfig { get; set; } public IOperationConfig OpConfig { get; set; } readonly string MonitorSetId = ""; public FrmOpConfigEdit() { InitializeComponent(); } public FrmOpConfigEdit(string methodCode, string monitorSetId, IOperationConfig opConfig) { InitializeComponent(); lblOpType.Text = MethodCode = methodCode; MonitorSetId = monitorSetId; OpConfig = opConfig; } private void btnCancel_Click(object sender, EventArgs e) { SetOperationConfigMonitorSetId(OpConfig); SetOperationConfigMonitorSetId(BackupConfig); DialogResult = DialogResult.Cancel; } private void btnConfirm_Click(object sender, EventArgs e) { SetOperationConfigMonitorSetId(OpConfig); SetOperationConfigMonitorSetId(BackupConfig); DialogResult = DialogResult.OK; } private void SetOperationConfigMonitorSetId(IOperationConfig config) { if (config != null) { config.MonitorSetId = MonitorSetId; } } private void btnReset_Click(object sender, EventArgs e) { string opType = ""; using (var scope = GlobalVar.Container.BeginLifetimeScope()) { List methodList = scope.Resolve>(); var method = methodList.FirstOrDefault(u => u.MethodCode == MethodCode); if (method != null) { opType = method.DeviceType; BackupConfig = ConfigFactory.GetOperationConfig(opType); } } propGrid.SelectedObject = OpConfig = ConfigFactory.GetOperationConfig(opType); } private void FrmOpConfigEdit_Load(object sender, EventArgs e) { string opType = ""; using (var scope = GlobalVar.Container.BeginLifetimeScope()) { List methodList = scope.Resolve>(); var method = methodList.FirstOrDefault(u => u.MethodCode == MethodCode); if (method != null) { opType = method.DeviceType; BackupConfig = ConfigFactory.GetOperationConfig(opType); } } if (OpConfig == null) { OpConfig = ConfigFactory.GetOperationConfig(opType); } else { BackupConfig.DataFrom(OpConfig); } propGrid.SelectedObject = OpConfig; } } }