private void 磁盘comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //string diskName =  磁盘comboBox.SelectedValue.ToString().Replace("System.Windows.Controls.ComboBoxItem: ","");
            //string diskName = 磁盘comboBox.Items[磁盘comboBox.SelectedIndex].ToString();
            //string diskName = 磁盘comboBox.Items[磁盘comboBox.SelectedIndex].ToString();
            //string diskName = 磁盘comboBox.SelectedItem.ToString();

            DataRowView drv      = (DataRowView)磁盘comboBox.SelectedItem;
            string      diskName = Convert.ToString(drv.Row["Text"]);

            foreach (VdiskTemplate temp in vdiskTempletList)
            {
                if (temp.DiskName == diskName)
                {
                    还原点dataGridView.AutoGenerateColumns = false;
                    还原点dataGridView.DataSource          = temp.vdiskRestorePoint;
                    vDiskParent = temp;
                    return;
                }
                else
                {
                    还原点dataGridView.AutoGenerateColumns = false;
                    还原点dataGridView.DataSource          = new List <VdiskRestorePoint>();
                }
            }
        }
Beispiel #2
0
        private void button添加_Click(object sender, EventArgs e)
        {
            string disk_id   = "";
            string disk_name = "";
            string disk_path = "";

            if (磁盘fromdataGridView.Rows.Count != 0)
            {
                int a = 磁盘fromdataGridView.CurrentRow.Index;
                disk_id   = 磁盘fromdataGridView.Rows[a].Cells["diskId"].Value.ToString();
                disk_name = 磁盘fromdataGridView.Rows[a].Cells["diskName"].Value.ToString();
                disk_path = 磁盘fromdataGridView.Rows[a].Cells["diskPath"].Value.ToString();

                foreach (VdiskTemplate vdisk in vdiskTempletList)
                {
                    if (vdisk.DiskId == disk_id)
                    {
                        vdiskTempletList.Remove(vdisk);
                        break;
                    }
                }
                磁盘fromdataGridView.DataSource = null;

                if (vdiskTempletList.Count != 0)
                {
                    磁盘fromdataGridView.DataSource = vdiskTempletList;
                }


                //int addindex = this.磁盘todataGridView.Rows.Add();
                //this.磁盘todataGridView.Rows[addindex].Cells["toDiskId"].Value = disk_id;
                //this.磁盘todataGridView.Rows[addindex].Cells["toDiskName"].Value = disk_name;


                this.磁盘todataGridView.AutoGenerateColumns = false;
                磁盘todataGridView.DataSource = null;
                VdiskTemplate tovdisk = new VdiskTemplate();
                tovdisk.DiskId   = disk_id;
                tovdisk.DiskName = disk_name;
                tovdisk.DiskPath = disk_path;
                tovdiskTempletList.Add(tovdisk);

                if (tovdiskTempletList.Count != 0)
                {
                    磁盘todataGridView.DataSource = tovdiskTempletList;
                }

                磁盘todataGridView.Refresh();
                //磁盘todataGridView.CurrentCell = 磁盘todataGridView.Rows[0].Cells[0];
            }
        }
Beispiel #3
0
        private void  原button_Click(object sender, EventArgs e)
        {
            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from VDISK_TEMPLET;");

                    vdiskTempletList.Clear();

                    VdiskTemplate vdiskTemp;

                    foreach (DataRow row in dt.Rows)
                    {
                        vdiskTemp          = new VdiskTemplate();
                        vdiskTemp.DiskId   = row["disk_id"].ToString();
                        vdiskTemp.DiskName = row["disk_name"].ToString();
                        vdiskTemp.DiskPath = row["disk_path"].ToString();
                        vdiskTempletList.Add(vdiskTemp);
                    }

                    this.磁盘fromdataGridView.AutoGenerateColumns = false;
                    this.磁盘todataGridView.AutoGenerateColumns   = false;

                    this.磁盘fromdataGridView.DataSource = null;
                    this.磁盘fromdataGridView.DataSource = vdiskTempletList;

                    this.磁盘todataGridView.DataSource = null;
                    tovdiskTempletList.Clear();

                    conn.Close();
                }
            }

            磁盘todataGridView.DataSource = new List <VdiskTemplate>();
        }
        private void VdiskTemplateManageWindow_Load(object sender, EventArgs e)
        {
            IniFile ini = new IniFile(Environment.CurrentDirectory + "\\setting.ini");

            iscsiURL = ini.ReadString("IscsiServer", "URL", "");
            username = ini.ReadString("IscsiServer", "USERNAME", "");
            password = ini.ReadString("IscsiServer", "PASSWORD", "");

            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from VDISK_TEMPLET;");

                    VdiskTemplate vdiskTemp;

                    foreach (DataRow row in dt.Rows)
                    {
                        vdiskTemp          = new VdiskTemplate();
                        vdiskTemp.DiskId   = row["disk_id"].ToString();
                        vdiskTemp.DiskName = row["disk_name"].ToString();
                        vdiskTemp.DiskSize = (int)row["disk_size"];
                        vdiskTemp.DiskPath = row["disk_path"].ToString();
                        vdiskTemp.DiskType = (int)row["disk_type"];
                        vdiskTempletList.Add(vdiskTemp);
                    }
                    this.磁盘管理dataGridView.AutoGenerateColumns = false;
                    this.磁盘管理dataGridView.DataSource          = vdiskTempletList;

                    conn.Close();
                }
            }
        }
Beispiel #5
0
        private void button删除_Click(object sender, EventArgs e)
        {
            string disk_id   = "";
            string disk_name = "";
            string disk_path = "";


            if (磁盘todataGridView.Rows.Count != 0)
            {
                int a = 磁盘todataGridView.CurrentRow.Index;
                disk_id   = 磁盘todataGridView.Rows[a].Cells["toDiskId"].Value.ToString();
                disk_name = 磁盘todataGridView.Rows[a].Cells["toDiskName"].Value.ToString();
                disk_path = 磁盘todataGridView.Rows[a].Cells["toDiskPath"].Value.ToString();

                foreach (VdiskTemplate vdisk in tovdiskTempletList)
                {
                    if (vdisk.DiskId == disk_id)
                    {
                        tovdiskTempletList.Remove(vdisk);
                        break;
                    }
                }
                磁盘todataGridView.DataSource = null;
                磁盘todataGridView.DataSource = tovdiskTempletList;

                //int addindex = this.磁盘todataGridView.Rows.Add();
                //this.磁盘todataGridView.Rows[addindex].Cells["toDiskId"].Value = disk_id;
                //this.磁盘todataGridView.Rows[addindex].Cells["toDiskName"].Value = disk_name;
                磁盘fromdataGridView.DataSource = null;
                VdiskTemplate fromvdisk = new VdiskTemplate();
                fromvdisk.DiskId   = disk_id;
                fromvdisk.DiskName = disk_name;
                fromvdisk.DiskPath = disk_path;
                vdiskTempletList.Add(fromvdisk);
                磁盘fromdataGridView.DataSource = vdiskTempletList;
            }
        }
Beispiel #6
0
        private void ClientAdd_Load(object sender, EventArgs e)
        {
            IniFile ini = new IniFile(Environment.CurrentDirectory + "\\setting.ini");

            iscsiURL = ini.ReadString("IscsiServer", "URL", "");
            username = ini.ReadString("IscsiServer", "USERNAME", "");
            password = ini.ReadString("IscsiServer", "PASSWORD", "");


            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from SYSTEM_SETTING;");



                    foreach (DataRow row in dt.Rows)
                    {
                        client_name_prefix = row["client_name_prefix"].ToString();
                        client_work_path   = row["client_disk_path"].ToString();
                    }


                    string sqlString = "select count(*) from CLIENT;";
                    int    count     = int.Parse(sh.ExecuteScalar(sqlString).ToString());
                    client_name   = client_name_prefix + "-" + ++count;
                    称textBox.Text = client_name;
                    conn.Close();
                }
            }

            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    DataTable dts = new DataTable();
                    dts.Columns.Add("Text", Type.GetType("System.String"));
                    dts.Columns.Add("Value", Type.GetType("System.String"));
                    dts.Rows.Add("未分组", "0");


                    分组comboBox.DataSource    = dts;
                    分组comboBox.DisplayMember = "Text";
                    分组comboBox.ValueMember   = "Value";

                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from CLIENT_GROUP;");


                    int count = 1;
                    foreach (DataRow row in dt.Rows)
                    {
                        dts.Rows.Add(row["client_group_name"], count++);
                    }



                    conn.Close();
                }
            }

            工作目录textBox.Text = client_work_path;


            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from VDISK_TEMPLET;");

                    VdiskTemplate vdiskTemp;

                    foreach (DataRow row in dt.Rows)
                    {
                        vdiskTemp          = new VdiskTemplate();
                        vdiskTemp.DiskId   = row["disk_id"].ToString();
                        vdiskTemp.DiskName = row["disk_name"].ToString();
                        vdiskTemp.DiskPath = row["disk_path"].ToString();
                        vdiskTempletList.Add(vdiskTemp);
                    }

                    this.磁盘fromdataGridView.DataSource = vdiskTempletList;

                    conn.Close();
                }
            }
        }
        private void VdiskRestorePointManageWindow_Load(object sender, EventArgs e)
        {
            IniFile ini = new IniFile(Environment.CurrentDirectory + "\\setting.ini");

            iscsiURL = ini.ReadString("IscsiServer", "URL", "");
            username = ini.ReadString("IscsiServer", "USERNAME", "");
            password = ini.ReadString("IscsiServer", "PASSWORD", "");

            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dt = sh.Select("select * from VDISK_TEMPLET;");

                    VdiskTemplate vdiskTemp;


                    DataTable dts = new DataTable();
                    dts.Columns.Add("Text", Type.GetType("System.String"));
                    dts.Columns.Add("Value", Type.GetType("System.String"));
                    dts.Rows.Add("请选择", "0");
                    int i = 0;
                    foreach (DataRow row in dt.Rows)
                    {
                        vdiskTemp          = new VdiskTemplate();
                        vdiskTemp.DiskId   = row["disk_id"].ToString();
                        vdiskTemp.DiskName = row["disk_name"].ToString();
                        vdiskTemp.DiskSize = (int)row["disk_size"];
                        vdiskTemp.DiskPath = row["disk_path"].ToString();
                        vdiskTemp.DiskType = (int)row["disk_type"];



                        dts.Rows.Add(vdiskTemp.DiskName, i++);



                        DataTable rs = sh.Select("select * from VDISK_RESTORE_POINT where disk_id = '" + vdiskTemp.DiskId + "';");
                        foreach (DataRow rows in rs.Rows)
                        {
                            VdiskRestorePoint point = new VdiskRestorePoint();
                            point.VdiskRestorePointId          = rows["vdisk_restore_point_id"].ToString();
                            point.VdiskRestorePointCreateTime  = rows["vdisk_restore_point_create_time"].ToString();
                            point.VdiskResotrePointName        = rows["vdisk_resotre_point_name"].ToString();
                            point.VdiskRestorePointDescription = rows["vdisk_restore_point_description"].ToString();
                            point.VdiskRestorePointPath        = rows["vdisk_restore_point_path"].ToString();
                            point.VdiskRestorePointSort        = float.Parse(rows["vdisk_restore_point_sort"].ToString());
                            point.VdiskTemplet = vdiskTemp;

                            vdiskTemp.AddVdiskRestorePoint(point);
                        }

                        vdiskTempletList.Add(vdiskTemp);
                    }

                    conn.Close();

                    磁盘comboBox.DataSource    = dts;
                    磁盘comboBox.DisplayMember = "Text";   // Text,即显式的文本
                    磁盘comboBox.ValueMember   = "Value";  // Value,即实际的值
                    磁盘comboBox.SelectedIndex = 0;
                }
            }
        }
Beispiel #8
0
        private void ClientEdit_Load(object sender, EventArgs e)
        {
            IniFile ini = new IniFile(Environment.CurrentDirectory + "\\setting.ini");

            iscsiURL = ini.ReadString("IscsiServer", "URL", "");
            username = ini.ReadString("IscsiServer", "USERNAME", "");
            password = ini.ReadString("IscsiServer", "PASSWORD", "");

            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    client_id = parentDataGridView.CurrentRow.Cells["IDColumn"].Value.ToString();

                    DataTable dt = sh.Select("select * from CLIENT where client_id = '" + client_id + "';");


                    foreach (DataRow row in dt.Rows)
                    {
                        client_group_id     = row["client_group_id"].ToString();
                        client_group_name   = row["client_group_id"].ToString();
                        client_work_path    = row["client_work_path"].ToString();
                        client_mac          = row["client_mac"].ToString();
                        client_description  = row["client_description"].ToString();
                        client_name         = row["client_name"].ToString();
                        client_disk_list_id = row["client_disk_list_id"].ToString();


                        if (row["client_enable"].ToString() == "1")
                        {
                            启用工作站checkBox.Checked = true;
                        }
                        else
                        {
                            启用工作站checkBox.Checked = false;
                        }

                        称textBox.Text    = client_name;
                        MACtextBox.Text  = client_mac;
                        工作目录textBox.Text = client_work_path;
                        备注textBox.Text   = client_description;
                    }

                    //设置combobox的值
                    DataTable dtCombobox = new DataTable();
                    dtCombobox.Columns.Add("Text", Type.GetType("System.String"));
                    dtCombobox.Columns.Add("Value", Type.GetType("System.String"));
                    dtCombobox.Rows.Add("未分组", "0");

                    分组comboBox.DataSource    = dtCombobox;
                    分组comboBox.DisplayMember = "Text";
                    分组comboBox.ValueMember   = "Value";

                    DataTable dtAvailableCombobox = sh.Select("select * from CLIENT_GROUP;");
                    int       count = 1;
                    foreach (DataRow row in dtAvailableCombobox.Rows)
                    {
                        dtCombobox.Rows.Add(row["client_group_name"].ToString(), count++);
                    }


                    if (client_group_name == "未分组")
                    {
                        分组comboBox.SelectedIndex = 0;
                    }
                    else
                    {
                        DataTable dtCurrentCombobox = sh.Select("select * from CLIENT_GROUP where client_group_id = '" + client_group_name + "';");
                        foreach (DataRow row in dtCurrentCombobox.Rows)
                        {
                            string temp = row["client_group_name"].ToString();


                            for (int i = 0; i < 分组comboBox.Items.Count; i++)
                            {
                                if (分组comboBox.GetItemText(分组comboBox.Items[i]) == temp)
                                {
                                    分组comboBox.SelectedIndex = i;
                                }
                            }
                        }
                    }



                    conn.Close();
                }
            }


            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    DataTable dtFrom = sh.Select("select * from VDISK_TEMPLET;");

                    VdiskTemplate vdiskTemp;

                    foreach (DataRow row in dtFrom.Rows)
                    {
                        vdiskTemp          = new VdiskTemplate();
                        vdiskTemp.DiskId   = row["disk_id"].ToString();
                        vdiskTemp.DiskName = row["disk_name"].ToString();
                        vdiskTemp.DiskPath = row["disk_path"].ToString();
                        vdiskTempletList.Add(vdiskTemp);
                    }

                    DataTable            dtTo = sh.Select("select * from CLIENT_DISK_LIST where client_disk_list_id='" + client_disk_list_id + "';");
                    List <VdiskTemplate> tempVdiskTempletList = new List <VdiskTemplate>();

                    if (dtTo.Rows.Count == 0)
                    {
                    }
                    else
                    {
                        foreach (DataRow row in dtTo.Rows)
                        {
                            foreach (VdiskTemplate v in vdiskTempletList)
                            {
                                string to_disk_id = row["disk_id"].ToString();
                                if (v.DiskId == to_disk_id)
                                {
                                    tovdiskTempletList.Add(v);
                                }

                                /**
                                 * else
                                 * {
                                 *
                                 * foreach (VdiskTemplate vv in tempVdiskTempletList)
                                 * {
                                 *  if (vv.DiskId == v.DiskId)
                                 *  {
                                 *      hasItem = true;
                                 *  }
                                 * }
                                 * if (!hasItem)
                                 * {
                                 *  tempVdiskTempletList.Add(v);
                                 *  hasItem = false;
                                 * }
                                 * }
                                 * */
                            }
                        }

                        foreach (VdiskTemplate vv in tovdiskTempletList)
                        {
                            foreach (VdiskTemplate v in vdiskTempletList)
                            {
                                if (vv.DiskId == v.DiskId)
                                {
                                    vdiskTempletList.Remove(v);
                                    break;
                                }
                            }
                        }

                        //vdiskTempletList = tempVdiskTempletList;
                    }

                    this.磁盘fromdataGridView.AutoGenerateColumns = false;
                    this.磁盘todataGridView.AutoGenerateColumns   = false;
                    this.磁盘fromdataGridView.DataSource          = null;
                    this.磁盘todataGridView.DataSource            = null;
                    if (vdiskTempletList.Count != 0)
                    {
                        this.磁盘fromdataGridView.DataSource = vdiskTempletList;
                    }

                    if (tovdiskTempletList.Count != 0)
                    {
                        this.磁盘todataGridView.DataSource = tovdiskTempletList;
                    }


                    conn.Close();
                }
            }
        }
        private void 确定button_Click(object sender, EventArgs e)
        {
            if (this.磁盘名称textBox.Text.Replace(" ", "") == "" || this.磁盘容量textBox.Text.Replace(" ", "") == "" || this.像文件textBox.Text.Replace(" ", "") == "")
            {
                MessageBox.Show("请填写完整的信息!");
                return;
            }

            if (!TextInputStringValidator.IsEnglishWithNum(this.磁盘名称textBox.Text.Replace(" ", "")))
            {
                MessageBox.Show("磁盘名需以英文字母、数字、_组成!");
                return;
            }

            if (!TextInputStringValidator.IsNumber(this.磁盘容量textBox.Text.Replace(" ", "")))
            {
                MessageBox.Show("磁盘大小只能为数字!");
                return;
            }


            string diskName = this.磁盘名称textBox.Text.Replace(" ", "");
            int    diskSize = int.Parse(this.磁盘容量textBox.Text.Replace(" ", ""));
            string diskPath = this.像文件textBox.Text.Replace(" ", "");
            int    diskType;

            if (this.稀疏文件checkBox.Checked)
            {
                diskType = 3;
            }
            else
            {
                diskType = 2;
            }

            if (diskSize < 1 || diskSize > 2048)
            {
                MessageBox.Show("磁盘大小应介于1-2048G之间!");
                return;
            }

            for (int i = 0; i < this.vdiskTempletList.Count; i++)
            {
                if (vdiskTempletList[i].DiskName == diskName)
                {
                    MessageBox.Show("磁盘名称已存在!");
                    return;
                }
            }

            var dic = new Dictionary <string, object>();

            dic["disk_name"] = diskName;
            dic["disk_size"] = diskSize;
            dic["disk_path"] = diskPath + "\\";
            dic["disk_type"] = diskType;
            dic["disk_id"]   = System.Guid.NewGuid().ToString("N");


            //插入磁盘数据到数据库
            using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection = conn;
                    conn.Open();

                    SQLiteHelper sh = new SQLiteHelper(cmd);

                    sh.Insert("VDISK_TEMPLET", dic);

                    VdiskTemplate vdiskTemplet = new VdiskTemplate();
                    vdiskTemplet.DiskId   = dic["disk_id"].ToString();
                    vdiskTemplet.DiskName = dic["disk_name"].ToString();
                    vdiskTemplet.DiskSize = int.Parse(dic["disk_size"].ToString());
                    vdiskTemplet.DiskPath = dic["disk_path"].ToString();
                    vdiskTemplet.DiskType = int.Parse(dic["disk_type"].ToString());

                    vdiskTempletList.Add(vdiskTemplet);
                    parentDataGridView.AutoGenerateColumns = false;
                    parentDataGridView.DataSource          = vdiskTempletList.ToArray();

                    //创建磁盘文件
                    DiskManagementData ParamObj = new DiskManagementData(); // TODO: 初始化为适当的值

                    if (this.稀疏文件checkBox.Checked)
                    {
                        ParamObj.VhdxType = 3; //动态盘
                    }
                    else
                    {
                        ParamObj.VhdxType = 2; //固定大小
                    }

                    ParamObj.DevicePath = dic["disk_path"].ToString() + dic["disk_name"].ToString() + ".vhdx";
                    ParamObj.TargetName = dic["disk_name"].ToString();
                    ParamObj.DiskSize   = ushort.Parse(dic["disk_size"].ToString());
                    ParamObj.TargetIQN  = "HstecsTemplet." + dic["disk_name"].ToString();
                    ParamObj.ParentPath = dic["disk_path"].ToString() + dic["disk_name"].ToString() + ".vhdx";
                    ParamObj.serverURL  = iscsiURL;
                    ParamObj.Username   = username;
                    ParamObj.Password   = password;



                    bool actual;
                    actual = DiskManager.CreateVhdxDisk(ParamObj);

                    if (actual == true)
                    {
                        MessageBox.Show("磁盘添加成功!");
                    }
                    else
                    {
                        MessageBox.Show("磁盘添加失败!");
                    }

                    conn.Close();

                    this.Close();
                }
            }
        }
        private void 导入button_Click(object sender, EventArgs e)
        {
            string devicePath        = "";
            string fileName          = "";
            string fileNameWithOutEx = "";
            string fileDirectoryName = "";

            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                fileName          = System.IO.Path.GetFileName(dialog.FileName);
                fileNameWithOutEx = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
                devicePath        = System.IO.Path.GetFullPath(dialog.FileName);
                fileDirectoryName = System.IO.Path.GetDirectoryName(dialog.FileName) + "\\";


                for (int i = 0; i < this.vdiskTempletList.Count; i++)
                {
                    if (vdiskTempletList[i].DiskName == fileNameWithOutEx)
                    {
                        MessageBox.Show("磁盘名称已存在!");
                        return;
                    }
                }

                DiskManagementData ParamObj = new DiskManagementData(); // TODO: 初始化为适当的值
                ParamObj.DevicePath = devicePath;
                ParamObj.TargetName = fileNameWithOutEx;
                ParamObj.TargetIQN  = "HstecsTemplet." + fileNameWithOutEx;
                ParamObj.serverURL  = iscsiURL;
                ParamObj.Username   = username;
                ParamObj.Password   = password;
                bool actual;
                actual = DiskManager.ImportVhdxDisk(ParamObj);

                if (actual == true)
                {
                    //获取虚拟磁盘的类型和大小
                    ManagementObject DiskObj = null;
                    if (!DiskManager.GetVirtualDisk(@devicePath, ref DiskObj, iscsiURL, username, password))
                    {
                        throw new Exception(Extension.GetEnumDescription(ReturnCode.RC_GetDisk));
                    }
                    else
                    {
                        var dic = new Dictionary <string, object>();
                        dic["disk_name"] = fileNameWithOutEx;
                        dic["disk_size"] = uint.Parse(DiskObj.GetPropertyValue("Size").ToString()) / 1024;
                        dic["disk_path"] = fileDirectoryName;
                        dic["disk_type"] = uint.Parse(DiskObj.GetPropertyValue("Type").ToString());
                        dic["disk_id"]   = System.Guid.NewGuid().ToString("N");


                        using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
                        {
                            using (SQLiteCommand cmd = new SQLiteCommand())
                            {
                                cmd.Connection = conn;
                                conn.Open();

                                SQLiteHelper sh = new SQLiteHelper(cmd);

                                sh.Insert("VDISK_TEMPLET", dic);

                                VdiskTemplate vdiskTemplet = new VdiskTemplate();
                                vdiskTemplet.DiskId   = dic["disk_id"].ToString();
                                vdiskTemplet.DiskName = dic["disk_name"].ToString();
                                vdiskTemplet.DiskSize = int.Parse(dic["disk_size"].ToString());
                                vdiskTemplet.DiskPath = dic["disk_path"].ToString();
                                vdiskTemplet.DiskType = int.Parse(dic["disk_type"].ToString());

                                vdiskTempletList.Add(vdiskTemplet);
                                this.磁盘管理dataGridView.AutoGenerateColumns = false;
                                this.磁盘管理dataGridView.DataSource          = vdiskTempletList.ToArray();


                                conn.Close();
                            }
                        }
                        MessageBox.Show("磁盘添加成功!");
                    }
                }
                else
                {
                    MessageBox.Show("磁盘添加失败!");
                }
            }
        }