using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Linq; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors.Filtering.Templates; using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjReport.OpenDoor; using Mesnac.Basic; using Mesnac.Codd.Session; using Mesnac.Controls.Base; using Mesnac.Controls.Default; namespace Mesnac.Action.ChemicalWeighing.Test { public class TestAction : DatabaseAction, IAction { MCButton mCButton; public void timer1EventProcessor(object source, EventArgs e) { OpenDoorService.Insert(new OpenDoorEntity() { DeviceId = 0, OpenTime = DateTime.Now, CreateTime = DateTime.Now, Status = 0 }); } public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 var allDb=GetAllControls(); DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } // dbHelper.ClearParameter(); // dbHelper.CommandType = CommandType.Text; // dbHelper.CommandText = sql; int[] ssss = new int [] { }; var ss2s = BasePlcHelper.Instance.PlcReadByRunName("BU1BLT01_Set", out ssss); Timer timer1 = new Timer(); timer1.Interval = 1000; timer1.Enabled = true; timer1.Tick += new EventHandler(timer1EventProcessor);//添加事件 mCButton = allDb.FirstOrDefault(x => x.Name == "MCButton1") as MCButton; mCButton.Click += new EventHandler(timer1EventProcessor); //MCButton1 //OpenDoorService } } }