Ejemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            //定时获取数据
            if (!client.Connected)//已经连接
            {
                timer1.Enabled = true;
                return;
            }
            DbContext <T_Test1> db            = new DbContext <T_Test1>();
            List <T_Test1>      Temp_lstEvent = db.GetList(item => item.ID > Para.SyncIDFlag);

            foreach (T_Test1 item in Temp_lstEvent)
            {
                SendCmd(Agreement.GetEventCmd(item));
            }
            timer1.Enabled = true;
        }
Ejemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            //写入看门狗日志
            PubMethod.WriteIniFile(SystemSet_Basic.WatchDogSetIniFilePath, "Basic", "WatchDogFlag", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            //定时获取数据
            if (!client.IsStarted)//已经连接
            {
                timer1.Enabled = true;
                return;
            }
            DbContext <T_Test1> db            = new DbContext <T_Test1>();
            List <T_Test1>      Temp_lstEvent = db.GetList(item => item.ID > Para.SyncIDFlag);

            foreach (T_Test1 item in Temp_lstEvent)
            {
                string send  = Agreement.GetEventCmd(item);
                byte[] bytes = Encoding.UTF8.GetBytes(send);

                if (client.Send(bytes, bytes.Length))
                {
                    Configuration config = ConfigurationManager.OpenExeConfiguration(file);
                    Para.SyncIDFlag = item.ID;
                    config.AppSettings.Settings["SM_SyncIDFlag"].Value = Convert.ToString(item.ID);
                    config.Save();
                    CommonMethod.Common.Delay_Millisecond(100);
                }
                else if (!client.IsStarted)
                {
                    string strMsg = string.Format("$ ({0}) Send Fail --> {1} ({2})", client.ConnectionId, item.NameT, item.NameT.Length);
                    AddLog(strMsg);
                    AddMsg(strMsg);
                    timer1.Enabled = true;
                    return;
                }
            }
            timer1.Enabled = true;
        }