コード例 #1
0
        void Work()
        {
            while (Convert.ToInt32(lblTimesToDo.Text) > 0)
            {
                lblTimesToDo.Text = (Convert.ToInt32(lblTimesToDo.Text) - 1).ToString();
                foreach(Command c in commands)
                {
                    switch(c.Open)
                    {
                        case "open":
                            {
                                _serialPort.BaudRate = c.Files;
                                try
                                {
                                    _serialPort.Open();
                                }
                                catch(Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                    Application.Exit();
                                }
                                break;
                            }
                        case"close":
                            {
                                _serialPort.Close();
                                break;
                            }
                        case "send":
                            {
                                WritePort(c.Array);
                                break;
                            }
                        case "sleep":
                            {
                                Thread.Sleep(c.Files);
                                break;
                            }
                    }
                }
            }
            StartAnaly(Application.StartupPath + @"\SendData\" + DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日.txt"
                , Application.StartupPath + @"\ReciveData\" + DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日.txt");

            while (pro != null && !pro.HasExited)
                Thread.Sleep(1000);

            this.lbAnaly.Items.Add("正在导出为Excel...");
            this.lbAnaly.SelectedIndex = this.lbAnaly.Items.Count - 1;
            try
            {
                Exporter ept = new Exporter(DateTime.Now);
                ept.Export();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "异常");
            }
            this.lbAnaly.Items.Add("正在导出为Excel完成!");
            this.lbAnaly.SelectedIndex = this.lbAnaly.Items.Count - 1;

            btnStart.Enabled = true;
            txtTimes.Enabled = true;
        }
コード例 #2
0
 private void btnGetData_Click(object sender, EventArgs e)
 {
     Exporter ex = new Exporter(dtpDate.Value);
     ex.Export();
 }
コード例 #3
0
        private void btnGetData_Click(object sender, EventArgs e)
        {
            Exporter ex = new Exporter(dtpDate.Value);

            ex.Export();
        }