Exemplo n.º 1
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            string fileName = @"E:\ToanTV\STM\2.source c#\STM_TestDevice\STM_TestDevice\bin\Debug\ConfigBatery.xlsx";
            // generateReport();
            //TestCopyPasteTextExcell();
            DevicesParser devicesParser = new DevicesParser(fileName);

            devicesParser.Open();

            List <Device> devices = devicesParser.ParseConfigDefine();
            List <Device> detail  = devicesParser.ParseSetupData(devices[0]);

            devicesParser.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// close form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BatteryTest_FormClosed(object sender, FormClosedEventArgs e)
        {
            // close thread background
            try
            {
                mFileSaveWorker.CancelAsync();
                mPasteExcellWorker.CancelAsync();
                mUpdateBatStatUIWoker.CancelAsync();
            }
            catch (Exception ex)
            {
            }

            // close stream writer
            try
            {
                mtWriteBufferFile.Close();
                mWriteResuleBat.Close();
            }
            catch (Exception ex)
            {
            }

            // close serial port
            try
            {
                serialPortControl.Close();
                serialPortData.Close();
            }
            catch (Exception ex)
            {
            }

            // close exporter
            try
            {
                if (!File.Exists(getPathReportFile()))
                {
                    MessageBox.Show("Generate file not exsisted, Auto generate file");
                    File.Copy(fileResult_battery_Root, getPathReportFile());
                }

                string preCloseString = File.ReadAllText(FILE_BUFFER);

                if (mtExcelExporter != null)
                {
                    lock (mtExcelExporter)
                    {
                        mtExcelExporter.PasteText(preCloseString, 1, 1, 1);
                        mtExcelExporter.CloseExcelFile();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // close device parser
            try
            {
                mDevicesParser.Close();
            }
            catch (Exception ex)
            {
            }
        }