浏览代码

Merge branch 'master' of http://192.168.1.222:3000/duhongyu/HeBi12345_API

liyuanyuan 1 年之前
父节点
当前提交
fffbfcb663

+ 2 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/HomeController.cs

26
         // GET: Home
26
         // GET: Home
27
         public ActionResult Index()
27
         public ActionResult Index()
28
         {
28
         {
29
-            
30
 
29
 
31
             return Success("成功");
30
             return Success("成功");
32
         }
31
         }
32
+
33
+       
33
         [Authorize]
34
         [Authorize]
34
         public JsonResult json1()
35
         public JsonResult json1()
35
         {
36
         {

+ 108 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/AffairsController.cs

22
 using System.Security.Cryptography.X509Certificates;
22
 using System.Security.Cryptography.X509Certificates;
23
 using System.Text;
23
 using System.Text;
24
 using System.Text.RegularExpressions;
24
 using System.Text.RegularExpressions;
25
+using System.Threading;
25
 using System.Threading.Tasks;
26
 using System.Threading.Tasks;
26
 using System.Transactions;
27
 using System.Transactions;
27
 using System.Web;
28
 using System.Web;
32
   //[Authority]
33
   //[Authority]
33
     public class AffairsController : BaseController
34
     public class AffairsController : BaseController
34
     {
35
     {
36
+      
37
+
38
+
39
+        public ActionResult PushPhone()
40
+        {
41
+            string message = "";
42
+            int Phone = 0; int Phonecount = 0;
43
+            try
44
+            {
45
+                string PushWorkorder = "SELECT top 1  *  FROM T_Bus_PushWorkorder";
46
+               var  BusPushPhone = DbHelperSQL.Query(PushWorkorder).Tables[0];
47
+                if (BusPushPhone != null)
48
+                {
49
+                    Phone = int.Parse(BusPushPhone.Rows[0]["id"].ToString());
50
+                    Phonecount = int.Parse(BusPushPhone.Rows[0]["count"].ToString());
51
+                }
52
+                var modellist = new BLL.T_Bus_WorkOrder
53
+                    ().GetModelList(100000, "ISNULL(F_CallRecordId,'')!='' and F_CreateTime>'2023-11-11 01:00:07.000' " +
54
+                    $" and F_CreateTime < '2024-03-13 17:01:46.000' and F_Id>={Phone} and F_IsDelete =0", " F_Id asc");
55
+                if (modellist!=null && modellist.Count >0)
56
+                {
57
+
58
+                    foreach (var it in modellist)
59
+                    {
60
+                        Thread.Sleep(300);
61
+                        Phone = it.F_Id;
62
+                        Phonecount++;
63
+                        WebClient web = new WebClient();
64
+                        web.Encoding = Encoding.UTF8;
65
+                        string Dataurl = web.DownloadString(FrontUrl + "/Affairs/case_record?workorderid=" + it.F_WorkOrderId );
66
+                        if (!string .IsNullOrEmpty (it .F_File ) )
67
+                        {
68
+                            string Dataur2 = web.DownloadString(FrontUrl 
69
+                                + "/Affairs/" + "case_material_info" + "?WorkOrderId=" + it .F_WorkOrderId 
70
+                                + "&file=" + it .F_File + "&id=" + it .F_Id + "&type=" + 10);
71
+                        }
72
+                        string ts = "update T_Bus_PushWorkorder set id='" + Phone + "' ,count='" + Phonecount + "'";
73
+                        var rh = DbHelperSQL.GetSingle(ts);
74
+                    }
75
+                    message = "成功";
76
+                }
77
+            }
78
+            catch(Exception e)
79
+            {
80
+                string ts = "update T_Bus_PushWorkorder set id='" + Phone + "' ,count='" + Phonecount + "'";
81
+                var rh = DbHelperSQL.GetSingle(ts);
82
+                message = e.ToJson();
83
+            }
84
+
85
+            return Success(message);
86
+        }
35
 
87
 
36
-    
37
 
88
 
38
 
89
 
90
+        public ActionResult Pushhandleinfo()
91
+        {
92
+            string message = "";
93
+            int Phone = 0; int Phonecount = 0;
94
+            try
95
+            {
96
+                string PushWorkorder = "SELECT top 1  *  FROM T_Bus_PushWorkorder1";
97
+                var BusPushPhone = DbHelperSQL.Query(PushWorkorder).Tables[0];
98
+                if (BusPushPhone != null)
99
+                {
100
+                    Phone = int.Parse(BusPushPhone.Rows[0]["id"].ToString());
101
+                    Phonecount = int.Parse(BusPushPhone.Rows[0]["count"].ToString());
102
+                }
103
+                var modellist = new BLL.T_Bus_WorkOrder
104
+                    ().GetModelList(100000, "F_WorkOrderId in( " +
105
+                    " select F_WorkOrderId  from T_Bus_Feedback  " +
106
+                    " where F_CreateTime > '2023-11-10 18:46:48.000'  " +
107
+                    " and F_CreateTime < '2024-03-13 17:02:45.000'  " +
108
+                    $" and F_IsDelete = 0 and F_Type = 1) and F_Id>={Phone} and F_IsDelete =0", " F_Id asc");
109
+                if (modellist != null && modellist.Count > 0)
110
+                {
111
+
112
+                    foreach (var it in modellist)
113
+                    {
114
+                        Thread.Sleep(500);
115
+                        Phone = it.F_Id;
116
+                        Phonecount++;
117
+                        WebClient web = new WebClient();
118
+                        web.Encoding = Encoding.UTF8;
119
+                        string Dataurl = web.DownloadString(FrontUrl + "/Affairs/handle_info_1?workorderid=" + it.F_WorkOrderId);
120
+                        var model = new BLL.T_Bus_Feedback().GetNewModelByWorkOrderID(it.F_WorkOrderId);
121
+                        if (model!=null )
122
+                        {
123
+                            if (!string.IsNullOrEmpty(model.F_File))
124
+                            {
125
+                                string Dataur2 = web.DownloadString(FrontUrl
126
+                                    + "/Affairs/" + "case_material_info" + "?WorkOrderId=" + it.F_WorkOrderId
127
+                                    + "&file=" + model.F_File + "&id=" + model.F_Id + "&type=" + 20);
128
+                            }
129
+                        }
130
+                       
131
+                        string ts = "update T_Bus_PushWorkorder1 set id='" + Phone + "' ,count='" + Phonecount + "'";
132
+                        var rh = DbHelperSQL.GetSingle(ts);
133
+                    }
134
+                    message = "成功";
135
+                }
136
+            }
137
+            catch (Exception e)
138
+            {
139
+                string ts = "update T_Bus_PushWorkorder1 set id='" + Phone + "' ,count='" + Phonecount + "'";
140
+                var rh = DbHelperSQL.GetSingle(ts);
141
+                message = e.ToJson();
142
+            }
143
+
144
+            return Success(message);
145
+        }
39
 
146
 
40
 
147
 
41
         private BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
148
         private BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();

+ 6 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

2518
                             sql += " and F_WorkState = '" + strstate.Trim() + "' ";
2518
                             sql += " and F_WorkState = '" + strstate.Trim() + "' ";
2519
                         //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
2519
                         //sql += " and F_WorkState = '" + strstate.Trim() + "' ";
2520
                     }
2520
                     }
2521
-                    if (User.F_RoleCode != "GLY" && User.F_RoleCode != "DDZG" && User.F_RoleCode != "DBZY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
2521
+                    if (islabel != 1)
2522
                     {
2522
                     {
2523
-                        sql += " and F_CreateUser='" + User.F_UserCode + "'";
2523
+                        if (User.F_RoleCode != "GLY" && User.F_RoleCode != "DDZG" && User.F_RoleCode != "DBZY" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
2524
+                        {
2525
+                            sql += " and F_CreateUser='" + User.F_UserCode + "'";
2526
+                        }
2524
                     }
2527
                     }
2528
+                      
2525
                     break;
2529
                     break;
2526
                 case "2"://已回访的工单
2530
                 case "2"://已回访的工单
2527
                     if (strstate.Trim() != "" && strstate != "undefined")
2531
                     if (strstate.Trim() != "" && strstate != "undefined")

+ 4 - 0
CallCenterCommon/CallCenter.Utility/CallCenter.Utility.csproj

34
     <Reference Include="Aspose.Words">
34
     <Reference Include="Aspose.Words">
35
       <HintPath>..\..\CallCenterApi\CallCenterApi.Interface\CallCenterApi.Interface\Lib\Aspose.Words.dll</HintPath>
35
       <HintPath>..\..\CallCenterApi\CallCenterApi.Interface\CallCenterApi.Interface\Lib\Aspose.Words.dll</HintPath>
36
     </Reference>
36
     </Reference>
37
+    <Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
38
+      <HintPath>..\..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
39
+    </Reference>
37
     <Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
40
     <Reference Include="log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
38
       <HintPath>..\..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath>
41
       <HintPath>..\..\packages\log4net.2.0.7\lib\net45-full\log4net.dll</HintPath>
39
       <Private>True</Private>
42
       <Private>True</Private>
98
     <Compile Include="RedisHelper.cs" />
101
     <Compile Include="RedisHelper.cs" />
99
     <Compile Include="RedisHelper2.cs" />
102
     <Compile Include="RedisHelper2.cs" />
100
     <Compile Include="SaltAndHashHelper.cs" />
103
     <Compile Include="SaltAndHashHelper.cs" />
104
+    <Compile Include="SM2CryptoUtil.cs" />
101
     <Compile Include="Sms\SmsNewHelper.cs" />
105
     <Compile Include="Sms\SmsNewHelper.cs" />
102
     <Compile Include="Sms\SmsHelper.cs" />
106
     <Compile Include="Sms\SmsHelper.cs" />
103
     <Compile Include="SysInformationHelper.cs" />
107
     <Compile Include="SysInformationHelper.cs" />

+ 426 - 0
CallCenterCommon/CallCenter.Utility/SM2CryptoUtil.cs

1
+using Org.BouncyCastle.Crypto;
2
+using Org.BouncyCastle.Crypto.Digests;
3
+using Org.BouncyCastle.Crypto.Generators;
4
+using Org.BouncyCastle.Crypto.Parameters;
5
+using Org.BouncyCastle.Math;
6
+using Org.BouncyCastle.Math.EC;
7
+using Org.BouncyCastle.Security;
8
+using Org.BouncyCastle.Utilities.Encoders;
9
+using System;
10
+using System.Collections.Generic;
11
+using System.IO;
12
+using System.Linq;
13
+using System.Text;
14
+
15
+namespace CallCenter.Utility
16
+{
17
+    /// <summary>
18
+    /// SM2工具类
19
+    /// </summary>
20
+    public class SM2CryptoUtil
21
+    {
22
+
23
+        #region 获取公钥私钥
24
+        /// <summary>
25
+        /// 获取公钥私钥
26
+        /// </summary>
27
+        /// <returns></returns>
28
+        public static SM2Model GetKey()
29
+        {
30
+            SM2 sm2 = SM2.Instance;
31
+            AsymmetricCipherKeyPair key = sm2.ecc_key_pair_generator.GenerateKeyPair();
32
+            ECPrivateKeyParameters ecpriv = (ECPrivateKeyParameters)key.Private;
33
+            ECPublicKeyParameters ecpub = (ECPublicKeyParameters)key.Public;
34
+            BigInteger privateKey = ecpriv.D;
35
+            ECPoint publicKey = ecpub.Q;
36
+            SM2Model sM2Model = new SM2Model();
37
+            sM2Model.PrivateKey = Encoding.UTF8.GetString(Hex.Encode(privateKey.ToByteArray())).ToUpper();
38
+            sM2Model.PublicKey = Encoding.UTF8.GetString(Hex.Encode(publicKey.GetEncoded())).ToUpper();
39
+            return sM2Model;
40
+        }
41
+        #endregion
42
+
43
+        #region 加密
44
+        /// <summary>
45
+        /// 加密
46
+        /// </summary>
47
+        /// <param name="publickey">公钥</param>
48
+        /// <param name="sourceData">需要加密的值</param>
49
+        /// <returns>加密结果</returns>
50
+        public static string Encrypt(string publickey, string sourceData)
51
+        {
52
+            var data = Encrypt(Hex.Decode(publickey), Encoding.UTF8.GetBytes(sourceData));
53
+            return data;
54
+        }
55
+
56
+        /// <summary>
57
+        /// 加密
58
+        /// </summary>
59
+        /// <param name="publicKey">公钥</param>
60
+        /// <param name="data">需要加密的值</param>
61
+        /// <returns></returns>
62
+        public static String Encrypt(byte[] publicKey, byte[] data)
63
+        {
64
+            if (null == publicKey || publicKey.Length == 0)
65
+            {
66
+                return null;
67
+            }
68
+            if (data == null || data.Length == 0)
69
+            {
70
+                return null;
71
+            }
72
+
73
+            byte[] source = new byte[data.Length];
74
+            Array.Copy(data, 0, source, 0, data.Length);
75
+
76
+            Cipher cipher = new Cipher();
77
+            SM2 sm2 = SM2.Instance;
78
+
79
+            ECPoint userKey = sm2.ecc_curve.DecodePoint(publicKey);
80
+
81
+            ECPoint c1 = cipher.Init_enc(sm2, userKey);
82
+            cipher.Encrypt(source);
83
+
84
+            byte[] c3 = new byte[32];
85
+            cipher.Dofinal(c3);
86
+
87
+            String sc1 = Encoding.UTF8.GetString(Hex.Encode(c1.GetEncoded()));
88
+            String sc2 = Encoding.UTF8.GetString(Hex.Encode(source));
89
+            String sc3 = Encoding.UTF8.GetString(Hex.Encode(c3));
90
+
91
+            return (sc1 + sc2 + sc3).ToUpper();
92
+        }
93
+        #endregion
94
+
95
+        #region 解密
96
+
97
+        /// <summary>
98
+        /// 
99
+        /// </summary>
100
+        /// <param name="privateKey"></param>
101
+        /// <param name="encryptedData"></param>
102
+        /// <returns></returns>
103
+        public static string Decrypt(string privateKey, string encryptedData)
104
+        {
105
+            var data = Encoding.UTF8.GetString(Decrypt(Hex.Decode(privateKey), Hex.Decode(encryptedData)));
106
+            return data;
107
+        }
108
+        /// <summary>
109
+        /// 解密
110
+        /// </summary>
111
+        /// <param name="privateKey"></param>
112
+        /// <param name="encryptedData"></param>
113
+        /// <returns></returns>
114
+        public static byte[] Decrypt(byte[] privateKey, byte[] encryptedData)
115
+        {
116
+            if (null == privateKey || privateKey.Length == 0)
117
+            {
118
+                return null;
119
+            }
120
+            if (encryptedData == null || encryptedData.Length == 0)
121
+            {
122
+                return null;
123
+            }
124
+
125
+            String data = Encoding.UTF8.GetString(Hex.Encode(encryptedData));
126
+
127
+            byte[] c1Bytes = Hex.Decode(Encoding.UTF8.GetBytes(data.Substring(0, 130)));
128
+            int c2Len = encryptedData.Length - 97;
129
+            byte[] c2 = Hex.Decode(Encoding.UTF8.GetBytes(data.Substring(130, 2 * c2Len)));
130
+            byte[] c3 = Hex.Decode(Encoding.UTF8.GetBytes(data.Substring(130 + 2 * c2Len, 64)));
131
+
132
+            SM2 sm2 = SM2.Instance;
133
+            BigInteger userD = new BigInteger(1, privateKey);
134
+
135
+            //ECPoint c1 = sm2.ecc_curve.DecodePoint(c1Bytes);
136
+
137
+            ECPoint c1 = sm2.ecc_curve.DecodePoint(c1Bytes);
138
+            Cipher cipher = new Cipher();
139
+            cipher.Init_dec(userD, c1);
140
+            cipher.Decrypt(c2);
141
+            cipher.Dofinal(c3);
142
+
143
+            return c2;
144
+        }
145
+        #endregion
146
+
147
+        private class Cipher
148
+        {
149
+            private int ct;
150
+            private ECPoint p2;
151
+            private SM3Digest sm3keybase;
152
+            private SM3Digest sm3c3;
153
+            private byte[] key;
154
+            private byte keyOff;
155
+
156
+            public Cipher()
157
+            {
158
+                this.ct = 1;
159
+                this.key = new byte[32];
160
+                this.keyOff = 0;
161
+            }
162
+
163
+            public static byte[] byteConvert32Bytes(BigInteger n)
164
+            {
165
+                byte[] tmpd = null;
166
+                if (n == null)
167
+                {
168
+                    return null;
169
+                }
170
+
171
+                if (n.ToByteArray().Length == 33)
172
+                {
173
+                    tmpd = new byte[32];
174
+                    Array.Copy(n.ToByteArray(), 1, tmpd, 0, 32);
175
+                }
176
+                else if (n.ToByteArray().Length == 32)
177
+                {
178
+                    tmpd = n.ToByteArray();
179
+                }
180
+                else
181
+                {
182
+                    tmpd = new byte[32];
183
+                    for (int i = 0; i < 32 - n.ToByteArray().Length; i++)
184
+                    {
185
+                        tmpd[i] = 0;
186
+                    }
187
+                    Array.Copy(n.ToByteArray(), 0, tmpd, 32 - n.ToByteArray().Length, n.ToByteArray().Length);
188
+                }
189
+                return tmpd;
190
+            }
191
+
192
+            private void Reset()
193
+            {
194
+                this.sm3keybase = new SM3Digest();
195
+                this.sm3c3 = new SM3Digest();
196
+
197
+                byte[] p = byteConvert32Bytes(p2.Normalize().XCoord.ToBigInteger());
198
+                this.sm3keybase.BlockUpdate(p, 0, p.Length);
199
+                this.sm3c3.BlockUpdate(p, 0, p.Length);
200
+
201
+                p = byteConvert32Bytes(p2.Normalize().YCoord.ToBigInteger());
202
+                this.sm3keybase.BlockUpdate(p, 0, p.Length);
203
+                this.ct = 1;
204
+                NextKey();
205
+            }
206
+
207
+            private void NextKey()
208
+            {
209
+                SM3Digest sm3keycur = new SM3Digest(this.sm3keybase);
210
+                sm3keycur.Update((byte)(ct >> 24 & 0xff));
211
+                sm3keycur.Update((byte)(ct >> 16 & 0xff));
212
+                sm3keycur.Update((byte)(ct >> 8 & 0xff));
213
+                sm3keycur.Update((byte)(ct & 0xff));
214
+                sm3keycur.DoFinal(key, 0);
215
+                this.keyOff = 0;
216
+                this.ct++;
217
+            }
218
+
219
+            public ECPoint Init_enc(SM2 sm2, ECPoint userKey)
220
+            {
221
+                AsymmetricCipherKeyPair key = sm2.ecc_key_pair_generator.GenerateKeyPair();
222
+                ECPrivateKeyParameters ecpriv = (ECPrivateKeyParameters)key.Private;
223
+                ECPublicKeyParameters ecpub = (ECPublicKeyParameters)key.Public;
224
+                BigInteger k = ecpriv.D;
225
+                ECPoint c1 = ecpub.Q;
226
+                this.p2 = userKey.Multiply(k);
227
+                Reset();
228
+                return c1;
229
+            }
230
+
231
+            public void Encrypt(byte[] data)
232
+            {
233
+                this.sm3c3.BlockUpdate(data, 0, data.Length);
234
+                for (int i = 0; i < data.Length; i++)
235
+                {
236
+                    if (keyOff == key.Length)
237
+                    {
238
+                        NextKey();
239
+                    }
240
+                    data[i] ^= key[keyOff++];
241
+                }
242
+            }
243
+
244
+            public void Init_dec(BigInteger userD, ECPoint c1)
245
+            {
246
+                this.p2 = c1.Multiply(userD);
247
+                Reset();
248
+            }
249
+
250
+            public void Decrypt(byte[] data)
251
+            {
252
+                for (int i = 0; i < data.Length; i++)
253
+                {
254
+                    if (keyOff == key.Length)
255
+                    {
256
+                        NextKey();
257
+                    }
258
+                    data[i] ^= key[keyOff++];
259
+                }
260
+
261
+                this.sm3c3.BlockUpdate(data, 0, data.Length);
262
+            }
263
+
264
+            public void Dofinal(byte[] c3)
265
+            {
266
+                byte[] p = byteConvert32Bytes(p2.Normalize().YCoord.ToBigInteger());
267
+                this.sm3c3.BlockUpdate(p, 0, p.Length);
268
+                this.sm3c3.DoFinal(c3, 0);
269
+                Reset();
270
+            }
271
+        }
272
+        private class SM2
273
+        {
274
+            public static SM2 Instance
275
+            {
276
+                get
277
+                {
278
+                    return new SM2();
279
+                }
280
+
281
+            }
282
+            public static SM2 InstanceTest
283
+            {
284
+                get
285
+                {
286
+                    return new SM2();
287
+                }
288
+
289
+            }
290
+
291
+            public static readonly string[] sm2_param = {
292
+            "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",// p,0
293
+            "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",// a,1
294
+            "28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",// b,2
295
+            "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",// n,3
296
+            "32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7",// gx,4
297
+            "BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0" // gy,5
298
+        };
299
+
300
+            public string[] ecc_param = sm2_param;
301
+
302
+            public readonly BigInteger ecc_p;
303
+            public readonly BigInteger ecc_a;
304
+            public readonly BigInteger ecc_b;
305
+            public readonly BigInteger ecc_n;
306
+            public readonly BigInteger ecc_gx;
307
+            public readonly BigInteger ecc_gy;
308
+
309
+            public readonly ECCurve ecc_curve;
310
+            public readonly ECPoint ecc_point_g;
311
+
312
+            public readonly ECDomainParameters ecc_bc_spec;
313
+
314
+            public readonly ECKeyPairGenerator ecc_key_pair_generator;
315
+
316
+            private SM2()
317
+            {
318
+                ecc_param = sm2_param;
319
+
320
+                ECFieldElement ecc_gx_fieldelement;
321
+                ECFieldElement ecc_gy_fieldelement;
322
+
323
+                ecc_p = new BigInteger(ecc_param[0], 16);
324
+                ecc_a = new BigInteger(ecc_param[1], 16);
325
+                ecc_b = new BigInteger(ecc_param[2], 16);
326
+                ecc_n = new BigInteger(ecc_param[3], 16);
327
+                ecc_gx = new BigInteger(ecc_param[4], 16);
328
+                ecc_gy = new BigInteger(ecc_param[5], 16);
329
+
330
+
331
+                ecc_gx_fieldelement = new FpFieldElement(ecc_p, ecc_gx);
332
+                ecc_gy_fieldelement = new FpFieldElement(ecc_p, ecc_gy);
333
+
334
+                ecc_curve = new FpCurve(ecc_p, ecc_a, ecc_b);
335
+                ecc_point_g = new FpPoint(ecc_curve, ecc_gx_fieldelement, ecc_gy_fieldelement);
336
+
337
+                ecc_bc_spec = new ECDomainParameters(ecc_curve, ecc_point_g, ecc_n);
338
+
339
+                ECKeyGenerationParameters ecc_ecgenparam;
340
+                ecc_ecgenparam = new ECKeyGenerationParameters(ecc_bc_spec, new SecureRandom());
341
+
342
+                ecc_key_pair_generator = new ECKeyPairGenerator();
343
+                ecc_key_pair_generator.Init(ecc_ecgenparam);
344
+            }
345
+
346
+            public virtual byte[] Sm2GetZ(byte[] userId, ECPoint userKey)
347
+            {
348
+                SM3Digest sm3 = new SM3Digest();
349
+                byte[] p;
350
+                // userId length
351
+                int len = userId.Length * 8;
352
+                sm3.Update((byte)(len >> 8 & 0x00ff));
353
+                sm3.Update((byte)(len & 0x00ff));
354
+
355
+                // userId
356
+                sm3.BlockUpdate(userId, 0, userId.Length);
357
+
358
+                // a,b
359
+                p = ecc_a.ToByteArray();
360
+                sm3.BlockUpdate(p, 0, p.Length);
361
+                p = ecc_b.ToByteArray();
362
+                sm3.BlockUpdate(p, 0, p.Length);
363
+                // gx,gy
364
+                p = ecc_gx.ToByteArray();
365
+                sm3.BlockUpdate(p, 0, p.Length);
366
+                p = ecc_gy.ToByteArray();
367
+                sm3.BlockUpdate(p, 0, p.Length);
368
+
369
+                // x,y
370
+                p = userKey.AffineXCoord.ToBigInteger().ToByteArray();
371
+                sm3.BlockUpdate(p, 0, p.Length);
372
+                p = userKey.AffineYCoord.ToBigInteger().ToByteArray();
373
+                sm3.BlockUpdate(p, 0, p.Length);
374
+
375
+                // Z
376
+                byte[] md = new byte[sm3.GetDigestSize()];
377
+                sm3.DoFinal(md, 0);
378
+
379
+                return md;
380
+            }
381
+        }
382
+        public class SM2Model
383
+        {
384
+            /// <summary>
385
+            /// 公钥
386
+            /// </summary>
387
+            public string PublicKey { get; set; }
388
+            /// <summary>
389
+            /// 私钥
390
+            /// </summary>
391
+            public string PrivateKey { get; set; }
392
+        }
393
+        /// <summary>
394
+        /// 公钥
395
+        /// </summary>
396
+        public static string PublicKey = "042DBA45E7B03394F603CADAFCDDEC854D3E01A4E9C52CD799B85B1A14BDB970137AE58BA" +
397
+            "553D79F058604DC1CD4B77DE5408BA3308E767584100C2B663510C819";
398
+
399
+        /// <summary>
400
+        /// 私钥
401
+        /// </summary>
402
+        public static string PrivateKey = "BF1F907B4E0487F798DC80AFD7BC2A6201E8514233002272EA3BE2FC6F797843";
403
+
404
+        /// <summary>
405
+        /// 公钥加密明文
406
+        /// </summary>
407
+        /// <param name="plainText">明文</param>
408
+        /// <returns>密文</returns>
409
+        public static string Encrypt(string plainText)
410
+        {
411
+            return Encrypt(PublicKey, plainText);
412
+        }
413
+
414
+        /// <summary>
415
+        /// SM2私钥解密密文
416
+        /// </summary>
417
+        /// <param name="cipherText">密文</param>
418
+        /// <returns>明文</returns>
419
+        public static string Decrypt(string cipherText)
420
+        {
421
+            if (!cipherText.StartsWith("04")) cipherText = "04" + cipherText;//
422
+            return  Decrypt(PrivateKey, cipherText);
423
+
424
+        }
425
+    }
426
+}

+ 1 - 0
CallCenterCommon/CallCenter.Utility/packages.config

4
   <package id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" targetFramework="net45" />
4
   <package id="Microsoft.Office.Interop.Word" version="15.0.4797.1003" targetFramework="net45" />
5
   <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
5
   <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
6
   <package id="NPOI" version="2.3.0" targetFramework="net45" />
6
   <package id="NPOI" version="2.3.0" targetFramework="net45" />
7
+  <package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net45" />
7
   <package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
8
   <package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
8
   <package id="StackExchange.Redis" version="1.2.6" targetFramework="net45" />
9
   <package id="StackExchange.Redis" version="1.2.6" targetFramework="net45" />
9
   <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />
10
   <package id="System.ValueTuple" version="4.5.0" targetFramework="net45" />