FrmLiveUpdate.cs
48.6 KB
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.IO;
using System.Diagnostics;
using LiveUpdate.UpdateSvc;
using System.Collections.Generic;
namespace LiveUpdate
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class FrmLiveUpdate : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ListView LvProc;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Label LabHead;
private System.Windows.Forms.ProgressBar ProBar;
private System.Windows.Forms.Label LabProc;
private System.Windows.Forms.Button BtnOK;
private System.Windows.Forms.Button BtnCancel;
private DataSet UpdateFileList;
private DataSet LocalFileList;
private System.Windows.Forms.PictureBox pictureBox1;
private Thread ThreadProcedure;
private bool _Updating = false;
private bool _UpdateResult;
private bool IsAutoUpdate = false;
/// <summary>
/// 定义委托
/// </summary>
private delegate void ModifyFormStaticDelegate(int LvStep, string LvStatic, string LabCurrentText, int ProCurrentNum);
private delegate void ModifyFormStaticWarnDelegate(int LvStep, string LvStatic, string LabCurrentText, int ProCurrentNum);
private delegate void AddProgressDelegate(int AddNum);
private delegate void DecProgressDelegate(int DecNum);
private delegate void FinishUpdateDelegate();
private delegate void UpdateErrorDelegate(int LvStep);
private delegate void FileOpenErrorDelegate(int LvStep, string FileName);
/// <summary>
/// 声明委托
/// </summary>
private ModifyFormStaticDelegate modifyformstaticdelegate;
private ModifyFormStaticWarnDelegate modifyformstaticwarndelegate;
private AddProgressDelegate addprogressdelegate;
private DecProgressDelegate decprogressdelegate;
private FinishUpdateDelegate finishupdatedelegate;
private UpdateErrorDelegate updateerrordelegate;
private FileOpenErrorDelegate fileopenerrordelegate;
/// <summary>
/// 声明事件
/// </summary>
private System.EventHandler BtnOkClick;
/// <summary>
/// 升级步骤固定为六步
/// </summary>
private const string STEP_1 = "收集本地文件信息";
private const string STEP_2 = "连接到升级服务器";
private const string STEP_3 = "获取升级文件列表";
private const string STEP_4 = "处理升级文件列表";
private const string STEP_5 = "下载升级文件";
private const string STEP_6 = "升级本地文件";
/// <summary>
/// 升级时状态
/// </summary>
private const string STATIC_EXECUTE = "正在执行";
private const string STATIC_FAILED = "失败";
private const string STATIC_SUCCESSFUL = "已完成";
private const string STATIC_ABORT = "已取消";
/// <summary>
/// 常用静态字符
/// </summary>
private const string DOING = "正在";
private const string DOT = @"...";
private const string CONNECTIONED = "已连接到";
private const string NEWHEAD = "New_";
private const string OLDHEAD = "Old_";
private const string CONFIGFILE = @"App.exe.config";
private const string UPDATEASMX = @"UpdateSvc.asmx";
private string _UpdateServiceUrl = "";
private string[] FixFileList = new string[1];
private System.Windows.Forms.ImageList ImgList;
private System.ComponentModel.IContainer components;
public FrmLiveUpdate()
{
InitializeComponent();
Initialize();
}
/// <summary>
/// 重载初始化类,传入启动参数
/// </summary>
/// <param name="args"></param>
public FrmLiveUpdate(string args)
{
InitializeComponent();
Initialize();
// 启动参数为"-S" 自动启动LiveUpdate升级过程
if (args == "-S")
{
IsAutoUpdate = true;
AutoStartUpdate();
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose(bool disposing)
{
if (this._Updating)
{
return;
}
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLiveUpdate));
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.ProBar = new System.Windows.Forms.ProgressBar();
this.BtnCancel = new System.Windows.Forms.Button();
this.BtnOK = new System.Windows.Forms.Button();
this.LabProc = new System.Windows.Forms.Label();
this.LvProc = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.LabHead = new System.Windows.Forms.Label();
this.ImgList = new System.Windows.Forms.ImageList(this.components);
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Controls.Add(this.ProBar);
this.panel1.Controls.Add(this.BtnCancel);
this.panel1.Controls.Add(this.BtnOK);
this.panel1.Controls.Add(this.LabProc);
this.panel1.Controls.Add(this.LvProc);
this.panel1.Controls.Add(this.LabHead);
this.panel1.Location = new System.Drawing.Point(0, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(480, 272);
this.panel1.TabIndex = 0;
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 20);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(120, 104);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// ProBar
//
this.ProBar.Location = new System.Drawing.Point(136, 161);
this.ProBar.Name = "ProBar";
this.ProBar.Size = new System.Drawing.Size(336, 8);
this.ProBar.TabIndex = 5;
//
// BtnCancel
//
this.BtnCancel.Location = new System.Drawing.Point(392, 232);
this.BtnCancel.Name = "BtnCancel";
this.BtnCancel.Size = new System.Drawing.Size(75, 23);
this.BtnCancel.TabIndex = 4;
this.BtnCancel.Text = "取消(&C)";
this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// BtnOK
//
this.BtnOK.Location = new System.Drawing.Point(296, 232);
this.BtnOK.Name = "BtnOK";
this.BtnOK.Size = new System.Drawing.Size(75, 23);
this.BtnOK.TabIndex = 3;
this.BtnOK.Text = "开始(&S)";
this.BtnOK.Click += new System.EventHandler(this.button1_Click_1);
//
// LabProc
//
this.LabProc.Location = new System.Drawing.Point(144, 184);
this.LabProc.Name = "LabProc";
this.LabProc.Size = new System.Drawing.Size(328, 32);
this.LabProc.TabIndex = 2;
//
// LvProc
//
this.LvProc.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.LvProc.Location = new System.Drawing.Point(136, 19);
this.LvProc.Name = "LvProc";
this.LvProc.Size = new System.Drawing.Size(336, 128);
this.LvProc.TabIndex = 1;
this.LvProc.UseCompatibleStateImageBehavior = false;
this.LvProc.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "步骤";
this.columnHeader1.Width = 230;
//
// columnHeader2
//
this.columnHeader2.Text = "状态";
this.columnHeader2.Width = 98;
//
// LabHead
//
this.LabHead.Location = new System.Drawing.Point(144, 8);
this.LabHead.Name = "LabHead";
this.LabHead.Size = new System.Drawing.Size(328, 40);
this.LabHead.TabIndex = 0;
//
// ImgList
//
this.ImgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.ImgList.ImageSize = new System.Drawing.Size(16, 16);
this.ImgList.TransparentColor = System.Drawing.Color.Transparent;
//
// FrmLiveUpdate
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(484, 284);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "FrmLiveUpdate";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MyCMMI LiveUpdate";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args) ///可接受参数
{
if (args.Length == 0)
{
Application.Run(new FrmLiveUpdate());
}
else
{
Application.Run(new FrmLiveUpdate(args[0].ToString()));
}
}
/// <summary>
/// 初始化LiveUpdate
/// </summary>
private void Initialize()
{
///初试化ListView
LvProc.Items.Add(STEP_1);
LvProc.Items.Add(STEP_2);
LvProc.Items.Add(STEP_3);
LvProc.Items.Add(STEP_4);
LvProc.Items.Add(STEP_5);
LvProc.Items.Add(STEP_6);
// 初试化显示
LabHead.Text = ("欢迎使用MyCMMI Client LiveUpdate \n现将在您的计算机上执行以下更新步骤");
// 初试化进度条
ProBar.Minimum = 0;
ProBar.Maximum = 100;
ProBar.Step = 1;
// 初试化全局委托
modifyformstaticdelegate = new ModifyFormStaticDelegate(ModifyFormStatic);
modifyformstaticwarndelegate = new ModifyFormStaticWarnDelegate(ModifyFormStaticWarn);
addprogressdelegate = new AddProgressDelegate(AddProgress);
decprogressdelegate = new DecProgressDelegate(DecProgress);
finishupdatedelegate = new FinishUpdateDelegate(FinishUpdate);
updateerrordelegate = new UpdateErrorDelegate(UpdateError);
fileopenerrordelegate = new FileOpenErrorDelegate(FileOpenError);
// 初始化自定义事件
BtnOkClick = new EventHandler(button1_Click_1);
// 初试化固定文件数组
AddFixFileList();
}
/// <summary>
/// 查找客户端当前安装程序目录
/// </summary>
private string GetCurrentDir()
{
string strTemp = Application.ExecutablePath;
if (strTemp.LastIndexOf(@"\") + 1 <= strTemp.Length)
{
strTemp = strTemp.Substring(0, strTemp.LastIndexOf(@"\") + 1);
}
return strTemp;
}
/// <summary>
/// 将需要下载列表中固定移出的文件加载到FixFileList数组中
/// </summary>
private void AddFixFileList()
{
FixFileList[0] = @"App.exe.config";
}
/// <summary>
/// LiveUpdate后台线程升级程序入口
/// </summary>
private void UpdateEscaladeClient()
{
ThreadStart m_GetUFLThreadStart = new ThreadStart(CollectionLocalFileInfo);
ThreadProcedure = new Thread(m_GetUFLThreadStart);
ThreadProcedure.Start();
}
/// <summary>
/// 改变窗体显示状态
/// </summary>
/// <param name="LvStep">步骤</param>
/// <param name="LvStatic">状态</param>
/// <param name="LabCurrentText">提示</param>
/// <param name="ProCurrentNum">进度条数量</param>
private void ModifyFormStatic(int LvStep, string LvStatic, string LabCurrentText, int ProCurrentNum)
{
string LvProcName;
LvProcName = LvProc.Items[LvStep - 1].Text;
LvProc.Items[LvStep - 1].SubItems.Clear();
LvProc.Items[LvStep - 1].Text = LvProcName;
LvProc.Items[LvStep - 1].SubItems.Add(LvStatic);
LabProc.Text = LabCurrentText;
if (ProCurrentNum > 100)
{
ProCurrentNum = 100;
}
ProBar.Value = ProCurrentNum;
}
private void ModifyFormStaticWarn(int LvStep, string LvStatic, string LabCurrentText, int ProCurrentNum)
{
string LvProcName;
LvProcName = LvProc.Items[LvStep - 1].Text;
LvProc.SmallImageList = ImgList;
LvProc.Items[LvStep - 1].SubItems.Clear();
LvProc.Items[LvStep - 1].Text = LvProcName;
LvProc.Items[LvStep - 1].ImageIndex = 0;
LvProc.Items[LvStep - 1].SubItems.Add(LvStatic);
LabProc.Text = LabCurrentText;
if (ProCurrentNum > 100)
{
ProCurrentNum = 100;
}
ProBar.Value = ProCurrentNum;
}
/// <summary>
/// 设置窗体进度条数值加法
/// </summary>
/// <param name="AddNum">进度条数值</param>
private void AddProgress(int AddNum)
{
int f_TotalNum = ProBar.Value + AddNum;
if (f_TotalNum > 100)
{
ProBar.Value = 100;
}
else
{
ProBar.Value = f_TotalNum;
}
}
/// <summary>
/// 设置窗体进度条数值减法
/// </summary>
/// <param name="DecNum"></param>
private void DecProgress(int DecNum)
{
int f_TotalNum = ProBar.Value - DecNum;
if (f_TotalNum < 0)
{
ProBar.Value = 0;
}
else
{
ProBar.Value = f_TotalNum;
}
}
/// <summary>
/// 设置窗体显示为严重失败提示
/// </summary>
private void UpdateError(int LvStep)
{
LabHead.Text = "MyCMMI Client LiveUpdate 遇到了无法处理的错误 \n无法继续更新您的MyCMMI Client 程序, 请联系系统管理员!";
string LvProcName;
LvProcName = LvProc.Items[LvStep - 1].Text;
LvProc.Items[LvStep - 1].SubItems.Clear();
LvProc.Items[LvStep - 1].Text = LvProcName;
LvProc.Items[LvStep - 1].SubItems.Add(STATIC_FAILED);
ProBar.Value = 0;
BtnOK.Text = "完成(&F)";
BtnOK.Enabled = false;
BtnCancel.Text = "退出(&Q)";
BtnCancel.Enabled = true;
}
/// <summary>
/// 设置窗体显示为存在不可同时运行的程序已在运行中,停止升级流程
/// </summary>
/// <param name="LvStep">当前步骤</param>
/// <param name="FileName">程序名称</param>
private void FileOpenError(int LvStep, string FileName)
{
LabHead.Text = "检测到当前的" + FileName + "正在运行中! \n请关闭后再运行MyCMMI Client LiveUpdate!";
string LvProcName;
LvProcName = LvProc.Items[LvStep - 1].Text;
LvProc.Items[LvStep - 1].SubItems.Clear();
LvProc.Items[LvStep - 1].Text = LvProcName;
LvProc.Items[LvStep - 1].SubItems.Add(STATIC_ABORT);
ProBar.Value = 0;
LabProc.Text = "";
BtnOK.Text = "开始(&S)";
BtnOK.Enabled = true;
BtnCancel.Text = "退出(&Q)";
BtnCancel.Enabled = true;
}
/// <summary>
/// 设置窗体显示为存在程序被重复运行中,停止升级流程
/// </summary>
/// <param name="LvStep">当前步骤</param>
/// <param name="FileName">程序名称</param>
private void FileOpenMoreError(int LvStep, string FileName)
{
LabHead.Text = "检测到当前有多个" + FileName + "正在运行中! \n请关闭后再运行MyCMMI Client LiveUpdate!";
string LvProcName;
LvProcName = LvProc.Items[LvStep - 1].Text;
LvProc.Items[LvStep - 1].SubItems.Clear();
LvProc.Items[LvStep - 1].Text = LvProcName;
LvProc.Items[LvStep - 1].SubItems.Add(STATIC_ABORT);
ProBar.Value = 0;
LabProc.Text = "";
BtnOK.Text = "开始(&S)";
BtnOK.Enabled = true;
BtnCancel.Text = "退出(&Q)";
BtnCancel.Enabled = true;
}
/// <summary>
/// 设置窗体显示为成功完成状态
/// </summary>
private void FinishUpdate()
{
BtnOK.Text = "完成(&F)";
if (IsAutoUpdate)
{
BeginInvoke(BtnOkClick, new object[] { this, EventArgs.Empty });//自动完成
}
ProBar.Value = 100;
LabProc.Text = "已完成";
LabHead.Text = "感谢使用MyCMMI Client LiveUpdate \n您已成功完成所有更新步骤";
BtnOK.Text = "完成(&F)";
BtnOK.Enabled = true;
BtnCancel.Enabled = false;
}
/// <summary>
/// 停止升级过程
/// </summary>
/// <param name="m_LvStep"></param>
private void StopUpdate(int m_LvStep)
{
string LvStatic = STATIC_FAILED;
string LabCurrentText = "";
int ProCurrentNum = 0;
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ProCurrentNum });
BtnOK.Text = "开始(&S)";
BtnCancel.Enabled = true;
_Updating = false;
}
/// <summary>
/// 设置窗体显示为成功完成当前任务状态
/// </summary>
/// <param name="m_LvStep">步骤</param>
private void FinishCurrentTask(int m_LvStep)
{
string LvStatic = STATIC_SUCCESSFUL;
string LabCurrentText = "";
int ProCurrentNum = 0;
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ProCurrentNum });
}
/// <summary>
/// 设置窗体显示为完成任务状态,但在升级步骤可能存在需要警告的因素
/// </summary>
/// <param name="m_LvStep">步骤</param>
/// <param name="m_Warning">是否要显示警告标识</param>
private void FinishCurrentTask(int m_LvStep, bool m_Warning)
{
string LvStatic = STATIC_SUCCESSFUL;
string LabCurrentText = "";
int ProCurrentNum = 0;
BeginInvoke(modifyformstaticwarndelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ProCurrentNum });
}
/// <summary>
/// 设置窗体显示为开始当前任务状态
/// </summary>
/// <param name="m_LvStep">步骤</param>
/// <param name="m_LabCurrentText">提示</param>
private void StartCurrentTask(int m_LvStep, string m_LabCurrentText)
{
string LvStatic = STATIC_EXECUTE;
string LabCurrentText = DOING + m_LabCurrentText + DOT;
int ProCurrentNum = 1;
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ++ProCurrentNum });
}
/// <summary>
/// 设置窗体显示为开始当前任务状态
/// </summary>
/// <param name="m_LvStep">步骤</param>
/// <param name="m_LabCurrentText">提示</param>
/// <param name="Url">当前使用升级服务器的URL</param>
private void StartCurrentTask(int m_LvStep, string m_LabCurrentText, string Url)
{
string LvStatic = STATIC_EXECUTE;
string LabCurrentText = "正在从" + Url + "上" + m_LabCurrentText + DOT;
int ProCurrentNum = 1;
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ++ProCurrentNum });
}
/// <summary>
/// 设置窗体显示为开始下载文件状态
/// </summary>
/// <param name="m_LvStep">步骤</param>
/// <param name="FileName">文件名</param>
/// <param name="CurrentFileNum">当前下载文件的编号</param>
/// <param name="TotalFileNum">总需下载文件数</param>
private void StartDownLoadCurrentTask(int m_LvStep, string FileName, int CurrentFileNum, int TotalFileNum)
{
string LvStatic = STATIC_EXECUTE;
int ProCurrentNum = this.ProBar.Value;
string LabCurrentText = "正在从" + this._UpdateServiceUrl + "上下载更新文件" + FileName + "(第" + ++CurrentFileNum + "个文件,共" + TotalFileNum + "个文件)";
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ++ProCurrentNum });
}
/// <summary>
/// 设置窗体显示为取消升级状态
/// </summary>
/// <param name="m_LvStep">步骤</param>
private void AbortUpdateTask(int m_LvStep)
{
string LvStatic = STATIC_ABORT;
string LabCurrentText = "";
int ProCurrentNum = 0;
BeginInvoke(modifyformstaticdelegate, new object[] { m_LvStep, LvStatic, LabCurrentText, ProCurrentNum });
}
/// <summary>
/// 完成升级任务退出当前应用程序,重启MyCMMI Client
/// </summary>
private void EndLiveUpdate()
{
if (IsAutoUpdate || MessageBox.Show("您是否要现在启动MyCMMI Client?", "MyCMMI LiveUpate", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"App.exe";
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.Start();
}
StopUpdateThread();
this.Close();
}
/// <summary>
/// 升级文件时错误,失败处理
/// </summary>
private void UpdateFailed(int LvStep)
{
BeginInvoke(updateerrordelegate, new object[] { LvStep });
StopUpdateThread();
}
/// <summary>
/// 下载文件失败处理
/// </summary>
/// <param name="f_LvStep">步骤</param>
private void DownLoadFailed(int f_LvStep)
{
string f_CurrentPath = GetCurrentDir();
// 获取当前文件列表
string[] f_FilePaths = Directory.GetFiles(f_CurrentPath);
string f_filename;
int i;
int f_DecNum = 5;
for (i = 0; i < f_FilePaths.Length; i++)
{
BeginInvoke(decprogressdelegate, new object[] { f_DecNum });
f_filename = f_FilePaths[i];
if (f_filename.IndexOf(@"\") + 1 > f_filename.Length - 1)
{
continue;
}
f_filename = f_filename.Substring(f_filename.IndexOf(@"\") + 1);
if (f_filename.Length >=4 &&
(f_filename.Substring(0, 4) == NEWHEAD || f_filename.Substring(0, 4) == OLDHEAD))
{
BeginInvoke(decprogressdelegate, new object[] { f_DecNum });
File.Delete(f_FilePaths[i]);
}
}
StopUpdate(f_LvStep);
}
/// <summary>
/// 自动启动升级任务
/// </summary>
private void AutoStartUpdate()
{
// 通过触发开始按钮的Click事件启动升级任务
this.button1_Click_1(this, System.EventArgs.Empty);
}
private string[] GetFiles(string path)
{
string[] f_FilePaths = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
List<string> tempt = new List<string>();
for (int i = 0; i < f_FilePaths.Length; i++)
{
//将本地文件的信息读入到DataSet中
bool isUpdate = true;
FileInfo fileinfo = new FileInfo(f_FilePaths[i]);
string directoryName = fileinfo.DirectoryName;
string[] temp = directoryName.Split('\\');
for (int k = 0; k < temp.Length; k++)
{
if (temp[k] == "Adjust" || temp[k] == "Parameter" ||
temp[k] == "Product" || temp[k] == "TestData")
{
isUpdate = false;
break;
}
}
if (isUpdate)
{
tempt.Add(f_FilePaths[i]);
}
}
string[] return_FilePaths = new string[tempt.Count];
for (int i = 0; i < tempt.Count ; i++)
{
return_FilePaths[i] = tempt[i];
}
//return_FilePaths.
return return_FilePaths;
}
/// <summary>
/// 升级步骤之一:收集本地文件信息
/// </summary>
private void CollectionLocalFileInfo()
{
int f_LvStep = 1;
StartCurrentTask(f_LvStep, STEP_1);
int f_AddNum = 5;
int OpenNum = 0;
string f_strClientPath;
bool f_IsWarn = false;
f_strClientPath = GetCurrentDir();
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
// 检测是否已存在MyCMMI.app.exe 或是 LiveUpdate.exe 在运行中
try
{
Process[] myProcesses = Process.GetProcessesByName("Contamination Explorer");
foreach (Process myProcess in myProcesses)
{
if (myProcess.MainModule.FileName == f_strClientPath + @"App.exe")
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
FileOpenError(f_LvStep, "App.exe");
return;
}
}
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
myProcesses = Process.GetProcessesByName("LiveUpdate");
foreach (Process myProcess in myProcesses)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
if (myProcess.MainModule.FileName == f_strClientPath + @"LiveUpdate.exe")
{
OpenNum++;
}
}
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
if (OpenNum > 1)
{
FileOpenMoreError(f_LvStep, "LiveUpdate.exe");
return;
}
}
catch
{
f_IsWarn = true;
}
DataSet f_LocalFileInfo = new DataSet("LocalFileInfo");
//获取当前文件夹内所有文件信息
DataTable f_LocalFileTab = f_LocalFileInfo.Tables.Add("LocalFileTab");
f_LocalFileTab.Columns.Add("FileName", typeof(string));
f_LocalFileTab.Columns.Add("FileLength", typeof(string));
f_LocalFileTab.Columns.Add("FileDateTime", typeof(string));
//string[] f_FilePaths = Directory.GetFiles(f_strClientPath);
//todo modify by colbert liveupdate multiple Directories Files
string[] f_FilePaths = GetFiles(f_strClientPath);
//以异步方式更新界面进度条
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_AddNum = 3;
for (int i = 0; i < f_FilePaths.Length; i++)
{
if (f_FilePaths[i]=="")
{
continue;
}
//以异步方式更新界面进度条
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
//将本地文件的信息读入到DataSet中
DataRow f_LocalFileRow = f_LocalFileTab.NewRow();
FileInfo f_fileinfo = new FileInfo(f_FilePaths[i]);
f_LocalFileRow["FileName"] = f_fileinfo.FullName.Replace(f_strClientPath, "");
f_LocalFileRow["FileLength"] = f_fileinfo.Length.ToString();
f_LocalFileRow["FileDateTime"] = f_fileinfo.LastWriteTime.ToString();
f_LocalFileTab.Rows.Add(f_LocalFileRow);
//确保文件可写
//FileAttributes m_fa = File.GetAttributes(f_strClientPath + f_fileinfo.Name.ToString());
//todo modify by colbert liveupdate multiple Directories Files
FileAttributes m_fa = File.GetAttributes(f_fileinfo.FullName);
if ((m_fa & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) //若为只读
File.SetAttributes(f_fileinfo.FullName, m_fa ^ FileAttributes.ReadOnly);//则设为非只读
}
//将DataSet存入全局DataSet变量中
LocalFileList = f_LocalFileInfo;
//如果取不到文件则认为出错
if (LocalFileList == null || LocalFileList.Tables[0].Rows.Count < 1)
{
StopUpdate(f_LvStep);
LocalFileList = null;
}
else
{
if (f_IsWarn)
{
FinishCurrentTask(f_LvStep, f_IsWarn);
}
else
{
FinishCurrentTask(f_LvStep);
}
ConnectionUpdateWebService();
}
}
/// <summary>
/// 升级步骤之二:连接远端升级服务器
/// </summary>
private void ConnectionUpdateWebService()
{
int f_LvStep = 2;
StartCurrentTask(f_LvStep, STEP_2);
string f_UpdateServiceUrl = "";
int f_AddNum = 10;
UpdateSystem f_upws;
try
{
//改变界面进度条显示
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
//获取升级服务器地址
GlobalConfig m_gc = new GlobalConfig();
if (m_gc.WebServiceUrl != "")
{
//连到升级服务器并实列化
f_upws = new UpdateSystem(m_gc.WebServiceUrl);
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_UpdateServiceUrl = m_gc.WebServiceUrl;
}
else
{
f_upws = new UpdateSystem();
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_UpdateServiceUrl = f_upws.GetUpdateUrl();
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
}
if (f_UpdateServiceUrl.LastIndexOf(@"/") + 1 <= f_UpdateServiceUrl.Length)
{
f_UpdateServiceUrl = f_UpdateServiceUrl.Substring(0, f_UpdateServiceUrl.LastIndexOf(@"/") + 1);
}
}
catch
{
StopUpdate(f_LvStep);
}
if (!this._UpdateServiceUrl.EndsWith(@"/")) //若路径不是以\结尾,则追加之
this._UpdateServiceUrl += @"/";
this._UpdateServiceUrl = f_UpdateServiceUrl;
FinishCurrentTask(f_LvStep);
GetUpdateFileList();
}
/// <summary>
/// 升级步骤之三:获取升级文件列表
/// </summary>
private void GetUpdateFileList()
{
DataSet f_ds = null;
int f_LvStep = 3;
// 设置界面并显示所连接的升级服务器的URL
StartCurrentTask(f_LvStep, STEP_3, _UpdateServiceUrl);
int f_AddNum = 10;
UpdateSystem f_upws;
try
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
if (this._UpdateServiceUrl != "")
{
f_upws = new UpdateSystem(this._UpdateServiceUrl + UPDATEASMX);
}
else
{
f_upws = new UpdateSystem();
}
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
// 获取升级服务器端的升级文件列表
f_ds = f_upws.GetClientFileList();
}
catch(Exception ex)
{
UpdateFileList = null;
StopUpdate(f_LvStep);
}
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
// 如果获得空DataSet或是DataSet行数小于一行则认为错
if (f_ds == null || f_ds.Tables[0].Rows.Count < 1)
{
StopUpdate(f_LvStep);
}
else
{
UpdateFileList = f_ds;
FinishCurrentTask(f_LvStep);
TransactFileList();
}
}
/// <summary>
/// 升级步骤之四:处理升级文件列表
/// </summary>
private void TransactFileList()
{
int f_LvStep = 4;
StartCurrentTask(f_LvStep, STEP_4);
int f_AddNum = 1;
int i, j;
// 定义局部变量对应升级文件列表和本地文件列表
DataSet f_uds = this.UpdateFileList;
DataSet f_lds = this.LocalFileList;
// 从升级文件列表删去固定文件数组FixFileList中的文件
for (i = 0; i < FixFileList.Length; i++)
{
for (j = f_uds.Tables[0].Rows.Count - 1; j > -1; j--)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
if (f_uds.Tables[0].Rows[j]["FileName"].ToString() == FixFileList[i].ToString())
{
f_uds.Tables[0].Rows[j].Delete();
}
}
}
// 将本地文件列表和升级文件列表进行比对
for (i = 0; i < f_lds.Tables[0].Rows.Count; i++)
{
for (j = 0; j < f_uds.Tables[0].Rows.Count; j++)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
if (f_uds.Tables[0].Rows[j]["FileName"].ToString() == f_lds.Tables[0].Rows[i]["FileName"].ToString())
{
if (f_uds.Tables[0].Rows[j]["FileLength"].ToString() == f_lds.Tables[0].Rows[i]["FileLength"].ToString())
{
if (Convert.ToDateTime(f_uds.Tables[0].Rows[j]["FileDateTime"]) == Convert.ToDateTime(f_lds.Tables[0].Rows[i]["FileDateTime"]))
{
f_uds.Tables[0].Rows[j].Delete();
j = f_uds.Tables[0].Rows.Count;
}
}
}
}
}
this.UpdateFileList = f_uds;
FinishCurrentTask(f_LvStep);
DownLoadUpdateFile();
}
/// <summary>
/// 升级步骤之五:下载升级文件
/// </summary>
private void DownLoadUpdateFile()
{
int f_LvStep = 5;
StartCurrentTask(f_LvStep, STEP_5);
int f_AddNum = 1;
UpdateSystem f_upws;
string f_filename;
byte[] f_mbyte;
FileInfo f_fi;
DataSet f_uds = this.UpdateFileList;
BeginInvoke(addprogressdelegate, new object[] {f_AddNum});
try
{
if (this._UpdateServiceUrl != "")
{
f_upws = new UpdateSystem(this._UpdateServiceUrl + UPDATEASMX);
}
else
{
f_upws = new UpdateSystem();
}
BeginInvoke(addprogressdelegate, new object[] {f_AddNum});
}
catch
{
StopUpdate(f_LvStep);
return;
}
// 预先删除所有以"NEW_"和"Old_"开始的文件名以防与本次下载的新文件相混淆
int i;
string f_CurrentPath = GetCurrentDir();
string[] f_FilePaths = GetFiles(f_CurrentPath);
try
{
for (i = 0; i < f_FilePaths.Length; i++)
{
if (f_FilePaths[i] == "")
{
continue;
}
if (f_FilePaths[i].LastIndexOf(@"\") + 1 > f_FilePaths[i].Length - 1)
{
continue;
}
f_filename = f_FilePaths[i].Substring(f_FilePaths[i].LastIndexOf(@"\") + 1);
if (f_filename.Length >= 4 && (f_filename.Substring(0, 4) == NEWHEAD ||
f_filename.Substring(0, 4) == OLDHEAD))
{
if (f_filename.Contains("Old_LiveUpdate"))
continue;
try
{
File.Delete(f_FilePaths[i]);
}
catch
{
}
}
}
}
catch(Exception ex)
{
}
int f_total;
f_total = f_uds.Tables[0].Rows.Count;
BeginInvoke(addprogressdelegate, new object[] {f_AddNum});
// 依据升级文件列表从升级服务器依此下下载文件
try
{
for (i = 0; i < f_total; i++)
{
BeginInvoke(addprogressdelegate, new object[] {f_AddNum});
//取得需下载文件名
f_filename = f_uds.Tables[0].Rows[i]["FileName"].ToString();
BeginInvoke(addprogressdelegate, new object[] {f_AddNum});
//从升级服务器的GetClientFile方法以字节数组的方式获取文件
f_mbyte = f_upws.GetClientFile(f_filename);
int m = f_mbyte.Length;
// 改变界面显示方式,标识出当前下载的文件名
StartDownLoadCurrentTask(f_LvStep, f_filename, i, f_total);
// 将下载好的文件名字前面加"New_"的标识
if (f_filename.LastIndexOf(@"\") + 1 > f_filename.Length)
{
continue;
}
string childDir = f_filename.Substring(0, f_filename.LastIndexOf(@"\") + 1);
if (!String.IsNullOrEmpty(childDir))
{
f_filename = NEWHEAD + f_filename.Replace(childDir, "");
f_filename = f_CurrentPath + childDir + f_filename;
}
else
{
f_filename = NEWHEAD + f_filename;
}
f_fi = new FileInfo(f_filename);
// 如果存在同名文件则删除
if (f_fi.Exists)
{
f_fi.Delete();
}
// 以创建读写方式将字节数组写入本地文件中
FileStream f_fstr = new FileStream(f_filename, FileMode.OpenOrCreate, FileAccess.ReadWrite);
f_fstr.Write(f_mbyte, 0, m);
f_fstr.Close();
f_fi = new FileInfo(f_filename);
f_fi.LastWriteTime = Convert.ToDateTime(f_uds.Tables[0].Rows[i]["FileDateTime"]);
}
}
catch(Exception ex)
{
DownLoadFailed(f_LvStep);
}
FinishCurrentTask(f_LvStep);
UpdateLocalFile();
}
/// <summary>
/// 升级步骤之六:升级本地文件
/// </summary>
private void UpdateLocalFile()
{
int f_LvStep = 6;
StartCurrentTask(f_LvStep, STEP_6);
int f_AddNum = 2;
string f_CurrentPath = GetCurrentDir();
int i;
DataSet f_uds = this.UpdateFileList;
// 获取当前文件列表
string[] f_FilePaths = GetFiles(f_CurrentPath);
string f_filename;
FileInfo f_fi, f_oldfi;
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
// 将this._Updating属性设置为TRUE,
// 不允许在更新本地文件未完成时中断当前线程,
// 避免程序与程序引用之间版本不匹配导致程序无法运行
this._Updating = true;
try
{
for (i = 0; i < f_uds.Tables[0].Rows.Count; i++)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_filename = f_uds.Tables[0].Rows[i]["FileName"].ToString();
if (f_filename.LastIndexOf(@"\") + 1 > f_filename.Length)
{
continue;
}
string childDir = f_filename.Substring(0, f_filename.LastIndexOf(@"\") + 1);
if (!String.IsNullOrEmpty(childDir))
{
f_filename = NEWHEAD + f_filename.Replace(childDir, "");
f_filename = f_CurrentPath + childDir + f_filename;
}
else
{
f_filename = NEWHEAD + f_filename;
}
f_fi = new FileInfo(f_filename);
// 找到新下载成功的以"New_"开头的文件
if (f_fi.Exists)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_oldfi = new FileInfo(f_filename.Replace(NEWHEAD, ""));
// 找到与新文件相对应的旧文件
if (f_oldfi.Exists)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
// 将旧文件改名在文件头上加"Old_",如有相同文件先进行删除
f_oldfi = new FileInfo(f_filename.Replace(NEWHEAD, OLDHEAD));
if (f_oldfi.Exists)
{
BeginInvoke(addprogressdelegate, new object[] { f_AddNum });
f_oldfi.Delete();
}
File.Move(f_filename.Replace(NEWHEAD, ""), f_filename.Replace(NEWHEAD, OLDHEAD));
//隐藏旧文件
FileAttributes m_fa = File.GetAttributes(f_filename.Replace(NEWHEAD, OLDHEAD));
if ((m_fa & FileAttributes.Hidden) != FileAttributes.Hidden) //若为非隐藏
File.SetAttributes(f_filename.Replace(NEWHEAD, OLDHEAD), m_fa ^ FileAttributes.Hidden);//则设为隐藏
}
File.Move(f_filename, f_filename.Replace(NEWHEAD, ""));
}
// 在升级列表中存在但是在本地却找不到,
// 进行下载失败的处理
else
{
DownLoadFailed(f_LvStep);
}
}
}
catch
{
UpdateFailed(f_LvStep);
}
this._Updating = false;
// 检测文件替换是否成功
f_FilePaths = GetFiles(f_CurrentPath);
for (i = 0; i < f_FilePaths.Length; i++)
{
if (f_FilePaths[i] == "")
{
continue;
}
f_filename = new FileInfo(f_FilePaths[i]).Name;
if (f_filename.Length>=4 && f_filename.Substring(0, 4) == NEWHEAD)
{
i = f_FilePaths.Length;
UpdateFailed(f_LvStep);
}
}
for (i = f_FilePaths.Length - 1; i >= 0; i--)
{
if (f_FilePaths[i] == "")
{
continue;
}
f_filename = new FileInfo(f_FilePaths[i]).Name;
if (f_filename.Length >= 4 && f_filename.Substring(0, 4) == OLDHEAD)
{
try
{
File.Delete(f_FilePaths[i]);
}
catch
{
}
}
}
FinishCurrentTask(f_LvStep);
FinishUpdate();
}
/// <summary>
/// 确定按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click_1(object sender, System.EventArgs e)
{
if (BtnOK.Text == "完成(&F)")
{
EndLiveUpdate();
}
if (BtnOK.Text == "开始(&S)")
{
BtnOK.Enabled = false;
UpdateEscaladeClient();
}
}
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnCancel_Click(object sender, System.EventArgs e)
{
if (BtnCancel.Text == "退出(&Q)")
{
if (Updateing)
{
return;
}
if (ThreadProcedure.IsAlive)
{
ThreadProcedure.Abort();
ThreadProcedure.Join();
}
ThreadProcedure = null;
_UpdateResult = false;
_Updating = false;
this.Close();
}
else
{
if (this._Updating == true)
{
return;
}
else
{
if (ThreadProcedure != null)
{
if (ThreadProcedure.IsAlive)
{
ThreadProcedure.Abort();
ThreadProcedure.Join();
}
ThreadProcedure = null;
}
this.Close();
}
}
}
/// <summary>
/// 停止升级线程
/// </summary>
private void StopUpdateThread()
{
if (Updateing)
{
return;
}
if (ThreadProcedure.IsAlive)
{
ThreadProcedure.Abort();
ThreadProcedure.Join();
}
ThreadProcedure = null;
_UpdateResult = false;
_Updating = false;
}
/// <summary>
/// 是否在升级中
/// </summary>
public bool Updateing
{
get
{
return _Updating;
}
set
{
_Updating = value;
}
}
/// <summary>
/// 升级服务器地址
/// </summary>
public string UpdateServiceUrl
{
get
{
return _UpdateServiceUrl;
}
set
{
_UpdateServiceUrl = value;
}
}
/// <summary>
/// 是否升级成功
/// </summary>
public bool UpdateResult
{
get
{
return _UpdateResult;
}
set
{
_UpdateResult = value;
}
}
}
}