Exemplo n.º 1
0
        static public void loadUtils()
        {
            string FileName = @".\vmmodule.ps1";

            if (System.IO.File.Exists(FileName))
            {
                WraperPs.RunScript(@". " + FileName);
            }
        }
Exemplo n.º 2
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     try
     {
         txtResult.Clear();
         txtResult.Text = WraperPs.RunScript(txtScript.Text);
         toDataView(txtResult.Text);
     }
     catch (Exception error)
     {
         txtResult.Text += String.Format("\r\nError in script : {0}\r\n", error.Message);
     }
 }
Exemplo n.º 3
0
        public void DoScript(string scriptText)
        {
            if (Properties.Settings.Default.isDebug)
            {
                txtScript.Text += scriptText;
            }

            try
            {
                txtResult.Text = WraperPs.RunScript(scriptText);
            }
            catch (Exception error)
            {
                txtResult.Text += String.Format("\r\nError in script : {0}\r\n", error.Message);
            }
        }
Exemplo n.º 4
0
        private void btnDiskTree_Click(object sender, EventArgs e)
        {
            DataColumn dc = aTable.Columns["Disk Name"];

            if (dc == null)
            {
                MessageBox.Show("未選擇硬碟", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string id  = dataGridView1.SelectedCells[0].Value.ToString();
            string cmd = "Get-VHDChain -Path " + id;

            txtScript.Text = cmd;
            txtResult.Text = WraperPs.RunScript(cmd);
            toDataView(txtResult.Text, "Disk Tree");
        }
Exemplo n.º 5
0
        private void btnMergeDisk_Click(object sender, EventArgs e)
        {
            DataColumn dc = aTable.Columns["Disk Tree"];

            if (dc == null)
            {
                MessageBox.Show("未選擇虛擬機", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string id  = dataGridView1.SelectedCells[0].Value.ToString();
            string cmd = "MergeDisk -DiskPath " + id;

            txtScript.Text = cmd;
            txtResult.Text = WraperPs.RunScript(cmd);
            txtResult.Text = txtResult.Text + Environment.NewLine + "    ==>done";
            //toDataView(txtResult.Text, "Disk Tree");
        }
Exemplo n.º 6
0
        private void btnGetDisk_Click(object sender, EventArgs e)
        {
            string     prevAction = "Vm Name";
            DataColumn dc         = aTable.Columns[prevAction];

            //如果有的話,dc.ColumnName
            if (dc == null)
            {
                MessageBox.Show("未選擇虛擬機", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string id  = dataGridView1.SelectedCells[0].Value.ToString();
            string cmd = "listDisk -Name " + id;

            txtScript.Text = cmd;
            txtResult.Text = WraperPs.RunScript(cmd);
            toDataView(txtResult.Text, "Disk Name");
        }
Exemplo n.º 7
0
 private void btnGetVm_Click(object sender, EventArgs e)
 {
     txtResult.Text = WraperPs.RunScript("(Get-Vm).Name");
     toDataView(txtResult.Text, "Vm Name");
 }
Exemplo n.º 8
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     WraperPs.end_session();
 }
Exemplo n.º 9
0
 private void Form1_Load(object sender, EventArgs e)
 {
     WraperPs.init_session();
 }