예제 #1
0
        private void btRun_Click(object sender, EventArgs e)
        {
            try
            {
                main m = new main();

                // main main = new main();
                //main.GetFirstValue = ProjectPath;
                this.DialogResult = System.Windows.Forms.DialogResult.No;
                // Bước 1: tạo biến để lưu thư mục cần tạo, tên thư mục cần tạo là "StoredFiles"
                string path = txtBrowse.Text;
                string directoryPath = txtName.Text;
                // Bước 2: kiểm tra nếu thư mục "StoredFiles" chưa tồn tại thì tạo mới
                if (!System.IO.Directory.Exists(directoryPath))
                    System.IO.Directory.CreateDirectory(directoryPath);
                // Bước 4: tạo tập tin "EmployeeList.txt" trong thư mục "StoredFiles"
                ProjectPath = path + @"\" + directoryPath;
                ProjectPath1 = path + @"\" + directoryPath + @"\Data";
                string filePath = path + @"\" + directoryPath + @"\Script";
                string filePath1 = path + @"\" + directoryPath + @"\Data";
                string filePath2 = path + @"\" + directoryPath + @"\Interface";
                string filePath3 = path + @"\" + directoryPath + @"\Report";
                // System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
                System.IO.Directory.CreateDirectory(filePath);
                System.IO.Directory.CreateDirectory(filePath1);
                System.IO.Directory.CreateDirectory(filePath2);
                System.IO.Directory.CreateDirectory(filePath3);
                // Kết thúc: thông báo tạo tập tin thành công
                // và chỉ ra đường dẫn tập tin để người dùng dễ dàng kiểm tra tập tin vừa tạo
                //string mesage = "Tạo tập tin thành công";
                //string mesage = "Tạo tập tin \"Script\" thành công." + Environment.NewLine;
                //mesage += "Đường dẫn là \"" + System.Windows.Forms.Application.StartupPath + @"\" + directoryPath + filePath + "\"";
                //MessageBox.Show(mesage, "Thông báo");
                this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                this.Close();

            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.InnerException.ToString());
            }
        }
예제 #2
0
        private void addNewFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddFile1 newFile = new AddFile1();

            //newFile.labelX3.Text = newFile.labelX3.Text + "-" + treeViewproject.SelectedNode.Text;
            newFile.ShowDialog();
            main main = new main();

            Excel.Application xlApp = default(Excel.Application);
            Excel.Workbook xlWorkBook = default(Excel.Workbook);
            Excel.Worksheet xlWorkSheet = default(Excel.Worksheet);

            FileTreeNode treeNode = new FileTreeNode();
            treeNode.Text = newFile.txtName.Text + "." + newFile.cboType.Text;
            treeNode.Tag = CurrentProjectPath + @"\" + treeViewproject.SelectedNode.Text + @"\" + treeNode.Text;
            treeNode.Name = "File";
            treeNode.ImageIndex = newFile.cboType.SelectedIndex;
            newFile.Close();
            if (newFile.txtName.Text != "")
            {
                treeViewproject.SelectedNode.Nodes.Add(treeNode);
                treeViewproject.SelectedNode.ExpandAll();
                //@new new1 = new @new();
                //string path = new1.ProjectPath;
                //string fName = path + @"\" + treeViewproject.SelectedNode.Tag + @"\" + treeNode.Tag;
                string fName = treeViewproject.Nodes[0].Tag + @"\" + treeViewproject.SelectedNode.Text + @"\" + treeNode.Text;
                 //const string fName =@"F:\abc.xls";
                try
                {
                    object misValue = System.Reflection.Missing.Value;
                    xlApp = new Excel.Application();
                    xlWorkBook = xlApp.Workbooks.Add(misValue);
                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    xlWorkBook.SaveAs(fName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xlWorkBook.Close(true, misValue, misValue);
                    xlApp.Quit();
                    releaseObject(xlWorkSheet);
                    releaseObject(xlWorkBook);
                    releaseObject(xlApp);
                }
                finally
                {
                    if (xlApp != null)
                        releaseObject(xlApp);
                    if (xlWorkBook != null)
                        releaseObject(xlWorkBook);
                    if (xlWorkSheet != null)
                        releaseObject(xlWorkSheet);
                }
                //if (System.IO.File.Exists(fName))
                //{
                //    //if (System.Windows.Forms.MessageBox.Show("Would you like to open the excel file?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                //    //{
                //        //try
                //        //{
                //        //    System.Diagnostics.Process.Start(fName);
                //        //}
                //        //catch (Exception ex)
                //        //{
                //        //    System.Windows.Forms.MessageBox.Show("Error opening the excel file." + Environment.NewLine +
                //        //      ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        //}
                //    //}
                //}

               //CompoundDocument _doc = CompoundDocument.Open(fName);
            }
        }
예제 #3
0
        private void addNewFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddFile1 newFile = new AddFile1();

            //newFile.labelX3.Text = newFile.labelX3.Text + "-" + treeViewproject.SelectedNode.Text;
            newFile.ShowDialog();
            main main = new main();

            Excel.Application xlApp       = default(Excel.Application);
            Excel.Workbook    xlWorkBook  = default(Excel.Workbook);
            Excel.Worksheet   xlWorkSheet = default(Excel.Worksheet);

            FileTreeNode treeNode = new FileTreeNode();

            treeNode.Text       = newFile.txtName.Text + "." + newFile.cboType.Text;
            treeNode.Tag        = CurrentProjectPath + @"\" + treeViewproject.SelectedNode.Text + @"\" + treeNode.Text;
            treeNode.Name       = "File";
            treeNode.ImageIndex = newFile.cboType.SelectedIndex;
            newFile.Close();
            if (newFile.txtName.Text != "")
            {
                treeViewproject.SelectedNode.Nodes.Add(treeNode);
                treeViewproject.SelectedNode.ExpandAll();
                //@new new1 = new @new();
                //string path = new1.ProjectPath;
                //string fName = path + @"\" + treeViewproject.SelectedNode.Tag + @"\" + treeNode.Tag;
                string fName = treeViewproject.Nodes[0].Tag + @"\" + treeViewproject.SelectedNode.Text + @"\" + treeNode.Text;
                //const string fName =@"F:\abc.xls";
                try
                {
                    object misValue = System.Reflection.Missing.Value;
                    xlApp       = new Excel.Application();
                    xlWorkBook  = xlApp.Workbooks.Add(misValue);
                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    xlWorkBook.SaveAs(fName, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xlWorkBook.Close(true, misValue, misValue);
                    xlApp.Quit();
                    releaseObject(xlWorkSheet);
                    releaseObject(xlWorkBook);
                    releaseObject(xlApp);
                }
                finally
                {
                    if (xlApp != null)
                    {
                        releaseObject(xlApp);
                    }
                    if (xlWorkBook != null)
                    {
                        releaseObject(xlWorkBook);
                    }
                    if (xlWorkSheet != null)
                    {
                        releaseObject(xlWorkSheet);
                    }
                }
                //if (System.IO.File.Exists(fName))
                //{
                //    //if (System.Windows.Forms.MessageBox.Show("Would you like to open the excel file?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                //    //{
                //        //try
                //        //{
                //        //    System.Diagnostics.Process.Start(fName);
                //        //}
                //        //catch (Exception ex)
                //        //{
                //        //    System.Windows.Forms.MessageBox.Show("Error opening the excel file." + Environment.NewLine +
                //        //      ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        //}
                //    //}
                //}



                //CompoundDocument _doc = CompoundDocument.Open(fName);
            }
        }
예제 #4
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            Close();
            main m = new main();
            //string path = m.CurrentProjectPath;

            CurrenrtAutomation = new Automation(new ExcelFileParser(), new ExcelReporter(new ExcelFileParser()),
               CurrentProjectPath);
            UIAActionManager am = new UIAActionManager(CurrenrtAutomation);

            try
            {
                Script startScript = new Script(CurrenrtAutomation.Parser.NewInstance);
                startScript.FileName = _txtScript.Text;
                string dataset = _cboData.SelectedItem.ToString();
                if (dataset != @"[None]")
                {
                    Data data = new Data(CurrenrtAutomation.Parser.NewInstance);
                    data.FileName = dataset;
                    CurrenrtAutomation.Data = data;

                }

                CurrenrtAutomation.Name = "Regression 1";
                CurrenrtAutomation.Speed = 10;
                CurrenrtAutomation.StartScript = startScript;
                CurrenrtAutomation.Start();

                //CurrenrtAutomation.Paused += at_Paused;
                //CurrenrtAutomation.Resumed += at_Resumed;
                //CurrenrtAutomation.Interupted += at_Interupted;
                //CurrenrtAutomation.Ended += at_Ended;
                //CurrenrtAutomation.ActionPerforming += at_ActionPerforming;

                //System.Threading.Thread.Sleep(3000);
                //at.Pause();

                //System.Threading.Thread.Sleep(10000);
                //at.Resume();

                //System.Threading.Thread.Sleep(3000);
                //at.Interupt();
            }
            catch (Exception x)
            {
                System.Windows.Forms.MessageBox.Show(x.Message);
            }
            finally
            {
                //at.Interupt();
                //Console.ReadLine();
            }

            //Automation at = new Automation(new ExcelFileParser(), new ExcelReporter(), @"D:\codes\dotnetabt\seleniumabt\sample");
            //SeleniumActionManager am = new SeleniumActionManager(at, SeleniumActionManager.Browser.Chrome);

            //Script startScript = new Script(at.Parser.NewInstance);
            //startScript.FileName = "Script.xls";

            //at.Scripts.Push(startScript);
            //at.Start();
        }
예제 #5
0
파일: Run.cs 프로젝트: yhtsnda/dotnetabt
        private void btAdd_Click(object sender, EventArgs e)
        {
            Close();
            main m = new main();

            //string path = m.CurrentProjectPath;

            CurrenrtAutomation = new Automation(new ExcelFileParser(), new ExcelReporter(new ExcelFileParser()),
                                                CurrentProjectPath);
            UIAActionManager am = new UIAActionManager(CurrenrtAutomation);

            try
            {
                Script startScript = new Script(CurrenrtAutomation.Parser.NewInstance);
                startScript.FileName = _txtScript.Text;
                string dataset = _cboData.SelectedItem.ToString();
                if (dataset != @"[None]")
                {
                    Data data = new Data(CurrenrtAutomation.Parser.NewInstance);
                    data.FileName           = dataset;
                    CurrenrtAutomation.Data = data;
                }


                CurrenrtAutomation.Name        = "Regression 1";
                CurrenrtAutomation.Speed       = 10;
                CurrenrtAutomation.StartScript = startScript;
                CurrenrtAutomation.Start();


                //CurrenrtAutomation.Paused += at_Paused;
                //CurrenrtAutomation.Resumed += at_Resumed;
                //CurrenrtAutomation.Interupted += at_Interupted;
                //CurrenrtAutomation.Ended += at_Ended;
                //CurrenrtAutomation.ActionPerforming += at_ActionPerforming;

                //System.Threading.Thread.Sleep(3000);
                //at.Pause();

                //System.Threading.Thread.Sleep(10000);
                //at.Resume();

                //System.Threading.Thread.Sleep(3000);
                //at.Interupt();
            }
            catch (Exception x)
            {
                System.Windows.Forms.MessageBox.Show(x.Message);
            }
            finally
            {
                //at.Interupt();
                //Console.ReadLine();
            }

            //Automation at = new Automation(new ExcelFileParser(), new ExcelReporter(), @"D:\codes\dotnetabt\seleniumabt\sample");
            //SeleniumActionManager am = new SeleniumActionManager(at, SeleniumActionManager.Browser.Chrome);

            //Script startScript = new Script(at.Parser.NewInstance);
            //startScript.FileName = "Script.xls";

            //at.Scripts.Push(startScript);
            //at.Start();
        }