Пример #1
0
        private void importTestDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!m_bDBOpen)
            {
                GetDbPath();
            }

            FileDialog fd = new OpenFileDialog();
            fd.CheckFileExists = true;
            fd.CheckPathExists = true;
            fd.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
            fd.FileName = "";
            while (0 == fd.FileName.Length)
            {
                DialogResult dr = fd.ShowDialog();
                if (DialogResult.OK != dr)
                {
                    return;
                }
            }       // while ...

            m_ProgressDlg = new ProgressDialog();
            m_ProgressDlg.Text = "Table Import";
            string sTxt = "Importing stored test results from ";
            sTxt += fd.FileName;
            m_ProgressDlg.SetMessage (sTxt);
            m_ProgressDlg.StartPosition = FormStartPosition.CenterScreen;
            m_ProgressDlg.Show();
            //            m_DelegateUpdateProgressBar = new DelegateUpdateProgressBar (this.UpdateProgressBar);
            DbOperationThread importThread = new DbOperationThread (etDbOperation.eImportTable, this, fd.FileName);
            Thread t = new Thread (new ThreadStart (importThread.ThreadProc));
            t.Name = "Zal import worker thread";
            t.IsBackground = true;
            //              m_WorkerThread.Priority = ThreadPriority.Lowest;
            t.SetApartmentState (ApartmentState.STA);

            t.Start();
            //            t.Join();

            //            m_ProgressDlg.Close();
        }
Пример #2
0
        private void exportTestDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!m_bDBOpen)
            {
                GetDbPath();
            }

            FileDialog fd = new OpenFileDialog();
            fd.CheckFileExists = false;
            fd.CheckPathExists = true;
            fd.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
            fd.FileName = "";
            while (0 == fd.FileName.Length)
            {
                DialogResult dr = fd.ShowDialog();
                if (DialogResult.OK == dr)
                {
                    if (File.Exists(fd.FileName))
                    {
                        string sMsg = "File ";
                        sMsg += fd.FileName + " ";
                        sMsg += "already exists. Do you want to overwrite it?";
                        DialogResult dRes = MessageBox.Show (sMsg,
                                                             "Zal Test Export",
                                                             MessageBoxButtons.YesNoCancel,
                                                             MessageBoxIcon.Question);
                        switch (dRes)
                        {
                            case DialogResult.Yes:
                                break;
                            case DialogResult.No:
                                fd.FileName = "";
                                break;
                            case DialogResult.Cancel:
                                return;
                            default:
                                sMsg = "Illegal dialog return.";
                                MessageBox.Show(sMsg, "Zal Error", MessageBoxButtons.OK);
                                return;

                        }       // switch
                    }
                    //                    else
                    //                    {
                    //                        return;
                    //                    }
                }
                else
                {
                    return;
                }
            }       // while ...

            try
            {
                m_ProgressDlg = new ProgressDialog();
                m_ProgressDlg.Text = "Table Export";
                string sMsg = "Exporting test results to ";
                sMsg += fd.FileName;
                m_ProgressDlg.SetMessage(sMsg);
                m_ProgressDlg.StartPosition = FormStartPosition.CenterScreen;
                m_ProgressDlg.Show();
            //                m_DelegateUpdateProgressBar = new DelegateUpdateProgressBar (this.UpdateProgressBar);
                DbOperationThread exportThread = new DbOperationThread (etDbOperation.eExportTable, this, fd.FileName);
                Thread t = new Thread (new ThreadStart (exportThread.ThreadProc));
                t.Name = "Zal export worker thread";
                t.IsBackground = true;
                //              m_WorkerThread.Priority = ThreadPriority.Lowest;
                t.SetApartmentState (ApartmentState.STA);

                t.Start();
            //                t.Join();

                // m_ProgressDlg.Close();
            }
            catch (Exception ex)
            {
            //                MainLib.ZalError err = new MainLib.ZalError();
                string sMsg = "exportTestDataToolStripMenuItem_Click: ";
                sMsg += ex.Message;
                sMsg += "\n";
            //                sMsg += err.LastError;
                MessageBox.Show (sMsg, "Zal Error", MessageBoxButtons.OK);
                return;
            }
        }