Exemplo n.º 1
0
 /// <summary>
 /// 启动服务。
 /// </summary>
 protected override void OnStart(string[] args)
 {
     try
     {
         this._eventLog.WriteEntry("MES.IVTestDataTransfer 服务启动");
         if (lstWrapper == null)
         {
             lstWrapper = new List <IVTestDataTransferThreadWrapper>();
         }
         //获取配置节信息
         this._section = (IVTestConfigurationSection)ConfigurationManager.GetSection("mes.ivtest");
         //增加线程个数。
         foreach (IVTestDeviceElement element in this._section.Devices)
         {
             ParameterizedThreadStart        threadStart = new ParameterizedThreadStart(TransferData);
             IVTestDataTransferThreadWrapper wrapper     = new IVTestDataTransferThreadWrapper(element, threadStart);
             lstWrapper.Add(wrapper);
         }
         //启动线程。
         foreach (IVTestDataTransferThreadWrapper wrapper in lstWrapper)
         {
             Thread.Sleep(500);
             wrapper.Start();
         }
     }
     catch (Exception ex)
     {
         this._eventLog.WriteEntry(string.Format("MES.IVTestDataTransfer:{0}", ex.Message), EventLogEntryType.Error);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 启动服务。
        /// </summary>
        protected override void OnStart(string[] args)
        {
            _evnetLog.WriteEntry("FanHai.MES.IVTest.Service服务启动");
            //获取配置节信息
            this._section = (IVTestConfigurationSection)ConfigurationManager.GetSection("ivtest");
            string sleepTime = System.Configuration.ConfigurationManager.AppSettings["SLEEP_TIME"];

            if (!string.IsNullOrEmpty(sleepTime))
            {
                _sleepTime = Convert.ToInt32(sleepTime);
            }
            //增加线程个数。
            foreach (DeviceElement element in this._section.Devices)
            {
                ParameterizedThreadStart        threadStart = new ParameterizedThreadStart(TransferData);
                IVTestDataTransferThreadWrapper wrapper     = new IVTestDataTransferThreadWrapper(element, threadStart);
                lstWrapper.Add(wrapper);
            }
            //启动线程。
            foreach (IVTestDataTransferThreadWrapper wrapper in lstWrapper)
            {
                Thread.Sleep(100);
                wrapper.Start();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 窗体载入事件。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void frmMain_Load(object sender, EventArgs e)
 {
     //获取配置节信息
     this._section = (IVTestConfigurationSection)ConfigurationManager.GetSection("ivtest");
     if (this._section != null)
     {
         //绑定设备
         foreach (DeviceElement device in this._section.Devices)
         {
             this.cmbDevice.Items.Add(device.Name);
         }
     }
     InitServiceStatus();
 }
Exemplo n.º 4
0
        private void FrmIVDataUpload_Load(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            bool   blFound  = false;
            string hostInfo = Dns.GetHostName();

            System.Net.IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            //IPAddress ipaddress = addressList[0];
            //string ips = ipaddress.ToString();
            //MessageBox.Show(ips);


            //获取配置节信息
            this._section = (IVTestConfigurationSection)ConfigurationManager.GetSection("mes.ivtest");
            //增加线程个数。
            foreach (IVTestDeviceElement element in this._section.Devices)
            {
                foreach (IPAddress ipAddress in addressList)
                {
                    strIP = ipAddress.ToString();
                    if (strIP == element.Name)
                    {
                        blFound        = true;
                        _deviceElement = element;
                        break;
                    }
                }
            }
            if (blFound == false)
            {
                MessageBox.Show("此电脑的IP地址没有在配置文件中找到对应的配置,请联系IT");
                Application.Exit();
            }
            else
            {
                txtFilePath.Text = CommonFun.GetFullFile(_deviceElement.Path, _deviceElement.Format);
                //txtFilePath.Text = _deviceElement.Path;
                txtSourceImagePath.Text = _deviceElement.SourceImagePathRoot;
            }

            string strSql = " select top 1 * from [dbo].[ZWIP_IV_TEST] where EQUIPMENT_CODE='"
                            + _deviceElement.EqpName + "'  order by TEST_TIME desc";

            DataTable dt = DatabaseEx.getDbInstance().getDataTable(strSql);

            if (dt != null && dt.Rows.Count > 0)
            {
                txtTestTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt.Rows[0]["TEST_TIME"].ToString());
                //txtTestTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", "2015-06-11 09:10:10");
            }
            else
            {
                txtTestTime.Text = "1900-01-01 01:01:01";
            }
            txtEqpName.Text = _deviceElement.EqpName;

            btnStart.Enabled     = true;
            btnPause.Enabled     = false;
            txtEqpName.ReadOnly  = true;
            txtTestTime.ReadOnly = true;
            //btnStart_Click(null, null);

            notifyIVData.Visible = false;
        }