Kaynağa Gözat

给110推工单

liyuanyuan 1 yıl önce
ebeveyn
işleme
8c05f17b1d

+ 4 - 0
CallCenterApi/CallCenterApi.DB/CallCenterApi.DB.csproj

@@ -30,6 +30,9 @@
30 30
     <WarningLevel>4</WarningLevel>
31 31
   </PropertyGroup>
32 32
   <ItemGroup>
33
+    <Reference Include="MySql.Data">
34
+      <HintPath>D:\web\地铁\DLL\MySql.Data.dll</HintPath>
35
+    </Reference>
33 36
     <Reference Include="System" />
34 37
     <Reference Include="System.Configuration" />
35 38
     <Reference Include="System.Core" />
@@ -42,6 +45,7 @@
42 45
   </ItemGroup>
43 46
   <ItemGroup>
44 47
     <Compile Include="CommandInfo.cs" />
48
+    <Compile Include="DbHelperMySQL.cs" />
45 49
     <Compile Include="DbHelperSQL.cs" />
46 50
     <Compile Include="DbHelperSQLold.cs" />
47 51
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 463 - 0
CallCenterApi/CallCenterApi.DB/DbHelperMySQL.cs

@@ -0,0 +1,463 @@
1
+using MySql.Data.MySqlClient;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Configuration;
5
+using System.Data;
6
+using System.Data.SqlClient;
7
+
8
+namespace CallCenterApi.DB
9
+{
10
+    public abstract class DbHelperMySQL
11
+    {
12
+        //数据库连接字符串(web.config来配置),可以动态更改connectionString支持多数据库.		
13
+        public static string connectionString = ConfigurationManager.ConnectionStrings["MySqlconnection"].ConnectionString;
14
+        public DbHelperMySQL() { }
15
+        #region 公用方法
16
+        /// <summary>
17
+        /// 得到最大值
18
+        /// </summary>
19
+        /// <param name="FieldName"></param>
20
+        /// <param name="TableName"></param>
21
+        /// <returns></returns>
22
+        public static int GetMaxID(string FieldName, string TableName)
23
+        {
24
+            string strsql = "select max(" + FieldName + ")+1 from " + TableName;
25
+            object obj = GetSingle(strsql);
26
+            if (obj == null)
27
+            {
28
+                return 1;
29
+            }
30
+            else
31
+            {
32
+                return int.Parse(obj.ToString());
33
+            }
34
+        }
35
+        /// <summary>
36
+        /// 是否存在
37
+        /// </summary>
38
+        /// <param name="strSql"></param>
39
+        /// <returns></returns>
40
+        public static bool Exists(string strSql)
41
+        {
42
+            object obj = GetSingle(strSql);
43
+            int cmdresult;
44
+            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
45
+            {
46
+                cmdresult = 0;
47
+            }
48
+            else
49
+            {
50
+                cmdresult = int.Parse(obj.ToString());
51
+            }
52
+            if (cmdresult == 0)
53
+            {
54
+                return false;
55
+            }
56
+            else
57
+            {
58
+                return true;
59
+            }
60
+        }
61
+       
62
+        #endregion
63
+
64
+        #region  执行简单SQL语句
65
+
66
+        /// <summary>
67
+        /// 执行SQL语句,返回影响的记录数
68
+        /// </summary>
69
+        /// <param name="SQLString">SQL语句</param>
70
+        /// <returns>影响的记录数</returns>
71
+        public static int ExecuteSql(string SQLString)
72
+        {
73
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
74
+            {
75
+                using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
76
+                {
77
+                    try
78
+                    {
79
+                        connection.Open();
80
+                        int rows = cmd.ExecuteNonQuery();
81
+                        return rows;
82
+                    }
83
+                    catch (MySql.Data.MySqlClient.MySqlException e)
84
+                    {
85
+                        connection.Close();
86
+                        throw e;
87
+                    }
88
+                }
89
+            }
90
+        }
91
+
92
+
93
+
94
+        /// <summary>
95
+        /// 执行SQL语句,返回影响的记录数
96
+        /// </summary>
97
+        /// <param name="SQLString">SQL语句</param>
98
+        /// <returns>影响的记录数</returns>
99
+        public static int ExecuteSqlConn(string SQLString, string connectStr)
100
+        {
101
+            using (MySqlConnection connection = new MySqlConnection(connectStr))
102
+            {
103
+                using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
104
+                {
105
+                    try
106
+                    {
107
+                        connection.Open();
108
+                        int rows = cmd.ExecuteNonQuery();
109
+                        return rows;
110
+                    }
111
+                    catch (MySql.Data.MySqlClient.MySqlException e)
112
+                    {
113
+                        connection.Close();
114
+                        throw e;
115
+                    }
116
+                }
117
+            }
118
+        }
119
+
120
+        public static int ExecuteSqlByTime(string SQLString, int Times)
121
+        {
122
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
123
+            {
124
+                using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
125
+                {
126
+                    try
127
+                    {
128
+                        connection.Open();
129
+                        cmd.CommandTimeout = Times;
130
+                        int rows = cmd.ExecuteNonQuery();
131
+                        return rows;
132
+                    }
133
+                    catch (MySql.Data.MySqlClient.MySqlException e)
134
+                    {
135
+                        connection.Close();
136
+                        throw e;
137
+                    }
138
+                }
139
+            }
140
+        }
141
+
142
+
143
+        /// <summary>
144
+        /// 执行多条SQL语句,实现数据库事务。
145
+        /// </summary>
146
+        /// <param name="SQLStringList">多条SQL语句</param>        
147
+        public static int ExecuteSqlTran(List<String> SQLStringList)
148
+        {
149
+            using (MySqlConnection conn = new MySqlConnection(connectionString))
150
+            {
151
+                conn.Open();
152
+                MySqlCommand cmd = new MySqlCommand();
153
+                cmd.Connection = conn;
154
+                MySqlTransaction tx = conn.BeginTransaction();
155
+                cmd.Transaction = tx;
156
+                try
157
+                {
158
+                    int count = 0;
159
+                    for (int n = 0; n < SQLStringList.Count; n++)
160
+                    {
161
+                        string strsql = SQLStringList[n];
162
+                        if (strsql.Trim().Length > 1)
163
+                        {
164
+                            cmd.CommandText = strsql;
165
+                            count += cmd.ExecuteNonQuery();
166
+                        }
167
+                    }
168
+                    tx.Commit();
169
+                    return count;
170
+                }
171
+                catch (Exception ex)
172
+                {
173
+                    tx.Rollback();
174
+                    throw ex;
175
+                    return 0;
176
+                }
177
+            }
178
+        }
179
+        /// <summary>
180
+        /// 执行带一个存储过程参数的的SQL语句。
181
+        /// </summary>
182
+        /// <param name="SQLString">SQL语句</param>
183
+        /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
184
+        /// <returns>影响的记录数</returns>
185
+        public static int ExecuteSql(string SQLString, string content)
186
+        {
187
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
188
+            {
189
+                MySqlCommand cmd = new MySqlCommand(SQLString, connection);
190
+                MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@content", SqlDbType.NText);
191
+                myParameter.Value = content;
192
+                cmd.Parameters.Add(myParameter);
193
+                try
194
+                {
195
+                    connection.Open();
196
+                    int rows = cmd.ExecuteNonQuery();
197
+                    return rows;
198
+                }
199
+                catch (MySql.Data.MySqlClient.MySqlException e)
200
+                {
201
+                    throw e;
202
+                }
203
+                finally
204
+                {
205
+                    cmd.Dispose();
206
+                    connection.Close();
207
+                }
208
+            }
209
+        }
210
+        /// <summary>
211
+        /// 执行带一个存储过程参数的的SQL语句。
212
+        /// </summary>
213
+        /// <param name="SQLString">SQL语句</param>
214
+        /// <param name="content">参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加</param>
215
+        /// <returns>影响的记录数</returns>
216
+        public static object ExecuteSqlGet(string SQLString, string content)
217
+        {
218
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
219
+            {
220
+                MySqlCommand cmd = new MySqlCommand(SQLString, connection);
221
+                MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@content", SqlDbType.NText);
222
+                myParameter.Value = content;
223
+                cmd.Parameters.Add(myParameter);
224
+                try
225
+                {
226
+                    connection.Open();
227
+                    object obj = cmd.ExecuteScalar();
228
+                    if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
229
+                    {
230
+                        return null;
231
+                    }
232
+                    else
233
+                    {
234
+                        return obj;
235
+                    }
236
+                }
237
+                catch (MySql.Data.MySqlClient.MySqlException e)
238
+                {
239
+                    throw e;
240
+                }
241
+                finally
242
+                {
243
+                    cmd.Dispose();
244
+                    connection.Close();
245
+                }
246
+            }
247
+        }
248
+        /// <summary>
249
+        /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例)
250
+        /// </summary>
251
+        /// <param name="strSQL">SQL语句</param>
252
+        /// <param name="fs">图像字节,数据库的字段类型为image的情况</param>
253
+        /// <returns>影响的记录数</returns>
254
+        public static int ExecuteSqlInsertImg(string strSQL, byte[] fs)
255
+        {
256
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
257
+            {
258
+                MySqlCommand cmd = new MySqlCommand(strSQL, connection);
259
+                MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@fs", SqlDbType.Image);
260
+                myParameter.Value = fs;
261
+                cmd.Parameters.Add(myParameter);
262
+                try
263
+                {
264
+                    connection.Open();
265
+                    int rows = cmd.ExecuteNonQuery();
266
+                    return rows;
267
+                }
268
+                catch (MySql.Data.MySqlClient.MySqlException e)
269
+                {
270
+                    throw e;
271
+                }
272
+                finally
273
+                {
274
+                    cmd.Dispose();
275
+                    connection.Close();
276
+                }
277
+            }
278
+        }
279
+
280
+        /// <summary>
281
+        /// 执行一条计算查询结果语句,返回查询结果(object)。
282
+        /// </summary>
283
+        /// <param name="SQLString">计算查询结果语句</param>
284
+        /// <returns>查询结果(object)</returns>
285
+        public static object GetSingle(string SQLString)
286
+        {
287
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
288
+            {
289
+                using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
290
+                {
291
+                    try
292
+                    {
293
+                        connection.Open();
294
+                        object obj = cmd.ExecuteScalar();
295
+                        if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
296
+                        {
297
+                            return null;
298
+                        }
299
+                        else
300
+                        {
301
+                            return obj;
302
+                        }
303
+                    }
304
+                    catch (MySql.Data.MySqlClient.MySqlException e)
305
+                    {
306
+                        connection.Close();
307
+                        throw e;
308
+                    }
309
+                }
310
+            }
311
+        }
312
+        public static object GetSingle(string SQLString, int Times)
313
+        {
314
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
315
+            {
316
+                using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
317
+                {
318
+                    try
319
+                    {
320
+                        connection.Open();
321
+                        cmd.CommandTimeout = Times;
322
+                        object obj = cmd.ExecuteScalar();
323
+                        if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
324
+                        {
325
+                            return null;
326
+                        }
327
+                        else
328
+                        {
329
+                            return obj;
330
+                        }
331
+                    }
332
+                    catch (MySql.Data.MySqlClient.MySqlException e)
333
+                    {
334
+                        connection.Close();
335
+                        throw e;
336
+                    }
337
+                }
338
+            }
339
+        }
340
+        /// <summary>
341
+        /// 执行查询语句,返回MySqlDataReader ( 注意:调用该方法后,一定要对MySqlDataReader进行Close )
342
+        /// </summary>
343
+        /// <param name="strSQL">查询语句</param>
344
+        /// <returns>MySqlDataReader</returns>
345
+        public static MySqlDataReader ExecuteReader(string strSQL)
346
+        {
347
+            MySqlConnection connection = new MySqlConnection(connectionString);
348
+            MySqlCommand cmd = new MySqlCommand(strSQL, connection);
349
+            try
350
+            {
351
+                connection.Open();
352
+                MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
353
+                return myReader;
354
+            }
355
+            catch (MySql.Data.MySqlClient.MySqlException e)
356
+            {
357
+                throw e;
358
+            }
359
+
360
+        }
361
+
362
+
363
+        /// <summary>
364
+        /// 执行查询语句,返回MySqlDataReader ( 注意:调用该方法后,一定要对MySqlDataReader进行Close )
365
+        /// </summary>
366
+        /// <param name="strSQL">查询语句</param>
367
+        /// <returns>MySqlDataReader</returns>
368
+        public static MySqlDataReader ExecuteReader(string strSQL, string connectionStr)
369
+        {
370
+            MySqlConnection connection = new MySqlConnection(connectionStr);
371
+            MySqlCommand cmd = new MySqlCommand(strSQL, connection);
372
+            try
373
+            {
374
+                connection.Open();
375
+                MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
376
+                return myReader;
377
+            }
378
+            catch (MySql.Data.MySqlClient.MySqlException e)
379
+            {
380
+                throw e;
381
+            }
382
+
383
+        }
384
+
385
+        /// <summary>
386
+        /// 执行查询语句,返回DataSet
387
+        /// </summary>
388
+        /// <param name="SQLString">查询语句</param>
389
+        /// <returns>DataSet</returns>
390
+        public static DataSet Query(string SQLString)
391
+        {
392
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
393
+            {
394
+                DataSet ds = new DataSet();
395
+                try
396
+                {
397
+                    connection.Open();
398
+                    MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection);
399
+                    command.Fill(ds, "ds");
400
+                }
401
+                catch (MySql.Data.MySqlClient.MySqlException ex)
402
+                {
403
+                    throw new Exception(ex.Message);
404
+                }
405
+                return ds;
406
+            }
407
+        }
408
+
409
+        /// <summary>
410
+        /// 执行查询语句,返回DataSet
411
+        /// </summary>
412
+        /// <param name="SQLString">查询语句</param>
413
+        /// <returns>DataSet</returns>
414
+        public static DataSet QueryConn(string SQLString, string conStr)
415
+        {
416
+            using (MySqlConnection connection = new MySqlConnection(conStr))
417
+            {
418
+                DataSet ds = new DataSet();
419
+                try
420
+                {
421
+                    connection.Open();
422
+                    MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection);
423
+                    command.Fill(ds, "ds");
424
+                }
425
+                catch (MySql.Data.MySqlClient.MySqlException ex)
426
+                {
427
+                    throw new Exception(ex.Message);
428
+                }
429
+                finally
430
+                {
431
+                    connection.Close();
432
+                }
433
+                return ds;
434
+            }
435
+        }
436
+
437
+        public static DataSet Query(string SQLString, int Times)
438
+        {
439
+            using (MySqlConnection connection = new MySqlConnection(connectionString))
440
+            {
441
+                DataSet ds = new DataSet();
442
+                try
443
+                {
444
+                    connection.Open();
445
+                    MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection);
446
+                    command.SelectCommand.CommandTimeout = Times;
447
+                    command.Fill(ds, "ds");
448
+                }
449
+                catch (MySql.Data.MySqlClient.MySqlException ex)
450
+                {
451
+                    throw new Exception(ex.Message);
452
+                }
453
+                return ds;
454
+            }
455
+        }
456
+
457
+
458
+
459
+        #endregion
460
+
461
+
462
+    }
463
+}

+ 3 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

@@ -107,7 +107,7 @@
107 107
   <add key="10086SmsPassword" value="Ay+12345-Rx" />
108 108
   <add key="10086SmsSign" value="q4dGVsCk2" />
109 109
   <!-- ================== 14:其他配置 ================== -->
110
-  <add key="AuthDate" value="2023-10-12" />
110
+  <add key="AuthDate" value="2035-10-12" />
111 111
   <add key="OutSignCode" value="$AY12345#" />
112 112
   <add key="Affairs" value="0" />
113 113
 
@@ -144,5 +144,7 @@
144 144
   <add key="SendToPhone" value="15605815106"/>
145 145
 
146 146
   <add key="maindeptid" value="1600"/>
147
+  <add key="PushErrorOrder" value="http://localhost:51927/api/Info/addorder"/>
147 148
   
149
+
148 150
 </appSettings>

+ 245 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/APPController.cs

@@ -2381,5 +2381,250 @@ namespace CallCenterApi.Interface.Controllers
2381 2381
                 string Dataurl = web.DownloadString(url + "case_material_info" + "?WorkOrderId=" + WorkOrderId + "&file=" + file  + "&id=" + id + "&type=" + type);
2382 2382
             }
2383 2383
         }
2384
+
2385
+        
2386
+        public ActionResult PushErrorWorkOrder()
2387
+        {
2388
+            var dt = DbHelperSQL.Query("select * from t_PushError where F_Success=0 and F_PushCount<5").Tables[0];
2389
+
2390
+            if (dt != null && dt.Rows.Count > 0)
2391
+            {
2392
+                foreach (DataRow item in dt.Rows)
2393
+                {
2394
+                    // 存到mysql表里
2395
+                 
2396
+
2397
+                    var modelT_Bus_WorkOrder = workorderBLL.GetModel(item["F_WorkOrderCode"].ToString());
2398
+                    string strlevel = "";
2399
+                    if (modelT_Bus_WorkOrder.F_Level != null)
2400
+                    {
2401
+                        if (modelT_Bus_WorkOrder.F_Level == 1)
2402
+                        {
2403
+                            strlevel = "一般";
2404
+                        }
2405
+                        else
2406
+                        {
2407
+                            strlevel = "紧急";
2408
+                        }
2409
+                    }
2410
+                    string strsjlx = "";
2411
+                    var sjlx = DbHelperSQL.GetSingle($"select dbo.GetDictionaryName('{modelT_Bus_WorkOrder.F_Key}' ) ");
2412
+                    if (sjlx != null)
2413
+                    {
2414
+                        strsjlx = sjlx.ToString();
2415
+                    }
2416
+                    string strsjly = "";
2417
+                    var sjly = DbHelperSQL.GetSingle($"select dbo .GetDictionaryName('{modelT_Bus_WorkOrder.F_InfoSource}' ) ");
2418
+
2419
+                    if (sjly != null)
2420
+                    {
2421
+                        strsjly = sjly.ToString();
2422
+                    }
2423
+                    string strsex = "";
2424
+                    if (modelT_Bus_WorkOrder.F_CusSex != null)
2425
+                    {
2426
+                        if (modelT_Bus_WorkOrder.F_CusSex == "1")
2427
+                        {
2428
+                            strsex = "女";
2429
+                        }
2430
+                        else
2431
+                        {
2432
+                            strsex = "男";
2433
+                        }
2434
+                    }
2435
+                    string strsjdd = "";
2436
+                    var sjdd = DbHelperSQL.GetSingle($"select  dbo.GetAreaName('{modelT_Bus_WorkOrder.F_SourceArea}') + isnull(  dbo.GetAreaChildrenCode('{modelT_Bus_WorkOrder.F_Township}'),'') + ISNULL( dbo.GetAreaChildrenCode('{modelT_Bus_WorkOrder.F_Village}') ,'')");
2437
+                    if (sjdd != null)
2438
+                    {
2439
+                        strsjdd = sjdd.ToString();
2440
+                    }
2441
+                    Guid guid = Guid.NewGuid();
2442
+                    string insertsql = $"insert into BM_hbszwf_rxyzf_001(RowGuid,sjmc,fssj,fsdd,sjjb,sjlx,sjly,dsrxm,dsrdh,dsrxb,dsrjzxz,sjjs,sjbh) values('{guid}','{modelT_Bus_WorkOrder.F_ComTitle}','{modelT_Bus_WorkOrder.F_CreateTime}','{strsjdd}','{strlevel}','{strsjlx}','{strsjly}','{modelT_Bus_WorkOrder.F_CusName}','{modelT_Bus_WorkOrder.F_CusPhone}','{strsex}','{modelT_Bus_WorkOrder.F_SourceAddress}','{modelT_Bus_WorkOrder.F_ComContent}','{modelT_Bus_WorkOrder.F_WorkOrderId}')";
2443
+                    try
2444
+                    {
2445
+
2446
+                      //  string url = "http://localhost:51927/api/Info/addorder";
2447
+                        string url = Configs.GetValue("PushErrorOrder");
2448
+                        Dictionary<string, object> dic = new Dictionary<string, object>();
2449
+
2450
+                        dic.Add("sql", insertsql);
2451
+
2452
+                        var resss = Post(url, dic);
2453
+
2454
+
2455
+                        if (Convert.ToInt32(resss) > 0)
2456
+                        {
2457
+                            DbHelperSQL.ExecuteSql($" update t_PushError set F_Success=1,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2458
+                        }
2459
+                        else
2460
+                        {
2461
+                            // 更新推送次数
2462
+                            DbHelperSQL.ExecuteSql($" update t_PushError set F_PushCount=F_PushCount+1 ,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2463
+                        }
2464
+                        #region 注释
2465
+                        //int res = DbHelperMySQL.ExecuteSql(insertsql);
2466
+
2467
+                        ////查看是否mysql数据库是否有数据
2468
+                        ////有数据更新本地表的success=1
2469
+                        ////     没数据 count+1;
2470
+                        //var exist = DbHelperMySQL.GetSingle($" select count(1) from BM_hbszwf_rxyzf_001 where sjbh='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2471
+                        //if (Convert.ToInt32(exist) > 0)
2472
+                        //{
2473
+                        //    DbHelperSQL.ExecuteSql($" update t_PushError set F_Success=1,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2474
+
2475
+                        //    return Success("");
2476
+                        //}
2477
+                        //else
2478
+                        //{
2479
+                        //    DbHelperSQL.ExecuteSql($" update t_PushError set F_PushCount=F_PushCount+1 ,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2480
+                        //    return Success("");
2481
+                        //}
2482
+#endregion
2483
+                    }
2484
+                    catch  
2485
+                    {
2486
+
2487
+                        DbHelperSQL.ExecuteSql($" update t_PushError set F_PushCount=F_PushCount+1 ,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2488
+                        return Success("");
2489
+                    }
2490
+                  
2491
+
2492
+                  
2493
+                    //查看是否mysql数据库是否有数据
2494
+                    //有数据更新本地表的success=1
2495
+                    //     没数据 count+1;
2496
+                }
2497
+            }
2498
+            return Success("");
2499
+
2500
+
2501
+
2502
+
2503
+        }
2504
+        public static string Post(string url, Dictionary<string, object> dic)
2505
+        {
2506
+            string result = "";
2507
+            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
2508
+            req.Method = "POST";
2509
+            req.ContentType = "application/x-www-form-urlencoded";
2510
+            #region 添加Post 参数
2511
+            StringBuilder builder = new StringBuilder();
2512
+            int i = 0;
2513
+            foreach (var item in dic)
2514
+            {
2515
+                if (i > 0)
2516
+                    builder.Append("&");
2517
+                builder.AppendFormat("{0}={1}", item.Key, item.Value);
2518
+                i++;
2519
+            }
2520
+            byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
2521
+            req.ContentLength = data.Length;
2522
+            using (Stream reqStream = req.GetRequestStream())
2523
+            {
2524
+                reqStream.Write(data, 0, data.Length);
2525
+                reqStream.Close();
2526
+            }
2527
+            #endregion
2528
+            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
2529
+            Stream stream = resp.GetResponseStream();
2530
+            //获取响应内容
2531
+            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
2532
+            {
2533
+                result = reader.ReadToEnd();
2534
+            }
2535
+            return result;
2536
+        }
2537
+
2538
+        public ActionResult PushSingleErrorWorkOrder(string code)
2539
+        {
2540
+                    // 存到mysql表里
2541
+                    var modelT_Bus_WorkOrder = workorderBLL.GetModel(code);
2542
+                    string strlevel = "";
2543
+                    if (modelT_Bus_WorkOrder.F_Level != null)
2544
+                    {
2545
+                        if (modelT_Bus_WorkOrder.F_Level == 1)
2546
+                        {
2547
+                            strlevel = "一般";
2548
+                        }
2549
+                        else
2550
+                        {
2551
+                            strlevel = "紧急";
2552
+                        }
2553
+                    }
2554
+                    string strsjlx = "";
2555
+                    var sjlx = DbHelperSQL.GetSingle($"select dbo.GetDictionaryName('{modelT_Bus_WorkOrder.F_Key}' ) ");
2556
+                    if (sjlx != null)
2557
+                    {
2558
+                        strsjlx = sjlx.ToString();
2559
+                    }
2560
+                    string strsjly = "";
2561
+                    var sjly = DbHelperSQL.GetSingle($"select dbo .GetDictionaryName('{modelT_Bus_WorkOrder.F_InfoSource}' ) ");
2562
+
2563
+                    if (sjly != null)
2564
+                    {
2565
+                        strsjly = sjly.ToString();
2566
+                    }
2567
+                    string strsex = "";
2568
+                    if (modelT_Bus_WorkOrder.F_CusSex != null)
2569
+                    {
2570
+                        if (modelT_Bus_WorkOrder.F_CusSex == "1")
2571
+                        {
2572
+                            strsex = "女";
2573
+                        }
2574
+                        else
2575
+                        {
2576
+                            strsex = "男";
2577
+                        }
2578
+                    }
2579
+                    string strsjdd = "";
2580
+                    var sjdd = DbHelperSQL.GetSingle($"select  dbo.GetAreaName('{modelT_Bus_WorkOrder.F_SourceArea}') + isnull(  dbo.GetAreaChildrenCode('{modelT_Bus_WorkOrder.F_Township}'),'') + ISNULL( dbo.GetAreaChildrenCode('{modelT_Bus_WorkOrder.F_Village}') ,'')");
2581
+                    if (sjdd != null)
2582
+                    {
2583
+                        strsjdd = sjdd.ToString();
2584
+                    }
2585
+                    Guid guid = Guid.NewGuid();
2586
+                    string insertsql = $"insert into BM_hbszwf_rxyzf_001(RowGuid,sjmc,fssj,fsdd,sjjb,sjlx,sjly,dsrxm,dsrdh,dsrxb,dsrjzxz,sjjs,sjbh) values('{guid}','{modelT_Bus_WorkOrder.F_ComTitle}','{modelT_Bus_WorkOrder.F_CreateTime}','{strsjdd}','{strlevel}','{strsjlx}','{strsjly}','{modelT_Bus_WorkOrder.F_CusName}','{modelT_Bus_WorkOrder.F_CusPhone}','{strsex}','{modelT_Bus_WorkOrder.F_SourceAddress}','{modelT_Bus_WorkOrder.F_ComContent}','{modelT_Bus_WorkOrder.F_WorkOrderId}')";
2587
+                    try
2588
+                    {
2589
+
2590
+                        
2591
+                        string url = Configs.GetValue("PushErrorOrder");
2592
+                        Dictionary<string, object> dic = new Dictionary<string, object>();
2593
+
2594
+                        dic.Add("sql", insertsql);
2595
+
2596
+                        var resss = Post(url, dic);
2597
+
2598
+
2599
+                        if (Convert.ToInt32(resss) > 0)
2600
+                        {
2601
+                            DbHelperSQL.ExecuteSql($" update t_PushError set F_Success=1,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2602
+                        }
2603
+                        else
2604
+                        {
2605
+                            // 更新推送次数
2606
+                            DbHelperSQL.ExecuteSql($" update t_PushError set F_PushCount=F_PushCount+1 ,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2607
+                        }
2608
+                     
2609
+                    }
2610
+                    catch
2611
+                    {
2612
+
2613
+                        DbHelperSQL.ExecuteSql($" update t_PushError set F_PushCount=F_PushCount+1 ,F_UpdateTime=getdate()   where F_WorkOrderCode='{modelT_Bus_WorkOrder.F_WorkOrderId}'");
2614
+                        return Success("");
2615
+                    }
2616
+
2617
+
2618
+             
2619
+                    //成功更新本地表的success=1
2620
+                    //    没成功 推送次数count+1;
2621
+                
2622
+          
2623
+            return Success("执行完成");
2624
+
2625
+
2626
+
2627
+
2628
+        }
2384 2629
     }
2385 2630
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 141 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs


+ 1 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Web.config

@@ -30,7 +30,7 @@
30 30
     <add name="ConnectionString" connectionString="Data Source=192.168.1.36;User ID=sa;pwd=hykj800100;Initial Catalog=HB12345;" />
31 31
 
32 32
     <add name="ConnectionStringOld" connectionString="Data Source=192.168.1.36;User ID=sa;pwd=hykj800100;Initial Catalog=HBSZRX;" />
33
-
33
+    <add name="MySqlconnection" connectionString="server=192.168.1.200;Port=3306;User ID=root;Password=800100;database=ay110;charset=utf8mb4;Allow User Variables=true;" />
34 34
 
35 35
   </connectionStrings>
36 36
   <system.web>

+ 20 - 1
CallCenterCommon/CallCenter.QuartzService/PushWorkorder.cs

@@ -24,7 +24,26 @@ namespace CallCenter.QuartzService
24 24
 
25 25
         public void PushApp(object sender, EventArgs e)
26 26
         {
27
-            var Dataurl = HttpMethods.HttpPost("http://10.0.38.106:8002/PushMessage/SmsOverTime");
27
+            
28
+            try
29
+            {
30
+                var Dataurl = HttpMethods.HttpPost("http://10.0.38.106:8002/PushMessage/SmsOverTime");
31
+            }
32
+            catch (Exception)
33
+            {
34
+
35
+                
36
+            }
37
+            try
38
+            {
39
+                //var Dataurl2 = HttpMethods.HttpPost("http://10.0.38.106:8002/WorkOrder/PushErrorWorkOrder");
40
+                var Dataurl2 = HttpMethods.HttpPost("http://localhost:63663/App/PushErrorWorkOrder");
41
+            }
42
+            catch (Exception)
43
+            {
44
+
45
+
46
+            }
28 47
         }
29 48
     
30 49