GlobalInfo.cs
40.4 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.IO;
using GeneralLib;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
using ProService;
using System.Diagnostics;
//using RealVote;
namespace SunVoteARSPPT
{
/// <summary>
/// SDK操作类型
/// </summary>
public enum OperateType
{
otWrite = 1,
otRead = 2
}
/// <summary>
/// OEM的Logo类型
/// 创建:杨斌 2012-05-15
/// 修改:杨斌 2017-10-17
/// </summary>
public enum OEMLogos
{
/// <summary>
/// 标准版
/// </summary>
SunVote = 0,
/// <summary>
/// 中性版
/// </summary>
ZX,
/// <summary>
/// 日本木村公司
/// </summary>
oem3eAnalyzer,
/// <summary>
/// 美国Tony
/// </summary>
oemMyVote,
/// <summary>
/// 美国Tony的RealVote
/// </summary>
oemRealVote,
/// <summary>
/// 匈牙利Mekka Interaktív Kft.
/// </summary>
oemApaczaiKiado,
/// <summary>
/// 印度EasyTest-C1826
/// 杨斌 2013-05-03
/// </summary>
oemEasyTest,
/// <summary>
/// 信德服务版。杨斌 2014-07-07
/// </summary>
oemXDServer,
/// <summary>
/// 墨西哥 SmartVote 杨斌 2016-01-25
/// </summary>
oemSmartVote,
/// <summary>
/// 巴西 Option Maker 杨斌 2014-12-22
/// 隐藏图表,后台发报表邮件
/// </summary>
oemOptionMaker,
/// <summary>
/// 西班牙CustomVote
/// 杨斌 2015-01-26
/// </summary>
oemCustomVote,
/// <summary>
/// 波兰ACTRONIX
/// </summary>
oemACTRONIX,
/// <summary>
/// 法国PowerVote,C2579
/// </summary>
oemPowerVote,
/// <summary>
/// 法国i-Pericles
/// 杨斌 2016-04-28
/// </summary>
oemiPericles,
/// <summary>
/// 西班牙Clickmaster
/// 杨斌 2016-09-20
/// </summary>
oemClickmaster,
/// <summary>
/// 美国ShoutPoll
/// </summary>
oemShoutPoll,
/// <summary>
/// 沙特阿拉伯SolutionsBox
/// </summary>
oemSolutionsBox,
/// <summary>
/// 成都六韬?PowerCom,目前只修改ToolKit键盘型号
/// </summary>
oemPowerCom,
/// <summary>
/// C4002-Ministr贴牌定制
/// </summary>
oemMinistr,
/// <summary>
/// C4058-BOAVC,广州捷思通,博安至高
/// </summary>
oemBOAVC,
/// <summary>
/// Klickr贴牌定制。杨斌 2017-10-17
/// </summary>
oemKlickrQuiz,
/// <summary>
/// 深圳艾博德科技股份有限公司
/// </summary>
oemDrawViewVote,
/// <summary>
/// C3897定制WeVote贴牌。杨斌 2018-01-22
/// </summary>
oemWeVote,
/// <summary>
/// C3677法国Vote-Explorer的OEM。杨斌 2018-03-06
/// </summary>
oemVoteExplorer,
/// <summary>
/// C2579-原来的PowerVote改成Angage,不知什么原因改品牌名字了。杨斌 2018-03-22
/// </summary>
oemAngage,
/// <summary>
/// C4108-20180518-D001贴牌QResponse Audience Response System;EDU ASSE是TURNING印度经销商。杨斌 2018-05-31
/// </summary>
oemQResponse,
/// <summary>
/// 自定义OEM,根据配置文件设置About等信息。杨斌 2018-09-19
/// 新增配置:WolfPoll PPT Plugin贴牌定制。C2972-20190124-PI002-D001 定制。2019-05-29
/// </summary>
oemCustom,
}
/// <summary>
/// 标准版或Oem的子版本类型。
/// </summary>
public enum OEMLogos2
{
/// <summary>
/// 标准版
/// </summary>
SunVote = 0,
/// <summary>
/// 中国/福建/龙岩/龙阳市金创新电子技术有限公司
/// </summary>
oem龙阳市金创新,
/// <summary>
/// PowerVote特定版本MRC Quiz
/// </summary>
oemPowerVoteMRCQuiz,
/// <summary>
/// 定制M52+功能的多人选举,C3322北京顺义三中的先进党员选举
///// </summary>
//oemSunVoteMultiPoll,
/// <summary>
/// 新加坡HumanspherePte Ltd新增定制报表Polling Data Report Example;定制个人明细与成绩报表格式,加批注
/// </summary>
oemSunVoteOEMReportAddComment,
/// <summary>
/// EasyTest关于详细信息为空。杨斌 2016-12-23
/// </summary>
oemEasyTestBlank,
/// <summary>
/// 是否显示老版本的报表。杨斌 2017-04-11
/// </summary>
oemSunVoteOldReportVoterDetail,
/// <summary>
/// PowerVote特殊定制评分表决。杨斌 2017-05-31
/// </summary>
oemPowerVoteForORPI,
/// <summary>
/// C1082-AVATAR,分组对比图表显示堆积图,百分比时,柱状图高度一致。杨斌 2017-06-13
/// </summary>
oemAVATAR,
/// <summary>
/// 河北鑫考,增加如从SQLServer导入名单功能,安装包包含iVote,eTest。杨斌 2018-06-28
/// </summary>
oemHBXK,
/// <summary>
/// 湖南沃阿汇网络科技有限公司,成绩数据上传
/// </summary>
oemWoAHuiUpload,
/// <summary>
/// 隐藏数据查看权限。i-Pericles定制。杨斌 2020-03-06
/// </summary>
oemHideData,
/// <summary>
/// C5282- Inno Vietnam。杨斌 2020-04-01
/// </summary>
oemINNO,
/// <summary>
/// C5641-东莞松山湖网络。显示表决项目名单。杨斌 2020-04-29
/// </summary>
oemShowVoteNameList,
}
public class GlobalInfo
{
/// <summary>
/// OEM标志Logo
/// 创建:杨斌 2012-05-23
/// 隐藏主界面帮助按钮,根据OEM类型调用对应的关于窗体
/// 注意工程名改为:Angage Quiz Plus
/// </summary>
public static OEMLogos OEMLogo = OEMLogos.SunVote;//oemCustom
/// <summary>
/// OEM标志2,不修改Logo,在标准版基础上修改一些关于信息
/// 杨斌 2016-01-05
/// </summary>
public static OEMLogos2 OEMLogo2 = OEMLogos2.SunVote;//oemINFO
/// <summary>
/// 版本补充信息,与标准版Logo一样,但功能不同,以此做区分
/// 杨斌 2014-08-20
/// -Alpha -Beta -2-3..l
/// </summary>
public static string VerInfo
{
get
{
if (OEMLogo == OEMLogos.oemOptionMaker)
return "-Option Maker";
else if (OEMLogo == OEMLogos.oemACTRONIX)
return "-ACTRONIX";
else
return "";//第4位版本为0则是正式版。杨斌 2015-01-05
}
}
/// <summary>
/// 键盘限制个数,限制版投票表决时只允许有限个键盘提交数据,=0时不限制
/// 创建:杨斌 2012-11-05
/// </summary>
public static int LIMITED_EDITION = 0;
/// <summary>
/// 获取SDK类型。0=ARS/EVS/CRS,1=PVS。杨斌 2015-03-05
/// </summary>
/// <returns></returns>
public static int GetSdkType()
{
//杨斌 2015-03-13
//switch (hardwareManage.KeyModel)
switch (SystemConfig.KeypadType)
{
case "M52":
case "M50":
case "M52Plus":
case "M52Li"://杨斌 2015-06-17
case "M30"://杨斌 2017-02-07
case "F00":
case "M40L":
case "S50":
case "S50Li":
case "S70":
return 0;
break;
case "W52":
case "W00":
case "W40":
return 1;
break;
default://其他OEM定制的型号,默认ARS
return 0;
break;
}
}
/// <summary>
/// RealVote的软件狗。
/// 杨斌 2015-01-22
/// </summary>
public static object RealVoteSoftDog = null;
/// <summary>
/// 软件狗是否验证成功,在使用硬件投票时判断。
/// 杨斌 2015-01-22
/// </summary>
public static bool SoftDogOK = false;
/// <summary>
/// 软件狗失败提示信息。
/// 杨斌 2015-01-22
/// </summary>
/// <returns></returns>
public static string DogFailedMsg
{
get
{
return GlobalInfo.SysLanguage.LPT.ReadString("Other", "DogFailed", "软件狗验证失败,不能使用键盘反馈功能。");
}
}
/// <summary>
/// 启动反馈时判断软件狗是否失败
/// 杨斌 2015-01-22
/// </summary>
/// <returns></returns>
public static bool JudgeDogFailed()
{
bool res = false;
if ((GlobalInfo.OEMLogo == OEMLogos.oemRealVote) && (!GlobalInfo.SoftDogOK) && (!GlobalInfo.sysConfig.DemoEnable))
res = true;
return res;
}
/// <summary>
/// 是否启用了SN
/// 杨斌 2015-01-14
/// </summary>
public static bool EnabledSN
{
get
{
bool res = false;
if (GlobalInfo.baseConnect.BaseList.Count > 0)
res = (GlobalInfo.baseConnect[0].BaseMatchMode >= 4);
return res;
}
}
/// <summary>
/// 判断键盘支持的反馈类型,杨斌 2017-08-18;Globals.SunVoteARSAddIn.PPTShow.ResponseType
/// </summary>
public static bool IsSupportVoteType(ResponseType rType = ResponseType.None)
{
bool res = true;
if (rType == ResponseType.None)
rType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
if (GlobalInfo.hardwareManage.KeyModel == "S60")
{
switch (rType)
{
//不支持的
case ResponseType.Number:
case ResponseType.Text:
case ResponseType.Score:
case ResponseType.Order:
case ResponseType.Poll:
res = false;
break;
}
}
return res;
}
/// <summary>
/// 最大选项个数。杨斌 2018-10-16
/// </summary>
public static int MaxOptionCount = 10;
/// <summary>
/// 最大选项个数,高级定制版。杨斌 2018-02-02
/// </summary>
public static int MaxOptionCountAdv
{
get
{
int res = 10;
switch(GlobalInfo.OEMLogo)
{
case OEMLogos.oemShoutPoll://高级定制版
case OEMLogos.SunVote:
case OEMLogos.oemAngage://2018-10-16
res = 20;
break;
}
return res;
}
}
/// <summary>
/// 基站连接类
/// </summary>
public static BaseConnect baseConnect = null;
/// <summary>
/// 硬件管理类
/// </summary>
public static HardwareManageARS hardwareManage = null;
/// <summary>
/// 系统语言类
/// </summary>
public static Language SysLanguage = null;
/// <summary>
/// 系统指定字体
/// 杨斌 2015-02-27
/// </summary>
public static string SysFontName = "";
/// <summary>
/// 是否显示调试信息
/// 杨斌 2015-03-12
/// </summary>
public static bool ShowDebug = false;
/// <summary>
/// 调试模式
/// 杨斌 2015-05-21
/// </summary>
public static bool DebugMode = false;
/// <summary>
/// 配置文件类
/// </summary>
public static SysConfig sysConfig = null;
/// <summary>
/// 反馈接口类
/// </summary>
public static Response response = null;
/// <summary>
/// 最小基站编号
/// </summary>
public static int minBaseID = 1;
/// <summary>
/// 最大基站编号
/// </summary>
public static int maxBaseID = 8;
/// <summary>
/// 最小频点号
/// </summary>
public static int minChannel = 1;
/// <summary>
/// 最大频点号
/// </summary>
public static int maxChannel = 80;//有的基站频点最大80.杨斌 2016-04-18
/// <summary>
/// 北京顺义数字选举的可选人数最大值60。
/// 杨斌 2016-04-28
/// 2020-04-03支持255
/// </summary>
public static int maxNumberPollSelect = 255;//60
/// <summary>
/// 项目根目录
/// </summary>
public static string APP_DIR = new DirectoryInfo(GetAppWorkDir()).Parent.FullName;
/// <summary>
///系统错误日志文件路径
/// </summary>
public static string SYSTEM_LOG = APP_DIR + @"\Resources\SystemLog\";
/// <summary>
/// 键盘配置文件路径
/// </summary>
public static string KEYPAD_CONFIG_PATH = APP_DIR + @"\Resources\SystemConfig\KeypadConfig.ini";
/// <summary>
/// 系统配置文件路径
/// </summary>
public static string SYSTEM_CONFIG_PATH = APP_DIR + @"\Resources\SystemConfig\System.ini";
/// <summary>
/// 备份信息文件路径
/// </summary>
public static string SYSTEM_BACKUP = APP_DIR + @"\Resources\SystemConfig\";
/// <summary>
///多基站模式,基站列表路径
/// </summary>
public static string BASELIST_PATH = APP_DIR + @"\Resources\SystemConfig\BaseList.ini";
/// <summary>
/// 数据库路径
/// </summary>
public static string DB_PATH = APP_DIR + @"\Resources\DataBase\";
/// <summary>
/// 数据库临时文件夹
/// </summary>
public static string DBTEMP_PATH = APP_DIR + @"\Resources\DBTemp\";
//public static string DB_PATH = APP_DIR + @"\Resources\DataBase\SunVote.mdb";
/// <summary>
/// 数据库模板文件路径
/// 修改:杨斌 2012-05-23,改成中性的名称
/// </summary>
public static string ACCESS_DATASOUREMODE = APP_DIR + @"\Resources\SystemConfig\TempDB.mdb";//原来是SunVote.mdb
/// <summary>
/// 图片临时文件夹
/// </summary>
public static string PICTURETEMP_PATH = APP_DIR + @"\Resources\PictureTemp\";
/// <summary>
/// 图标图片文件夹。杨斌 2020-02-13
/// </summary>
public static string IMAGE_VoteBar_DIR = APP_DIR + @"\Resources\Image\VoteBar\";
/// <summary>
/// 音效文件的目录
/// </summary>
public static string SOUND_DIR = APP_DIR + @"\Resources\Sound\";
/// <summary>
/// Excel报表导出的目录
/// </summary>
public static string Reports_DIR = APP_DIR + @"\Reports\";
/// <summary>
/// OEM贴牌配置信息的目录。杨斌 2018-09-19
/// </summary>
public static string OEMInfoDir = APP_DIR + @"\Resources\AppInfo\";
/// <summary>
/// OEM贴牌配置信息。杨斌 2018-09-19
/// </summary>
public static string OEMInfoFile = APP_DIR + @"\Resources\AppInfo\About.xml";
/// <summary>
/// OEM贴牌配置信息的Logo图片。杨斌 2018-09-19
/// </summary>
public static string OEMInfoLogo = APP_DIR + @"\Resources\AppInfo\Logo.png";
/// <summary>
/// 播放背景音效的键
/// </summary>
public const string Sound_Key_Back = "Back";
/// <summary>
/// 播放投票按键音效的键
/// </summary>
public const string Sound_Key_Vote = "Vote";
/// <summary>
/// 播放背景音效的键,在幻灯片中设置的。杨斌 2015-04-10
/// </summary>
public const string Sund_Key_BackSlide = "BackSlide";
/// <summary>
/// 显示结果图表提示音,停止投票后手动显示结果或者投票停止后自动显示结果。杨斌 2019-01-07
/// </summary>
public const string Sund_Key_SlideShowResult = "SlideShowResult";
/// <summary>
/// 显示正确答案提示音。杨斌 2019-01-07
/// </summary>
public const string Sund_Key_ShowCorrectAnswer = "ShowCorrectAnswer";
/// <summary>
/// 播放音效的对象
/// </summary>
public static PLSound DXSoundPlay = null;//杨斌 2012-06-25
public static DBOper DBOperation = null;
/// <summary>
/// 数据库名称
/// </summary>
public static string DBName = "";
/// <summary>
/// 获取程序集名称
/// 创建:杨斌 2012-05-15
/// </summary>
/// <returns></returns>
public static string GetAppName()
{
return Assembly.GetExecutingAssembly().GetName().Name;
}
/// <summary>
/// 获取软件名称
/// 创建:杨斌 2012-11-13
/// </summary>
/// <returns></returns>
public static string GetAppTitle()
{
string appName = Assembly.GetExecutingAssembly().GetName().Name;
switch (GlobalInfo.OEMLogo)
{
case OEMLogos.oemApaczaiKiado:
appName = "Apáczai Kiadó";//工程名叫:Interaktivtabla,因为安装工厂文件名不支持匈牙利语,显示乱码
break;
case OEMLogos.oemCustomVote:
appName = "CustomVote " + DateTime.Now.Year;
break;
case OEMLogos.oemiPericles:
if (GlobalInfo.OEMLogo2== OEMLogos2.oemHideData)
{
appName += "(private)";
}
break;
default:
break;
}
return appName;
}
/// <summary>
/// 获取工作目录,即VSTO文件的目录
/// 安装VSTO后,真正执行的工程DLL位于“C:\Documents and Settings\用户名\....”下面
/// 创建:杨斌 2010-08-18
/// 修改:杨斌 2012-05-15
/// </summary>
/// <returns></returns>
public static string GetAppWorkDir()
{
string path = "";
try
{
path = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Office\PowerPoint\Addins\" + GlobalInfo.GetAppName()).GetValue("Manifest", "").ToString();
if (path.Length > 0)
{
//TODO:路径字符串"/"必须从系统环境中获取,如日本的为"¥"
path = path.Replace(@"/", @"\");
path = path.Replace(@"file:\\\", @"");
path = path.Remove(path.LastIndexOf(@"\") + 1);
}
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
return path;
}
/// <summary>
/// 系统内置图表颜色表,只读
/// 修改:杨斌 2012-03-20
/// </summary>
public static Color[] ChartColors
{
get
{
//Color[] res = new Color[]
//{
// Color.FromArgb(65, 140, 240),
// Color.FromArgb(224, 64, 10),
// Color.FromArgb(252, 180, 65),
// Color.FromArgb(5, 100, 146),
// Color.FromArgb(191, 191, 191),
// Color.FromArgb(26, 59, 105),
// Color.FromArgb(255, 227, 130),
// Color.FromArgb(18, 156, 221),
// Color.FromArgb(202, 107, 75),
// Color.FromArgb(0, 92, 219)
//};
//颜色表修改,PowerVote提出修改的,也同iVote。杨斌 2018-07-26
Color[] res = new Color[]
{
Color.FromArgb(18, 177, 90),
Color.FromArgb(255, 12, 26),
Color.FromArgb(253, 215, 108),
Color.FromArgb(0, 68, 205),
Color.FromArgb(0, 189, 189),
Color.FromArgb(241, 48, 243),
Color.FromArgb(102, 205, 52),
Color.FromArgb(155, 102, 0),
Color.FromArgb(4, 227, 229),
Color.FromArgb(247, 56, 133),
};
//if (GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX)
//{
// res[0] = Color.FromArgb(65, 140, 240);
// res[1] = Color.FromArgb(224, 64, 10);
// res[2] = Color.FromArgb(252, 180, 65);
//}
return res;
}
}
/// <summary>
/// 获取ppt文件名不含后缀名
/// 杨斌 2016-07-28
/// </summary>
/// <param name="Pres"></param>
/// <returns></returns>
public static string GetPPTFileName(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
string res = "";
try
{
res = Pres.Name;
res = Path.GetFileNameWithoutExtension(res);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
return res;
}
public static string GetNewDBName(Microsoft.Office.Interop.PowerPoint.Presentation Pres, string defName = "")
{
string res = "";
try
{
string name = defName;
if (name.Length < 1)
name = GetPPTFileName(Pres);
res = name + "[" + DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond + "]" + ".mdb";
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
return res;
}
/// <summary>
/// 复制数据库
/// </summary>
public static void CopySystemDB(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
try
{
string sourcePath = ACCESS_DATASOUREMODE;
//杨斌 2016-07-28
bool beCopyNew = false;
if (DBName == "")
{
//DBName = System.Guid.NewGuid() + ".mdb";
DBName = GetNewDBName(Pres);
beCopyNew = true;
}
string targetPath = DB_PATH + DBName;
bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之
System.IO.File.Copy(sourcePath, targetPath, isrewrite);
//连接数据库。杨斌 2018-06-28
DBOperation.InitConnStrAccess(DB_PATH + DBName, "");
DBOperation.OpenConn();
UpdateDB();//杨斌 2015-01-05
if (beCopyNew)
PPTEdit.UpdatePresPathToDB(Pres);
if (!Directory.Exists(DBTEMP_PATH))
Directory.CreateDirectory(DBTEMP_PATH);//路径不存在则创建,否则下面删除目录中文件时报错
foreach (string str in System.IO.Directory.GetFiles(DBTEMP_PATH))
{
FileInfo info = new FileInfo(str);
info.Attributes = FileAttributes.Normal;
info.Delete();
}
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
/// <summary>
/// 将数据库暂存到临时文件夹
/// </summary>
public static void CopyTempDB()
{
if (!System.IO.Directory.Exists(DBTEMP_PATH))
{
// 目录不存在,建立目录
System.IO.Directory.CreateDirectory(DBTEMP_PATH);
}
string sourcePath = DB_PATH + DBName;
string targetPath = DBTEMP_PATH + DBName;
System.IO.File.Copy(sourcePath, targetPath, true);
DBOperation.CloseConn();
System.IO.File.SetAttributes(DB_PATH + DBName, FileAttributes.Normal);
System.IO.File.Delete(DB_PATH + DBName);
}
/// <summary>
/// 更新数据库结构
/// 杨斌 2015-03-31
/// </summary>
public static void UpdateDB(DBOper dbOperation)
{
dbOperation.SetTableColumnType("ST_Voter", "V_KeypadID", "Text(255)");
//杨斌 2020-04-03。选举999选255的按键值字段不够长
dbOperation.SetTableColumnType("ST_Response", "R_Result", "Memo");
dbOperation.SetTableColumnType("ST_Response2", "R_Result", "Memo");
string sql = "SELECT TT_ID FROM ST_TopicType WHERE (TT_ID='Text')";
if (!dbOperation.RecordIsExist(sql))
{
sql = "INSERT INTO ST_TopicType (TT_ID, TT_Code, TT_Note)" +
" VALUES ('Text', 11, '文本')";
dbOperation.ExecuteNonQuery(sql);
}
//杨斌 2015-07-13
string sTable = "ST_Response2";
if (!TableExists(dbOperation, sTable))//外键约束,参照完整性,级联更新删除
{
try
{
//sql = "create table " + sTable + " ("
// + " T_ID varchar(255) CONSTRAINT ARS_ResponseT_ID REFERENCES ST_Topic(T_ID) not null,"
// + " V_ID long CONSTRAINT ARS_ResponseV_ID not null,"
// + " R_ID identity primary key,"
// + " R_KeypadID varchar(255) not null,"
// + " R_Result varchar(255),"
// + " R_Speed double,"
// + " R_Time Datetime"
// + ")";
sql = "create table " + sTable + " ("
+ " T_ID varchar(255) REFERENCES ST_Topic(T_ID) ON UPDATE CASCADE ON DELETE CASCADE not null,"
+ " V_ID long REFERENCES ST_Voter (V_ID) not null,"
+ " R_ID identity,"
+ " R_KeypadID varchar(255) not null,"
+ " R_Result varchar(255),"
+ " R_Speed double,"
+ " R_Time Datetime,"
+ " CONSTRAINT PrimaryKey primary key (R_ID))";
dbOperation.ExecuteNonQuery(sql);
sql = "create index"
+ " ARS_ResponseT_ID on " + sTable + " (T_ID)";
dbOperation.ExecuteNonQuery(sql);
sql = "create index"
+ " ARS_ResponseV_ID on " + sTable + " (V_ID)";
dbOperation.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
dbOperation.AddTableColumn("ST_Response2", "R_Score", "Double", 0);//杨斌 2016-01-08
}
public static bool TableExists(DBOper dbOperation, string sTable)
{
bool res = false;
string[] red = new string[4];
red[2] = sTable;
System.Data.DataTable dt = dbOperation.DBConnection.GetSchema("Tables", red);
if (dt != null)
res = dt.Rows.Count > 0;
return res;
}
/// <summary>
/// 更新数据库结构
/// 杨斌 2015-01-05
/// </summary>
public static void UpdateDB()
{
UpdateDB(DBOperation);//杨斌 2015-03-31
}
public static INIControl IniCtlSystem = null;//杨斌 2014-07-24
/// <summary>
/// ToolKit服务
/// </summary>
public static MyService Servive = null;
private static bool RunInitMain = false;
public static void InitMain()
{
try
{
if (RunInitMain) return;//只运行一次
RunInitMain = true;
//杨斌 2015-03-13
SystemConfig.KeypadType = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).ReadString("Device", "KeypadType", "M52Plus");
//CopySystemDB();
SystemLog.LogFile = new DirectoryInfo(GlobalInfo.GetAppWorkDir()).Parent.FullName + @"\Resources\SystemLog\";
//暂时不能屏蔽,应屏蔽SDK相关。杨斌 2017-04-19
baseConnect = new BaseConnect();
hardwareManage = new HardwareManageARS(baseConnect);
DBOperation = new DBOper();
SysLanguage = new Language(APP_DIR);
SysLanguage.LoadLanguage();//在sysConfig.iniSystemInfo中调用,但这里不能省,暂多调用一次。杨斌 2012-03-26
sysConfig = new SysConfig();
response = new Response();
sysConfig.iniSystemInfo();
IniCtlSystem = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH);//杨斌 2014-07-24
Servive = MyService.GetService(GetSevName());
GlobalInfo.RunToolKit("RunBack");//杨斌 2017-12-21
RefreshConnectState();
//杨斌 2017-12-08
VoteServer.ServerInit();
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
public static string GetSevName(bool reverse = false)
{
string res = "";
if (GlobalInfo.GetSdkType() == (reverse ? 1 : 0))
res = "ToolKitArsSev";
else
res = "ToolKitPvsSev";
return res;
}
static List<object> LstServerRequestException = new List<object>();
/// <summary>
/// 检查连接状态。杨斌 2016-10-26
/// </summary>
public static string GetBaseConnectOkIDs()
{
string res = "";
Param e = new Param();
Param p = ServerRequest(e);
if (p.Pa.ContainsKey("BaseConnectOkIDs"))
{
res = p.Pa["BaseConnectOkIDs"].ToString();
}
if (p.Pa.ContainsKey("KeypadTypeSet"))
{
string keypadType = p.Pa["KeypadTypeSet"].ToString();
FrmKeypadType.UpdateKeypadType(keypadType);
}
//杨斌 2018-03-09
if (e.Pa.ContainsKey(KeyServerRequestException))
{
LstServerRequestException.Add(e.Pa[KeyServerRequestException]);
if (LstServerRequestException.Count >= 10)
{
LstServerRequestException.Clear();
RunToolKit("RunBack");
}
}
return res;
}
/// <summary>
/// 刷新连接状态。杨斌 2016-10-24
/// </summary>
public static void RefreshConnectState()
{
string baseIDs = GetBaseConnectOkIDs();
bool isOK = (baseIDs.Length > 0);
Globals.Ribbons.rbSunVoteARS.SetBaseConnectStatus(isOK);
}
public static void InitRemontControl()
{
Param p = new Param();
switch (GlobalInfo.sysConfig.RemontControl)
{
case "50R":
case "R51":
case "R52"://杨斌 2019-07-02
case "R53"://杨斌 2020-03-20
p.Pa.Add("EnableRequest", "1");
break;
default:
p.Pa.Add("EnableRequest", "0");
break;
}
GlobalInfo.ServerRequest(p);
}
public static string KeyServerRequestException = "ServerRequestException";
/// <summary>
/// 服务请求。杨斌 2016-10-24
/// </summary>
public static Param ServerRequest(Param e)
{
Param res = new Param();
try
{
if (Globals.SunVoteARSAddIn.IsExitApp)//杨斌 2017-03-02
return res;
res = Servive.Request(e);
}
catch (Exception ex)
{
if (!e.Pa.ContainsKey(KeyServerRequestException))
e.Pa.Add(KeyServerRequestException, ex + "");
//杨斌 2017-12-09
string s = ex.ToString();
}
return res;
}
/// <summary>
/// 立即显示ToolKit,若服务未启动,则后台模式启动ToolKit并显示。杨斌 2017-12-19
/// </summary>
public static void ShowToolKit(string args = "")
{
Param res = new Param();
try
{
if (Globals.SunVoteARSAddIn.IsExitApp)//杨斌 2017-03-02
return;
Param e = new Param();
e.Pa.Add("ShowToolKit", "");
if (!string.IsNullOrEmpty(args))//杨斌 2019-12-06
e.Pa.Add(args, "");
res = Servive.Request(e);
}
catch (Exception ex)
{
//杨斌 2017-12-09
string s = ex.ToString();
if (!string.IsNullOrEmpty(args))//杨斌 2019-12-06
args = " " + args;
RunToolKit("RunBack Show" + args);
}
}
public static string ToolKitName
{
get
{
string res = "SunVote ARS Tool Kit";
string toolKey = "";
if (GlobalInfo.GetSdkType() == 0)
toolKey = "ToolName";
else
toolKey = "ToolNamePvs";
res = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).ReadString("SoftInfo", toolKey, "Tool Kit");
return res;
}
}
/// <summary>
/// 启动ToolKit,参数可以是:"RunBack", "Show"
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
public static bool RunToolKit(string arg)
{
bool res = false;
Process[] process = Process.GetProcessesByName(ToolKitName);
if ((process == null) || (process.Length < 1))//杨斌 2017-12-19
{
string toolName = ToolKitName;
string path = GlobalInfo.APP_DIR + @"\" + toolName + @"\" + toolName + ".exe";
if (File.Exists(path))
{
Process.Start(path, arg);
res = true;
}
}
return res;
}
/// <summary>
/// 颜色对话框的自定义颜色缓存
/// 杨斌 2014-10-16
/// </summary>
public static int[] MyCustomColors = null;
/// <summary>
/// 打开文件对话框选择单个文件
/// sFilter = "Excel(*.xls;*.xlsx)|*.xls;*.xlsx";
/// </summary>
public static string OpenFileDialog(string sFilter = "(*.*)|*.*", string dir = "")
{
string res = "";
try
{
OpenFileDialog dlg = new OpenFileDialog();
if (dir == "")
{
dir = AppDomain.CurrentDomain.BaseDirectory;
dlg.InitialDirectory = dir;
}
dlg.Filter = sFilter;//"Excel(*.xls;*.xlsx)|*.xls;*.xlsx";
if (dlg.ShowDialog() == DialogResult.OK)
{
res = dlg.FileName;
}
}
catch (Exception ex)
{
string sErr = ex + "";
//FrmError.DoErr(ex);
}
return res;
}
/// <summary>
/// 保存文件对话框
/// sFilter = "Excel(*.xls;*.xlsx)|*.xls;*.xlsx";
/// </summary>
public static string SaveFileDialog(string sFilter = "(*.*)|*.*", string dir = "")
{
string res = "";
try
{
SaveFileDialog dlg = new SaveFileDialog();
if (dir == "")
dir = AppDomain.CurrentDomain.BaseDirectory;
dlg.InitialDirectory = dir;
dlg.Filter = sFilter;//杨斌 2012-05-23
dlg.AddExtension = true;
dlg.OverwritePrompt = true;
dlg.ValidateNames = true;
if (dlg.ShowDialog() == DialogResult.OK)
res = dlg.FileName;
}
catch (Exception ex)
{
string sErr = ex + "";
//FrmError.DoErr(ex);
}
return res;
}
}
/// <summary>
/// 硬件信息
/// 创建:杨斌 2010-08-09
/// </summary>
class HardWareInfo
{
/// <summary>
/// 键盘型号W52
/// </summary>
public const string KeypadType_W52 = "W52";
/// <summary>
/// 键盘型号W00
/// </summary>
public const string KeypadType_W00 = "W00";
/// <summary>
/// 键盘型号W40
/// </summary>
public const string KeypadType_W40 = "W40";
/// <summary>
/// 键盘型号M52
/// </summary>
public const string KeypadType_M52 = "M52";
/// <summary>
/// 键盘型号M52+
/// 杨斌 2013-05-08
/// </summary>
public const string KeypadType_M52Plus = "M52Plus";
/// <summary>
/// 键盘型号M30
/// 杨斌 2017-02-07
/// </summary>
public const string KeypadType_M30 = "M30";
/// <summary>
/// 键盘型号M52Li
/// 杨斌 2015-06-17
/// </summary>
public const string KeypadType_M52Li = "M52Li";
/// <summary>
/// 键盘型号M50
/// </summary>
public const string KeypadType_M50 = "M50";
/// <summary>
/// 键盘型号Su30
/// </summary>
public const string KeypadType_Su30 = "Su30";
/// <summary>
/// 键盘型号F00
/// </summary>
public const string KeypadType_F00 = "F00";
/// <summary>
/// 键盘型号M40L
/// 杨斌 2014-02-21
/// </summary>
public const string KeypadType_M40L = "M40L";
/// <summary>
/// 键盘型号S50
/// 杨斌 2014-10-20
/// </summary>
public const string KeypadType_S50 = "M40L";
/// <summary>
/// 基站最小编号
/// </summary>
public const int BaseID_Min = 1;
/// <summary>
/// 基站最大编号
/// </summary>
public const int BaseID_Max = 255;
/// <summary>
/// 基站最小频点
/// </summary>
public const int BaseChannel_Min = 1;
/// <summary>
/// 基站最大频点
/// </summary>
public const int BaseChannel_Max = 80;
/// <summary>
/// 最小键盘编号
/// </summary>
public const int KeypadID_Min = 0;
/// <summary>
/// 最大键盘编号
/// </summary>
public const int KeypadID_Max = 9999;
/// <summary>
/// 键盘最小自动关机时间秒
/// </summary>
public const int KeypadAtuoOff_Min = 0;
/// <summary>
/// 键盘最大自动关机时间秒
/// </summary>
public const int KeypadAtuoOff_Max = 255;
}
}