-
Notifications
You must be signed in to change notification settings - Fork 14
/
ClientEdit.cs
768 lines (586 loc) · 31 KB
/
ClientEdit.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;
using Win2012WMIiSCSIVhdxManager;
namespace NoDiskSystem
{
public delegate void DelegateUpdateGrid(Client client);
public partial class ClientEdit : Form
{
public event DelegateUpdateGrid updateGrid;
private DataGridView parentDataGridView;
string client_id = "";
int client_enable = 1;
string client_name = "";
string client_mac = "";
string client_group_id = "";
string client_work_path = "";
string client_disk_list_id = "";
string client_name_prefix = "";
string client_group_name = "";
string client_description = "";
string iscsiURL;
string username;
string password;
List<VdiskTemplate> vdiskTempletList = new List<VdiskTemplate>();
List<VdiskTemplate> tovdiskTempletList = new List<VdiskTemplate>();
public ClientEdit(DataGridView parentDataGridView)
{
InitializeComponent();
this.parentDataGridView = parentDataGridView;
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
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 button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog path = new FolderBrowserDialog();
path.ShowDialog();
工作目录textBox.Text = path.SelectedPath;
}
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 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];
}
}
private void button删除_Click(object sender, EventArgs e)
{
string disk_id = "";
string disk_name = "";
string disk_path = "";
this.磁盘fromdataGridView.AutoGenerateColumns = false;
this.磁盘todataGridView.AutoGenerateColumns = false;
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;
if (tovdiskTempletList.Count != 0)
{
磁盘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);
if (vdiskTempletList.Count != 0)
{
磁盘fromdataGridView.DataSource = vdiskTempletList;
}
}
}
private void 排序向上button_Click(object sender, EventArgs e)
{
string disk_id = "";
string disk_name = "";
string disk_path = "";
this.磁盘fromdataGridView.AutoGenerateColumns = false;
this.磁盘todataGridView.AutoGenerateColumns = false;
if (磁盘todataGridView.Rows.Count != 0)
{
int rowIndex = 磁盘todataGridView.CurrentRow.Index;
disk_id = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskId"].Value.ToString();
disk_name = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskName"].Value.ToString();
disk_path = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskPath"].Value.ToString();
if (磁盘todataGridView.Rows.Count == 1)
{
return;
}
else {
if (rowIndex == 0)
{
return;
}
else {
for (int i = 0; i < tovdiskTempletList.Count; i++)
{
if (((VdiskTemplate)tovdiskTempletList[i]).DiskId == disk_id)
{
((VdiskTemplate)tovdiskTempletList[i]).DiskId = ((VdiskTemplate)tovdiskTempletList[i - 1]).DiskId;
((VdiskTemplate)tovdiskTempletList[i]).DiskName = ((VdiskTemplate)tovdiskTempletList[i - 1]).DiskName;
((VdiskTemplate)tovdiskTempletList[i - 1]).DiskId = disk_id;
((VdiskTemplate)tovdiskTempletList[i - 1]).DiskName = disk_name;
((VdiskTemplate)tovdiskTempletList[i - 1]).DiskPath = disk_path;
磁盘todataGridView.DataSource = null;
if (tovdiskTempletList.Count != 0)
{
磁盘todataGridView.DataSource = tovdiskTempletList;
}
磁盘todataGridView.Rows[rowIndex - 1].Selected = true;
磁盘todataGridView.Rows[rowIndex].Selected = false;
磁盘todataGridView.CurrentCell = 磁盘todataGridView.Rows[rowIndex - 1].Cells[0];
break;
}
}
}
}
}
}
private void 排序向下button_Click(object sender, EventArgs e)
{
string disk_id = "";
string disk_name = "";
string disk_path = "";
this.磁盘fromdataGridView.AutoGenerateColumns = false;
this.磁盘todataGridView.AutoGenerateColumns = false;
if (磁盘todataGridView.Rows.Count != 0)
{
int rowIndex = 磁盘todataGridView.CurrentRow.Index;
disk_id = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskId"].Value.ToString();
disk_name = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskName"].Value.ToString();
disk_path = 磁盘todataGridView.Rows[rowIndex].Cells["toDiskPath"].Value.ToString();
if (磁盘todataGridView.Rows.Count == 1)
{
return;
}
else
{
if (rowIndex == (磁盘todataGridView.Rows.Count - 1))
{
return;
}
else
{
for (int i = 0; i < tovdiskTempletList.Count; i++)
{
if (((VdiskTemplate)tovdiskTempletList[i]).DiskId == disk_id)
{
((VdiskTemplate)tovdiskTempletList[i]).DiskId = ((VdiskTemplate)tovdiskTempletList[i + 1]).DiskId;
((VdiskTemplate)tovdiskTempletList[i]).DiskName = ((VdiskTemplate)tovdiskTempletList[i + 1]).DiskName;
((VdiskTemplate)tovdiskTempletList[i + 1]).DiskId = disk_id;
((VdiskTemplate)tovdiskTempletList[i + 1]).DiskName = disk_name;
((VdiskTemplate)tovdiskTempletList[i + 1]).DiskPath = disk_path;
磁盘todataGridView.DataSource = null;
if (tovdiskTempletList.Count != 0)
{
磁盘todataGridView.DataSource = tovdiskTempletList;
}
磁盘todataGridView.Rows[rowIndex + 1].Selected = true;
磁盘todataGridView.Rows[rowIndex].Selected = false;
磁盘todataGridView.CurrentCell = 磁盘todataGridView.Rows[rowIndex + 1].Cells[0];
break;
}
}
}
}
}
}
private void 应用button_Click(object sender, EventArgs e)
{
if((名称textBox.Text.Trim() == "") || (MACtextBox.Text.Trim() == "") || (工作目录textBox.Text.Trim() == ""))
{
MessageBox.Show("请填写完整的信息!");
return;
}
string client_name = 名称textBox.Text.Trim();
string client_mac = MACtextBox.Text.Trim();
string client_work_path = 工作目录textBox.Text.Trim();
string client_description = 备注textBox.Text.Trim();
string client_group_id = "";
string client_group_tag = "";
if (client_disk_list_id == "")
{
client_disk_list_id = System.Guid.NewGuid().ToString("N");
}
if (启用工作站checkBox.Checked == true)
{
client_enable = 1;
}
else {
client_enable = 0;
}
using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
string tempSelectedText = 分组comboBox.Text;
DataTable dt = sh.Select("select * from CLIENT_GROUP where client_group_name = '" + tempSelectedText + "';");
if (dt.Rows.Count == 0)
{
client_group_id = "未分组";
client_group_tag = "未分组";
}else{
foreach (DataRow row in dt.Rows)
{
client_group_id = row["client_group_id"].ToString();
client_group_tag = row["client_group_name"].ToString();
}
}
conn.Close();
}
}
//判断是否有重复的MAC地址,如果有则不允许添加
bool tempMacOnly = false;
using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
string tempMacString = "select count(*) from CLIENT where client_mac = '" + client_mac + "' and client_id != '" + client_id + "';";
int count = int.Parse(sh.ExecuteScalar(tempMacString).ToString());
if (count == 0)
{
tempMacOnly = true;
}
else
{
tempMacOnly = false;
}
conn.Close();
}
}
if (tempMacOnly == true)
{
using (SQLiteConnection conn = new SQLiteConnection("data source=nodisk.db"))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
//更新主页datagrid的source
Client client = new Client();
client.ClientId = client_id;
client.ClientName = client_name;
client.ClientMac = client_mac;
client.clientWorkPath = client_work_path;
client.clientDescription = client_description;
//string addClientSql = "udpate CLIENT (client_id,client_name,client_mac,client_work_path,client_description,client_group_id,client_disk_list_id,client_enable) values ('" + client_id + "','" + client_name + "','" + client_mac + "','" + client_work_path + "','" + client_description + "','" + client_group_id + "','" + client_disk_list_id + "','" + client_enable + "');";
string updateClientSql = "update CLIENT set client_name='" + client_name + "',client_mac='" + client_mac + "',client_work_path='" + client_work_path + "',client_description='" + client_description + "',client_group_id='" + client_group_id + "',client_disk_list_id='" + client_disk_list_id + "',client_enable='" + client_enable + "' where client_id='" + client_id + "';";
sh.ExecuteScalar(updateClientSql);
//删除原先已经创建的磁盘以及数据库中的内容
string deleteClientDiskList = "delete from CLIENT_DISK_LIST where client_disk_list_id='" + client_disk_list_id + "';";
DataTable dtClintDiskList = sh.Select("select * from CLIENT_DISK_LIST where client_disk_list_id = '" + client_disk_list_id + "';");
foreach (DataRow row in dtClintDiskList.Rows)
{
string sqlClientDiskName = "select * from VDISK_TEMPLET where disk_id='" + row["disk_id"] + "';";
DataTable dtClientDisk = sh.Select(sqlClientDiskName);
foreach (DataRow rows in dtClientDisk.Rows)
{
DiskManagementData ParamObj = new DiskManagementData(); // TODO: 初始化为适当的值
ParamObj.DevicePath = client_work_path + "\\" + rows["disk_name"].ToString() + "-" + client_mac + ".vhdx"; ;
ParamObj.TargetName = rows["disk_name"].ToString() + "-" + client_mac;
ParamObj.serverURL = iscsiURL;
ParamObj.Username = username;
ParamObj.Password = password;
bool actual;
actual = DiskManager.RemoveDisk(ParamObj);
if (actual == true)
{
//MessageBox.Show("磁盘删除成功!");
}
}
}
sh.ExecuteScalar(deleteClientDiskList);
int diskSort = 0;
string addClientDiskList = "";
foreach (VdiskTemplate v in tovdiskTempletList)
{
addClientDiskList = "insert into CLIENT_DISK_LIST (client_disk_list_id,disk_id,disk_sort) values ('" + client_disk_list_id + "','" + v.DiskId + "','" + diskSort++ + "');";
sh.ExecuteScalar(addClientDiskList);
}
conn.Close();
this.Close();
//创建客户端启动脚本
//创建客户端启动盘
foreach (VdiskTemplate v in tovdiskTempletList)
{
//获取最新的还原点的磁盘路径
string parentPointPath = "";
string sort = "0";
DataTable rs = sh.Select("select * from VDISK_RESTORE_POINT where disk_id = '" + v.DiskId + "';");
int count = rs.Rows.Count;
if (count != 0)
{
foreach (DataRow rows in rs.Rows)
{
if (float.Parse(sort) < float.Parse(rows["vdisk_restore_point_sort"].ToString()))
{
sort = rows["vdisk_restore_point_sort"].ToString();
parentPointPath = rows["vdisk_restore_point_path"].ToString();
}
}
}
else
{
parentPointPath = v.DiskPath + v.DiskName + ".vhdx";
}
//创建磁盘文件
DiskManagementData ParamObj = new DiskManagementData(); // TODO: 初始化为适当的值
ParamObj.VhdxType = 4; //动态盘
ParamObj.DevicePath = client_work_path + "\\" + v.DiskName + "-" + client_mac + ".vhdx";
ParamObj.TargetName = v.DiskName + "-" + client_mac;
ParamObj.DiskSize = ushort.Parse("10");
ParamObj.TargetIQN = "HstecsClient." + v.DiskName + "-" + client_mac;
ParamObj.ParentPath = parentPointPath;
ParamObj.serverURL = iscsiURL;
ParamObj.Username = username;
ParamObj.Password = password;
DiskManager.CreateVhdxDisk(ParamObj);
}
//更新tree及主页datagrid
TreeNode node = new TreeNode(client_name, IconIndexes.computer, IconIndexes.computer);
node.Tag = client_name;
node.Text = client_name;
UpdateGrid(client);
MessageBox.Show("工作站编辑成功!");
}
}
}
else {
MessageBox.Show("已存在指定MAC地址的客户端!");
}
}
private void UpdateGrid(Client client)
{
updateGrid(client);
}
}
}