Response.cs 218 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 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009
///--------------------------------------------------------------------------
/// 文 件 名:Response.cs
/// 功能描述:反馈控制类
/// 修改标识:赵丽 2012-1-10
/// 修改标志:杨斌 2018-04-09
///--------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GeneralLib;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.Data;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using System.Diagnostics;
using KingLib;
using ProService;

namespace SunVoteARSPPT
{
    public delegate void ResponseEventHander(ResponsePar ObjResponsePar);
    /// <summary>
    /// 应用业务接口
    /// </summary>
    public interface IResponse
    {
        /// <summary>
        /// 反馈事件
        /// </summary>
        event ResponseEventHander ResponseEventHander;
        /// <summary>
        /// 启动应用反馈
        /// </summary>
        void Start();
        /// <summary>
        /// 停止应用反馈
        /// </summary>
        void Stop();
        /// <summary>
        /// 基站连接
        /// </summary>
        SunVote.BaseConnection BaseConnection { get; set; }
        /// <summary>
        /// 幻灯片Tag值
        /// </summary>
        TagSet TagSet { get; set; }
        /// <summary>
        /// 反馈类型
        /// </summary>
        ResponseType ResponseType { get; set; }
    }

    /// <summary>
    /// 反馈数据类
    /// </summary>
    public class ResponsePar
    {
        /// <summary>
        /// 基站标签
        /// </summary>
        public string BaseTag { get; set; }

        /// <summary>
        /// 键盘ID
        /// </summary>
        public string KeyID { get; set; }
        /// <summary>
        /// 键盘值
        /// </summary>
        public string KeyValue { get; set; }
        /// <summary>
        /// 按键速度,即答题用时(秒),用于名单排序,得分相同比速度
        /// </summary>
        public double Speed { get; set; }
        /// <summary>
        /// 按键日期时间,如签到时间
        /// </summary>
        public DateTime Time { get; set; }
        /// <summary>
        /// 是否答对(答对个数) 
        /// </summary>
        public int Correct { get; set; }
        /// <summary>
        /// 答题得分
        /// </summary>
        public double Score { get; set; }
        ///// <summary>
        ///// 确认键。杨斌 2020-06-16
        ///// </summary>
        //public int CommitOK = -1;
    }

    /// <summary>
    /// 候选人信息
    /// </summary>
    public class CandidateInfo
    {
        /// <summary>
        /// 候选人ID
        /// </summary>
        public string CandidateID { get; set; }
        /// <summary>
        /// 候选人名称
        /// </summary>
        public string CandidateName { get; set; }

    }

    public enum ResponseStatus
    {
        /// <summary>
        /// 准备
        /// </summary>
        bsReady = 0,
        /// <summary>
        /// 开始
        /// </summary>
        bsStart = 1,
        /// <summary>
        /// 停止
        /// </summary>
        bsStop = 2,
    }

    /// <summary>
    /// 排序记分元素
    /// 杨斌 2014-04-18
    /// </summary>
    public class OrderItem
    {
        public int No = 0;
        public double Score = 0;
        public int[] Count = null;

        public OrderItem(int no, double score, int[] count)
        {
            No = no;
            Score = score;
            Count = count;
        }
    }

    /// <summary>
    /// 到时停止
    /// </summary>
    public delegate void StopEventHander();
    /// <summary>
    /// 下一张幻灯片
    /// </summary>
    public delegate void NextSlideEventHander();
    /// <summary>
    /// 启用名单事件
    /// </summary>
    public delegate void VoteListEnabledEventHander(bool enabled);
    /// <summary>
    /// 有反馈时间
    /// </summary>
    public delegate void IsResponsedEventHander();
    /// <summary>
    /// 应用业务类
    /// </summary>
    public class Response
    {
        public event VoteListEnabledEventHander VoteListEnabledEvent;
        //public event StopEventHander StopEvent;//杨斌 2014-08-20 屏蔽
        public event IsResponsedEventHander IsResponsedEvent;
        /// <summary>
        /// 下一张幻灯片
        /// </summary>
        public event NextSlideEventHander NextSlideEvent;
        /// <summary>
        /// 键盘反馈信息
        /// </summary>
        public TDictionary<string, ResponsePar> ResponseDataList { get; set; }
        //public 
        /// <summary>
        /// 存储选项反馈数量
        /// </summary>
        public Dictionary<string, double> ResponseOptionList { get; set; }
        /// <summary>
        /// 存储选项反馈数量,不计算权重。杨斌 2016-11-12
        /// </summary>
        public Dictionary<string, double> ResponseOptionListNoRate { get; set; }
        /// <summary>
        /// 存储选项反馈数量,重复按键值的。杨斌 2016-01-07
        /// </summary>
        public Dictionary<string, double> ResponseOptionListCount { get; set; }
        /// <summary>
        /// 保存更新的键盘信息
        /// </summary>
        public TDictionary<string, ResponsePar> ResponseKeypadList { get; set; }
        /// <summary>
        /// 键盘授权列表
        /// </summary>
        public Dictionary<string, string> AuthorKeypadList { get; set; }

        /// <summary>
        /// 抢答成功的键盘编号。翻页时清除。抢答成功后赋值。优先于授权
        /// 杨斌 2014-05-20
        /// </summary>
        public string KeyIDQDOK = "";

        /// <summary>
        /// 候选人信息
        /// </summary>
        public Dictionary<string, CandidateInfo> CandidateInfoList { get; set; }
        /// <summary>
        /// 签到码信息 2012-06-18
        /// </summary>
        public Dictionary<string, string> SignInCode { get; set; }
        /// <summary>
        /// 幻灯片内存值
        /// </summary>
        public TagSet TagSet = new TagSet();
        /// <summary>
        /// 当前幻灯片
        /// </summary>
        public PowerPoint.Slide CurrentSlide { get; set; }
        /// <summary>
        /// 反馈对象
        /// </summary>
        public IResponse Busines = null;
        /// <summary>
        /// 远程控制
        /// </summary>
        public SunVote.Request ARSRequest = null;
        /// <summary>
        /// 下一张幻灯片
        /// </summary>
        public bool NextSlide = false;
        /// <summary>
        /// 下一张幻灯片自动开始反馈,在幻灯片翻页事件中判断调用启动反馈
        /// 杨斌 2012-03-06
        /// </summary>
        public bool NextSlideAutoStart = false;
        /// <summary>
        /// 是否允许刷新图表
        /// </summary>
        public bool AllowRefreshChart = false;
        /// <summary>
        /// 其他操作时,投票无效,如:键盘替换过程
        /// </summary>
        public bool IsAnOtherOper = false;

        /// <summary>
        /// 记录原来设置的事件
        /// </summary>
        private string oldTimerValue = "00:30";

        /// <summary>
        /// 是否启用名单 true:是
        /// </summary>
        public bool EnableList
        {
            get
            {
                //杨斌 2015-03-27。避免重复查询性能问题。
                //return new RosterList().RosterEnabled;
                return Globals.Ribbons.rbSunVoteARS.chkVoterEnabled.Checked;
            }
            set
            {
                VoteListEnabledEvent(value);
                new RosterList().RosterEnabled = value;
                if (value)
                {
                    InitRosterInfo();//这里可能有问题。如果重新导入名单,新的值没有被加载。杨斌 2012-11-27
                }
            }
        }

        /// <summary>
        /// 是否启用签到码
        /// </summary>
        public int SignInCodeIndex
        {
            get
            {
                return new RosterList().SignInCodeIndex;
            }
            set
            {
                new RosterList().SignInCodeIndex = value;
            }
        }

        /// <summary>
        /// 作为显示姓名的字段
        /// 杨斌 2013-12-23
        /// </summary>
        public string ShowNameCol
        {
            get
            {
                string col = "";
                try
                {
                    col = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags["ShowNameField"];
                }
                catch { }
                return col;
            }
            set
            {
                try
                {
                    Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags.Add("ShowNameField", value);
                }
                catch { }
            }
        }

        /// <summary>
        /// 报表中显示的字段
        /// 杨斌 2015-11-27
        /// </summary>
        public string ShowReportCol
        {
            get
            {
                string col = "";
                try
                {
                    col = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags["ShowReportCol"];
                }
                catch { }
                return col;
            }
            set
            {
                try
                {
                    Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags.Add("ShowReportCol", value);
                }
                catch { }
            }
        }

        public string VoteWeightCol
        {
            get
            {
                string col = "";
                try
                {
                    col = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags["VoteWeightCol"];
                }
                catch { }
                return col;
            }
            set
            {
                try
                {
                    Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags.Add("VoteWeightCol", value);
                }
                catch { }
            }
        }

        /// <summary>
        /// 作为学号或身份ID判定的字段
        /// 杨斌 2013-12-23
        /// </summary>
        public string UIDCol
        {
            get
            {
                string col = "";
                //try
                //{
                //    col = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags["UIDField"];                   

                //}
                //catch { }

                try//杨斌 2015-11-03
                {
                    string sql = "Select * From ST_TopicPar Where TP_Name='UIDCol'";
                    DataSet ds = GlobalInfo.DBOperation.GetDataSet(sql);
                    if (ds.Tables.Count > 0)
                    {
                        DataTable tb = ds.Tables[0];
                        if (tb.Rows.Count > 0)
                            col = tb.Rows[0]["TP_Value"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    SystemLog.WriterLog(ex);
                }

                return col;
            }
            set
            {
                //try
                //{
                //    Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags.Add("UIDField", value);
                //}
                //catch { }

                try//杨斌 2015-11-03
                {
                    string sql = "Select * From ST_TopicPar Where TP_Name='UIDCol'";
                    GlobalInfo.DBOperation.OpenDataSet(sql);
                    if (GlobalInfo.DBOperation.DataSet.Tables.Count > 0)
                    {
                        DataTable tb = GlobalInfo.DBOperation.DataSet.Tables[0];
                        if (tb.Rows.Count > 0)
                        {
                            tb.Rows[0]["TP_Value"] = value;
                            GlobalInfo.DBOperation.UpdateDataSet();
                        }
                        else
                        {
                            GlobalInfo.DBOperation.CloseDataSet();
                            sql = "INSERT INTO ST_TopicPar (TP_Name, TP_Value)" +
                                    " VALUES ('UIDCol', '" + value + "')";
                            GlobalInfo.DBOperation.ExecuteNonQuery(sql);
                        }
                    }
                    GlobalInfo.DBOperation.CloseDataSet();
                }
                catch (Exception ex)
                {
                    SystemLog.WriterLog(ex);
                }
            }
        }

        private static string ShowMapColListCount = "ShowMapColListCount";
        private static string ShowMapColListKey = "ShowMapColListKey";
        /// <summary>
        /// 作为显示按键明细的字段,自定义多个。若个数为0则非自定义
        /// 杨斌 2014-09-09
        /// </summary>
        public List<string> ShowMapColList
        {
            get
            {
                List<string> lstCol = new List<string>();
                try
                {
                    PowerPoint.Tags tags = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags;
                    int count = ConvertOper.Convert(tags[ShowMapColListCount]).ToInt;
                    for (int i = 1; i <= count; i++)
                    {
                        string name = tags[ShowMapColListKey + i];
                        lstCol.Add(name);
                    }
                }
                catch { }
                return lstCol;
            }
            set
            {
                try
                {
                    PowerPoint.Tags tags = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags;
                    tags.Add(ShowMapColListCount, value.Count.ToString());
                    for (int i = 0; i < value.Count; i++)
                    {
                        tags.Add(ShowMapColListKey + (i + 1), value[i]);
                    }
                }
                catch { }
            }
        }

        /// <summary>
        /// 作为显示按键明细的字段
        /// 杨斌 2014-06-16
        /// </summary>
        public string ShowMapCol
        {
            get
            {
                string col = "";
                try
                {
                    col = Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags["ShowMapCol"];
                    if (col == "")
                        col = ShowNameCol;
                }
                catch { }
                return col;
            }
            set
            {
                try
                {
                    Globals.SunVoteARSAddIn.Application.ActivePresentation.Tags.Add("ShowMapCol", value);
                }
                catch { }
            }
        }

        /// <summary>
        /// 投票键盘权重
        /// 创建:杨斌 2012-11-27
        /// </summary>
        public int VoteRateIndex
        {
            get
            {
                return new RosterList().VoteRateIndex;
            }
            set
            {
                new RosterList().VoteRateIndex = value;
            }
        }

        /// <summary>
        /// 保存播放状态时的幻灯片图表显示状态
        /// 杨斌 2014-12-04
        /// </summary>
        public Dictionary<int, bool> DicSlideShowChart = new Dictionary<int, bool>();

        /// <summary>
        /// 是否手动启用显示图表
        /// </summary>
        private bool showPicture = false;
        public bool ShowPicture
        {
            get { return showPicture; }
            set
            {
                showPicture = value;
                if (value)
                {
                    ////刷新图表
                    RefreshChart();

                    //杨斌 2016-06-21
                    if (Globals.SunVoteARSAddIn.PPTShow.SlideShow != null)
                        if (Globals.SunVoteARSAddIn.PPTShow.IsChartShowWindow(Globals.SunVoteARSAddIn.PPTShow.SlideShow))
                            if ((Globals.SunVoteARSAddIn.PPTShow.FrmChart != null) && (!Globals.SunVoteARSAddIn.PPTShow.FrmChart.Visible))
                                Globals.SunVoteARSAddIn.PPTShow.FrmChart.ShowCenter();
                }
                else
                {
                    //隐藏图片
                    foreach (PowerPoint.Shape s in CurrentSlide.Shapes)
                    {
                        if (s.Name == "pic")
                            s.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                    }

                    //杨斌 2016-06-21
                    if (Globals.SunVoteARSAddIn.PPTShow.SlideShow != null)
                        if (Globals.SunVoteARSAddIn.PPTShow.IsChartShowWindow(Globals.SunVoteARSAddIn.PPTShow.SlideShow))
                            if ((Globals.SunVoteARSAddIn.PPTShow.FrmChart != null) && (Globals.SunVoteARSAddIn.PPTShow.FrmChart.Visible))
                                Globals.SunVoteARSAddIn.PPTShow.FrmChart.Hide();
                }
                PPTOper.ShowDataLabel(CurrentSlide, DataLabelType.VOTEMEAN, value);//显示平均值。杨斌 2014-04-15

                PPTOper.ShowDataLabel(CurrentSlide, DataLabelType.VoteMedian, value);//显示中间值。杨斌 2016-03-29
                PPTOper.ShowDataLabel(CurrentSlide, DataLabelType.VoteRange, value);//显示投票范围。杨斌 2016-03-29

                PPTOper.ShowDataLabel(CurrentSlide, DataLabelType.GradeAvg, value);//显示评议平均分。杨斌 2019-06-27

                PPTOper.ShowTableVoteCount(CurrentSlide, false, LabelTypes.ltNone, 0, true);//杨斌 2016-11-12
            }
        }
        /// <summary>
        /// 图表显示方式
        /// </summary>
        private ChartViewType chartViewType = ChartViewType.csStop;
        public ChartViewType ChartViewType
        {
            get { return chartViewType; }
            set { chartViewType = value; }
        }
        /// <summary>
        /// 停止状态,停止时控制图表显示
        /// </summary>
        //public bool IsStop = false;
        /// <summary>
        /// 键盘授权:是否所有人,Ture 是
        /// </summary>
        public bool IsAllPerson = true;

        /// <summary>
        /// 自定义背景音乐。杨斌 2015-04-10
        /// </summary>
        public string SlideBackMusic = "";

        public bool IsNextSlide = false;
        /// <summary>
        /// 业务状态:true 开始
        /// </summary>
        private ResponseStatus businessStatus = ResponseStatus.bsReady;
        public ResponseStatus BusinessStatus
        {
            get { return businessStatus; }
            set
            {
                if (businessStatus != value)
                {

                    businessStatus = value;
                    //点开始恢复时间,先恢复时间标签,再启用定时器

                    //tmrTimer.Enabled = (value == ResponseStatus.bsStart ? true : false);
                    //若启动投票时,计时器为0,则恢复初始值,开始计时。计时器设置为0则自动变为30秒。 杨斌 2012-03-15
                    if (value == ResponseStatus.bsStart)
                    {
                        if (GetTimerCount() <= 0)
                        {
                            List<PowerPoint.Shape> lstShape = PPTOper.GetDataLabelShape(CurrentSlide, DataLabelType.TIMER);
                            foreach (PowerPoint.Shape shape in lstShape)
                            {
                                shape.TextFrame.TextRange.Text = TagSet.GetValue(TagKey.ResponseTimer).Value;
                            }
                        }
                        //shape.TextFrame.TextRange.Text = TagSet.GetValue(TagKey.ResponseTimer).Value;
                        tmrTimer.Enabled = true;
                    }
                    else
                    {
                        tmrTimer.Enabled = false;
                    }

                    //杨斌 2015-03-27
                    if (value == ResponseStatus.bsStart)
                    {
                        //杨斌 2015-04-01。修复Interval=0的错误,导致签到码签到清空后不能签到了。
                        int voterCount = GetParticipateNum();
                        int itv = voterCount * 1;
                        if (itv < 1000)
                            itv = 1000;
                        tmrRefresh.Interval = itv;

                        tmrRefresh.Enabled = true;
                    }
                    else
                    {
                        tmrRefresh.Enabled = false;
                    }

                    if (value != ResponseStatus.bsStop)
                    {
                        TagSet tagSet = new SunVoteARSPPT.TagSet(CurrentSlide.Tags);
                        int runTimeShowScore = tagSet.GetValue(TagKey.Score_RunTimeShowScore).ToInt;
                        int showTotal = tagSet.GetValue(TagKey.Score_ShowTotal).ToInt;
                        int showAvg = tagSet.GetValue(TagKey.Score_ShowAvg).ToInt;

                        IsNextSlide = false;
                        foreach (PowerPoint.Shape shape in CurrentSlide.Shapes)
                        {
                            switch (shape.Name)
                            {
                                case "TIMER":
                                    //陈总说:继续时剩下几秒,就是几秒。屏蔽下面一行代码即可继续计时。杨斌 2012-03-15
                                    //shape.TextFrame.TextRange.Text = TagSet.GetValue(TagKey.ResponseTimer).Value;
                                    break;
                                case "SUMSCORE"://杨斌 2016-12-13
                                    if (value == ResponseStatus.bsStart)
                                    {
                                        if ((runTimeShowScore == 1) && (showTotal == 1))
                                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                                        else
                                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                                    }
                                    break;
                                case "AVGSCORE"://杨斌 2016-12-13
                                    if (value == ResponseStatus.bsStart)
                                    {
                                        if ((runTimeShowScore == 1) && (showAvg == 1))
                                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                                        else
                                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                                    }
                                    break;
                                case "AVGScoreGroup"://杨斌 2015-07-28
                                case "AVGScoreTableGroup":
                                case "AVGScoreTableGroupDetail":
                                    if (value == ResponseStatus.bsStart)
                                        shape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                                    break;
                            }
                        }
                        RefreshChart();
                        //HidePicture();
                    }
                    else
                    {
                        if (value == ResponseStatus.bsStop)
                        {
                            //评分刷新分数
                            if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Score)
                                CaculateScore(Globals.SunVoteARSAddIn.PPTShow.SlideShow, true);
                            RefreshLable();
                            RefreshChart();//ToDo: 高度可能为0,则出错,影响下面代码执行
                            //RefreshPollRank();
                        }
                    }
                }

                //杨斌 2015-03-17
                //if (businessStatus != ResponseStatus.bsStop)
                ////if (businessStatus == ResponseStatus.bsStart) //启动了才需要停止
                //{
                //    if (Busines != null)
                //        Busines.Stop();
                //}
                if (value == ResponseStatus.bsStop)
                {
                    if (Busines != null)
                        Busines.Stop();
                }

                if (businessStatus == ResponseStatus.bsStart)
                {
                    InitBusines();

                    //杨斌 2015-04-10
                    if (string.IsNullOrEmpty(SlideBackMusic))
                    {
                        if (GlobalInfo.sysConfig.BackgSoundEnabled)
                            GlobalInfo.DXSoundPlay.PlayLoop(GlobalInfo.Sound_Key_Back);
                    }
                    else
                    {
                        GlobalInfo.DXSoundPlay.PlayLoop(GlobalInfo.Sund_Key_BackSlide);
                    }
                }

                //杨斌 2015-04-10
                if (businessStatus == ResponseStatus.bsStop)
                {
                    GlobalInfo.DXSoundPlay.Stop(GlobalInfo.Sound_Key_Back);
                    GlobalInfo.DXSoundPlay.Stop(GlobalInfo.Sund_Key_BackSlide);
                }

            }

        }


        /// <summary>
        /// 记录参与者人数
        /// </summary>
        private double ParticipateNum = 0;
        /// <summary>
        /// 刷新定时器标签
        /// </summary>
        private System.Windows.Forms.Timer tmrTimer = null;
        /// <summary>
        /// 刷新标签、图表
        /// </summary>
        public System.Windows.Forms.Timer tmrRefresh = null;

        /// <summary>
        /// 反馈数据库业务存取模块
        /// </summary>
        private ResponseDB ResponseDB = new ResponseDB();

        public Response()
        {
            ResponseDataList = new TDictionary<string, ResponsePar>();
            ResponseOptionList = new Dictionary<string, double>();
            ResponseOptionListNoRate = new Dictionary<string, double>();//杨斌 2016-11-12
            ResponseOptionListCount = new Dictionary<string, double>();
            ResponseKeypadList = new TDictionary<string, ResponsePar>();
            AuthorKeypadList = new Dictionary<string, string>();
            CandidateInfoList = new Dictionary<string, CandidateInfo>();
            //2012-06-18 赵丽 签到码数据
            SignInCode = new Dictionary<string, string>();
            tmrTimer = new System.Windows.Forms.Timer();
            tmrTimer.Interval = 1000;
            tmrTimer.Tick += new EventHandler(tmrTimer_Tick);
            tmrTimer.Enabled = false;

            tmrRefresh = new System.Windows.Forms.Timer();
            tmrRefresh.Interval = 1000;
            tmrRefresh.Tick += new EventHandler(tmrRefresh_Tick);
            tmrRefresh.Enabled = false;

            //不需要,屏蔽。杨斌 2016-12-13
            //ARSRequest = new SunVote.Request();
            //ARSRequest.BaseConnection = GlobalInfo.baseConnect.baseConnection;

        }

        /// <summary>
        /// 投票键盘权重:key=键盘,item=权重值(默认=1)
        /// 创建:杨斌 2012-11-27
        /// </summary>
        public TDictionary<string, double> VoterRate = new TDictionary<string, double>();

        /// <summary>
        /// 初始化签到码字段
        /// //杨斌 2017-03-30
        /// </summary>
        public void InitRosterSignInCode(PowerPoint.Slide sld)
        {
            try
            {
                SignInCode.Clear();

                FrmVoteDetail frmDetail = Globals.SunVoteARSAddIn.frmVoteBar.frmVoteDetail;
                if (frmDetail != null)
                    frmDetail.SignInCodeIndex = 0;

                TagSet tagSet = new TagSet(sld.Tags);

                int sinMode = tagSet.GetValue(TagKey.SignIn_Mode).ToInt;
                string colName = "";
                if (sinMode == 1)
                {
                    colName = tagSet.GetValue(TagKey.SignIn_CodeField).Value;
                    if (colName.Length < 1)
                        return;
                }

                RosterList Roster = new RosterList();
                int colIndex = -1;

                if (!Roster.RosterEnabled) return;

                Roster.LoadRoster();

                if (sinMode == 1)
                {
                    for (int i = 0; i < Roster.Columns.Count; i++)
                    {
                        if (Roster.Columns[i].ColumnName == colName)
                        {
                            colIndex = i;
                            break;
                        }
                    }
                }
                else if (sinMode == 2)
                {
                    colIndex = Roster.Columns.Count - 1;
                }

                if (frmDetail != null)
                    frmDetail.SignInCodeIndex = colIndex;

                if (colIndex == -1)
                    return;

                for (int i = 0; i < Roster.Rows.Count; i++)
                {
                    string keyID = Roster.Rows[i].Cells[0].ToString();
                    //签到码
                    if (keyID != "")
                    {
                        if (!SignInCode.Keys.Contains(keyID))
                        {
                            string code = Roster.Rows[i].Cells[colIndex].ToString();
                            SignInCode.Add(keyID, code);
                        }
                    }
                }
                //}
                //if (sinMode == 2)//杨斌 2017-03-30
                //{
                //    Dictionary<string, string> dicRUID = FrmVoterList.GetDicRUID(Roster);
                //    for (int i = 0; i < Roster.Rows.Count; i++)
                //    {
                //        string keyID = Roster.Rows[i].Cells[0].ToString();
                //        if (keyID != "")
                //        {
                //            if (!SignInCode.Keys.Contains(keyID))
                //            {
                //                string rid = Roster.Rows[i].RowIndex + "";
                //                if (dicRUID.ContainsKey(rid))
                //                    SignInCode.Add(keyID, dicRUID[rid]);
                //            }
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex, false);
            }
        }

        /// <summary>
        /// 权重值总和。杨斌 2015-01-26
        /// </summary>
        public double VoteRateSum = 0;
        /// <summary>
        /// 人员名单总数
        /// </summary>
        public double RousterCount = 0;
        /// <summary>
        /// 初始化权重字段
        /// 杨斌 2014-10-27
        /// 杨斌 2015-01-26
        /// 杨斌 2015-03-27
        /// </summary>
        public void InitRosterVoteRate(PowerPoint.Slide sld)
        {
            try
            {
                VoterRate.Clear();
                VoteRateSum = 0;//反馈人数总权重
                totalWeight = 0;//参与人数总权重

                TagSet tagSet = new TagSet(sld.Tags);
                string colName = tagSet.GetValue(TagKey.ResponsePara_VoteRateField).Value;
                if (colName.Length < 1)
                    return;

                RosterList Roster = new RosterList();
                int colIndex = -1;

                if (!Roster.RosterEnabled) return;

                Roster.LoadRoster();

                RousterCount = Roster.Rows.Count;//杨斌 2015-03-27

                for (int i = 0; i < Roster.Columns.Count; i++)
                {
                    if (Roster.Columns[i].ColumnName == colName)
                    {
                        colIndex = i;
                        break;
                    }
                }

                if (colIndex == -1)
                    return;

                for (int i = 0; i < Roster.Rows.Count; i++)
                {
                    string keyID = Roster.Rows[i].Cells[0].ToString();
                    //杨斌 2015-03-27
                    if (GlobalInfo.response.ResponseDataList.Contains(keyID))
                        VoteRateSum += ConvertOper.Convert(Roster.Rows[i].Cells[colIndex].ToString()).ToDouble;

                    //权重
                    if (keyID != "")
                    {
                        if (!VoterRate.Contains(keyID))
                        {
                            //小数点问题处理。杨斌 2020-02-20
                            bool beConvert = true;
                            double rate = 0;
                            if (beConvert)
                                rate = ConvertOper.Convert(Roster.Rows[i].Cells[colIndex].ToString()).ToDouble;//2020-02-20 权重小数点问题                            
                            else
                                double.TryParse(Roster.Rows[i].Cells[colIndex].ToString(), out rate);

                            totalWeight += rate;
                            //杨斌 2018-05-22
                            if (rate < 0)
                                rate = 0;
                            //if (rate <= 0) rate = 1;
                            VoterRate.Add(keyID, rate);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex, false);
            }
        }

        //2014-3-17 增加权重总值
        public double totalWeight = 0;
        /// <summary>
        /// 创建 赵丽 2012-06-18 
        /// 创建:杨斌 2012-11-27
        /// 加载签到码信息、加载投票键盘权重
        /// </summary>
        public void InitRosterInfo()
        {
            //取消该函数功能。将名单中字段设置移到签到和投票权重设置的面板中独立设置。在播放时初始化。杨斌 2014-10-27
            //拆分函数分别为InitRosterSignInCode,InitRosterVoteRate
            return;
            try
            {
                totalWeight = 0;
                SignInCode.Clear();
                VoterRate.Clear();

                RosterList Roster = new RosterList();

                if (!Roster.RosterEnabled) return;

                Roster.LoadRoster();

                for (int i = 0; i < Roster.Rows.Count; i++)
                {
                    string keyID = Roster.Rows[i].Cells[0].ToString();
                    //签到码
                    if (!SignInCode.Keys.Contains(keyID))
                    {
                        string code = Roster.Rows[i].Cells[GlobalInfo.response.SignInCodeIndex].ToString();
                        SignInCode.Add(keyID, code);
                    }
                    if (keyID != "")
                    {
                        //投票键盘权重
                        if ((GlobalInfo.response.VoteRateIndex > 0) && (!VoterRate.Contains(keyID)))
                        {
                            double rate = ConvertOper.Convert(Roster.Rows[i].Cells[GlobalInfo.response.VoteRateIndex].ToString()).ToDouble;
                            totalWeight += rate;
                            //杨斌 2018-05-22
                            if (rate < 0)
                                rate = 0;
                            //if (rate <= 0) rate = 1;
                            VoterRate.Add(keyID, rate);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex, false);
            }
        }

        /// <summary>
        /// 改成public,停止时再调用一次刷新。杨斌 2015-03-30。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void tmrRefresh_Tick(object sender, EventArgs e)
        {
            //tmrRefresh.Enabled = false;//屏蔽。杨斌 2018-12-25。修改:杨斌 2015-03-27

            //杨斌 2018-12-14。注销下面代码
            ////杨斌 2015-04-10
            //if (businessStatus != ResponseStatus.bsStart)
            //    return;

            RefreshPPTShowObjects();//杨斌 2018-04-20

            //tmrRefresh.Enabled = true;//屏蔽。杨斌 2018-12-25。修改:杨斌 2015-03-27
        }

        /// <summary>
        /// 刷新播放幻灯片的所有对象。杨斌 2018-04-20
        /// </summary>
        public void RefreshPPTShowObjects()
        {
            RefreshLable();
            //RefreshPollRank();
            //ChartViewType chartViewType=EnumName<ChartViewType>.GetEnum(TagSet.GetValue(TagKey.ChartPara_ShowTime).Value);
            switch (chartViewType)
            {
                case ChartViewType.csStart:
                    RefreshChart();
                    break;
                default:
                    break;
            }
            if (showPicture)
                RefreshChart();

            //实时计算分数。杨斌 2016-04-15
            if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Score)
            {
                CaculateScore(Globals.SunVoteARSAddIn.PPTShow.SlideShow);
            }

            //杨斌 2015-03-27
            if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar != null)
            {
                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.ChangeDataInitMap();
                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.ReDrawMap();
            }
        }

        /// <summary>
        /// 获取计时器时间
        /// 创建:杨斌 2012-03-15
        /// </summary>
        /// <returns></returns>
        public int GetTimerCount()
        {
            int res = 0;
            try
            {
                string lblText = "";

                List<PowerPoint.Shape> lstShape = PPTOper.GetDataLabelShape(CurrentSlide, DataLabelType.TIMER);
                foreach (PowerPoint.Shape shape in lstShape)
                {
                    lblText = shape.TextFrame.TextRange.Text.Trim();
                    res = ConvertOper.TimeToSecond(lblText);
                    break;
                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex, false);
            }
            return res;
        }

        void tmrTimer_Tick(object sender, EventArgs e)
        {
            string lblText = "";
            string[] s;

            List<PowerPoint.Shape> lstShape = PPTOper.GetDataLabelShape(CurrentSlide, DataLabelType.TIMER);
            foreach (PowerPoint.Shape shape in lstShape)
            {
                lblText = shape.TextFrame.TextRange.Text.Trim();
                lblText = GetTimerValue(lblText);
                s = lblText.Split(':');
                //秒值
                int sValue = ConvertOper.Convert(s[1]).ToInt;
                //分钟值
                int mValue = ConvertOper.Convert(s[0]).ToInt;
                //时间到
                if ((sValue == 0) && (mValue == 0))
                {
                    //反馈停止
                    //if (StopEvent != null) { StopEvent(); }//杨斌 2014-08-20 屏蔽

                    //杨斌 2014-11-05
                    if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsVoteStart)
                    {
                        Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.VoteStart(false);
                        if (!Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsVoteStart && GlobalInfo.sysConfig.StopShowCorrectAsw)//杨斌 2019-09-03
                        {
                            Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.tsbCorrectAnswer.Checked = true;//ShowCorrectAnswerButtonState();
                        }
                    }

                    if (GlobalInfo.sysConfig.IsAutoPageTimeOut)
                    {
                        //tmrRefresh.Enabled = false;                                                

                        //杨斌 2014-08-20
                        if ((!Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.tmrDelayVoteStart.Enabled) &&
                            (!Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsRunNextSlideEvent))
                        {
                            Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsAutoPageTimeOut = true;
                            Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.DelayVoteStart = GlobalInfo.sysConfig.AutoPageWaitTime;
                            NextSlide = true;
                            //NextSlideEvent();//用事件会发生意外的时序,乱。杨斌 2014-08-20
                            Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.response_NextSlideEvent();
                        }
                    }
                    return;
                }
                if (sValue == 0) { mValue = mValue - 1; sValue = 59; } else { sValue = sValue - 1; }
                s[1] = sValue.ToString().PadLeft(2, '0');
                s[0] = mValue.ToString().PadLeft(2, '0');
                shape.TextFrame.TextRange.Text = s[0] + ":" + s[1];
                if (VoteServer.IsStart)
                    Globals.SunVoteARSAddIn.PPTShow.SendSlideScreenTimer();//多地点刷新计时器。杨斌 2018-06-25
                break;
            }
        }

        /// <summary>
        /// 转换时间值
        /// </summary>
        /// <param name="strValue"></param>
        /// <returns></returns>
        internal static string GetTimerValue(string strValue)
        {
            if (strValue.IndexOf(":") == -1)
            {
                int t = ConvertOper.Convert(strValue).ToInt;
                string mm = (t / 60).ToString().PadLeft(2, '0');
                string ss = (t % 60).ToString().PadLeft(2, '0');
                strValue = mm + ":" + ss;
            }
            return strValue;
        }

        /// <summary>
        /// 清空反馈数据
        /// 创建 赵丽
        /// </summary>
        public void ClearResponse()
        {
            try
            {
                //初始化标签
                InitLable();
                //清空所有内存
                ResponseDataList.Clear();
                LstResponseData.Clear();//杨斌 2016-01-13
                ResponseOptionList.Clear();
                ResponseOptionListNoRate.Clear();//杨斌 2016-11-12
                ResponseOptionListCount.Clear();//杨斌 2016-01-07
                ResponseKeypadList.Clear();
                //初始化选项个数列表(1-10)
                for (int i = 0; i < 10; i++)
                {
                    ResponseOptionList.Add(i.ToString(), 0);
                    ResponseOptionListNoRate.Add(i.ToString(), 0);//杨斌 2016-11-12
                    ResponseOptionListCount.Add(i.ToString(), 0);//杨斌 2016-01-07
                }
                ClearScoreLable();
                RefreshLable();
                GlobalInfo.response.ShowPicture = true;
                RefreshChart();
                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.ClearMapData();
            }
            catch (Exception ex)
            {
            }
            //重新添加定时器标签
            //清空所有标签
        }

        /// <summary>
        /// 选项文本排序。停止时排序,开始或清除时恢复原来顺序。
        /// 杨斌 2014-04-25
        /// </summary>
        /// <param name="isSort"></param>
        public void SetOrderOptionText(PowerPoint.Slide slide, bool isSort)
        {
            try
            {
                if (slide == null)
                    return;

                TagSet tagSet = new TagSet(slide.Tags);
                ResponseType rType = EnumName<ResponseType>.GetEnum(tagSet.GetValue(TagKey.ResponseType).Value.ToString());

                if (rType != ResponseType.Order) return;

                int scoreMode = tagSet.GetValue(TagKey.Order_ScoreMode).ToInt;
                if (scoreMode != 1) return;

                if (isSort)
                {
                    PowerPoint.Shape shaOpt = PPTOper.GetOptionTextLinkShape(slide);
                    if (shaOpt != null)
                    {
                        string[] aryOpt = PPTOper.GetShapeOptionText(shaOpt);
                        List<string> lstNewOpt = new List<string>();
                        string sortResult = "";
                        for (int i = 0; i < GlobalInfo.response.ListOrderScore.Count; i++)
                        {
                            OrderItem odItem = GlobalInfo.response.ListOrderScore[i];
                            if (i > 0)
                                sortResult += ",";
                            sortResult += odItem.No;

                            if (aryOpt.Length >= odItem.No)
                                lstNewOpt.Add(odItem.No + ". " + aryOpt[odItem.No - 1]);
                        }
                        tagSet.SetValue(TagKey.Order_SortResult, sortResult);

                        shaOpt.TextFrame.TextRange.Paragraphs(-1, -1).ParagraphFormat.Bullet.Type = PowerPoint.PpBulletType.ppBulletNone;
                        shaOpt.TextFrame.TextRange.Text = PPTOper.FormatShapeOptionText(lstNewOpt.ToArray());
                    }
                }
                else
                {
                    PowerPoint.Shape shaOpt = PPTOper.GetOptionTextLinkShape(slide);
                    if (shaOpt != null)
                    {
                        string sortResult = tagSet.GetValue(TagKey.Order_SortResult).Value;
                        if (sortResult.Length > 0)
                        {
                            string[] arySort = sortResult.Split(new char[] { ',' });
                            if (arySort.Length > 0)
                            {
                                string[] aryOpt = PPTOper.GetShapeOptionText(shaOpt);
                                List<string> lstOldOpt = arySort.ToList<string>();
                                for (int i = 0; i < arySort.Length; i++)
                                {
                                    int n = ConvertOper.Convert(arySort[i]).ToInt - 1;
                                    if (aryOpt.Length > i)
                                    {
                                        string sNo = (n + 1) + ".";
                                        int m = aryOpt[i].IndexOf(sNo);
                                        if (m >= 0)
                                            lstOldOpt[n] = aryOpt[i].Substring(sNo.Length).TrimStart(new char[] { ' ' });
                                        else
                                            lstOldOpt[n] = aryOpt[i];
                                    }
                                }
                                tagSet.SetValue(TagKey.Order_SortResult, "");

                                PPTOper.SetShapeOptionText(shaOpt, PPTOper.FormatShapeOptionText(lstOldOpt.ToArray()), false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }

        /// <summary>
        /// 清除评分标签
        /// 杨斌 2015-07-28
        /// </summary>
        public void ClearScoreLable()
        {
            foreach (PowerPoint.Shape shape in CurrentSlide.Shapes)
            {
                if ((shape.Name == "SUMSCORE") || (shape.Name == "AVGSCORE")
                    || (shape.Name == "AVGScoreGroup"))
                {
                    string lblText = shape.TextFrame.TextRange.Text.Trim();
                    string[] s = lblText.Split(':');
                    if (s.Length >= 2)//杨斌 2015-07-28                                      
                        lblText = s[0].TrimEnd(' ') + " : " + "0";//杨斌 2019-06-06//lblText = s[0] + ":" + "0";
                    else
                        lblText = "0";
                    shape.TextFrame.TextRange.Text = lblText;
                }
                if (shape.Name == "AVGScoreTableGroup")
                {
                    try
                    {
                        if (shape.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            //杨斌 2015-11-24
                            for (int i = 2; i <= shape.Table.Rows.Count; i++)
                            {
                                if (shape.Table.Columns.Count >= 3)
                                    shape.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text = "0";
                                if (shape.Table.Columns.Count >= 4)
                                    shape.Table.Cell(i, 4).Shape.TextFrame.TextRange.Text = "0";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SystemLog.WriterLog(ex);
                    }
                }
                if (shape.Name == "AVGScoreTableGroupDetail")
                {
                    try
                    {
                        if (shape.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            //杨斌 2015-11-24
                            for (int i = 2; i <= shape.Table.Rows.Count; i++)
                            {
                                if (shape.Table.Columns.Count >= 3)
                                    shape.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text = "0";
                                for (int col = 1; col <= shape.Table.Columns.Count; col++)
                                    shape.Table.Rows[i].Cells[col].Shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SystemLog.WriterLog(ex);
                    }
                }
            }
        }

        /// <summary>
        /// 用来保存做选择题时,数字选举按键模式的
        /// </summary>
        Dictionary<string, List<string>> DicChoicePoll = null;

        /// <summary>
        /// 启动MySDK。杨斌 2016-08-28
        /// </summary>
        public void StartMySDK()
        {
            TagSet tagSet = new TagSet(Globals.SunVoteARSAddIn.PPTShow.SlideShow.Tags);

            Param e = new Param();

            DicChoicePoll = null;//杨斌 2018-02-06

            //SDK中0按字母,1按数字。杨斌 2016-11-16
            int OptionsMode = tagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 0 ? 1 : 0;
            switch (Globals.SunVoteARSAddIn.PPTShow.ResponseType)
            {
                case ResponseType.SignIn:
                    e.Pa.Add("StartVote", "SignIn");
                    //int SignInMode = tagSet.GetValue(TagKey.SignIn_Mode).ToInt > 0 ? 1 : 0;//杨斌 2017-03-30
                    int SignInMode = tagSet.GetValue(TagKey.SignIn_Mode).ToInt;//杨斌 2019-02-26
                    //日本的S50Plus支持签到模式5:数字+字母大小写+空格。杨斌 2019-03-05。需在签到面板增加选项“支持数字和字母大小写和空格”
                    if ((SignInMode == 1) && (SystemConfig.KeypadType == "S50Plus"))
                        SignInMode = 5;
                    if (SignInMode == 2)//杨斌 2020-11-12
                        SignInMode = 1;
                    e.Pa.Add("SignInMode", SignInMode);
                    break;
                case ResponseType.Choice:
                    int ChoicesCount = tagSet.GetValue(TagKey.Choice_OptionCount).ToInt;
                    int ChoicesLimit = tagSet.GetValue(TagKey.Choice_OptionLimit).ToInt;
                    if (ChoicesCount > GlobalInfo.MaxOptionCount)//超过10个选项做选举。杨斌 2018-02-02
                    {
                        DicChoicePoll = new Dictionary<string, List<string>>();
                        //if (ChoicesLimit > 1)
                        //{
                        e.Pa.Add("StartVote", "Election");
                        e.Pa.Add("ElectionSelects", ChoicesLimit);
                        //}
                        //else
                        //{
                        //    e.Pa.Add("StartVote", "Number");
                        //    e.Pa.Add("NumberMode", 0);
                        //}

                        //杨斌 2018-12-26。M52Li只支持分段式选举模式
                        int UIMode = 4;
                        switch (SystemConfig.KeypadType)
                        {
                            case "M52Li":
                                UIMode = 7;
                                break;
                        }
                        if (UIMode == 7)
                        {
                            e.Pa.Add("UIMode", UIMode);//4=数字编号,7=分段式。杨斌 2018-09-29
                            int MinSelects = (tagSet.GetValue(TagKey.Choice_IisN).ToInt == 1) ? ChoicesLimit : 1;
                            e.Pa.Add("MinSelects", MinSelects);//最少可选。
                            e.Pa.Add("DuplicateOptions", 1);//0=允许重复,1=不允许重复。
                            //选举编号分段范围。杨斌 2018-12-26
                            e.Pa.Add("LimitNumber1Min", 1);
                            e.Pa.Add("LimitNumber1Max", ChoicesCount);
                            e.Pa.Add("LimitNumber2Min", 65535);
                            e.Pa.Add("LimitNumber2Max", 65535);
                            e.Pa.Add("LimitNumber3Min", 65535);
                            e.Pa.Add("LimitNumber3Max", 65535);
                        }
                        if (UIMode == 4)//杨斌 2020-05-25
                        {
                            e.Pa.Add("NumberOptions", ChoicesCount);
                            //杨斌 2020-06-16
                            e.Pa.Add("ItemStartID", 1);
                            e.Pa.Add("ItemEndID", ChoicesCount);
                        }
                    }
                    else
                    {
                        //杨斌 2019-12-06。国防科大定制6级评议,单选题使用名单式选举模式进行分组。名单下载点击调用ToolKit下载
                        if ((SystemConfig.KeypadType == "E11") && (ChoicesLimit == 1))
                        {
                            DicChoicePoll = new Dictionary<string, List<string>>();
                            e.Pa.Add("StartVote", "Election");
                            e.Pa.Add("UIMode", 1);//UI模式1=名单式选举
                            e.Pa.Add("ElectionSelects", 1);//可选人数,选出人数
                            e.Pa.Add("MinSelects", 1);//最小可选,硬件无效果
                        }
                        else
                        {
                            e.Pa.Add("StartVote", "Choices");
                            int ChoicesLessEnabled = tagSet.GetValue(TagKey.Choice_IisN).ToInt;
                            e.Pa.Add("ChoicesCount", ChoicesCount);
                            e.Pa.Add("ChoicesLimit", ChoicesLimit);
                            e.Pa.Add("OptionsMode", OptionsMode);
                            e.Pa.Add("ChoicesLessEnabled", ChoicesLessEnabled);
                        }
                    }
                    break;
                case ResponseType.Group://杨斌 2018-05-17
                    int GroupCount = tagSet.GetValue(TagKey.Group_OptionCount).ToInt;
                    if (GroupCount > GlobalInfo.MaxOptionCount)//超过10个选项用数字模式。杨斌 2018-02-02
                    {
                        DicChoicePoll = new Dictionary<string, List<string>>();
                        e.Pa.Add("StartVote", "Number");
                        e.Pa.Add("NumberMode", 0);
                    }
                    else
                    {
                        e.Pa.Add("StartVote", "Choices");
                        e.Pa.Add("ChoicesCount", GroupCount);
                        e.Pa.Add("ChoicesLimit", 1);
                        e.Pa.Add("OptionsMode", OptionsMode);
                        e.Pa.Add("ChoicesLessEnabled", 0);
                    }
                    break;
                case ResponseType.Judge:
                    switch (SystemConfig.KeypadType)
                    {
                        case "M30":
                        case "S52Plus":                        
                        case "M5"://杨斌 2020-06-22。M5=S52Plus升级版增加(CommitOK==1)判断
                        case "Interact+"://"Interact+"=="S52Plus",杨斌 2020-08-24
                        case "Interact++"://"Interact++"=="M5",杨斌 2020-08-24
                        case "M00":
                        case "S60"://杨斌 2017-08-22
                        case "S53"://杨斌 2019-03-25
                        case "SHV52plus"://杨斌 2020-07-28,SHV52plus即S53
                        case "SHV52Plus"://杨斌 2020-07-28,SHV52plus即S53
                        case "M52Li"://杨斌 2020-05-06
                        case "G1"://杨斌 2020-05-06
                            e.Pa.Add("StartVote", "TrueFalse");//支持判断键
                            e.Pa.Add("TrueFalseMode", 1);
                            break;
                        default:
                            e.Pa.Add("StartVote", "Choices");
                            e.Pa.Add("ChoicesCount", 2);
                            e.Pa.Add("ChoicesLimit", 1);
                            e.Pa.Add("OptionsMode", OptionsMode);
                            e.Pa.Add("ChoicesLessEnabled", 0);
                            break;
                    }
                    break;
                case ResponseType.Order:
                    e.Pa.Add("StartVote", "Sequence");
                    int OrderCount = tagSet.GetValue(TagKey.Order_OptionCount).ToInt;
                    int OrderLimit = tagSet.GetValue(TagKey.Order_OptionLimit).ToInt;
                    int IisN = TagSet.GetValue(TagKey.Order_IisN).ToInt;
                    int AABB = TagSet.GetValue(TagKey.Order_AABB).ToInt;
                    e.Pa.Add("OrderCount", OrderCount);
                    e.Pa.Add("OrderLimit", OrderLimit);
                    e.Pa.Add("OptionsMode", OptionsMode);
                    if (AABB == 1)
                    {
                        e.Pa.Add("SequenceLessEnabled", 2);
                    }
                    else
                    {
                        if (IisN == 1)
                            e.Pa.Add("SequenceLessEnabled", 1);
                        else
                            e.Pa.Add("SequenceLessEnabled", 0);
                    }
                    break;
                case ResponseType.Number:
                    e.Pa.Add("StartVote", "Number");
                    e.Pa.Add("NumberMode", 0);
                    break;
                case ResponseType.Poll:
                    int isMulti = tagSet.GetValue(TagKey.Poll_Multi).ToInt;

                    //去掉多次提交功能。杨斌 2017-09-30
                    ////PowerVote的定制选举,多个采用多次提交。杨斌 2017-06-12
                    //if ((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote) && (GlobalInfo.OEMLogo2 == OEMLogos2.SunVote))
                    //    isMulti = 0;

                    //判断选举模式:数字or分段式选举
                    int UseModeLimitNumber = tagSet.GetValue(TagKey.Poll_UseModeLimitNumber).ToInt;
                    switch (SystemConfig.KeypadType)
                    {
                        case "M52Li"://刘红英说:以后M52Li和其他键盘不再支持数字选举模式。杨斌 2018-12-27
                            if (UseModeLimitNumber != 1)
                            {
                                UseModeLimitNumber = 1;
                                tagSet.SetValue(TagKey.Poll_UseModeLimitNumber, UseModeLimitNumber);
                            }
                            break;
                    }
                    if ((isMulti == 1) || (UseModeLimitNumber == 1))//杨斌 2018-12-27
                    {
                        DicChoicePoll = new Dictionary<string, List<string>>();//杨斌 2020-06-12
                        e.Pa.Add("StartVote", "Election");
                        e.Pa.Add("ElectionSelects", tagSet.GetValue(TagKey.Poll_EffectiveVotes).ToInt);//数字选举可选数                        
                        int UIMode = (UseModeLimitNumber == 1) ? 7 : 4;
                        e.Pa.Add("UIMode", UIMode);//4=数字编号,7=分段式。杨斌 2018-09-29
                        if (UIMode == 7)
                        {
                            int MinSelects = tagSet.GetValue(TagKey.Poll_MinSelects).ToInt;
                            int DuplicateOptions = tagSet.GetValue(TagKey.Poll_CanRepeat).ToInt;
                            int LimitRange2Enabled = tagSet.GetValue(TagKey.Poll_LimitRange2Enabled).ToInt;
                            int LimitRange3Enabled = tagSet.GetValue(TagKey.Poll_LimitRange3Enabled).ToInt;
                            string range1 = tagSet.GetValue(TagKey.Poll_LimitRange1).Value;
                            string range2 = tagSet.GetValue(TagKey.Poll_LimitRange2).Value;
                            string range3 = tagSet.GetValue(TagKey.Poll_LimitRange3).Value;
                            e.Pa.Add("MinSelects", MinSelects);//最少可选。杨斌 2018-09-29
                            e.Pa.Add("DuplicateOptions", DuplicateOptions);//0=允许重复,1=不允许重复。杨斌 2018-09-29
                            int LimitNumber1Min = 0;
                            int LimitNumber1Max = 0;
                            int LimitNumber2Min = 0;
                            int LimitNumber2Max = 0;
                            int LimitNumber3Min = 0;
                            int LimitNumber3Max = 0;
                            GetRangeNum(range1, 1, out LimitNumber1Min, out LimitNumber1Max);
                            GetRangeNum(range2, LimitRange2Enabled, out LimitNumber2Min, out LimitNumber2Max);
                            GetRangeNum(range3, LimitRange3Enabled, out LimitNumber3Min, out LimitNumber3Max);
                            //选举编号分段范围。杨斌 2018-09-29
                            e.Pa.Add("LimitNumber1Min", LimitNumber1Min);
                            e.Pa.Add("LimitNumber1Max", LimitNumber1Max);
                            e.Pa.Add("LimitNumber2Min", LimitNumber2Min);
                            e.Pa.Add("LimitNumber2Max", LimitNumber2Max);
                            e.Pa.Add("LimitNumber3Min", LimitNumber3Min);
                            e.Pa.Add("LimitNumber3Max", LimitNumber3Max);
                        }
                        if (UIMode == 4)//杨斌 2020-06-16
                        {
                            e.Pa.Add("NumberOptions", CandidateInfoList.Count);
                            //杨斌 2020-06-16                            
                            List<int> lstNum = new List<int>();
                            foreach (var v in CandidateInfoList)
                            {
                                int num = ConvertOper.Convert(v.Value.CandidateID).ToInt;
                                if (num > 0)
                                    lstNum.Add(num);
                            }
                            int minNum = lstNum.Min();
                            int maxNum = lstNum.Max();
                            e.Pa.Add("ItemStartID", minNum);
                            e.Pa.Add("ItemEndID", maxNum);
                        }
                    }
                    else
                    {
                        e.Pa.Add("StartVote", "Number");
                        e.Pa.Add("NumberMode", 0);
                    }
                    break;
                case ResponseType.Score:
                    e.Pa.Add("StartVote", "Number");
                    e.Pa.Add("NumberMode", 0);
                    break;
                case ResponseType.Text:
                    e.Pa.Add("StartVote", "Cloze");
                    //GlobalInfo.SDK.Cloze.ClozeType = 0;
                    //GlobalInfo.SDK.Cloze.MaxLength = 16;
                    //GlobalInfo.SDK.Cloze.PromptMode = 0;
                    //GlobalInfo.SDK.Cloze.CorrectAnswer = "";
                    break;
                case ResponseType.Vote:
                    int VoteCount = tagSet.GetValue(TagKey.Vote_OptionCount).ToInt;
                    switch (SystemConfig.KeypadType)
                    {
                        case "M30":
                        case "S52Plus":                        
                        case "M5"://杨斌 2020-06-22。M5=S52Plus升级版增加(CommitOK==1)判断
                        case "Interact+"://"Interact+"=="S52Plus",杨斌 2020-08-24
                        case "Interact++"://"Interact++"=="M5",杨斌 2020-08-24
                        case "M00":
                        case "W00"://杨斌 2018-06-04
                        case "S53"://杨斌 2019-03-25
                        case "SHV52plus"://杨斌 2020-07-28,日本Votingeyes的SHV52plus=S53
                        case "SHV52Plus"://杨斌 2020-07-28,日本Votingeyes的SHV52plus=S53
                        case "M52Li"://杨斌 2020-04-30
                        case "G1"://杨斌 2020-05-06
                            e.Pa.Add("StartVote", "Vote");//支持表决键
                            e.Pa.Add("VoteMode", VoteCount == 2 ? 1 : 0);
                            break;
                        default:
                            e.Pa.Add("StartVote", "Choices");
                            //int VoteOptionsMode = tagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt;
                            e.Pa.Add("ChoicesCount", VoteCount);
                            e.Pa.Add("ChoicesLimit", 1);
                            e.Pa.Add("OptionsMode", OptionsMode);
                            e.Pa.Add("ChoicesLessEnabled", 0);
                            break;
                    }
                    break;
                case ResponseType.Grade:
                    //杨斌 2019-02-26。国防科大定制6级评议,使用表决的按键模式2。其他功能均不支持
                    if (SystemConfig.KeypadType == "E11")
                    {
                        e.Pa.Add("StartVote", "Vote");
                        e.Pa.Add("VoteMode", 2);
                    }
                    else
                    {
                        e.Pa.Add("StartVote", "Choices");
                        int GradeCount = tagSet.GetValue(TagKey.Grade_OptionCount).ToInt;
                        //int GradeOptionsMode = tagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt;
                        e.Pa.Add("ChoicesCount", GradeCount);
                        e.Pa.Add("ChoicesLimit", 1);
                        e.Pa.Add("OptionsMode", OptionsMode);
                        e.Pa.Add("ChoicesLessEnabled", 0);
                    }
                    break;
            }
            int VoteModifyMode = tagSet.GetValue(TagKey.KeypadPara_ModifyMode).ToInt == 1 ? 0 : 1;
            int VoteSecrecyMode = tagSet.GetValue(TagKey.KeypadPara_SecrecyMode).ToInt;

            e.Pa.Add("VoteModifyMode", VoteModifyMode);
            e.Pa.Add("VoteSecrecyMode", VoteSecrecyMode);

            if (VoteServer.IsStart)//杨斌 2017-12-11
            {
                SendMeetVoteSDK(e);
            }
            else
            {
                GlobalInfo.ServerRequest(e);
            }
        }
        private void GetRangeNum(string range, int enabled, out int numStart, out int numEnd)
        {
            numStart = 1;
            numEnd = 65535;
            try
            {
                if (enabled == 1)
                {
                    var ary = range.Split('-');
                    if (ary.Length >= 2)
                    {
                        numStart = ConvertOper.Convert(ary[0]).ToInt;
                        numEnd = ConvertOper.Convert(ary[1]).ToInt;
                    }
                }
                else
                {
                    numStart = 65535;
                    numEnd = 65535;
                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }
        /// <summary>
        /// 停止MySDK。杨斌 2016-08-28
        /// </summary>
        public void StopMySDK()
        {
            //GlobalInfo.SDK.VoteStart = false;
            Param e = new Param();
            e.Pa.Add("StartVote", "Stop");

            if (VoteServer.IsStart)//杨斌 2017-12-11
            {
                SendMeetVoteSDK(e);
            }
            else
            {
                Param p = GlobalInfo.ServerRequest(e);
            }
        }

        void SendMeetVoteSDK(Param e)
        {
            Dictionary<string, object> dicSend = new Dictionary<string, object>();
            int itemCount = PPTOper.GetVoteChartItemCount(Globals.SunVoteARSAddIn.PPTShow.SlideShow);
            dicSend.Add("ItemCount", itemCount);
            foreach (var v in e.Pa)
            {
                dicSend.Add(v.Key, v.Value);
            }
            VoteServer.SendMsg(dicSend);
        }

        /// <summary>
        /// 杨斌 2018-12-14
        /// </summary>
        void SendVoteAck(ResponsePar resPar)
        {
            Dictionary<string, object> dicSend = new Dictionary<string, object>();
            dicSend.Add("SendVoteAck", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            dicSend.Add("KeyID", resPar.KeyID);
            dicSend.Add("KeyValue", resPar.KeyValue);
            dicSend.Add("Speed", resPar.Speed);
            dicSend.Add("Time", resPar.Time);
            VoteServer.SendMsg(dicSend);
        }

        public bool IsStartRunshAnswer = false;
        /// <summary>
        /// 启动抢答
        /// 杨斌 2013-12-24
        /// </summary>
        public void RushAnswerStart()
        {
            ResponseType responseType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;

            Busines = new ARSRushAnswer();
            //ARSRushAnswer.KeyModel = GlobalInfo.hardwareManage.KeyModel;

            Busines.TagSet = TagSet;
            Busines.BaseConnection = GlobalInfo.baseConnect.baseConnection;
            Busines.ResponseType = responseType;
            //Busines.Keypad = GlobalInfo.hardwareManage.KeyModel;
            //Busines.IniBusiness();

            //if (GlobalInfo.GetSdkType() == 0)//杨斌 2016-10-26
            //{
            Param e = new Param();
            e.Pa.Add("StartVote", "RushAnswer");
            GlobalInfo.ServerRequest(e);
            //}
            //else
            //{
            //    Busines.ResponseEventHander -= Busines_ResponseEventHander;
            //    Busines.ResponseEventHander += Busines_ResponseEventHander;//杨斌 2016-10-26
            //    Busines.Start();
            //}
            IsStartRunshAnswer = true;
        }
        /// <summary>
        /// 停止抢答
        /// 杨斌 2013-12-24
        /// </summary>
        public void RushAnswerStop()
        {
            IsStartRunshAnswer = false;
            //if (GlobalInfo.GetSdkType() == 0)//杨斌 2016-10-26
            //{
            Param e = new Param();
            e.Pa.Add("StartVote", "Stop");
            GlobalInfo.ServerRequest(e);
            //}
            //else
            //{
            //    if (Busines != null)
            //    {
            //        Busines.Stop();
            //        Busines.ResponseEventHander -= Busines_ResponseEventHander;//杨斌 2016-10-26
            //    }
            //    Busines = null;
            //}
        }

        /// <summary>
        /// 签到模式
        /// 杨斌 2013-01-24
        /// </summary>
        public int SignInMode = 0;

        /// <summary>
        /// 初始化应用
        /// </summary>
        private void InitBusines()
        {
            ResponseType responseType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
            //选择应用
            Busines = null;
            //杨斌 2017-04-19
            //if ((GlobalInfo.hardwareManage.GetConnectBaseNum() > 0) && (!GlobalInfo.sysConfig.DemoEnable))
            if (!GlobalInfo.sysConfig.DemoEnable)
            {
                switch (responseType)
                {
                    case ResponseType.None:
                    case ResponseType.Slide:
                        return;
                        break;
                    case ResponseType.Choice:
                        Busines = new ARSChoise();
                        break;
                    case ResponseType.SignIn:
                        //2012-06-18 添加签到码签到功能
                        SignInMode = TagSet.GetValue(TagKey.SignIn_Mode).ToInt;//杨斌 2013-01-24
                        if (SignInMode == 0)//杨斌 2017-03-30
                            Busines = new ARSSignIn();
                        else
                        {
                            //杨斌 由于S70不能修改签到码,所以暂时用数值模式。 2015-04-28
                            //同样问题,S50、S56
                            //if (GlobalInfo.hardwareManage.KeyModel == "S70")
                            //    Busines = new ARSSignIn(true);
                            //else
                            Busines = new ARSScore();
                        }
                        break;
                    case ResponseType.Group:
                        Busines = new ARSChoise();
                        break;
                    case ResponseType.Judge:
                        //ARSChoise choiseJudge = new ARSChoise();
                        //choiseJudge.Choise.Options = 2;
                        //choiseJudge.Choise.OptionalN = 1;
                        //Busines = choiseJudge;
                        Busines = new ARSChoise();
                        break;
                    case ResponseType.Vote:
                        //ARSChoise choiseVote = new ARSChoise();
                        //choiseVote.Choise.Options = 3;
                        //choiseVote.Choise.OptionalN = 1;
                        //Busines = choiseVote;
                        Busines = new ARSChoise();
                        break;
                    case ResponseType.Grade:
                        //ARSChoise choiseGrade = new ARSChoise();
                        //choiseGrade.Choise.OptionalN = 1;
                        //Busines = choiseGrade;
                        Busines = new ARSChoise();
                        break;
                    case ResponseType.Score:
                        Busines = new ARSScore();
                        break;
                    case ResponseType.Number:
                        Busines = new ARSScore();
                        break;
                    case ResponseType.Text:
                        Busines = new ARSText();
                        break;
                    case ResponseType.Order:
                        Busines = new ARSSequence();
                        break;
                    case ResponseType.Poll:
                        LoadCandidateList();//必须在new ARSElection()前面初始化。杨斌 2016-04-26
                        //杨斌 2016-04-26
                        //if ((GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
                        //杨斌 2017-02-13
                        if (PanelPoll.IsUseMultiPoll(Globals.SunVoteARSAddIn.PPTShow.SlideShow) && PanelPoll.IsMultiPollKeypad())
                            Busines = new ARSElection();
                        else
                            Busines = new ARSScore();
                        break;
                    default:
                        break;
                }
            }
            else
            {
                Busines = new Demo();
                //初始化演示模式键盘
                if (IsAllPerson)
                {

                    //杨斌 2016-12-05
                    List<int> ls = FrmImportSlideSelect.GetNumRange(GlobalInfo.hardwareManage.RangeOfKey);
                    if (ls.Count > 0)
                    {
                        int cnt = GlobalInfo.hardwareManage.PersonNum;
                        if (ls.Count < cnt)
                            cnt = ls.Count;
                        Demo.Keypads = new string[cnt];
                        for (int i = 0; i < cnt; i++)
                        {
                            Demo.Keypads[i] = ls[i].ToString();
                        }
                    }
                    else
                    {
                        Demo.Keypads = new string[GlobalInfo.hardwareManage.PersonNum];
                        for (int i = 0; i < GlobalInfo.hardwareManage.PersonNum; i++)
                        {
                            Demo.Keypads[i] = (i + 1).ToString();
                        }
                    }
                }
                else
                {
                    Demo.Keypads = AuthorKeypadList.Values.ToArray<string>();
                }
                if (responseType == ResponseType.Poll)
                {
                    string[] pollList = CandidateInfoList.Keys.ToArray<string>();
                    Demo.PollList = new Dictionary<string, string>(pollList.Length);
                    for (int i = 0; i < pollList.Length; i++)
                    {
                        Demo.PollList.Add(i.ToString(), pollList[i]);
                    }
                }
                ////2012-06-19 赵丽 添加签到码签到的演示模式
                //if ((responseType == ResponseType.SignIn) && (TagSet.GetValue(TagKey.SignIn_Mode).ToInt == 1))
                //{

                //}
            }
            Busines.TagSet = TagSet;
            Busines.BaseConnection = GlobalInfo.baseConnect.baseConnection;
            Busines.ResponseType = responseType;
            Busines.ResponseEventHander += new ResponseEventHander(Busines_ResponseEventHander);
            chartViewType = EnumName<ChartViewType>.GetEnum(TagSet.GetValue(TagKey.ChartPara_ShowTime).Value);

            //杨斌 2015-04-10
            SlideBackMusic = TagSet.GetValue(TagKey.ResponsePara_SlideBackMusic).Value;
            GlobalInfo.DXSoundPlay.RemoveSound(GlobalInfo.Sund_Key_BackSlide);
            string pathSound = GlobalInfo.SOUND_DIR + SlideBackMusic;
            if (File.Exists(pathSound))
                GlobalInfo.DXSoundPlay.LoadSound(GlobalInfo.Sund_Key_BackSlide, pathSound);
        }

        /// <summary>
        /// 当前名单,Slide初始化时加载
        /// 杨斌 2014-06-11
        /// </summary>
        RosterList RosterNow = new RosterList();
        /// <summary>
        /// 评委权重
        /// 杨斌 2014-06-11
        /// </summary>
        Dictionary<string, double> DicJudgeRage = new Dictionary<string, double>();

        /// <summary>
        /// 初始化应用业务
        /// 根据幻灯片类型 选择应用业务
        /// 创建 赵丽
        /// </summary>
        public void InitResponse()
        {
            //杨斌 2014-06-11
            RosterNow.LoadRoster();
            LoadJudgeRage();

            //加载授权键盘列表
            LoadAuthorKeypadList();
            //加载反馈数据
            LoadResponseData();

            //刷新标签
            //RefreshLable();//放在PPTShow文件的(InitMap加载坐席图数据)后面刷新。杨斌 2013-02-26
        }

        /// <summary>
        /// 初始化应用业务数据。杨斌 2017-08-07
        /// </summary>
        public void InitResponse2()
        {
            RosterNow.LoadRoster();
            LoadAuthorKeypadList();
            LoadResponseData();
        }

        /// <summary>
        /// 加载评委权重
        /// 杨斌 2014-06-11
        /// </summary>
        private void LoadJudgeRage()
        {
            try
            {
                DicJudgeRage.Clear();

                TagSet tagSet = new TagSet(CurrentSlide.Tags);

                string sJudgeRage = tagSet.LoadValue(TagKey.Score_JudgeRage, "").Value;
                int RateCol = -1;
                if (sJudgeRage.Length > 0)
                {
                    for (int i = 0; i < RosterNow.Columns.Count; i++)
                    {
                        if (RosterNow.Columns[i].ColumnName == sJudgeRage)
                        {
                            RateCol = i;
                            break;
                        }
                    }

                    for (int i = 0; i < RosterNow.Rows.Count; i++)
                    {
                        string key = RosterNow.Rows[i].Cells[RosterNow.KeypadIdColumnIndex].ToString();
                        double rate = 1;
                        if (RosterNow.RosterEnabled && (RateCol != -1))//杨斌 2014-07-28
                        {
                            rate = ConvertOper.Convert(RosterNow.Rows[i].Cells[RateCol].ToString()).ToDouble;
                            //杨斌 2018-05-22
                            if (rate < 0)
                                rate = 0;
                            //if (rate <= 0)
                            //    rate = 1;
                            if (!DicJudgeRage.ContainsKey(key))
                                DicJudgeRage.Add(key, rate);
                        }
                        else//杨斌 2014-07-28
                            if (!DicJudgeRage.ContainsKey(key))
                            DicJudgeRage.Add(key, 1);

                        //double rate = ConvertOper.Convert(RosterNow.Rows[i].Cells[RateCol].ToString()).ToDouble;
                        //if (rate < 0)
                        //    rate = 0;
                        //if (!DicJudgeRage.ContainsKey(key))
                        //    DicJudgeRage.Add(key, rate);
                    }

                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }

        /// <summary>
        /// 隐藏图片
        /// 创建 赵丽
        /// </summary>
        public void HidePicture()
        {
            if (CurrentSlide == null) { return; }
            if ((chartViewType != ChartViewType.csStart) && (showPicture == false))
            {
                //隐藏图片
                foreach (PowerPoint.Shape s in CurrentSlide.Shapes)
                {
                    if (s.Name == "pic")
                        s.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                }
            }
        }

        /// <summary>
        /// 若选择题则必须从"AB"格式化为"1,2"
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public string FormatABCTo123(string result)
        {
            string res = "";
            try
            {
                for (int i = 0; i < result.Length; i++)
                {
                    char chr = result[i];
                    try
                    {
                        int n = Convert.ToInt32(chr) - 64;
                        if (n > 0)
                        {
                            if (res.Length > 0) res = res + ",";
                            res = res + n.ToString();
                        }
                        else//杨斌 2012-10-22
                        {
                            if (res.Length > 0) res = res + ",";
                            res = res + chr.ToString();
                        }
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
            catch (Exception ex)
            {
                res = result;
            }

            return res;
        }

        ///// <summary>
        ///// 杨斌 2016-08-28
        ///// </summary>
        ///// <param name="data"></param>
        //public void SDK_OnKeyVoteEvt(KeyData data)
        //{
        //    ResponsePar ObjResponseValue = new ResponsePar();
        //    ObjResponseValue.BaseTag = "";
        //    ObjResponseValue.KeyID = data.KeyID;
        //    ObjResponseValue.KeyValue = data.KeyValue;
        //    ObjResponseValue.Speed = data.Speed;

        //    Busines_ResponseEventHander(ObjResponseValue);
        //}

        public void GetKeyPress()
        {
            if (VoteServer.IsStart)//由网络代收。杨斌 2017-12-11
                return;

            Param p = new Param();
            p.Pa.Add("GetKeyPress", "");
            Param r = GlobalInfo.ServerRequest(p);

            TagSet tagSet = new TagSet(Globals.SunVoteARSAddIn.PPTShow.SlideShow.Tags);//杨斌 2020-05-25
            if (r.Pa.ContainsKey("GetKeyPress"))
            {
                Dictionary<string, KeyData> dic = MyService.DeserializeObj<Dictionary<string, KeyData>>(r.Pa["GetKeyPress"].ToString());
                foreach (var v in dic)
                {
                    ResponsePar pa = new ResponsePar();
                    //杨斌 2018-02-06
                    if (DicChoicePoll == null)
                    {
                        pa.KeyID = v.Value.KeyID;
                        pa.KeyValue = v.Value.KeyValue;
                        pa.Speed = v.Value.Speed;
                        //pa.CommitOK = v.Value.CommitOK;
                        Busines_ResponseEventHander(pa);
                    }
                    else//CommitOK=1,KeyValue=1=11
                    {
                        //string[] a = v.Value.KeyValue.Split('=');
                        //杨斌 2018-12-26
                        var bb = v.Value.KeyValue.Split(',');
                        foreach (var b in bb)//杨斌 2020-06-17
                        {
                            string[] a = null;
                            if (b.IndexOf("-") > 0)
                                a = b.Split('-');//分段式选举:"01-5"
                            else if (b.IndexOf("=") > 0)//杨斌 2020-06-22
                                a = b.Split('=');//数字选举:"1=5"。"1=1,1025=0"是什么鬼?杨斌 2019-12-09
                            else
                                a = b.Split('\0');//杨斌 2020-06-22。只能呵呵
                            //if (v.Value.KeyValue.IndexOf("-") > 0)
                            //    a = v.Value.KeyValue.Split('-');//分段式选举:"01-5"
                            //else
                            //    a = v.Value.KeyValue.Split('=');//数字选举:"1=5"。"1=1,1025=0"是什么鬼?杨斌 2019-12-09

                            //if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Poll)//杨斌 2020-06-12
                            //{
                            //    int MaxSelects = TagSet.GetValue(TagKey.Poll_EffectiveVotes).ToInt;
                            //    int MinSelects = TagSet.GetValue(TagKey.Poll_MinSelects).ToInt;
                            //    if (!DicChoicePoll.ContainsKey(v.Value.KeyID))
                            //        DicChoicePoll.Add(v.Value.KeyID, new List<string>());
                            //}
                            //else
                            {
                                if (a.Length >= 2)//数字选举模式
                                {
                                    //杨斌 2020-06-15
                                    int MaxSelects = 0;//最大可选
                                    int MinSelects = 0;//最小可选
                                                       //需从选举名单计算选项最小最大值。S52和M52Li。2020-06-16
                                                       //杨斌 2020-05-25
                                    int ChoicesCount = tagSet.GetValue(TagKey.Choice_OptionCount).ToInt;
                                    //int ChoicesLimit = tagSet.GetValue(TagKey.Choice_OptionLimit).ToInt;
                                    //int ChoicesLessEnabled = tagSet.GetValue(TagKey.Choice_IisN).ToInt;
                                    int maxOption = GlobalInfo.MaxOptionCountAdv;
                                    if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Choice)
                                    {
                                        maxOption = ChoicesCount;
                                    }

                                    int selIndex = ConvertOper.Convert(a[0]).ToInt - 1;
                                    int selNo = ConvertOper.Convert(a[1]).ToInt;
                                    string strSelNo = a[1];
                                    string option = "";
                                    if (a[1].IndexOf(',') > 0)//杨斌 2019-12-09。兼容"1=1,1025=0"按键值
                                    {
                                        var aa = a[1].Split(',');
                                        selNo = ConvertOper.Convert(aa[0]).ToInt;
                                        strSelNo = aa[0];
                                    }
                                    //杨斌 2020-06-15。判断按键值有效性
                                    bool judgeValue = false;
                                    //杨斌 2020-06-22
                                    bool isOK = true;
                                    List<string> lstKeypadType = new List<string> { "G1", "M5", "Interact++" };//支持CommitOK==1判断,定制版的Interact++==M5。杨斌 2020-08-14
                                    if (lstKeypadType.Contains(SystemConfig.KeypadType))
                                        isOK = (v.Value.CommitOK == 1);
                                    if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Poll)
                                    {
                                        option = strSelNo;
                                        judgeValue = true;//CandidateInfoList.ContainsKey(strSelNo);
                                        MaxSelects = TagSet.GetValue(TagKey.Poll_EffectiveVotes).ToInt;
                                        MinSelects = TagSet.GetValue(TagKey.Poll_MinSelects).ToInt;
                                    }
                                    else
                                    {
                                        isOK = true;
                                        option = (char)(selNo + 64) + "";
                                        judgeValue = (selNo >= 1) && (selNo <= maxOption);
                                        MaxSelects = tagSet.GetValue(TagKey.Choice_OptionLimit).ToInt;
                                        int ChoicesLessEnabled = tagSet.GetValue(TagKey.Choice_IisN).ToInt;
                                        if (ChoicesLessEnabled == 1)
                                            MinSelects = MaxSelects;
                                    }

                                    //if ((selNo >= 1) && (selNo <= maxOption))//杨斌 2018-10-16
                                    if (judgeValue)//杨斌 2020-06-15
                                    {
                                        if (!DicChoicePoll.ContainsKey(v.Value.KeyID))
                                            DicChoicePoll.Add(v.Value.KeyID, new List<string>());
                                        List<string> ls = DicChoicePoll[v.Value.KeyID];
                                        if (Globals.SunVoteARSAddIn.PPTShow.ResponseType != ResponseType.Poll)
                                        {
                                            if (!ls.Contains(option))
                                            {
                                                for (int i = ls.Count; i <= selIndex; i++)
                                                    ls.Add("");
                                                ls[selIndex] = option;
                                            }
                                        }
                                        else
                                        {
                                            for (int i = ls.Count; i <= selIndex; i++)
                                                ls.Add("");
                                            if (selIndex >= 0)//杨斌 2020-06-22
                                                ls[selIndex] = option;
                                        }
                                        pa.KeyID = v.Value.KeyID;
                                        bool isValueOK = false;
                                        if (isOK)
                                        {
                                            if (MaxSelects > 1)
                                            {
                                                if (ls.Count >= MinSelects)
                                                    isValueOK = true;
                                            }
                                            else
                                            {
                                                isValueOK = true;
                                            }
                                        }
                                        if (isValueOK)
                                        {
                                            if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Poll)
                                            {
                                                for (int m = 0; m < ls.Count; m++)
                                                {
                                                    pa.KeyValue = (m + 1) + "=" + ls[m];
                                                    pa.Speed = v.Value.Speed;
                                                    //pa.CommitOK = v.Value.CommitOK;
                                                    Busines_ResponseEventHander(pa);
                                                }
                                            }
                                            else
                                            {
                                                pa.KeyValue = string.Join("", ls);
                                                pa.Speed = v.Value.Speed;
                                                //pa.CommitOK = v.Value.CommitOK;
                                                Busines_ResponseEventHander(pa);
                                            }
                                        }
                                        //if ((ChoicesLessEnabled == 1) && (ChoicesLimit > 1))//杨斌 2020-05-25
                                        //{
                                        //    if (ls.Count == ChoicesLimit)
                                        //    {
                                        //        Busines_ResponseEventHander(pa);
                                        //    }
                                        //}
                                        //else
                                        //{
                                        //    Busines_ResponseEventHander(pa);
                                        //}         
                                    }
                                }
                                else if (a.Length >= 1)//数字模式。杨斌 2018-05-17
                                {
                                    int selNo = ConvertOper.Convert(a[0]).ToInt;
                                    if ((selNo >= 1) && (selNo <= GlobalInfo.MaxOptionCountAdv))//杨斌 2018-10-16
                                    {
                                        string option = (char)(selNo + 64) + "";
                                        pa.KeyID = v.Value.KeyID;
                                        pa.KeyValue = option;
                                        pa.Speed = v.Value.Speed;
                                        //pa.CommitOK = v.Value.CommitOK;
                                        Busines_ResponseEventHander(pa);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }


        /// <summary>
        /// 提交后是否可修改:0=可修改,1=不可修改
        /// 杨斌 2016-01-18
        /// </summary>
        public int ModifyMode = 0;

        /// <summary>
        /// 检测是否按键重复提交。杨斌 2015-06-25
        /// </summary>
        List<string> LstResponseCheck = new List<string>();
        /// <summary>
        /// 存储每个键盘多次按键值。ResponseDataList存储的是每个键盘最新按键
        /// 杨斌 2015-06-26
        /// </summary>
        public List<ResponsePar> LstResponseData = new List<ResponsePar>();
        /// <summary>
        /// 键盘状态事件
        /// 创建  赵丽
        /// 修改:杨斌 2012-03-14
        /// 修改:杨斌 2012-04-11 改成public,方便外部模拟调用
        /// </summary>
        /// <param name="ObjResponsePar"></param>
        public void Busines_ResponseEventHander(ResponsePar ObjResponsePar)
        {
            //停止反馈或抢答后不接受数据,抢答没有使用BusinessStatus状态。杨斌 2018-05-30
            if ((BusinessStatus != ResponseStatus.bsStart) && !IsStartRunshAnswer)//停止反馈后不再接收数据。杨斌 2018-04-20
            {
                RefreshChart();//刷新图表。杨斌 2018-12-14
                return;
            }

            //杨斌 2018-12-14
            ResponsePar par = new ResponsePar();
            par.BaseTag = ObjResponsePar.BaseTag;
            par.KeyID = ObjResponsePar.KeyID;
            par.KeyValue = ObjResponsePar.KeyValue;
            par.Score = ObjResponsePar.Score;
            par.Correct = ObjResponsePar.Correct;
            par.Time = ObjResponsePar.Time;
            par.Speed = ObjResponsePar.Speed;

            Stopwatch t = Stopwatch.StartNew();
            string ss = "";

            //杨斌 2017-08-07
            Microsoft.Office.Interop.PowerPoint.Slide SlideNow = null;
            ResponseType ResponseTypeNow = ResponseType.None;
            if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
            {
                SlideNow = Globals.SunVoteARSAddIn.PPTShow.SlideShow;
                ResponseTypeNow = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
            }
            else
            {
                SlideNow = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit;
                ResponseTypeNow = Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit;
            }

            //表决等没有速度,不能用这种方式验证。杨斌 2015-07-07
            ////防止键盘重复提交按键。杨斌 2015-06-25
            //string sResKey = ObjResponsePar.KeyID + "_" + ObjResponsePar.KeyValue + "_" + ObjResponsePar.Speed;
            //if (LstResponseCheck.Contains(sResKey))
            //    return;
            //else
            //    LstResponseCheck.Add(sResKey);

            //是否限制键盘个数提交数据。杨斌 2012-11-05
            if (GlobalInfo.LIMITED_EDITION > 0)
            {
                if (ResponseDataList.Count >= GlobalInfo.LIMITED_EDITION) return;
            }

            //进行某些操作时,投票无效 如:键盘替换
            if (IsAnOtherOper) { return; }
            ResponseType responseType = ResponseTypeNow;
            string keyValue = ObjResponsePar.KeyValue;
            double score = 0;

            //杨斌 2017-08-07
            FrmRushAnswer frmRushAnswer = null;
            FrmVoteBar frmVoteBar = Globals.SunVoteARSAddIn.frmVoteBar;
            if (frmVoteBar != null)//杨斌 2017-08-07
            {
                frmRushAnswer = frmVoteBar.frmRushAnswer;
                if (frmVoteBar.isRushAnswer)
                {
                    if (frmRushAnswer != null)
                    {
                        frmRushAnswer.ShowRushAnswer(ObjResponsePar);

                        //if (!frmRushAnswer.CanPressQD) return;//杨斌 2011-08-18

                        //frmRushAnswer.StopRushAnswer();
                        //string keyIdOrName = "";
                        //if (!string.IsNullOrEmpty(MemberList.RushAnswer))
                        //{
                        //    keyIdOrName = MemberList.GetRushAnswerShow(MemberList.RushAnswer, ObjResponsePar.KeyID.ToString());
                        //}
                        //if (string.IsNullOrEmpty(keyIdOrName) == true)
                        //{
                        //    keyIdOrName = ObjResponsePar.KeyID.ToString();
                        //    string temp = GlobalInfo.LPT.ReadString("FrmRushAnswer", "lblMsg2", "请-号键盘作答!");
                        //    temp = temp.Replace("-", keyIdOrName);
                        //    frmRushAnswer.lblMsg.Text = temp;
                        //}
                        //else
                        //{
                        //    string temp = GlobalInfo.LPT.ReadString("FrmRushAnswer", "lblMsg3", "请-作答!");
                        //    temp = temp.Replace("-", keyIdOrName);
                        //    frmRushAnswer.lblMsg.Text = temp;
                        //}

                        ////杨斌 2011-08-18 抢答后授权引起签到图表数据错误
                        //if (Globals.SunVoteARSAddIn.ShowCurrBaseTagsModel.ResponseType != 0)
                        //{
                        //    if (VotingService.ResponseData.Count == 0)//杨斌 2011-08-18
                        //    {
                        //        //授权
                        //        VotingService.AuthorizeKeypad.Clear();
                        //        VotingService.AuthorizeKeypad.Add((int)KeypadResponseEventParam.KeypadID);
                        //    }
                        //}
                    }
                    return;
                }
            }

            if (frmRushAnswer != null)//杨斌 2015-04-29
            {
                if (frmRushAnswer.IsRun)
                    return;
            }

            if (ModifyMode == 1)//不允许修改,软件屏蔽。杨斌 2016-01-18
            {
                string sID = ObjResponsePar.KeyID;
                if (GlobalInfo.response.ResponseDataList.Contains(sID))
                {
                    //如果是选举模式多选,不允许修改,硬件屏蔽。杨斌 2019-03-15
                    if ((responseType == ResponseType.Poll)
                        && (PanelPoll.IsUseMultiPoll(SlideNow) && PanelPoll.IsMultiPollKeypad()))
                    {

                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(GlobalInfo.response.ResponseDataList[sID].KeyValue))
                            return;
                    }
                }
            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //评分判断数据
            if (responseType == ResponseType.Score)
            {
                if (!JudgeScoreValue(ref keyValue)) { return; }
                ObjResponsePar.KeyValue = keyValue;
            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //数字判断数据 杨斌 2012-03-13
            if (responseType == ResponseType.Number)
            {
                if (!JudgeNumberValue(ref keyValue)) { return; }
                ////2012-10-09 赵丽 数字题最多保留4位小数
                //try
                //{
                //    ObjResponsePar.KeyValue = Math.Round(Convert.ToDecimal(keyValue), 4).ToString();
                //}
                //catch
                //{
                //    ObjResponsePar.KeyValue = keyValue;
                //}
                ObjResponsePar.KeyValue = keyValue;//杨斌 2013-04-27 去掉小数位限制
            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //杨斌 2013-01-29 添加签到码签到
            bool bCheckKeyID = true;
            if ((responseType == ResponseType.SignIn) && EnableList)
            {
                int signInMode = 0;
                signInMode = TagSet.GetValue(TagKey.SignIn_Mode).ToInt;
                if (signInMode > 0)//杨斌 2017-03-30
                {
                    bCheckKeyID = false;
                    //杨斌 2017-02-23
                    if (SystemConfig.KeypadType == "M30")
                    {
                        if (ObjResponsePar.KeyValue.Length >= 3)
                        {
                            int n3 = 0;
                            if (int.TryParse(ObjResponsePar.KeyValue[2] + "", out n3))
                                ObjResponsePar.KeyValue = ObjResponsePar.KeyValue.Substring(0, 2) + (char)(n3 + 64);
                        }
                    }

                    //if (SignInCode[ObjResponsePar.KeyID.ToString()] != ObjResponsePar.KeyValue) { return; }
                }//签到码签到
            }
            if (bCheckKeyID)//杨斌 2013-01-29
            {
                //选举判断是否含有该候选人
                //未授权                
                if (!IsAuthorize(ObjResponsePar.KeyID)) { return; }
            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            string keyID = ObjResponsePar.KeyID.ToString();
            //按键音
            if (GlobalInfo.sysConfig.PressSoundEnabled)
            {
                GlobalInfo.DXSoundPlay.Play(GlobalInfo.Sound_Key_Vote);
                //GlobalInfo.DXSoundPlay.Stop(GlobalInfo.Sound_Key_Vote);
            }
            //ObjResponsePar.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ObjResponsePar.Time = DateTime.Now;

            //选择类型需要在收到按键时即计算对错和得分,减轻批量保存时运算
            ObjResponsePar.Correct = 0;
            ObjResponsePar.Score = 0;
            //ABC转换1,2,3,以下代码应放到接收按键值事件中
            string result = ObjResponsePar.KeyValue;
            string pollNo = "";
            string pollValue = "";
            int pollNoInt = 0;
            switch (responseType)
            {
                case ResponseType.Choice:
                case ResponseType.Group:
                case ResponseType.Grade:
                case ResponseType.Judge:
                case ResponseType.Vote:
                case ResponseType.Order:
                    if (GlobalInfo.GetSdkType() == 1)//杨斌 2016-12-06
                        result = result.Replace("Q", "J");
                    result = FormatABCTo123(result);
                    //判断是否正确,计算分数
                    //性能需要优化!!!杨斌 2015-03-27                    
                    if (IsCorrect(ResponseTypeNow, result, out score)) { ObjResponsePar.Correct = 1; }
                    //if (!string.IsNullOrEmpty(KeyIDQDOK) && (keyID != KeyIDQDOK) && (score < 0))//杨斌 2019-04-09
                    //    score = 0;
                    //按正确答案的[首次]答题时间记分。杨斌 2018-05-08
                    List<PowerPoint.Shape> lstShape = PPTOper.GetDataLabelShape(Globals.SunVoteARSAddIn.PPTShow.SlideShow, DataLabelType.TIMER);
                    if ((lstShape.Count > 0) && (responseType == ResponseType.Choice))//有计时器,可能按正确答案的剩余时间计分。杨斌 2018-09-12
                    {
                        TagSet tagSet = new TagSet(Globals.SunVoteARSAddIn.PPTShow.SlideShow.Tags);

                        //计分模式,1:按选项分值,0:按正确答案,2:按正确答案和剩余时间
                        int scoreMode = tagSet.GetValue(TagKey.Choice_ScoreMode).ToInt;
                        if (scoreMode == 2)
                        {
                            //按未改变按键值的首次按键速度计算分数。杨斌 2018-05-15
                            double speed = ObjResponsePar.Speed;
                            if (ResponseDataList.Contains(keyID))
                            {
                                if (ResponseDataList[keyID].KeyValue == result + ",")
                                    speed = ResponseDataList[keyID].Speed;//取未改变按键值的首次按键速度
                            }

                            string sTime = tagSet.GetValue(TagKey.ResponseTimer).Value;
                            double timeTotal = ConvertOper.TimeToSecond(sTime);
                            double timeRes = timeTotal - speed;
                            if (timeRes < 0)
                                timeRes = 0;
                            if (timeRes > timeTotal)
                                timeRes = timeTotal;
                            score = score * timeRes / timeTotal;
                            score = ConvertOper.Convert(score.ToString("F4")).ToDouble;//保留4位小数
                        }
                    }

                    ObjResponsePar.Score = score;
                    ObjResponsePar.KeyValue = result + ",";
                    break;
                case ResponseType.Number:
                case ResponseType.Text://杨斌 2015-01-12
                    //判断是否正确,计算分数
                    if (IsCorrect(ResponseTypeNow, result, out score)) { ObjResponsePar.Correct = 1; }
                    //if (!string.IsNullOrEmpty(KeyIDQDOK) && (keyID != KeyIDQDOK) && (score < 0))//杨斌 2019-04-09
                    //    score = 0;
                    ObjResponsePar.Score = score;
                    ObjResponsePar.KeyValue = result;
                    break;
                case ResponseType.Poll:
                    //杨斌 2016-04-26
                    //if ((GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
                    //杨斌 2017-02-13
                    if (PanelPoll.IsUseMultiPoll(SlideNow) && PanelPoll.IsMultiPollKeypad())
                    {
                        if (string.IsNullOrEmpty(result))
                            return;
                        string[] aryPoll = result.Split('=');
                        //杨斌 2018-09-30。SDK分段式选举与数字选举不兼容,数字选举模式4值为"1=4",而分段式模式7值为"01-4"
                        int UseModeLimitNumber = TagSet.GetValue(TagKey.Poll_UseModeLimitNumber).ToInt;
                        if (UseModeLimitNumber == 1)
                        {
                            //新的键盘又乱改分隔符了,以前分段式是'-',现在又改成'=',不兼容,很好,干得漂亮!2020-06-12
                            ////aryPoll = result.Split('-');
                            if (result.IndexOf("-") > 0)
                                aryPoll = result.Split('-');
                            else
                                aryPoll = result.Split('=');
                        }

                        //PowerVote的定制选举,多个采用多次提交。杨斌 2017-06-12
                        if (((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote) || (GlobalInfo.OEMLogo == OEMLogos.oemAngage))//杨斌 2018-03-22
                            && (GlobalInfo.OEMLogo2 == OEMLogos2.SunVote))
                        {
                            if (aryPoll.Length < 2)
                            {
                                pollNo = "1";
                                pollValue = aryPoll[0];
                                pollNoInt = ConvertOper.Convert(pollNo).ToInt;
                                if ((CandidateInfoList.Count > 0) && (pollValue != "0"))
                                    if (!CandidateInfoList.Keys.Contains(pollValue)) { return; }
                                break;
                            }
                        }

                        if (aryPoll.Length < 2)
                            return;

                        pollNo = aryPoll[0];
                        pollValue = aryPoll[1];
                        pollNoInt = ConvertOper.Convert(pollNo).ToInt;

                        if (CandidateInfoList.Count > 0)//有名单情况判断,没有名单情况也可投。杨斌 2014-10-24                        
                            if (!CandidateInfoList.Keys.Contains(pollValue)) { return; }
                    }
                    else
                    {
                        //已经投过
                        if (CandidateInfoList.Count > 0)//有名单情况判断,没有名单情况也可投。杨斌 2014-10-24
                            if (!CandidateInfoList.Keys.Contains(keyValue)) { return; }
                    }
                    break;
                default:
                    break;

            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //键盘反馈信息
            if (ResponseDataList.Contains(keyID))
            {
                ResponseDataList[keyID].BaseTag = ObjResponsePar.BaseTag;
                ////ResponseDataList[keyID].KeyValue = ObjResponsePar.KeyValue;
                ResponseDataList[keyID].Time = ObjResponsePar.Time;
                ResponseDataList[keyID].Score = ObjResponsePar.Score;
                ResponseDataList[keyID].Correct = ObjResponsePar.Correct;
                //提交同一个结果时,按键速度不变。杨斌 2018-04-09
                if (ResponseDataList[keyID].KeyValue != ObjResponsePar.KeyValue)//杨斌 2018-05-16
                    ResponseDataList[keyID].Speed = ObjResponsePar.Speed;
                //杨斌 2016-04-27
                //if ((responseType == ResponseType.Poll) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
                //杨斌 2017-02-13
                if ((responseType == ResponseType.Poll) && PanelPoll.IsUseMultiPoll(SlideNow) && PanelPoll.IsMultiPollKeypad())
                {
                    string[] ary = ResponseDataList[keyID].KeyValue.Split(',');

                    //PowerVote的定制选举,多个采用多次提交。杨斌 2017-06-12
                    if (((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote) || (GlobalInfo.OEMLogo == OEMLogos.oemAngage))//杨斌 2018-03-22
                        && (GlobalInfo.OEMLogo2 == OEMLogos2.SunVote))
                    {
                        if (ary.Contains(pollValue))
                            return;
                        pollNoInt = 0;
                        for (int n = 0; n < ary.Length; n++)
                        {
                            if (string.IsNullOrEmpty(ary[n]))
                            {
                                pollNoInt = n + 1;
                                break;
                            }
                        }
                    }

                    if ((pollNoInt >= 1) && (pollNoInt <= ary.Length))
                        ary[pollNoInt - 1] = pollValue;

                    //PowerVote的定制选举,多个采用多次提交。杨斌 2017-06-12
                    if (((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote) || (GlobalInfo.OEMLogo == OEMLogos.oemAngage))//杨斌 2018-03-22
                        && (GlobalInfo.OEMLogo2 == OEMLogos2.SunVote))
                    {
                        if (pollValue == "0")
                        {
                            for (int n = 0; n < ary.Length; n++)
                                ary[n] = "";
                        }
                    }

                    ResponseDataList[keyID].KeyValue = string.Join(",", ary);
                }
                else
                {
                    ResponseDataList[keyID].KeyValue = ObjResponsePar.KeyValue;
                }
            }
            else
            {
                //杨斌 2016-02-24。容器保留的必须是新创建的。否则
                //上面修改同一个键盘ResponseDataList[keyID]值会导致LstResponseData.Add(ObjResponsePar)值被改变
                ResponsePar resPar = new ResponsePar();
                resPar.BaseTag = ObjResponsePar.BaseTag;
                resPar.KeyID = ObjResponsePar.KeyID;
                ////resPar.KeyValue = ObjResponsePar.KeyValue;
                resPar.Score = ObjResponsePar.Score;
                resPar.Correct = ObjResponsePar.Correct;
                resPar.Time = ObjResponsePar.Time;
                resPar.Speed = ObjResponsePar.Speed;
                ////ResponseDataList.Add(keyID, ObjResponsePar);
                //杨斌 2016-04-27
                //if ((responseType == ResponseType.Poll) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
                //杨斌 2017-02-13
                if ((responseType == ResponseType.Poll) && PanelPoll.IsUseMultiPoll(SlideNow) && PanelPoll.IsMultiPollKeypad())
                {
                    int limit = TagSet.GetValue(TagKey.Poll_EffectiveVotes).ToInt;
                    string[] ary = new string[limit];//GlobalInfo.maxNumberPollSelect
                    for (int i = 0; i < ary.Length; i++)
                        ary[i] = "";
                    if ((pollNoInt >= 1) && (pollNoInt <= ary.Length))
                        ary[pollNoInt - 1] = pollValue;

                    //PowerVote的定制选举,多个采用多次提交。杨斌 2017-06-12
                    if (((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote) || (GlobalInfo.OEMLogo == OEMLogos.oemAngage))//杨斌 2018-03-22
                        && (GlobalInfo.OEMLogo2 == OEMLogos2.SunVote))
                    {
                        if (pollValue == "0")
                        {
                            for (int n = 0; n < ary.Length; n++)
                                ary[n] = "";
                        }
                    }

                    resPar.KeyValue = string.Join(",", ary);
                }
                else
                {
                    resPar.KeyValue = ObjResponsePar.KeyValue;
                }
                ResponseDataList.Add(keyID, resPar);
            }

            LstResponseData.Add(ObjResponsePar);

            //网络版。杨斌 2018-12-13
            if (VoteServer.IsStart)
            {
                SendVoteAck(par);
            }

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //* 杨斌 2015-03-27。屏蔽。避免性能问题
            //更新选项反馈个数
            UpdateResponseCount(ResponseTypeNow);

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            //刷新标签
            //RefreshLable();
            //判断图表是否时时显示,刷新图表
            //if(TagSet.GetValue(TagKey.ChartPara_ShowTime).Value=="csStart")
            //   RefreshChart();
            if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar != null)//杨斌 2015-03-19
                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.frmVoteDetail.ChangeData(ObjResponsePar);
            //*/

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            TagSet.SetValue(TagKey.Responsed, 1);
            FrmVoteBar.PanelEnabled = false;
            if (IsResponsedEvent != null)
                IsResponsedEvent();

            ////System.Windows.Forms.Application.DoEvents();//杨斌 2015-03-27。避免卡死

            ss += t.ElapsedMilliseconds + " ";
            t.Restart();

            FrmVoteBar.ShowDebug(ss);
        }

        /// <summary>
        /// 评分-判断分数值是否有效
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public bool JudgeScoreValue(ref string keyValue)
        {
            bool bResult = true;
            //反馈限制的小数个数
            double minValue = TagSet.GetValue(TagKey.Score_LowRange).ToDouble;
            double maxValue = 0;
            string highRange = TagSet.GetValue(TagKey.Score_HighRange).Value;
            if (highRange == "")
                maxValue = 9999999999;
            else
                maxValue = ConvertOper.Convert(highRange).ToDouble;
            double score = ConvertOper.Convert(keyValue).ToDouble;
            string decStr = TagSet.GetValue(TagKey.Score_DecimalFormat).Value;
            //限定了输入小数个数
            if (decStr != "")
            {
                int dec = ConvertOper.Convert(decStr).ToInt;
                string formatStr = "0.";
                for (int i = 0; i < dec; i++)
                    formatStr += "0";
                score = Convert.ToDouble(score.ToString(formatStr));
            }
            if ((score > maxValue) || (score < minValue)) { bResult = false; }

            keyValue = score.ToString();
            return bResult;
        }

        /// <summary>
        /// 数字-判断分数值是否有效
        /// 杨斌 2012-03-13
        /// 修改:杨斌 2012-06-27
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public bool JudgeNumberValue(ref string keyValue)
        {
            bool bResult = true;
            //反馈限制的小数个数
            double minValue = 0;
            string lowRange = TagSet.GetValue(TagKey.Number_LowRange).Value;
            if (lowRange == "")
                minValue = -999999999;
            else
                minValue = ConvertOper.Convert(lowRange).ToDouble;

            double maxValue = 0;
            string highRange = TagSet.GetValue(TagKey.Number_HighRange).Value;
            if (highRange == "")
                maxValue = 9999999999;
            else
                maxValue = ConvertOper.Convert(highRange).ToDouble;
            double score = ConvertOper.Convert(keyValue).ToDouble;
            string decStr = TagSet.GetValue(TagKey.Number_DecimalFormat).Value;
            //限定了输入小数个数
            if (decStr != "")
            {
                int dec = ConvertOper.Convert(decStr).ToInt;
                string formatStr = "0.";
                for (int i = 0; i < dec; i++)
                    formatStr += "0";
                score = Convert.ToDouble(score.ToString(formatStr));
            }
            if ((score > maxValue) || (score < minValue)) { bResult = false; }

            keyValue = score.ToString();
            return bResult;
        }

        /// <summary>
        /// 更新每个选项的反馈人数
        /// 创建 赵丽
        /// 修改:杨斌 2012-03-13
        /// </summary>
        private void UpdateResponseCount(ResponseType responseType, PowerPoint.Slide sld = null)
        {
            ResponseOptionList.Clear();
            ResponseOptionListNoRate.Clear();//杨斌 2016-11-12
            ResponseOptionListCount.Clear();//杨斌 2016-01-07
            //杨斌 2018-01-27
            TagSet tagSet = TagSet;
            if (sld != null)
                tagSet = new TagSet(sld.Tags);

            try
            {
                int optionCount = 0;
                switch (responseType)
                {
                    case ResponseType.SignIn:
                        optionCount = 2;
                        break;
                    case ResponseType.Group:
                        optionCount = tagSet.GetValue(TagKey.Group_OptionCount).ToInt;
                        break;
                    case ResponseType.Choice:
                        optionCount = tagSet.GetValue(TagKey.Choice_OptionCount).ToInt;
                        break;
                    case ResponseType.Judge:
                        optionCount = 2;
                        break;
                    case ResponseType.Vote:
                        optionCount = tagSet.GetValue(TagKey.Vote_OptionCount).ToInt;
                        break;
                    case ResponseType.Grade:
                        optionCount = tagSet.GetValue(TagKey.Grade_OptionCount).ToInt;
                        break;
                    default:
                        break;
                }

                if (responseType == ResponseType.SignIn)
                {
                    //int responseCount = 0;
                    //for (int i = 0; i < ResponseDataList.Count; i++)
                    //{                    
                    //    if (ResponseDataList[i].KeyValue != "")
                    //        responseCount += 1;
                    //    ResponseOptionList["0"] = responseCount;
                    //    //未签到的人数
                    //    int unSignInCount = 0;
                    //    //启用名单
                    //    if (IsAllPerson)
                    //        unSignInCount = GlobalInfo.hardwareManage.PersonNum - responseCount;
                    //    else
                    //        unSignInCount = AuthorKeypadList.Count - responseCount;
                    //    ResponseOptionList["1"] = unSignInCount;
                    //}
                }
                else
                {
                    //更新个选项对应的反馈人数
                    //键盘投票权重:杨斌 2012-11-27
                    //2014-3-17 增加是否加权的方法

                    //杨斌 2015-03-27
                    //bool useVoteRate = isVoteRateA();
                    bool useVoteRate = isVoteRate();
                    //bool useVoteRate = CanVoteRate();

                    //杨斌 2015-01-26。屏蔽下面代码
                    //键盘权重功能的开启。杨斌 2012-11-30
                    //switch (GlobalInfo.OEMLogo)
                    //{
                    //    case OEMLogos.oemSunVote:
                    //    case OEMLogos.oemZX:
                    //        break;
                    //    default:
                    //        useVoteRate = false;
                    //        break;
                    //}

                    //杨斌 2016-11-12
                    for (int i = 0; i < optionCount; i++)
                    {
                        int responseCount = 0;
                        //string option = NumToABC(i + 1);
                        string option = (i + 1).ToString();
                        for (int j = 0; j < ResponseDataList.Count; j++)
                        {
                            //if (ResponseDataList[j].KeyValue.IndexOf(option + ",") != -1)
                            if (ResponseDataList[j].KeyValue.Split(',').Contains(option))//杨斌 2018-02-06
                            {
                                responseCount += 1;
                            }
                        }
                        ResponseOptionListNoRate[i.ToString()] = responseCount;
                    }

                    if (useVoteRate)
                    {
                        for (int i = 0; i < optionCount; i++)
                        {
                            double responseCount = 0;
                            //string option = NumToABC(i + 1);
                            string option = (i + 1).ToString();
                            for (int j = 0; j < ResponseDataList.Count; j++)
                            {
                                //if (ResponseDataList[j].KeyValue.IndexOf(option + ",") != -1)
                                if (ResponseDataList[j].KeyValue.Split(',').Contains(option))//杨斌 2018-02-06
                                {
                                    string keyId = ResponseDataList[j].KeyID.ToString();
                                    if (VoterRate.Contains(keyId))
                                        responseCount += 1 * VoterRate[keyId];//乘以权重
                                    else
                                    {
                                        //启用了名单,已投过票,但单名单改变情况,已投票但名单里不存在的权重设置为0。杨斌 2017-04-20
                                        //responseCount += 1;
                                        if (RosterList.RosterLoad.GetRowByKeyId(keyId) == null)
                                            responseCount += 0;
                                        else
                                            responseCount += 1;
                                    }
                                }
                            }
                            ResponseOptionList[i.ToString()] = responseCount;
                            //杨斌 2016-01-12
                            //GlobalInfo.response.LstResponseData
                            double responseNumCount = 0;
                            for (int j = 0; j < LstResponseData.Count; j++)
                            {
                                //if (LstResponseData[j].KeyValue.IndexOf(option + ",") != -1)
                                if (LstResponseData[j].KeyValue.Split(',').Contains(option))//杨斌 2018-02-06
                                {
                                    string keyId = LstResponseData[j].KeyID.ToString();
                                    responseNumCount += 1;
                                }
                            }

                            ResponseOptionListCount[i.ToString()] = responseNumCount;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < optionCount; i++)
                        {
                            int responseCount = 0;
                            //string option = NumToABC(i + 1);
                            string option = (i + 1).ToString();
                            for (int j = 0; j < ResponseDataList.Count; j++)
                            {
                                //if (ResponseDataList[j].KeyValue.IndexOf(option + ",") != -1)
                                if (ResponseDataList[j].KeyValue.Split(',').Contains(option))//杨斌 2018-02-06
                                {
                                    responseCount += 1;
                                }
                            }
                            ResponseOptionList[i.ToString()] = responseCount;
                            //杨斌 2016-01-12
                            //GlobalInfo.response.LstResponseData
                            double responseNumCount = 0;
                            for (int j = 0; j < LstResponseData.Count; j++)
                            {
                                //if (LstResponseData[j].KeyValue.IndexOf(option + ",") != -1)
                                if (LstResponseData[j].KeyValue.Split(',').Contains(option))//杨斌 2018-02-06
                                {
                                    string keyId = LstResponseData[j].KeyID.ToString();
                                    responseNumCount += 1;
                                }
                            }

                            ResponseOptionListCount[i.ToString()] = responseNumCount;
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }

        /// <summary>
        /// 判断是否启用了权重,并初始化权重值。
        /// 杨斌 2015-03-27
        /// </summary>
        /// <returns></returns>
        public bool isVoteRate()
        {
            bool res = isVoteRateA();

            if (res)
            {
                PowerPoint.Slide sld = null;
                if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
                {
                    sld = Globals.SunVoteARSAddIn.PPTShow.SlideShow;
                }
                else
                {
                    sld = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit;
                }
                GlobalInfo.response.InitRosterVoteRate(sld);
            }

            return res;

            //ResponseType responseType = ResponseType.Slide;//杨斌 2014-06-04            
            //Slide sld = null;
            //if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
            //{
            //    responseType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
            //    sld = Globals.SunVoteARSAddIn.PPTShow.SlideShow;
            //}
            //else
            //{
            //    responseType = Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit;
            //    sld = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit;
            //}
            //TagSet tagSet = new TagSet(sld.Tags);

            //bool useVoteRate = false;
            ////if (this.VoteRateIndex > 0)//杨斌 2015-01-26 屏蔽
            //{
            //    switch (responseType)
            //    {
            //        case ResponseType.Choice:
            //        case ResponseType.Judge:
            //        case ResponseType.Vote:
            //        case ResponseType.Grade://杨斌 2013-02-25

            //            string colName = tagSet.GetValue(TagKey.ResponsePara_VoteRateField).Value;
            //            useVoteRate = (colName.Length > 0);

            //            GlobalInfo.response.InitRosterVoteRate(sld);
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //return useVoteRate;
        }

        /// <summary>
        /// 仅判断是否启用的权重。杨斌 2015-03-27
        /// </summary>
        /// <returns></returns>
        public bool isVoteRateA()
        {
            ResponseType responseType = ResponseType.Slide;//杨斌 2014-06-04            
            PowerPoint.Slide sld = null;
            if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
            {
                responseType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
                sld = Globals.SunVoteARSAddIn.PPTShow.SlideShow;
            }
            else
            {
                responseType = Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit;
                sld = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit;
            }
            TagSet tagSet = new TagSet(sld.Tags);

            bool useVoteRate = false;
            //if (this.VoteRateIndex > 0)//杨斌 2015-01-26 屏蔽
            {
                switch (responseType)
                {
                    case ResponseType.Choice:
                    case ResponseType.Judge:
                    case ResponseType.Vote:
                    case ResponseType.Grade://杨斌 2013-02-25
                    case ResponseType.Poll://杨斌 2018-01-30
                        string colName = tagSet.GetValue(TagKey.ResponsePara_VoteRateField).Value;
                        useVoteRate = (colName.Length > 0) && this.EnableList;//杨斌 2017-01-06
                        break;
                    default:
                        break;
                }
            }
            return useVoteRate;
        }

        /// <summary>
        /// 是否支持权重
        /// 杨斌 2014-10-27
        /// </summary>
        /// <returns></returns>
        public bool CanVoteRate()
        {
            ResponseType responseType = ResponseType.Slide;//杨斌 2014-06-04
            if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
                responseType = Globals.SunVoteARSAddIn.PPTShow.ResponseType;
            else
                responseType = Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit;

            bool useVoteRate = false;
            switch (responseType)
            {
                case ResponseType.Choice:
                case ResponseType.Judge:
                case ResponseType.Vote:
                case ResponseType.Grade://杨斌 2013-02-25
                case ResponseType.Poll://杨斌 2018-01-30
                    useVoteRate = true;
                    break;
                default:
                    break;
            }

            return useVoteRate;
        }

        /// <summary>
        /// 判断键盘是否授权 
        /// 创建 赵丽
        /// </summary>
        /// <param name="KeyID"></param>
        /// <returns></returns>
        public bool IsAuthorize(string KeyID)
        {
            try
            {
                bool bResult = true;

                if (KeyIDQDOK.Length > 0)//杨斌 2014-05-20
                {
                    bResult = (KeyID == KeyIDQDOK);
                }
                else
                {
                    bool rosterEnabled = EnableList;//杨斌 2015-03-27

                    //投票人数达到参与人数
                    //启用了名单以名单为主
                    if (!rosterEnabled)
                    {
                        //屏蔽!!!。杨斌 2015-03-27。性能问题
                        //if (!GlobalInfo.hardwareManage.JudgeKeyStatus(KeyID)) { return false; }
                        if (!GlobalInfo.hardwareManage.JudgeKeypadRangeSet(KeyID)) { return false; }//杨斌 2016-05-19
                        if ((ResponseDataList.Count >= GlobalInfo.hardwareManage.PersonNum) && (!ResponseDataList.Contains(KeyID.ToString()))) { return false; }
                    }
                    string authorType = TagSet.GetValue(TagKey.ResponsePara_CanVote).Value;
                    //列ID
                    string colID = TagSet.GetValue(TagKey.ResponsePara_CanVoteGroup).Value;
                    string curSlideID = CurrentSlide.SlideID.ToString();
                    switch (authorType)
                    {
                        case "cvAll":
                            if (rosterEnabled)
                                bResult = AuthorKeypadList.Keys.Contains(KeyID.ToString());
                            //bResult = true;//杨斌 2015-01-14
                            break;
                        case "cvPerson":
                            if (rosterEnabled)
                                bResult = AuthorKeypadList.Keys.Contains(KeyID.ToString());
                            break;
                        case "cvTopic":
                            //启用名单时,判断该键盘是否有对应名单
                            if (rosterEnabled)
                                bResult = IsExistKeypad(KeyID.ToString());
                            bResult = AuthorKeypadList.Keys.Contains(KeyID.ToString());
                            break;
                        default:
                            if (rosterEnabled)
                                bResult = AuthorKeypadList.Keys.Contains(KeyID.ToString());
                            break;
                    }
                }

                return bResult;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 加载候选人名单
        /// 创建 赵丽
        /// </summary>
        public void LoadCandidateList()
        {
            CandidateInfoList.Clear();
            int PollCount = TagSet.GetValue(TagKey.Poll_CandidatesCount).ToInt;
            for (int i = 0; i < PollCount; i++)
            {
                //string CandidateID = TagSet.LoadValue(TagKey.Poll_CandidatesID_, i, "").Value.ToString();
                //杨斌 2016-04-26
                string CandidateID = TagSet.LoadValue(TagKey.Poll_CandidatesID_, i, "").ToInt.ToString();
                string CandidateName = TagSet.LoadValue(TagKey.Poll_CandidatesName_, i, "").Value.ToString();
                CandidateInfo candidateInfo = new CandidateInfo();
                candidateInfo.CandidateID = CandidateID;
                candidateInfo.CandidateName = CandidateName;
                if (!CandidateInfoList.Keys.Contains(CandidateID))
                {
                    CandidateInfoList.Add(CandidateID, candidateInfo);
                }
                else
                {
                    CandidateInfoList[CandidateID].CandidateID = CandidateID;
                    CandidateInfoList[CandidateID].CandidateName = CandidateName;
                }

            }

        }

        /// <summary>
        /// 加载反馈数据
        /// </summary>
        public void LoadResponseData()
        {
            ResponseDB.LoadResponseData();
            //更新选项反馈数量
            if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
            {
                if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Poll)
                    LoadCandidateList();
                else
                    UpdateResponseCount(Globals.SunVoteARSAddIn.PPTShow.ResponseType);
            }
            else//杨斌 2017-08-07
            {
                UpdateResponseCount(Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit);
            }
        }

        /// <summary>
        /// 保存反馈题目信息
        /// </summary>
        public void SaveResponseInfo()
        {
            ResponseDB.SaveResponseInfo();
        }

        /// <summary>
        /// 保存反馈数据
        /// </summary>
        public void SaveResponseData()
        {
            ResponseDB.SaveResponseData();
        }


        /// <summary>
        /// 刷新图表
        /// </summary>
        public void RefreshChart()
        {
            //杨斌 2014-09-12
            if (ResponseDataList.Count > 0)
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_IsResponsed, 1);

            //更新图片
            Globals.SunVoteARSAddIn.PPTEdit.InitChart(false, CurrentSlide);
        }

        /// <summary>
        /// 获取答对人数
        /// 创建:杨斌 2012-03-14
        /// </summary>
        /// <returns></returns>
        public int GetCorrectCount()
        {
            int res = 0;

            try
            {
                for (int i = 0; i < ResponseDataList.Count; i++)
                {
                    if (ResponseDataList[i].Correct > 0)
                    {
                        res++;
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }

            return res;
        }

        /*
        /// <summary>
        /// 刷新选举排行
        /// </summary>
        public void RefreshPollRank()
        {
            TagSet tagSet = new TagSet();
            tagSet.Tags = CurrentSlide.Tags;
            ResponseType responseType = EnumName<ResponseType>.GetEnum(tagSet.GetValue(TagKey.ResponseType).Value.ToString());
            if (responseType != ResponseType.Poll) return;
            Dictionary<string, int> pollRankList = new Dictionary<string, int>();
            if (ResponseDataList.Count == 0) return;
            try
            {
                foreach (PowerPoint.Shape s in CurrentSlide.Shapes)
                {
                    if (s.Name == "PollRank")
                    {
                        for (int i = 1; i <= 8; i++)
                        {
                            for (int j = 0; j < 4; j++)
                                s.Table.Cell(i + 1, j + 1).Shape.TextFrame.TextRange.Text = "";
                        }
                        for (int i = 0; i < ResponseDataList.Count; i++)
                        {
                            if (pollRankList.ContainsKey(ResponseDataList[i].KeyValue))
                                pollRankList[ResponseDataList[i].KeyValue]++;
                            else
                                pollRankList.Add(ResponseDataList[i].KeyValue, 1);
                        }
                        string[] keys = new string[pollRankList.Count];
                        int[] values = new int[pollRankList.Count];
                        pollRankList.Values.CopyTo(values, 0);
                        pollRankList.Keys.CopyTo(keys, 0);
                        System.Array.Sort(values, keys);
                        int iCount = (pollRankList.Count > 8) ? 8 : pollRankList.Count;
                        try
                        {
                            for (int i = 1; i <= iCount; i++)
                            {
                                s.Table.Cell(i + 1, 1).Shape.TextFrame.TextRange.Text = i.ToString();
                                s.Table.Cell(i + 1, 2).Shape.TextFrame.TextRange.Text = keys[pollRankList.Count - i];
                                s.Table.Cell(i + 1, 3).Shape.TextFrame.TextRange.Text = CandidateInfoList[keys[pollRankList.Count - i]].CandidateName;
                                s.Table.Cell(i + 1, 4).Shape.TextFrame.TextRange.Text = values[pollRankList.Count - i].ToString();
                            }
                        }
                        catch { }

                    }


                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }
       */

        //public TDictionary<string,int> SortByValue(TDictionary<string, int> di)
        //{
        //    string[] keys = new string[di.Count];
        //    int[] values = new int[di.Count];
        //    di.Values.CopyTo(values, 0);
        //    di.Keys.CopyTo(keys, 0);

        //    TDictionary<string, int> pollRankList = new TDictionary<string, int>();

        //    for (int i = 0; i < values.Length; i++)
        //    {
        //        if(!pollRankList.ContainsKey(keys[i].ToString()))
        //            pollRankList.Add(keys[i].ToString(),values[i]);

        //    }
        //    return pollRankList;
        //}
        /// <summary>
        /// 刷新标签
        /// 创建 赵丽
        /// 修改:杨斌 2012-03-15
        /// 修改:杨斌 2012-06-01
        /// 修改:杨斌 2012-06-11 搜索:DefPercentDecCount
        /// 杨斌 2015-03-27
        /// </summary>
        public void RefreshLable()
        {
            try
            {
                if (CurrentSlide == null) return;

                int dueno = 0;//应到人数
                double votedOk = 0;//反馈人数                

                string colName = Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.GetValue(TagKey.ResponsePara_VoteRateField).Value;
                bool isRate = (colName.Length > 0) && this.EnableList;//杨斌 2017-01-06

                //不带权重。杨斌 2018-07-30
                double participateNum_Men = GetParticipateNum();//参与人数
                double votedOk_Men = ResponseDataList.Count;//反馈人数

                int signedNum = -1;//实到人数。杨斌 2018-12-25。

                if (isRate)
                {
                    votedOk = GlobalInfo.response.GetResponseNum();
                }
                else
                {
                    votedOk = ResponseDataList.Count;//有效反馈人数(签到码为签到成功人数)。杨斌 2013-02-26
                }
                int submitNumNoRate = ResponseDataList.Count;//反馈人数无权重。杨斌 2019-01-14

                if (EnableList)
                {
                    //dueno = AuthorKeypadList.Count;
                    //2012-07-11 赵丽 更改参与人数
                    dueno = ResponseDB.LoadPersonList().Count;
                    //杨斌 2013-01-29
                    if (Globals.SunVoteARSAddIn.frmVoteBar != null)
                    {
                        FrmVoteDetail frmDetail = Globals.SunVoteARSAddIn.frmVoteBar.frmVoteDetail;
                        if (frmDetail != null)
                        {
                            if (frmDetail.IsCodeSignIn())//杨斌 2013-02-26
                            {
                                dueno = frmDetail.VoterCount;
                                votedOk = frmDetail.SignInOkCount;//杨斌 2013-02-26
                                votedOk_Men = frmDetail.SignInOkCount;//参与人数-不带权重。杨斌 2018-07-30
                            }
                        }
                    }
                }
                else
                    dueno = GlobalInfo.hardwareManage.PersonNum;


                //记录应到人数,便于统计
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_Dueno, dueno);

                //不带权重保存。杨斌 2018-07-30
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_ParticipantNum_Men, participateNum_Men);
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_SubmitNum_Men, votedOk_Men);

                //记录参与人数,便于统计 //杨斌 2015-03-27
                if (isRate)
                {
                    if (Globals.SunVoteARSAddIn.PPTShow.SlideShow != null)
                        ParticipateNum = GlobalInfo.response.GetParticipantNum(Globals.SunVoteARSAddIn.PPTShow.ResponseType, Globals.SunVoteARSAddIn.PPTShow.SlideShow);
                }
                else
                    ParticipateNum = GetParticipateNum();

                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_ParticipantNum, ParticipateNum);
                //记录反馈人数,便于统计数据标签
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_SubmitNum, votedOk);//杨斌 2013-02-26

                //记录赞成人数。杨斌 2018-07-25
                double voteYesCount = 0;
                double voteNoCount = 0;
                double voteAbsCount = 0;
                if (Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.Vote)
                {
                    string opt = "0";
                    if (isRate)//带权重
                    {
                        if (GlobalInfo.response.ResponseOptionList.Keys.Contains(opt)) //有反馈数据                            
                            voteYesCount = GlobalInfo.response.ResponseOptionList[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteYesCount, voteYesCount);

                        opt = "1";
                        if (GlobalInfo.response.ResponseOptionList.Keys.Contains(opt)) //有反馈数据                            
                            voteNoCount = GlobalInfo.response.ResponseOptionList[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteNoCount, voteNoCount);

                        opt = "2";
                        if (GlobalInfo.response.ResponseOptionList.Keys.Contains(opt)) //有反馈数据                            
                            voteAbsCount = GlobalInfo.response.ResponseOptionList[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteAbsCount, voteAbsCount);
                    }
                    else//不带权重
                    {
                        if (GlobalInfo.response.ResponseOptionListNoRate.Keys.Contains(opt)) //有反馈数据                            
                            voteYesCount = GlobalInfo.response.ResponseOptionListNoRate[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteYesCount, voteYesCount);

                        opt = "1";
                        if (GlobalInfo.response.ResponseOptionListNoRate.Keys.Contains(opt)) //有反馈数据                            
                            voteNoCount = GlobalInfo.response.ResponseOptionListNoRate[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteNoCount, voteNoCount);

                        opt = "2";
                        if (GlobalInfo.response.ResponseOptionListNoRate.Keys.Contains(opt)) //有反馈数据                            
                            voteAbsCount = GlobalInfo.response.ResponseOptionListNoRate[opt];
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.VoteAbsCount, voteAbsCount);
                    }
                }

                string sPercent = "";//百分比
                int correct = GetCorrectCount();//答对人数
                //记录答对人数,便于统计数据标签
                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_CorrectNum, correct);

                //记录平均值。杨斌 2014-04-15
                int dMean = 0;
                for (int i = 0; i < ResponseDataList.Count; i++)
                {
                    string[] aryVal = ResponseDataList[i].KeyValue.Split(new char[] { ',' });
                    for (int n = 0; n < aryVal.Length; n++)
                        dMean += ConvertOper.Convert(aryVal[n]).ToInt;
                }
                string sMean = "0";
                if (votedOk > 0)
                    sMean = ConvertOper.Round45((double)dMean / votedOk, 2).ToString();

                if (ResponseDataList.Count > 0)
                    sMean = ConvertOper.Round45((double)dMean / ResponseDataList.Count, 2).ToString();

                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_VoteMean, sMean);

                //计算评议平均分。杨斌 2019-06-27
                string sGradeAvg = "0";
                string gradeScoreOption = Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.GetValue(TagKey.Grade_ScoreOption).Value;
                if (!string.IsNullOrEmpty(gradeScoreOption))
                {
                    var aryGradeScoreSet = gradeScoreOption.Split(PublicFunction.SplitItemScore);//杨斌 2019-07-19
                    if (aryGradeScoreSet.Length > 0)
                    {
                        sGradeAvg = GlobalInfo.response.ResponseDB.GetGradeScore(aryGradeScoreSet);
                        sGradeAvg = ConvertOper.Convert(sGradeAvg).ToDouble.ToString();
                        Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_GradeAvg, sGradeAvg);
                    }
                }

                //百分比分母,如图表、正确率
                string percentMode = Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.GetValue(TagKey.ChartPara_DataPercentBase).Value;
                double percentCountCorrect = ParticipateNum;//默认"crParticipant"
                switch (percentMode)
                {
                    case "crResponse":
                        percentCountCorrect = ResponseDataList.Count;
                        break;
                    case "crParticipant":
                        break;
                }
                //杨斌 2015-06-03
                if (isRate)
                {
                    if (Globals.SunVoteARSAddIn.PPTShow.SlideShow != null)
                        percentCountCorrect = GlobalInfo.response.GetParticipantNumNoRate(Globals.SunVoteARSAddIn.PPTShow.ResponseType, Globals.SunVoteARSAddIn.PPTShow.SlideShow);
                }
                else
                    percentCountCorrect = ParticipateNum;

                double notVoted = ParticipateNum - votedOk;//未按人数。杨斌 2015-04-20

                //杨斌 2015-06-15
                if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar != null)
                    Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.ShowVotedCount(submitNumNoRate);//之前是带权重的votedOk。杨斌 2019-04-17

                foreach (PowerPoint.Shape shape in CurrentSlide.Shapes)
                {
                    switch (shape.Name)
                    {
                        case "DUENO"://应到人数
                            PPTOper.ShowLabelData(shape, dueno.ToString());
                            break;
                        case "SIGNED"://实到人数。杨斌 2018-12-25
                            if (signedNum == -1)
                                signedNum = ReportEx.GetSignedNum(CurrentSlide);//实到人数=上一个签到的人数。杨斌 2018-12-24
                            PPTOper.ShowLabelData(shape, signedNum.ToString());
                            break;
                        case "NOTSIGNED"://未到人数。杨斌 2019-01-14
                            if (signedNum == -1)
                                signedNum = ReportEx.GetSignedNum(CurrentSlide);//实到人数=上一个签到的人数。
                            int notSignedNum = dueno - signedNum;//未到人数
                            PPTOper.ShowLabelData(shape, notSignedNum.ToString());
                            break;
                        case "VotingMissSigned"://已到未按人数。杨斌 2019-01-14
                            //if (signedNum == -1)
                            //    signedNum = ReportEx.GetSignedNum(CurrentSlide);//实到人数=上一个签到的人数。
                            //int notVotedSigned = signedNum - submitNumNoRate;
                            var lstIDSin = ReportEx.GetSignedIDs(CurrentSlide);
                            List<string> lstIDRes = new List<string>();
                            if (Globals.SunVoteARSAddIn.PPTShow.SlideShow == null)
                            {
                                lstIDRes = ReportEx.GetResponseIDs(CurrentSlide);
                            }
                            else
                            {
                                for (int i = 0; i < GlobalInfo.response.ResponseDataList.Count; i++)
                                {
                                    if (!lstIDRes.Contains(GlobalInfo.response.ResponseDataList[i].KeyID))
                                        lstIDRes.Add(GlobalInfo.response.ResponseDataList[i].KeyID);
                                }
                            }
                            int notVotedSigned = 0;
                            foreach (var v in lstIDSin)
                            {
                                if (!lstIDRes.Contains(v))
                                    notVotedSigned++;
                            }
                            PPTOper.ShowLabelData(shape, notVotedSigned.ToString());
                            break;
                        case "VOTENO"://反馈人数
                            PPTOper.ShowLabelData(shape, votedOk.ToString());//杨斌 2013-02-26
                            break;
                        case "VOTENOP"://反馈人数-百分比
                            sPercent = ConvertOper.GetPercent(votedOk, ParticipateNum, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, sPercent);
                            break;
                        case "VOTENOPV"://反馈人数-数值+百分比
                            sPercent = ConvertOper.GetPercent(votedOk, ParticipateNum, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, votedOk.ToString() + " (" + sPercent + ")");
                            break;
                        //杨斌 2015-04-20
                        case "VOTEMiss"://未按人数
                            PPTOper.ShowLabelData(shape, notVoted.ToString());//杨斌 2013-02-26
                            break;
                        case "VOTEMissP"://未按人数-百分比
                            sPercent = ConvertOper.GetPercent(notVoted, ParticipateNum, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, sPercent);
                            break;
                        case "VOTEMissPV"://未按人数-数值+百分比
                            sPercent = ConvertOper.GetPercent(notVoted, ParticipateNum, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, notVoted.ToString() + " (" + sPercent + ")");
                            break;

                        case "VOTEMEAN"://平均值。杨斌 2014-04-14                            
                            if ((GlobalInfo.OEMLogo == OEMLogos.oemiPericles) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemHideData))//杨斌 2020-03-06
                            {
                                sMean = "--";
                            }
                            PPTOper.ShowLabelData(shape, sMean);
                            break;
                        case "GradeAvg"://评议平均分。杨斌 2019-06-27
                            PPTOper.ShowLabelData(shape, sGradeAvg);
                            break;
                        case "ANSWER"://正确答案
                            string correctAsw = Globals.SunVoteARSAddIn.PPTEdit.GetSlideCorrectAnswer(CurrentSlide, Globals.SunVoteARSAddIn.PPTShow.ResponseType);
                            //杨斌 2012-07-02                            
                            bool bABCD = (Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1);
                            if (bABCD)
                                correctAsw = PPTOper.FormatNumABC(correctAsw);
                            PPTOper.ShowLabelData(shape, correctAsw);
                            break;
                        case "CorrectShape"://正确答案标记。杨斌 2015-01-26

                            break;
                        case "CRRECTNO"://答对人数
                            PPTOper.ShowLabelData(shape, correct.ToString());
                            break;
                        case "CRRECTNOP"://答对人数-百分比
                            sPercent = ConvertOper.GetPercent(correct, percentCountCorrect, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, sPercent);
                            break;
                        case "CRRECTNOPV"://答对人数-数值+百分比
                            sPercent = ConvertOper.GetPercent(correct, percentCountCorrect, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, correct.ToString() + " (" + sPercent + ")");
                            break;
                        case "PARTICIPATE"://参与人数
                            PPTOper.ShowLabelData(shape, ParticipateNum.ToString());
                            break;
                        case "VoteMedian"://平均值。杨斌 2016-03-29
                            //假设有5个参与者,他们选择的答案分别为 1,3,5,11,15,则中间值为5;即参与者提交的答案个数为奇数位时,中间值为正中位置的数值。
                            //假设有6个参与者,他们选择的答案分别为 1,3,5,10,11,12,则中间值为7.5(中间2位数的平均值,即5和10相加的后的平均值);即参与者提交的答案个数为偶数位时,中间值为正中间2个数值的平均值。
                            List<double> lstRes = new List<double>();
                            double median = 0;
                            string[] aryOption = PPTOper.GetOptionTextBySlide(Globals.SunVoteARSAddIn.PPTShow.SlideShow);
                            if (aryOption != null)
                            {
                                for (int i = 0; i < ResponseDataList.Count; i++)
                                {
                                    int a = 0;
                                    string sRes = ResponseDataList[i].KeyValue;
                                    if (sRes.Substring(sRes.Length - 1) == ",")
                                        sRes = sRes.Substring(0, sRes.Length - 1);
                                    if (int.TryParse(sRes, out a))
                                    {
                                        //取题目选项的数值
                                        if ((a >= 1) && (a <= aryOption.Length))
                                        {
                                            double b = 0;
                                            if (double.TryParse(aryOption[a - 1], out b))
                                            {
                                                //if (!lstRes.Contains(b))
                                                lstRes.Add(b);
                                            }
                                            else
                                            {
                                                lstRes.Add(a);//杨斌 2020-05-08
                                            }
                                        }
                                    }
                                }
                                if (lstRes.Count > 0)
                                {
                                    lstRes = lstRes.OrderBy(o => o).ToList<double>();
                                    if ((lstRes.Count % 2) == 1)
                                    {
                                        median = lstRes[lstRes.Count / 2];
                                    }
                                    else
                                    {
                                        median = ConvertOper.Round45((lstRes[lstRes.Count / 2 - 1] + lstRes[lstRes.Count / 2]) / 2, 2);
                                    }
                                }
                                //保存值
                                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_VoteMedian, median);
                            }
                            else//评分计算中间值。杨斌 2020-05-08
                            {
                                for (int i = 0; i < ResponseDataList.Count; i++)
                                {
                                    int a = 0;
                                    string sRes = ResponseDataList[i].KeyValue;
                                    //if (sRes.Substring(sRes.Length - 1) == ",")
                                    //    sRes = sRes.Substring(0, sRes.Length - 1);
                                    if (int.TryParse(sRes, out a))
                                    {
                                        lstRes.Add(a);//杨斌 2020-05-08
                                    }
                                }
                                if (lstRes.Count > 0)
                                {
                                    lstRes = lstRes.OrderBy(o => o).ToList<double>();
                                    if ((lstRes.Count % 2) == 1)
                                    {
                                        median = lstRes[lstRes.Count / 2];
                                    }
                                    else
                                    {
                                        median = ConvertOper.Round45((lstRes[lstRes.Count / 2 - 1] + lstRes[lstRes.Count / 2]) / 2, 2);
                                    }
                                }
                                //保存值
                                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_VoteMedian, median);
                            }
                            string sMedian = median.ToString();
                            if ((GlobalInfo.OEMLogo == OEMLogos.oemiPericles) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemHideData))//杨斌 2020-03-06
                            {
                                sMedian = "--";
                            }
                            PPTOper.ShowLabelData(shape, sMedian);
                            break;
                        case "VoteRange"://投票范围。杨斌 2016-03-29
                            //假设有5个参与者,他们选择的答案选项分别为3,4,5,6,9. 那么答案选项的范围则为3-9.
                            List<double> lstResR = new List<double>();
                            string range = "-";
                            string[] aryOptionR = PPTOper.GetOptionTextBySlide(Globals.SunVoteARSAddIn.PPTShow.SlideShow);
                            if (aryOptionR != null)
                            {
                                for (int i = 0; i < ResponseDataList.Count; i++)
                                {
                                    int a = 0;
                                    string sRes = ResponseDataList[i].KeyValue;
                                    if (sRes.Substring(sRes.Length - 1) == ",")
                                        sRes = sRes.Substring(0, sRes.Length - 1);
                                    if (int.TryParse(sRes, out a))
                                    {
                                        //取题目选项的数值
                                        if ((a >= 1) && (a <= aryOptionR.Length))
                                        {
                                            double b = 0;
                                            if (double.TryParse(aryOptionR[a - 1], out b))
                                            {
                                                if (!lstResR.Contains(b))
                                                    lstResR.Add(b);
                                            }
                                            else
                                            {
                                                if (!lstResR.Contains(a))//杨斌 2020-05-08
                                                    lstResR.Add(a);
                                            }
                                        }
                                    }
                                }
                                if (lstResR.Count > 0)
                                {
                                    lstResR = lstResR.OrderBy(o => o).ToList<double>();
                                    range = lstResR[0] + "-" + lstResR[lstResR.Count - 1];
                                }
                                //保存值
                                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_VoteRange, range);
                            }
                            else//评分计算中间值。杨斌 2020-05-08
                            {
                                for (int i = 0; i < ResponseDataList.Count; i++)
                                {
                                    int a = 0;
                                    string sRes = ResponseDataList[i].KeyValue;
                                    //if (sRes.Substring(sRes.Length - 1) == ",")
                                    //    sRes = sRes.Substring(0, sRes.Length - 1);
                                    if (int.TryParse(sRes, out a))
                                    {
                                        if (!lstResR.Contains(a))//杨斌 2020-05-08
                                            lstResR.Add(a);
                                    }
                                }
                                if (lstResR.Count > 0)
                                {
                                    lstResR = lstResR.OrderBy(o => o).ToList<double>();
                                    range = lstResR[0] + "-" + lstResR[lstResR.Count - 1];
                                }
                                //保存值
                                Globals.SunVoteARSAddIn.PPTShow.TagSetSlide.SetValue(TagKey.Slide_VoteRange, range);
                            }
                            PPTOper.ShowLabelData(shape, range);
                            break;
                        case "VotePassResult"://表决通过结果。杨斌 2018-07-25
                            string pass = GlobalInfo.SysLanguage.LPT.ReadString("PanelVote", "VotePass", "Pass");
                            string noPass = GlobalInfo.SysLanguage.LPT.ReadString("PanelVote", "VoteNotPass", "Not Pass");
                            bool isPass = PPTEdit.IsVotePass(CurrentSlide);
                            string passResult = isPass ? pass : noPass;
                            PPTOper.ShowLabelData(shape, passResult);
                            break;
                        case "PARTICIPATE_Men"://参与人数-不带权重。杨斌 2018-07-30
                            PPTOper.ShowLabelData(shape, participateNum_Men.ToString());
                            break;
                        case "VOTENO_Men"://反馈人数-不带权重。杨斌 2018-07-30
                            PPTOper.ShowLabelData(shape, votedOk_Men.ToString());
                            break;
                        case "VOTENOP_Men"://反馈人数-百分比-不带权重。杨斌 2018-07-30
                            sPercent = ConvertOper.GetPercent(votedOk_Men, participateNum_Men, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, sPercent);
                            break;
                        case "VOTENOPV_Men"://反馈人数-数值+百分比-不带权重。杨斌 2018-07-30
                            sPercent = ConvertOper.GetPercent(votedOk_Men, participateNum_Men, PPTEdit.DefPercentDecCount);
                            PPTOper.ShowLabelData(shape, votedOk_Men.ToString() + " (" + sPercent + ")");
                            break;
                        default:
                            break;
                    }
                }

                if ((ParticipateNum == ResponseDataList.Count) && (ParticipateNum != 0) && (businessStatus == ResponseStatus.bsStart))
                {
                    if (GlobalInfo.sysConfig.IsAutoPageAllVoted)
                    {
                        if (!IsNextSlide)
                        {
                            //杨斌 2014-08-20 屏蔽下面
                            //if (StopEvent != null) StopEvent();  //2013-2-27 最后一张幻灯片自动仍然在反馈                            

                            //杨斌 2014-11-05
                            if (Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsVoteStart)
                            {
                                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.VoteStart(false);
                                if (GlobalInfo.sysConfig.StopShowCorrectAsw)//杨斌 2019-09-03
                                {
                                    Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.tsbCorrectAnswer.Checked = true;//ShowCorrectAnswerButtonState();
                                }
                            }

                            //杨斌 2014-08-20
                            if ((!Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.tmrDelayVoteStart.Enabled) &&
                                (!Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsRunNextSlideEvent))
                            {
                                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.IsAutoPageAllVoted = true;
                                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.DelayVoteStart = GlobalInfo.sysConfig.AutoPageWaitTime;
                                NextSlide = true;
                                //NextSlideEvent();//用事件会发生意外的时序,乱。杨斌 2014-08-20
                                Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.response_NextSlideEvent();
                            }
                        }
                        IsNextSlide = true;
                    }

                }
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }

        /// <summary>
        /// 清空所有的标签数据
        /// 创建 赵丽
        /// </summary>
        public void InitLable()
        {
            foreach (PowerPoint.Shape shape in CurrentSlide.Shapes)
            {
                switch (shape.Name)
                {
                    case "CRRECTNO":
                        break;
                    case "VOTENO":
                        break;
                    case "VOTENOP":
                        break;
                    case "VOTENOPV":
                        break;
                    case "VOTENO_Men"://杨斌 2018-07-30
                        break;
                    case "VOTENOP_Men"://杨斌 2018-07-30
                        break;
                    case "VOTENOPV_Men"://杨斌 2018-07-30
                        break;
                    case "CRRECTNOP":
                        break;
                    case "CRRECTNOPV":
                        break;
                    case "TIMER":
                        //shape.TextFrame.TextRange.Text = "00:30";
                        PPTOper.ReSetTimer(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);//杨斌 2012-03-16
                        break;
                    default:
                        break;
                }
            }
        }


        /// <summary>
        /// 加载键盘授权信息
        /// 创建 赵丽
        /// </summary>
        private void LoadAuthorKeypadList()
        {
            try
            {
                AuthorKeypadList.Clear();
                string curSlideID = CurrentSlide.SlideID.ToString();
                int curSlideIndex = CurrentSlide.SlideIndex;
                string authorType = TagSet.GetValue(TagKey.ResponsePara_CanVote).Value;
                switch (authorType)
                {
                    case "cvPerson":
                        IsAllPerson = true;
                        if (EnableList)
                        {
                            IsAllPerson = false;
                            ResponseDB.LoadAuthorKeypadPerson(curSlideID, TagSet);
                        }
                        break;
                    case "cvTopic":
                        IsAllPerson = false;
                        ResponseDB.LoadAuthorKeypadTopic(TagSet, curSlideIndex);
                        break;
                    case "cvAll":
                        //所有人,且启用名单
                        if (EnableList) { IsAllPerson = false; LoadPersonList(); } else { IsAllPerson = true; }
                        ////杨斌 2015-01-14
                        //IsAllPerson = true;
                        //if (EnableList)                        
                        //    LoadPersonList();    
                        break;
                    default:
                        if (EnableList) { IsAllPerson = false; LoadPersonList(); } else { IsAllPerson = true; }
                        break;
                }

            }
            catch (Exception ex)
            {
            }
        }

        /// <summary>
        /// 加载人员名单 
        /// 创建 赵丽
        /// </summary>
        private void LoadPersonList()
        {
            AuthorKeypadList = ResponseDB.LoadPersonList();
        }


        /// <summary>
        /// 加载反馈结果,幻灯片浏览编辑的时候加载反馈数据
        /// </summary>
        /// <param name="topicID"></param>
        public void LoadTopicResult(string topicID, ResponseType responseType)
        {
            //LoadAuthorKeypadList();
            //List<string> keylist = AuthorKeypadList.Keys.ToList<string>();
            ResponseDataList.Clear();
            ResponseOptionList.Clear();
            ResponseOptionListNoRate.Clear();//杨斌 2016-11-12
            ResponseDataList = ResponseDB.GetResponseData(topicID, responseType, LstResponseData);
            //杨斌 2018-01-27
            PowerPoint.Slide sldFind = null;
            try
            {
                PowerPoint.Presentation pres = Globals.SunVoteARSAddIn.Application.ActivePresentation;
                sldFind = pres.Slides.FindBySlideID(ConvertOper.Convert(topicID).ToInt);
            }
            catch { }
            UpdateResponseCount(responseType, sldFind);
        }

        ///// <summary>
        ///// //2012-10-11 屏蔽名单更改
        ///// </summary>
        ///// <param name="topicID"></param>
        ///// <param name="responseType"></param>
        //public void RefreshResult(string topicID, ResponseType responseType)
        //{
        //    ResponseDB.DeleteTopicResult();
        //    LoadTopicResult(topicID, responseType);
        //    ResponseDB.SaveResponseResult(Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides.FindBySlideID(Convert.ToInt32(topicID)));
        //}




        /// <summary>
        /// 获得参与人数
        /// 创建 赵丽
        /// </summary>
        /// <returns></returns>
        public int GetParticipateNum()
        {
            try
            {
                int iNum = 0;
                string sSql = "";
                DataSet ds = null;
                string curSlideID = CurrentSlide.SlideID.ToString();
                string authorType = TagSet.GetValue(TagKey.ResponsePara_CanVote).Value;
                string authorValue = "0";
                switch (authorType)
                {
                    case "cvAll":
                    case "cvPerson":
                        if (EnableList) { iNum = AuthorKeypadList.Count; } else { iNum = GlobalInfo.hardwareManage.PersonNum; }
                        break;
                    case "cvTopic":
                        iNum = AuthorKeypadList.Count;
                        break;
                    default:
                        if (EnableList) { iNum = AuthorKeypadList.Count; } else { iNum = GlobalInfo.hardwareManage.PersonNum; }
                        break;
                }
                return iNum;
            }
            catch
            {
                return 0;
            }
        }

        /// <summary>
        /// 判断键盘是否有名单对应
        /// </summary>
        /// <param name="keyID"></param>
        public bool IsExistKeypad(string keyID)
        {
            bool bResult = false;
            DataSet ds = null;
            string sSql = "select a.* from ST_RosterValue a,ST_RosterColumn b where "
                       + "a.RC_ID=b.RC_ID and b.RC_Index=1 and a.RV_Text='" + keyID + "'";
            ds = GlobalInfo.DBOperation.OpenDataSet(sSql);
            if (ds.Tables[0].Rows.Count != 0)
                bResult = true;
            return bResult;
        }

        /// <summary>
        /// 判断答案是否正确,计算得分
        /// 创建 赵丽
        /// 修改:杨斌 2012-03-13
        /// 修改:杨斌 2012-10-22
        /// </summary>
        /// <returns></returns>
        private bool IsCorrect(ResponseType responseType, string keyValue, out double dScore)
        {
            string currectAnswer = "";
            string currectAnswer2 = "";//杨斌 2012-10-22
            bool bResult = false;
            dScore = 0;

            int scoreMode = 0;
            string[] aryAnswer = null;
            string[] keyValues = null;

            switch (responseType)
            {
                case ResponseType.Choice:
                    currectAnswer = TagSet.GetValue(TagKey.Choice_CorrectAnswer).Value;
                    currectAnswer2 = TagSet.GetValue(TagKey.Choice_CorrectAnswer2).Value;//杨斌 2012-10-22

                    //计分模式,1:按选项分值,0:按正确答案,2:按正确答案和剩余时间
                    scoreMode = TagSet.GetValue(TagKey.Choice_ScoreMode).ToInt;

                    //按选项计分或按正确答案计分。杨斌 2015-03-27。为投票性能优化                    
                    if ((scoreMode == 0) || (scoreMode == 2))//正确答案和剩余时间,杨斌 2018-05-08
                    {
                        if (currectAnswer.Length < 1)
                            return false;
                    }

                    aryAnswer = currectAnswer.Split(',');
                    keyValues = keyValue.Split(',');
                    if (PublicFunction.AryIsEqual(aryAnswer, keyValues))
                        bResult = true;
                    //按选项计分或按正确答案计分,
                    if (scoreMode == 1)
                    {
                        string optionScore = TagSet.GetValue(TagKey.Choice_ScoreOption).Value;
                        Dictionary<int, double> optionScoreList = PublicFunction.GetItemScore(optionScore);
                        double dTotalScore = 0;
                        //计算总分数
                        for (int i = 0; i < keyValues.Length; i++)
                        {
                            int optionItem = ConvertOper.Convert(keyValues[i]).ToInt;
                            if (optionScoreList.Keys.Contains(optionItem))
                                dTotalScore += optionScoreList[optionItem];
                        }
                        dScore = dTotalScore;
                        //选项总分为负清零
                        int ScoreOptionZero = TagSet.GetValue(TagKey.Choice_ScoreOptionZero).ToInt;
                        if ((ScoreOptionZero == 1) && (dScore < 0))
                            dScore = 0;
                        //杨斌 2012-10-22    
                        bResult = false;
                        string sNum = FormatABCTo123(currectAnswer2);
                        sNum = sNum.Replace("10", "0");
                        aryAnswer = sNum.Split(',');
                        if (PublicFunction.AryIsEqual(aryAnswer, keyValues))
                            bResult = true;
                        //2012-11-21 日本按选项计分,设置正确答案后,只要没有答对都计0分
                        if (GlobalInfo.OEMLogo == OEMLogos.oem3eAnalyzer)
                        {
                            if ((!bResult) && (currectAnswer2 != ""))
                                dScore = 0;
                        }
                    }//按选项计分
                    else
                    {
                        if (currectAnswer.Length > 0)//没有正确答案不计分,杨斌 2012-03-01
                        {
                            if (bResult)
                            {
                                int rightScore = TagSet.GetValue(TagKey.Choice_ScoreRight).ToInt;
                                dScore = rightScore;
                            }
                            else
                            {
                                int wrongScore = TagSet.GetValue(TagKey.Choice_ScoreWrong).ToInt;
                                dScore = wrongScore;
                            }
                        }
                    }//按正确答案计分
                    break;
                case ResponseType.Judge://杨斌 2012-03-13
                    currectAnswer = TagSet.GetValue(TagKey.Judge_CorrectAnswer).Value;
                    currectAnswer2 = TagSet.GetValue(TagKey.Judge_CorrectAnswer2).Value;//杨斌 2012-10-22

                    //计分模式,1:按选项分值,0:按正确答案
                    scoreMode = TagSet.GetValue(TagKey.Judge_ScoreMode).ToInt;

                    //按选项计分或按正确答案计分。杨斌 2015-03-27。为投票性能优化                    
                    if ((scoreMode == 0) || (scoreMode == 2))//正确答案和剩余时间,杨斌 2018-05-08
                    {
                        if (currectAnswer.Length < 1)
                            return false;
                    }

                    aryAnswer = currectAnswer.Split(',');
                    keyValues = keyValue.Split(',');
                    if (PublicFunction.AryIsEqual(aryAnswer, keyValues))
                        bResult = true;
                    //按选项计分或按正确答案计分,
                    if (scoreMode == 1)
                    {
                        string optionScore = TagSet.GetValue(TagKey.Judge_ScoreOption).Value;
                        Dictionary<int, double> optionScoreList = PublicFunction.GetItemScore(optionScore);
                        double dTotalScore = 0;
                        //计算总分数
                        for (int i = 0; i < keyValues.Length; i++)
                        {
                            int optionItem = ConvertOper.Convert(keyValues[i]).ToInt;
                            if (optionScoreList.Keys.Contains(optionItem))
                                dTotalScore += optionScoreList[optionItem];
                        }
                        dScore = dTotalScore;
                        //选项总分为负清零
                        int ScoreOptionZero = TagSet.GetValue(TagKey.Judge_ScoreOptionZero).ToInt;
                        if ((ScoreOptionZero == 1) && (dScore < 0))
                            dScore = 0;

                        //杨斌 2012-10-22    
                        bResult = false;
                        string sNum = FormatABCTo123(currectAnswer2);
                        sNum = sNum.Replace("10", "0");
                        aryAnswer = sNum.Split(',');
                        if (PublicFunction.AryIsEqual(aryAnswer, keyValues))
                            bResult = true;
                        //2012-11-21 日本按选项计分,设置正确答案后,只要没有答对都计0分
                        if (GlobalInfo.OEMLogo == OEMLogos.oem3eAnalyzer)
                        {
                            if ((!bResult) && (currectAnswer2 != ""))
                                dScore = 0;
                        }

                    }//按选项计分
                    else
                    {
                        if (currectAnswer.Length > 0)//没有正确答案不计分,杨斌 2012-03-01
                        {
                            if (bResult)
                            {
                                int rightScore = TagSet.GetValue(TagKey.Judge_ScoreRight).ToInt;
                                dScore = rightScore;
                            }
                            else
                            {
                                int wrongScore = TagSet.GetValue(TagKey.Judge_ScoreWrong).ToInt;
                                dScore = wrongScore;
                            }
                        }
                    }//按正确答案计分
                    break;
                case ResponseType.Order:
                    //2012-12-25 不需要去掉分隔符,否则答案判断有误 赵丽
                    //keyValue = keyValue.Replace(",", "");//排序题格式化去掉分隔符。杨斌 2012-11-19
                    currectAnswer = TagSet.GetValue(TagKey.Order_CorrectAnswer).Value;
                    scoreMode = TagSet.GetValue(TagKey.Order_ScoreMode).ToInt;
                    if (scoreMode == 0)//排序计分模式2判断有误。杨斌 2018-07-06
                    //if ((scoreMode == 0) || (scoreMode == 2))//正确答案和剩余时间,杨斌 2018-05-08
                    {
                        if (currectAnswer.Length > 0)//没有正确答案不计分,杨斌 2012-03-01
                        {
                            if (keyValue == currectAnswer) { bResult = true; }
                            if (bResult)
                            {
                                int rightScore = TagSet.GetValue(TagKey.Order_ScoreRight).ToInt;
                                dScore = rightScore;
                            }
                            else
                            {
                                int wrongScore = TagSet.GetValue(TagKey.Order_ScoreWrong).ToInt;
                                dScore = wrongScore;
                            }
                        }
                    }
                    else if (scoreMode == 2)//杨斌 2016-06-02
                    {
                        if ((currectAnswer.Length > 0) && (keyValue.Length > 0))
                        {
                            string[] aryCorrect = currectAnswer.Split(',');
                            string[] aryResult = keyValue.Split(',');

                            Dictionary<int, double> dicScoreOpt = new Dictionary<int, double>();
                            string scoreOpt = TagSet.GetValue(TagKey.Order_ScoreOption).Value;
                            string[] aryScore = scoreOpt.Split(PublicFunction.SplitItemScore);//杨斌 2019-07-19
                            for (int i = 0; i < aryScore.Length; i++)
                            {
                                string[] aryScoreItem = aryScore[i].Split(new char[] { '=' });
                                if (aryScoreItem.Length >= 2)
                                {
                                    int opt = ConvertOper.Convert(aryScoreItem[0]).ToInt;
                                    double noScore = ConvertOper.Convert(aryScoreItem[1]).ToDouble;
                                    if (!dicScoreOpt.ContainsKey(opt))
                                        dicScoreOpt.Add(opt, noScore);
                                }
                            }

                            int countRight = 0;
                            for (int i = 0; i < aryResult.Length; i++)
                            {
                                if (i < aryCorrect.Length)
                                {
                                    if (aryResult[i] == aryCorrect[i])
                                    {
                                        int n = i + 1;
                                        countRight++;
                                        if (dicScoreOpt.ContainsKey(n))
                                            dScore += dicScoreOpt[n];
                                    }
                                }
                            }
                            if (countRight >= aryCorrect.Length)
                                bResult = true;
                        }
                    }
                    break;
                case ResponseType.Number://杨斌 2012-03-13
                    currectAnswer = TagSet.GetValue(TagKey.Number_CorrectAnswer).Value;
                    if (currectAnswer.Length > 0)//没有正确答案不计分,杨斌 2012-03-01
                    {
                        if (keyValue == currectAnswer) { bResult = true; }
                        if (bResult)
                        {
                            int rightScore = TagSet.GetValue(TagKey.Number_ScoreRight).ToInt;
                            dScore = rightScore;
                        }
                        else
                        {
                            int wrongScore = TagSet.GetValue(TagKey.Number_ScoreWrong).ToInt;
                            dScore = wrongScore;
                        }
                    }
                    break;
                case ResponseType.Text://杨斌 2015-01-12
                    currectAnswer = TagSet.GetValue(TagKey.Number_CorrectAnswer).Value;
                    if (currectAnswer.Length > 0)//没有正确答案不计分,杨斌 2012-03-01
                    {
                        if (keyValue == currectAnswer) { bResult = true; }
                        if (bResult)
                        {
                            int rightScore = TagSet.GetValue(TagKey.Number_ScoreRight).ToInt;
                            dScore = rightScore;
                        }
                        else
                        {
                            int wrongScore = TagSet.GetValue(TagKey.Number_ScoreWrong).ToInt;
                            dScore = wrongScore;
                        }
                    }
                    break;
                case ResponseType.Score:
                    break;
                default:
                    break;
            }
            return bResult;
        }

        /// <summary>
        /// 计算评委分组平均分
        /// 键为空的值为最后加权的总分,其他为各组平均分
        /// 杨斌 2015-07-30
        /// </summary>
        public Dictionary<string, double> CaculateScoreAvgGroup(PowerPoint.Slide slide)
        {
            Dictionary<string, double> res = new Dictionary<string, double>();

            try
            {
                TagSet tagSet = new TagSet(slide.Tags);
                string group = "";
                Dictionary<string, double> dicGroupRate = FrmScoreGroupRate.GetDicScoreGroupRate(slide, out group);

                if (group.Length < 1)
                    return res;

                Dictionary<string, List<double>> dicScore = new Dictionary<string, List<double>>();
                foreach (var v in dicGroupRate)
                {
                    dicScore.Add(v.Key, new List<double>());
                }

                int colGroup = 0;
                for (int i = 1; i < RosterNow.Columns.Count; i++)
                {
                    if (RosterNow.Columns[i].ColumnName == group)
                    {
                        colGroup = i;
                        break;
                    }
                }
                for (int i = 0; i < ResponseDataList.Count; i++)
                {
                    string key = ResponseDataList[i].KeyID;
                    RosterRow rr = RosterNow.GetRowByKeyId(key);
                    string groupVal = rr.Cells[colGroup];
                    if (dicScore.ContainsKey(groupVal))
                    {
                        double score = ConvertOper.Convert(ResponseDataList[i].KeyValue).ToDouble;
                        dicScore[groupVal].Add(score);
                    }
                }

                res.Add("", 0);
                foreach (var v in dicScore)
                {
                    int remMax = ConvertOper.Convert(slide.Tags[group + "_" + v.Key + "_RemoveMax"].ToString()).ToInt;
                    int remMin = ConvertOper.Convert(slide.Tags[group + "_" + v.Key + "_RemoveMin"].ToString()).ToInt;
                    List<double> lst = v.Value.ToList();
                    lst = lst.OrderBy(o => o).ToList();
                    for (int i = 0; i < remMin; i++)
                    {
                        if (lst.Count > 0)
                            lst.RemoveAt(0);
                    }
                    for (int i = 0; i < remMax; i++)
                    {
                        if (lst.Count > 0)
                            lst.RemoveAt(lst.Count - 1);
                    }
                    if (lst.Count > 0)
                        res.Add(v.Key, lst.Average());
                    else
                        res.Add(v.Key, 0);
                    //if (v.Value.Count > 0)
                    //    res.Add(v.Key, v.Value.Average());
                    //else
                    //    res.Add(v.Key, 0);
                }
                double endScore = 0;
                foreach (var v in res)
                {
                    if (v.Key.Length > 0)
                    {
                        double rate = 1;
                        if (dicGroupRate.ContainsKey(v.Key))
                        {
                            rate = dicGroupRate[v.Key];
                        }
                        endScore += v.Value * rate;
                    }
                }
                res[""] = endScore;

            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }

            return res;
        }

        /// <summary>
        /// 计算评分结果
        /// 杨斌 2015-01-07
        /// </summary>
        /// <param name="slide">计算的幻灯片</param>
        /// <param name="scoreSum">计算出的总分</param>
        /// <param name="scoreAvg">计算出的平均分</param>
        public void CaculateScore(PowerPoint.Slide slide, out double totalScore, out double avgScore)
        {
            totalScore = 0;
            avgScore = 0;

            try
            {
                if (slide == null) { return; }

                TagSet currentTagSet = new TagSet();
                currentTagSet.Tags = slide.Tags;
                int minNum = currentTagSet.GetValue(TagKey.Score_RemoveLowCount).ToInt;
                int maxNum = currentTagSet.GetValue(TagKey.Score_RemoveHighCount).ToInt;
                int resultFormat = currentTagSet.GetValue(TagKey.Score_ResultFormat).ToInt;

                string formatStr = "0.";
                for (int i = 0; i < resultFormat; i++)
                    formatStr += "0";
                //double[] aryScore = new double[ResponseDataList.Count];
                List<double[]> lstScore = new List<double[]>();
                for (int i = 0; i < ResponseDataList.Count; i++)
                {
                    //aryScore[i] = ConvertOper.Convert(ResponseDataList[i].KeyValue).ToDouble;

                    double[] aryScoreAdd = new double[2];
                    aryScoreAdd[0] = ConvertOper.Convert(ResponseDataList[i].KeyValue).ToDouble;
                    aryScoreAdd[1] = 1;
                    string key = ResponseDataList[i].KeyID.ToString();
                    if (DicJudgeRage.ContainsKey(key))
                    {
                        aryScoreAdd[1] = DicJudgeRage[key];
                    }
                    lstScore.Add(aryScoreAdd);
                }
                lstScore = lstScore.OrderBy(o => o[0]).ToList();

                double rateCount = 0;//总权重
                double totalScoreRate = 0;
                if ((minNum + maxNum) < ResponseDataList.Count)//不能全去掉了
                {
                    for (int i = minNum; i < lstScore.Count - maxNum; i++)
                    {
                        totalScore += lstScore[i][0];
                        totalScoreRate += lstScore[i][0] * lstScore[i][1];
                        rateCount += lstScore[i][1];
                    }
                }
                if (rateCount != 0)
                    avgScore = totalScoreRate / rateCount;

                ////杨斌 2014-06-11 计算评委权重。需要屏蔽去掉最高最低分                
                //if (DicJudgeRage.Count > 0)
                //{
                //    for (int i = 0; i < ResponseDataList.Count; i++)
                //    {
                //        string key = ResponseDataList[i].KeyID.ToString();
                //        if (DicJudgeRage.ContainsKey(key))
                //        {
                //            aryScore[i] *= DicJudgeRage[key];
                //        }
                //    }
                //    minNum = 0;
                //    maxNum = 0;
                //}
                //else
                //{
                //    Array.Sort(aryScore);
                //}

                //if ((minNum + maxNum) >= ResponseDataList.Count)
                //    totalScore = 0;
                //else
                //    for (int i = minNum; i < aryScore.Length - maxNum; i++)
                //        totalScore += aryScore[i];

                //int totalNum = (ResponseDataList.Count - (minNum + maxNum));
                //if (totalNum > 0)
                //    avgScore = totalScore / totalNum;

                //进行两次转换,实现四舍五入
                totalScore = Convert.ToDouble(totalScore.ToString(formatStr));
                if (totalScoreRate != 0)
                    totalScore = Convert.ToDouble(totalScoreRate.ToString(formatStr));//总分加权。杨斌 2016-01-04
                avgScore = Convert.ToDouble(avgScore.ToString(formatStr));
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }

        /// <summary>
        /// 计算得分
        /// </summary>
        ///<param name="slide">计算的幻灯片</param>
        /// <returns></returns>
        public void CaculateScore(PowerPoint.Slide slide, bool isVoteStop = false)
        {
            if (slide == null) { return; }
            double totalScore = 0;
            double avgScore = 0;

            TagSet currentTagSet = new TagSet();
            currentTagSet.Tags = slide.Tags;

            int showAvgG = currentTagSet.GetValue(TagKey.Score_ShowAvgGroup).ToInt;
            int showAvgTG = currentTagSet.GetValue(TagKey.Score_ShowAvgTableGroup).ToInt;
            int resultDec = currentTagSet.GetValue(TagKey.Score_ResultFormat).ToInt;
            int runTimeShowScore = currentTagSet.GetValue(TagKey.Score_RunTimeShowScore).ToInt;
            if (isVoteStop)
                runTimeShowScore = 1;

            CaculateScore(slide, out totalScore, out avgScore);

            //小数点格式化。杨斌 2016-01-04
            int decEndScore = currentTagSet.GetValue(TagKey.Score_ResultFormat).ToInt;
            string strTotalScore = ConvertOper.Round45String(totalScore, decEndScore);
            string strAvgScore = ConvertOper.Round45String(avgScore, decEndScore);

            Dictionary<string, double> dicScore = CaculateScoreAvgGroup(slide);//杨斌 2015-07-30

            //保存分数,方便编辑插入时显示 杨斌 2012-03-16
            //currentTagSet.SetValue(TagKey.Slide_ScoreSUM, totalScore);
            //currentTagSet.SetValue(TagKey.Slide_ScoreAVG, avgScore);
            //杨斌 2016-01-04
            currentTagSet.SetValue(TagKey.Slide_ScoreSUM, strTotalScore);
            currentTagSet.SetValue(TagKey.Slide_ScoreAVG, strAvgScore);

            //刷新平均分和总分
            string lblText = "";
            string[] s = null;
            foreach (PowerPoint.Shape shape in slide.Shapes)
            {
                switch (shape.Name)
                {
                    case "SUMSCORE":
                        lblText = shape.TextFrame.TextRange.Text.Trim();
                        s = lblText.Split(':');
                        //if (s.Length >= 2)//杨斌 2015-07-28
                        //    lblText = s[0] + ":" + totalScore.ToString();
                        //else
                        //    lblText = totalScore.ToString();
                        //杨斌 2016-01-04
                        if (s.Length >= 2)//杨斌 2015-07-28
                            lblText = s[0].TrimEnd(' ') + " : " + strTotalScore;//杨斌 2019-06-06//lblText = s[0] + ":" + strTotalScore;
                        else
                            lblText = strTotalScore;

                        shape.TextFrame.TextRange.Text = lblText;
                        int showTotal = currentTagSet.GetValue(TagKey.Score_ShowTotal).ToInt;
                        if ((showTotal == 1) && (runTimeShowScore == 1))//杨斌 2016-04-26
                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        break;
                    case "AVGSCORE":
                        lblText = shape.TextFrame.TextRange.Text.Trim();
                        s = lblText.Split(':');
                        //if (s.Length >= 2)//杨斌 2015-07-28
                        //    lblText = s[0] + ":" + avgScore.ToString();
                        //else
                        //    lblText = avgScore.ToString();
                        //杨斌 2016-01-04
                        if (s.Length >= 2)//杨斌 2015-07-28
                            lblText = s[0].TrimEnd(' ') + " : " + strAvgScore;//杨斌 2019-06-06//lblText = s[0] + ":" + strAvgScore;
                        else
                            lblText = strAvgScore;

                        shape.TextFrame.TextRange.Text = lblText;
                        int showAvg = currentTagSet.GetValue(TagKey.Score_ShowAvg).ToInt;
                        if ((showAvg == 1) && (runTimeShowScore == 1))//杨斌 2016-04-26
                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        break;
                    case "AVGScoreGroup"://评委分组平均分
                        double scoreAvgG = 0;
                        if (dicScore.ContainsKey(""))
                            scoreAvgG = dicScore[""];
                        lblText = shape.TextFrame.TextRange.Text.Trim();
                        s = lblText.Split(':');
                        string scoreAvgGStr = "0";
                        if (scoreAvgG != 0)
                            scoreAvgGStr = ConvertOper.Round45String(scoreAvgG, resultDec);
                        if (s.Length >= 2)//杨斌 2015-07-28
                            lblText = s[0].TrimEnd(' ') + " : " + scoreAvgGStr;//杨斌 2019-06-06//lblText = s[0] + ":" + scoreAvgGStr;
                        else
                            lblText = scoreAvgGStr;
                        shape.TextFrame.TextRange.Text = lblText;

                        if (showAvgG == 1)
                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        break;
                    case "AVGScoreTableGroup"://评委分组平均分表
                        if (shape.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            string groupName = currentTagSet.GetValue(TagKey.Score_JudgeGroupDetail_GroupName).Value;
                            Dictionary<string, int> dicGroup = PanelScore.GetScoreGroupVotedCount(groupName);
                            for (int i = 2; i <= shape.Table.Rows.Count; i++)
                            {
                                double scoreAvgI = 0;
                                if (dicScore.Count > (i - 1))
                                    scoreAvgI = dicScore.Values.ToList()[i - 1];
                                string scoreAvgIStr = "0";
                                if (scoreAvgI != 0)
                                    scoreAvgIStr = ConvertOper.Round45String(scoreAvgI, resultDec);
                                ////shape.Table.Cell(i, 2).Shape.TextFrame.TextRange.Text = "参与数?";
                                ////shape.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text = "反馈数?";
                                string groupValue = shape.Table.Cell(i, 1).Shape.TextFrame.TextRange.Text;
                                if (dicGroup.ContainsKey(groupValue))
                                    shape.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text = dicGroup[groupValue].ToString();
                                shape.Table.Cell(i, 4).Shape.TextFrame.TextRange.Text = scoreAvgIStr;
                            }
                        }
                        if (showAvgTG == 1)
                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        break;
                    case "AVGScoreTableGroupDetail"://评委分组平均分表明细表
                        if (shape.HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            Dictionary<int, double> dicSort = new Dictionary<int, double>();
                            for (int i = 2; i <= shape.Table.Rows.Count; i++)
                            {
                                //double scoreAvgI = 0;
                                //if (dicScore.Count > i)
                                //    scoreAvgI = dicScore.Values.ToList()[i];
                                //string scoreAvgIStr = "0";
                                //if (scoreAvgI != 0)
                                //    scoreAvgIStr = ConvertOper.Round45String(scoreAvgI, resultDec);
                                string keyId = shape.Table.Cell(i, 1).Shape.TextFrame.TextRange.Text;
                                string score = "";
                                double dScore = 0;
                                if (GlobalInfo.response.ResponseDataList.Contains(keyId))
                                    score = GlobalInfo.response.ResponseDataList[keyId].KeyValue;
                                dScore = ConvertOper.Convert(score).ToDouble;
                                shape.Table.Cell(i, 3).Shape.TextFrame.TextRange.Text = score;
                                if (score.Length > 0)//未评分的不计算。                                
                                    dicSort.Add(i, dScore);
                            }
                            List<int> lstSort = dicSort.OrderBy(o => o.Value).ToDictionary(o => o.Key, o => o.Value).Keys.ToList();
                            string group = currentTagSet.GetValue(TagKey.Score_JudgeGroupDetail_GroupName).Value;
                            string groupVal = currentTagSet.GetValue(TagKey.Score_JudgeGroupDetail_GroupValue).Value;
                            int remMax = ConvertOper.Convert(slide.Tags[group + "_" + groupVal + "_RemoveMax"].ToString()).ToInt;
                            int remMin = ConvertOper.Convert(slide.Tags[group + "_" + groupVal + "_RemoveMin"].ToString()).ToInt;
                            for (int i = 0; i < lstSort.Count; i++)
                            {
                                int row = lstSort[i];
                                for (int col = 1; col <= shape.Table.Columns.Count; col++)
                                {
                                    if (i < remMin)
                                    {
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.BackColor.RGB = Convert.ToInt32("0000FF", 16);
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.ForeColor.RGB = Convert.ToInt32("0000FF", 16);
                                    }
                                    else if (i >= (lstSort.Count - remMax))
                                    {
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.BackColor.RGB = Convert.ToInt32("00FF00", 16);
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.ForeColor.RGB = Convert.ToInt32("00FF00", 16);
                                    }
                                    else
                                        shape.Table.Rows[row].Cells[col].Shape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                                }
                            }
                        }
                        if (showAvgTG == 1)
                            shape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                        break;
                }
            }

            PPTOper.ShowTableScoreRank(slide, false);//杨斌 2017-09-21
        }

        /// <summary>
        /// 删除题目反馈记录
        /// </summary>
        /// <param name="topicID"></param>
        public void ClearResponseDB(string topicID)
        {
            string sSql = "delete from ST_Response where T_ID='" + topicID + "'";
            GlobalInfo.DBOperation.ExecuteNonQuery(sSql);
            ClearResponse();
        }


        /// <summary>
        /// 20140317- 赵丽 获取加权后的反馈人数
        /// </summary>
        /// <returns></returns>
        public double GetResponseNum()
        {
            double iNum = 0;
            if (isVoteRate())
            {
                //杨斌 2015-01-26 屏蔽
                //for (int i = 0; i < ResponseDataList.Count; i++)
                //{
                //    //杨斌 2014-06-04
                //    string key = ResponseDataList[i].KeyID.ToString();
                //    if (VoterRate.Contains(key))
                //        iNum += VoterRate[key];
                //}

                iNum = VoteRateSum;//杨斌 2015-01-26

            }
            else
            {
                return ResponseDataList.Count;
            }

            return iNum;
        }

        /// <summary>
        /// 获得参与人数(2014-3-17 增加加权值)
        /// 杨斌 2015-03-27。加权
        /// 创建 赵丽
        /// </summary>
        /// <returns></returns>
        public double GetParticipantNum(ResponseType responseType, PowerPoint.Slide slide)
        {

            TagSet tagSet = new TagSet();
            tagSet.Tags = slide.Tags;
            double iNum = 0;
            if (GlobalInfo.response.isVoteRate())
            {
                iNum = GlobalInfo.response.totalWeight;
            }
            else
            {
                if (responseType == ResponseType.SignIn)
                    iNum = tagSet.GetValue(TagKey.Slide_Dueno).ToDouble;
                else
                {
                    iNum = tagSet.GetValue(TagKey.Slide_ParticipantNum).ToDouble;
                }
            }

            return iNum;
        }

        /// <summary>
        /// 获得参与人数,不加权,用于计算正确率。杨斌 2015-03-27
        /// </summary>
        /// <param name="responseType"></param>
        /// <param name="slide"></param>
        /// <returns></returns>
        public double GetParticipantNumNoRate(ResponseType responseType, PowerPoint.Slide slide)
        {
            TagSet tagSet = new TagSet(slide.Tags);
            double iNum = 0;
            if (responseType == ResponseType.SignIn)
                iNum = tagSet.GetValue(TagKey.Slide_Dueno).ToDouble;
            else
            {
                iNum = EnableList ? RousterCount : GlobalInfo.hardwareManage.PersonNum;
            }
            return iNum;
        }

        /// <summary>
        /// 排序题记分排序
        /// 杨斌 2014-04-18
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private int CompareOrderItem(OrderItem x, OrderItem y)
        {
            int res = 0;

            //Asc
            if (x.No > y.No)
                res = 1;
            else if (x.No < y.No)
                res = -1;

            //Desc
            for (int i = y.Count.Length - 1; i >= 0; i--)
            {
                if (x.Count[i] > y.Count[i])
                    res = -1;
                else if (x.Count[i] < y.Count[i])
                    res = 1;
            }

            //Desc
            if (x.Score > y.Score)
                res = -1;
            else if (x.Score < y.Score)
                res = 1;

            return res;
        }

        /// <summary>
        /// 排序题结果分数
        /// </summary>
        public List<OrderItem> ListOrderScore = new List<OrderItem>();

        /// <summary>
        /// 获得排序题结果
        /// 杨斌 2014-04-17
        /// </summary>
        public void GetOrderResult(PowerPoint.Slide slide)
        {
            try
            {
                ListOrderScore.Clear();
                //TagSet tagSet = null;

                //if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
                //{
                //    if (Globals.SunVoteARSAddIn.PPTShow.ResponseType != ResponseType.Order) return;
                //    tagSet = Globals.SunVoteARSAddIn.PPTShow.TagSetSlide;
                //}
                //else
                //{
                //    if (Globals.SunVoteARSAddIn.PPTEdit.ResponseTypeSlideEdit != ResponseType.Order) return;
                //    tagSet = Globals.SunVoteARSAddIn.PPTEdit.TagSet;
                //}

                TagSet tagSet = new TagSet(slide.Tags);
                ResponseType rType = EnumName<ResponseType>.GetEnum(tagSet.GetValue(TagKey.ResponseType).Value.ToString());
                if (rType != ResponseType.Order) return;

                int scoreMode = tagSet.GetValue(TagKey.Order_ScoreMode).ToInt;
                if (scoreMode != 1) return;

                int optCount = tagSet.GetValue(TagKey.Order_OptionCount).ToInt;
                if (optCount < 1) return;

                List<OrderItem> lstItem = new List<OrderItem>();

                double[] aryOptScore = new double[optCount];
                for (int i = 0; i < optCount; i++)
                    lstItem.Add(new OrderItem(i + 1, 0, new int[optCount]));

                string score = tagSet.GetValue(TagKey.Order_ScoreOption).Value;
                string[] aryScore = score.Split(new char[] { PublicFunction.SplitItemScore });//杨斌 2019-07-19
                for (int i = 0; i < aryScore.Length; i++)
                {
                    string[] aryScoreItem = aryScore[i].Split(new char[] { '=' });
                    if (aryScoreItem.Length >= 2)
                    {
                        int opt = ConvertOper.Convert(aryScoreItem[0]).ToInt;
                        double noScore = ConvertOper.Convert(aryScoreItem[1]).ToDouble;
                        if ((opt >= 1) && (opt <= optCount))
                            aryOptScore[opt - 1] = noScore;
                    }
                }

                for (int i = 0; i < this.ResponseDataList.Count; i++)
                {
                    string[] aryVal = ResponseDataList[i].KeyValue.Split(new char[] { ',' });
                    for (int n = 0; n < aryVal.Length; n++)
                    {
                        int opt = ConvertOper.Convert(aryVal[n]).ToInt;
                        if ((opt >= 1) && (opt <= optCount) && (n < optCount))
                        {
                            int no = opt - 1;
                            lstItem[no].Score += aryOptScore[n];
                            lstItem[no].Count[n]++;
                        }
                    }
                }

                lstItem.Sort(CompareOrderItem);

                ListOrderScore = lstItem;

                ////调试显示。杨斌 2014-04-18
                //List<string> lstShow = new List<string>();
                //lstShow.Add("no\t score\t count");
                //foreach (OrderItem a in lstItem)
                //{
                //    string[] aryCnt = new string[a.Count.Length];
                //    for (int i = 0; i < aryCnt.Length; i++)
                //        aryCnt[i] = a.Count[i].ToString();
                //    lstShow.Add(a.No + "\t " + a.Score + "\t " + string.Join(",", aryCnt));
                //}
                //MessageBox.Show(string.Join("\r\n", lstShow.ToArray()));
            }
            catch (Exception ex)
            {
                SystemLog.WriterLog(ex);
            }
        }
    }

}