zhaozhiqiang 5 lat temu
rodzic
commit
7bf21f264f

+ 42 - 0
代码/MadRunFabirc.Model/OnlineServiceApi/T_Msg_Chat.cs

@@ -0,0 +1,42 @@
1
+using MadRunFabric.Common;
2
+using MongoDB.Bson.Serialization.Attributes;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel.DataAnnotations;
6
+using System.Text;
7
+
8
+namespace MadRunFabric.Model.OnlineServiceApi
9
+{
10
+  public   class T_Msg_Chat : IBaseModel<string>
11
+    {
12
+        /// <summary>
13
+        /// id
14
+        /// </summary>
15
+        [Key]
16
+        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
17
+        public string id { get; set; }
18
+        /// <summary>
19
+        /// 内容
20
+        /// </summary>
21
+        public string Msgcontent { get; set; }
22
+        /// <summary>
23
+        /// 创建时间
24
+        /// </summary>
25
+        public DateTime createtime { get; set; }
26
+
27
+        /// <summary>
28
+        /// 消息来源
29
+        /// </summary>
30
+        public string  fromuserid { get; set; }
31
+
32
+        /// <summary>
33
+        /// 消息发送给谁
34
+        /// </summary>
35
+        public string  touserid { get; set; }
36
+
37
+        /// <summary>
38
+        /// 是否删除
39
+        /// </summary>
40
+        public int isdelete { get; set; }
41
+    }
42
+}

+ 50 - 0
代码/MadRunFabirc.Model/OnlineServiceApi/T_Msg_Chat_Map.cs

@@ -0,0 +1,50 @@
1
+using MadRunFabric.Common;
2
+using MongoDB.Bson.Serialization.Attributes;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel.DataAnnotations;
6
+using System.Text;
7
+
8
+namespace MadRunFabric.Model.OnlineServiceApi
9
+{
10
+   public  class T_Msg_Chat_Map : IBaseModel<string>
11
+    {
12
+        /// <summary>
13
+        /// id
14
+        /// </summary>
15
+        [Key]
16
+        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
17
+        public string id { get; set; }
18
+        /// <summary>
19
+        /// 消息主键id编号
20
+        /// </summary>
21
+        public string chatid { get; set; }
22
+        /// <summary>
23
+        /// 内容
24
+        /// </summary>
25
+        public string Msgcontent { get; set; }
26
+        /// <summary>
27
+        /// 消息来源
28
+        /// </summary>
29
+        public string fromuserid { get; set; }
30
+        public string fromusername { get; set; }
31
+        /// <summary>
32
+        /// 消息发送给谁
33
+        /// </summary>
34
+        public string touserid { get; set; }
35
+        public string tousername { get; set; }
36
+        /// <summary>
37
+        /// 创建时间
38
+        /// </summary>
39
+        public DateTime createtime { get; set; }
40
+        /// <summary>
41
+        /// 是否查看过 0未查看 1查看过
42
+        /// </summary>
43
+        public int isread { get; set; }
44
+
45
+        /// <summary>
46
+        /// 是否删除
47
+        /// </summary>
48
+        public int isdelete { get; set; }
49
+    }
50
+}

+ 49 - 0
代码/MadRunFabirc.Model/TestUserTypeApi/T_Msg_Chat.cs

@@ -0,0 +1,49 @@
1
+using MadRunFabric.Common;
2
+using MongoDB.Bson.Serialization.Attributes;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel.DataAnnotations;
6
+using System.Text;
7
+
8
+namespace MadRunFabric.Model.TestUserTypeApi
9
+{
10
+  public   class T_Msg_Chat : IBaseModel<string>
11
+    {
12
+        /// <summary>
13
+        /// id
14
+        /// </summary>
15
+        [Key]
16
+        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
17
+        public string id { get; set; }
18
+        /// <summary>
19
+        /// 内容
20
+        /// </summary>
21
+        public string Msgcontent { get; set; }
22
+        /// <summary>
23
+        /// 创建时间
24
+        /// </summary>
25
+        public DateTime createtime { get; set; }
26
+
27
+        /// <summary>
28
+        /// 消息来源
29
+        /// </summary>
30
+        public string fromuserid { get; set; }
31
+
32
+        /// <summary>
33
+        /// 消息发送给谁
34
+        /// </summary>
35
+        public string touserid { get; set; }
36
+
37
+        /// <summary>
38
+        /// 是否删除
39
+        /// </summary>
40
+        public int isdelete { get; set; }
41
+        /// <summary>
42
+        /// 区分微信接口和网站接口
43
+        /// </summary>
44
+
45
+        public int isonetype { get; set; }
46
+
47
+       
48
+    }
49
+}

+ 45 - 0
代码/MadRunFabirc.Model/TestUserTypeApi/T_Msg_Chat_Map.cs

@@ -0,0 +1,45 @@
1
+using MadRunFabric.Common;
2
+using MongoDB.Bson.Serialization.Attributes;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel.DataAnnotations;
6
+using System.Text;
7
+
8
+namespace MadRunFabric.Model.TestUserTypeApi
9
+{
10
+   public  class T_Msg_Chat_Map : IBaseModel<string>
11
+    {
12
+        /// <summary>
13
+        /// id
14
+        /// </summary>
15
+        [Key]
16
+        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
17
+        public string id { get; set; }
18
+        /// <summary>
19
+        /// 消息主键id编号
20
+        /// </summary>
21
+        public string chatid { get; set; }
22
+        /// <summary>
23
+        /// 消息来源
24
+        /// </summary>
25
+        public string  fromuserid { get; set; }
26
+
27
+        /// <summary>
28
+        /// 消息发送给谁
29
+        /// </summary>
30
+        public string  touserid { get; set; }
31
+        /// <summary>
32
+        /// 创建时间
33
+        /// </summary>
34
+        public DateTime createtime { get; set; }
35
+        /// <summary>
36
+        /// 是否查看过 0未查看 1查看过
37
+        /// </summary>
38
+        public int isread { get; set; }
39
+
40
+        /// <summary>
41
+        /// 是否删除
42
+        /// </summary>
43
+        public int isdelete { get; set; }
44
+    }
45
+}

+ 12 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.IRepositories/ImsgonlineRepository.cs

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using MadRunFabric.Common;
5
+using MadRunFabric.Model.OnlineServiceApi;
6
+
7
+namespace TestUserTypeApi.IRepositories
8
+{
9
+   public  interface ImsgonlineRepository : IRepository<T_Msg_Chat, string>
10
+    {
11
+    }
12
+}

+ 12 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.IRepositories/ImsgonlinemapRepository.cs

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using MadRunFabric.Common;
5
+using MadRunFabric.Model.TestUserTypeApi;
6
+
7
+namespace TestUserTypeApi.IRepositories
8
+{
9
+    public interface ImsgonlinemapRepository : IRepository<T_Msg_Chat_Map, string>
10
+    {
11
+    }
12
+}

+ 37 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Model/Dto/T_Msg_Chat.cs

@@ -0,0 +1,37 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace TestUserTypeApi.Model.Dto
6
+{
7
+   public  class T_Msg_Chat
8
+    {
9
+        /// <summary>
10
+        /// id
11
+        /// </summary>
12
+        public string id { get; set; }
13
+        /// <summary>
14
+        /// 内容
15
+        /// </summary>
16
+        public string Msgcontent { get; set; }
17
+        /// <summary>
18
+        /// 创建时间
19
+        /// </summary>
20
+        public DateTime createtime { get; set; }
21
+
22
+        /// <summary>
23
+        /// 消息来源
24
+        /// </summary>
25
+        public int fromuserid { get; set; }
26
+
27
+        /// <summary>
28
+        /// 消息发送给谁
29
+        /// </summary>
30
+        public int touserid { get; set; }
31
+
32
+        /// <summary>
33
+        /// 是否删除
34
+        /// </summary>
35
+        public int isdelete { get; set; }
36
+    }
37
+}

+ 37 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Model/Dto/T_Msg_Chat_Map.cs

@@ -0,0 +1,37 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace TestUserTypeApi.Model.Dto
6
+{
7
+   public  class T_Msg_Chat_Map
8
+    {
9
+        public string id { get; set; }
10
+        /// <summary>
11
+        /// 消息主键id编号
12
+        /// </summary>
13
+        public string chatid { get; set; }
14
+        /// <summary>
15
+        /// 消息来源
16
+        /// </summary>
17
+        public int fromuserid { get; set; }
18
+
19
+        /// <summary>
20
+        /// 消息发送给谁
21
+        /// </summary>
22
+        public int touserid { get; set; }
23
+        /// <summary>
24
+        /// 创建时间
25
+        /// </summary>
26
+        public DateTime createtime { get; set; }
27
+        /// <summary>
28
+        /// 是否查看过 0未查看 1查看过
29
+        /// </summary>
30
+        public int isread { get; set; }
31
+
32
+        /// <summary>
33
+        /// 是否删除
34
+        /// </summary>
35
+        public int isdelete { get; set; }
36
+    }
37
+}

+ 24 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Repositories/msgonlineRepository.cs

@@ -0,0 +1,24 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using MadRunFabric.Common;
5
+using MadRunFabric.Common.Options;
6
+using MadRunFabric.Model.OnlineServiceApi;
7
+using Microsoft.Extensions.Logging;
8
+using Microsoft.Extensions.Options;
9
+using MongoDB.Driver;
10
+
11
+
12
+namespace TestUserTypeApi.Repositories
13
+{
14
+   public  class msgonlineRepository : BaseRepository<T_Msg_Chat, string>, IRepositories.ImsgonlineRepository
15
+    {
16
+        protected readonly ILogger<BaseRepository<T_Msg_Chat, string>> _logger;
17
+        protected readonly IMongoCollection<T_Msg_Chat> _collection_MassageInfo;
18
+        public msgonlineRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<T_Msg_Chat, string>> logger) : base(settings, logger)
19
+        {
20
+            _collection_MassageInfo = _context.GetCollection<T_Msg_Chat>();
21
+            _logger = logger;
22
+        }
23
+    }
24
+}

+ 23 - 0
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi.Repositories/msgonlinemapRepository.cs

@@ -0,0 +1,23 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using MadRunFabric.Common;
5
+using MadRunFabric.Common.Options;
6
+using MadRunFabric.Model.OnlineServiceApi;
7
+using Microsoft.Extensions.Logging;
8
+using Microsoft.Extensions.Options;
9
+using MongoDB.Driver;
10
+
11
+namespace TestUserTypeApi.Repositories
12
+{
13
+  public   class msgonlinemapRepository : BaseRepository<T_Msg_Chat_Map, string>, IRepositories.ImsgonlinemapRepository
14
+    {
15
+        protected readonly ILogger<BaseRepository<T_Msg_Chat_Map, string>> _logger;
16
+        protected readonly IMongoCollection<T_Msg_Chat_Map> _collection_MassageInfo;
17
+        public msgonlinemapRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<T_Msg_Chat_Map, string>> logger) : base(settings, logger)
18
+        {
19
+            _collection_MassageInfo = _context.GetCollection<T_Msg_Chat_Map>();
20
+            _logger = logger;
21
+        }
22
+    }
23
+}

+ 260 - 77
代码/MadRunFabric.TestUserTypeApi/TestUserTypeApi/Controllers/TestUserTypeController.cs

@@ -21,6 +21,7 @@ using System.ServiceModel;
21 21
 using System.Collections;
22 22
 using System.Net.Http;
23 23
 using System.Reflection;
24
+using MadRunFabric.Model.OnlineServiceApi;
24 25
 
25 26
 // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
26 27
 
@@ -37,35 +38,55 @@ namespace TestUserTypeApi.Controllers
37 38
         {
38 39
             return View();
39 40
         }
41
+        #region 定义接口模块
42
+
40 43
         private readonly ILogger<TestUserTypeController> _logger;
41 44
         private readonly IConfiguration _configuration;
42 45
         private readonly ItestusertypeRepository _tsertuserRepository;//每一道试题信息表
43 46
         private readonly ItesttypeRepository _ItesttypeRepository;    //试题类型表
44
-        private readonly IUserTestRepository   _IUserTestRepository;  //用户总分表
47
+        private readonly IUserTestRepository _IUserTestRepository;  //用户总分表
45 48
         private readonly IUserDoTestRepository _IUserDoTestRepository;//用户做每一题的信息表
49
+        /// <summary>
50
+        /// 信息模块
51
+        /// </summary>
46 52
         private readonly IMassageInfoRepository _IMassageInfoRepository;//发送信息记录表
47 53
         private readonly ItestquestionRepository _ItestquestionRepository;//发送信息记录表
48 54
         private readonly IMassageTypeRepository _IMassageTypeRepository;//短信模板
55
+
56
+        /// <summary>
57
+        /// 在线客服模块
58
+        /// </summary>
59
+        private readonly ImsgonlineRepository _ImsgonlineRepository;//在线客服
60
+        private readonly ImsgonlinemapRepository _ImsgonlinemapRepository;//在线客服
61
+
62
+
49 63
         public TestUserTypeController(ILogger<TestUserTypeController> logger,
50
-            IConfiguration configuration,
51
-            ItestusertypeRepository tsertuserRepository,
52
-            ItesttypeRepository testtypeRepository, 
53
-            IUserTestRepository UserTestRepository, 
54
-            IUserDoTestRepository UserDoTestRepository, 
55
-            IMassageInfoRepository MassageInfoRepository,
56
-            ItestquestionRepository ItestquestionRepository,
57
-            IMassageTypeRepository IMassageTypeRepository)
64
+           IConfiguration configuration,
65
+           ItestusertypeRepository tsertuserRepository,
66
+           ItesttypeRepository testtypeRepository,
67
+           IUserTestRepository UserTestRepository,
68
+           IUserDoTestRepository UserDoTestRepository,
69
+           IMassageInfoRepository MassageInfoRepository,
70
+           ItestquestionRepository ItestquestionRepository,
71
+           IMassageTypeRepository IMassageTypeRepository,
72
+           ImsgonlineRepository ImsgonlineRepository,//在线客服
73
+           ImsgonlinemapRepository ImsgonlinemapRepository//在线客服
74
+           )
58 75
         {
59 76
             _logger = logger;
60 77
             _configuration = configuration;
61 78
             _tsertuserRepository = tsertuserRepository;
62 79
             _ItesttypeRepository = testtypeRepository;
63
-            _IUserTestRepository  =UserTestRepository;
80
+            _IUserTestRepository = UserTestRepository;
64 81
             _IUserDoTestRepository = UserDoTestRepository;
65 82
             _IMassageInfoRepository = MassageInfoRepository;
66 83
             _ItestquestionRepository = ItestquestionRepository;
67 84
             _IMassageTypeRepository = IMassageTypeRepository;
68
-        }
85
+            _ImsgonlineRepository = ImsgonlineRepository;
86
+            _ImsgonlinemapRepository = ImsgonlinemapRepository;
87
+        } 
88
+        #endregion
89
+        #region 满意度模块
69 90
         /// <summary>
70 91
         /// 查询试题
71 92
         /// </summary>
@@ -74,7 +95,7 @@ namespace TestUserTypeApi.Controllers
74 95
         public async Task<IActionResult> GetListDrop(int PageIndex, int PageSize, string testtypeid)
75 96
         {
76 97
             //var list1 = await _tsertuserRepository.Get(p=>p.testtype==testtypeid);
77
-           
98
+
78 99
             //if (testtypeid != null)
79 100
             //{
80 101
             //    list = await _tsertuserRepository.Get(s => s.testtype == testtypeid);
@@ -94,14 +115,14 @@ namespace TestUserTypeApi.Controllers
94 115
             var redCount = await _tsertuserRepository.CountAsync(filter);   //获取总数
95 116
             var listmodel = new List<TestPager>();
96 117
 
97
-          
118
+
98 119
             int iscount = 1;
99 120
             foreach (var item in list)
100 121
             {
101 122
                 ///定义选项
102 123
                 var optioncenter = "";
103 124
                 TestTypes ttps = await _ItesttypeRepository.GetSingle(p => p.id == item.testtype);
104
-               var  tqn = await _ItestquestionRepository.Get(p=>p.testid==item.id);
125
+                var tqn = await _ItestquestionRepository.Get(p => p.testid == item.id);
105 126
                 foreach (var tqnitem in tqn)
106 127
                 {
107 128
                     optioncenter += tqnitem.questname;
@@ -136,7 +157,7 @@ namespace TestUserTypeApi.Controllers
136 157
         [HttpGet("getlistdroplis")]
137 158
         public async Task<IActionResult> GetListDropLis(int PageIndex, int PageSize, string testtypeid)
138 159
         {
139
-           
160
+
140 161
             //排序字段
141 162
             var sort = Builders<TestPager>.Sort.Descending("createdatatime");
142 163
             //根据条件查询集合
@@ -152,11 +173,11 @@ namespace TestUserTypeApi.Controllers
152 173
             var redCount = await _tsertuserRepository.CountAsync(filter);   //获取总数
153 174
             var listmodel = new List<TestPager>();
154 175
 
155
-           
176
+
156 177
             foreach (var item in list)
157 178
             {
158 179
                 TestTypes ttps = await _ItesttypeRepository.GetSingle(p => p.id == item.testtype);
159
-                
180
+
160 181
                 var tqn = await _ItestquestionRepository.Get(p => p.testid == item.id);
161 182
                 var model = new TestPager();
162 183
                 model.id = item.id;
@@ -191,16 +212,16 @@ namespace TestUserTypeApi.Controllers
191 212
             tp.standardkey = tps.standardkey;
192 213
             tp.isdelete = 0;
193 214
             tp.createdatatime = DateTime.Now;
194
-            var a =  _tsertuserRepository.AddRetID(tp);
195
-            if (a.Result != null||a.Result!="")
215
+            var a = _tsertuserRepository.AddRetID(tp);
216
+            if (a.Result != null || a.Result != "")
196 217
             {
197
-                return Success("成功",a.Result);
218
+                return Success("成功", a.Result);
198 219
             }
199 220
             else
200 221
             {
201 222
                 return Error("失败");
202 223
             }
203
-            
224
+
204 225
         }
205 226
         /// <summary>
206 227
         /// 根据id获取详情信息
@@ -250,11 +271,11 @@ namespace TestUserTypeApi.Controllers
250 271
         /// <param name="tps"></param>
251 272
         /// <returns></returns>
252 273
         [HttpGet("updatestpageoption")]
253
-        public async Task<IActionResult> updatestpageoption(string id ,string testoptions)
274
+        public async Task<IActionResult> updatestpageoption(string id, string testoptions)
254 275
         {
255 276
             var model = await _tsertuserRepository.GetSingle(p => p.id == id);
256 277
             model.testoptions = testoptions;
257
-            
278
+
258 279
             var resua = _tsertuserRepository.Update(model);
259 280
             if (resua.Result)
260 281
             {
@@ -313,14 +334,14 @@ namespace TestUserTypeApi.Controllers
313 334
         /// </summary>
314 335
         /// <returns></returns>
315 336
         [HttpGet("gettesttype")]
316
-        public async Task<IActionResult> Gettesttype(int PageIndex,int PageSize)
337
+        public async Task<IActionResult> Gettesttype(int PageIndex, int PageSize)
317 338
         {
318 339
             //排序字段
319 340
             var sort = Builders<TestTypes>.Sort.Descending("Createtime");
320 341
             //根据条件查询集合
321 342
             var listApp = new List<FilterDefinition<TestTypes>>();
322 343
             listApp.Add(Builders<TestTypes>.Filter.Eq("isdelete", 0));
323
-           
344
+
324 345
             var filter = Builders<TestTypes>.Filter.And(listApp);
325 346
 
326 347
             var list = await _ItesttypeRepository.GetByPage(filter, PageIndex, PageSize, sort);
@@ -351,7 +372,7 @@ namespace TestUserTypeApi.Controllers
351 372
             var model = await _ItesttypeRepository.GetSingle(p => p.id == id);
352 373
             var listmodel = new List<TestTypes>();
353 374
             listmodel.Add(model);
354
-            
375
+
355 376
             return Success("成功", listmodel);
356 377
         }
357 378
         /// <summary>
@@ -401,7 +422,7 @@ namespace TestUserTypeApi.Controllers
401 422
         /// </summary>
402 423
         /// <returns></returns>
403 424
         [HttpGet("getUserDoTest")]
404
-        public async  Task<IActionResult> GetUserDoTest(int PageIndex, int PageSize,string telcode)
425
+        public async Task<IActionResult> GetUserDoTest(int PageIndex, int PageSize, string telcode)
405 426
         {
406 427
             //var list = await _IUserDoTestRepository.GetAll();
407 428
 
@@ -422,7 +443,7 @@ namespace TestUserTypeApi.Controllers
422 443
             {
423 444
                 listApp.Add(Builders<UserDoTest>.Filter.Eq("telcode", telcode));
424 445
             }
425
-           
446
+
426 447
             var filter = Builders<UserDoTest>.Filter.And(listApp);
427 448
 
428 449
             var list = await _IUserDoTestRepository.GetByPage(filter, PageIndex, PageSize, sort);
@@ -475,20 +496,20 @@ namespace TestUserTypeApi.Controllers
475 496
             }
476 497
 
477 498
             UserDoTest tp = new UserDoTest();
478
-           tp.telcode = tps.telcode;//电话号
479
-           tp.testid =  tps.testid;//试卷表id
499
+            tp.telcode = tps.telcode;//电话号
500
+            tp.testid = tps.testid;//试卷表id
480 501
             tp.testtype = testtype;//试卷类型
481
-           tp.testoptions = tps.testoptions;//选项
482
-           tp.grade = tps.grade;//得分
483
-           tp.createtime = DateTime.Now;//做题时间
502
+            tp.testoptions = tps.testoptions;//选项
503
+            tp.grade = tps.grade;//得分
504
+            tp.createtime = DateTime.Now;//做题时间
484 505
             tp.isdelete = 0;
485
-           
486
-           var a = _IUserDoTestRepository.AddRetID(tp);
506
+
507
+            var a = _IUserDoTestRepository.AddRetID(tp);
487 508
 
488 509
             if (a.Result != null || a.Result != "")
489 510
             {
490
-               
491
-                var testuserlist = await _IUserTestRepository.GetSingle(p=>p.telcode==tps.telcode&&p.testtype==testtype);
511
+
512
+                var testuserlist = await _IUserTestRepository.GetSingle(p => p.telcode == tps.telcode && p.testtype == testtype);
492 513
                 if (testuserlist == null)
493 514
                 {
494 515
                     UserTest usertest = new UserTest();
@@ -513,8 +534,8 @@ namespace TestUserTypeApi.Controllers
513 534
                     UserTest usertest = new UserTest();
514 535
                     usertest.id = testuserlist.id;
515 536
                     usertest.telcode = tps.telcode;//电话号
516
-                    usertest.testcount = testuserlist.testcount+ 1;//答题数量
517
-                    usertest.allgrade =testuserlist.allgrade+ tps.grade;//总分数
537
+                    usertest.testcount = testuserlist.testcount + 1;//答题数量
538
+                    usertest.allgrade = testuserlist.allgrade + tps.grade;//总分数
518 539
                     usertest.testtype = testtype;//试卷类型
519 540
                     usertest.createtime = DateTime.Now;
520 541
                     var resua = _IUserTestRepository.Update(usertest);
@@ -562,8 +583,8 @@ namespace TestUserTypeApi.Controllers
562 583
                 model.allgrade = item.allgrade;//总分数
563 584
                 model.testtype = item.testtype;//试卷类型
564 585
                 model.testtypename = ttps.Typename;//试卷类型名称
565
-               // model.testid = item.testid;//问题id
566
-                
586
+                                                   // model.testid = item.testid;//问题id
587
+
567 588
                 listmodel.Add(model);
568 589
             }
569 590
             var obj = new
@@ -582,12 +603,12 @@ namespace TestUserTypeApi.Controllers
582 603
         public async Task<IActionResult> AddUserTest(Model.Dto.UserTestDto tps)
583 604
         {
584 605
             UserTest tp = new UserTest();
585
-            tp.telcode =   tps.telcode;//电话号
606
+            tp.telcode = tps.telcode;//电话号
586 607
             tp.testcount = tps.testcount;//答题数量
587
-            tp.allgrade =  tps.allgrade;//总分数
588
-            tp.testtype =  tps.testtype;//试卷类型
608
+            tp.allgrade = tps.allgrade;//总分数
609
+            tp.testtype = tps.testtype;//试卷类型
589 610
             tp.isdelete = 0;
590
-            var a =  _IUserTestRepository.AddRetID(tp);
611
+            var a = _IUserTestRepository.AddRetID(tp);
591 612
             if (a.Result != null || a.Result != "")
592 613
             {
593 614
                 return Success("成功", a.Result);
@@ -624,7 +645,7 @@ namespace TestUserTypeApi.Controllers
624 645
         [HttpGet("addtestquestion")]
625 646
         public async Task<IActionResult> AddTestQuestion(Model.Dto.testquestion tps)
626 647
         {
627
-            
648
+
628 649
             testquestion tp = new testquestion();
629 650
             tp.questname = tps.questname;//选项内容
630 651
             tp.testid = tps.testid;//题目编号
@@ -692,19 +713,20 @@ namespace TestUserTypeApi.Controllers
692 713
         {
693 714
             var model = await _ItestquestionRepository.Get(p => p.testid == testid);
694 715
             return Success("成功", model);
695
-        }
696
-
697
-       /// <summary>
698
-       /// 获取短信模板信息
699
-       /// </summary>
700
-       /// <param name="PageIndex"></param>
701
-       /// <param name="PageSize"></param>
702
-       /// <param name="typename"></param>
703
-       /// <returns></returns>
716
+        } 
717
+        #endregion
718
+        #region 短信模块
719
+        /// <summary>
720
+        /// 获取短信模板信息
721
+        /// </summary>
722
+        /// <param name="PageIndex"></param>
723
+        /// <param name="PageSize"></param>
724
+        /// <param name="typename"></param>
725
+        /// <returns></returns>
704 726
         [HttpGet("getlistmassagetype")]
705 727
         public async Task<IActionResult> GetListMassageType(int PageIndex, int PageSize, string typename)
706 728
         {
707
-          
729
+
708 730
             //排序字段
709 731
             var sort = Builders<MassageType>.Sort.Descending("Createtime");
710 732
             //根据条件查询集合
@@ -771,7 +793,7 @@ namespace TestUserTypeApi.Controllers
771 793
             {
772 794
                 return Error("该类型模板已存在请选择编辑");
773 795
             }
774
-           
796
+
775 797
         }
776 798
         /// <summary>
777 799
         /// 删除短信模板
@@ -785,7 +807,7 @@ namespace TestUserTypeApi.Controllers
785 807
             string[] arrStr = id.Split(',');
786 808
             foreach (var item in arrStr)
787 809
             {
788
-                var result =  _IMassageTypeRepository.Remove(item);
810
+                var result = _IMassageTypeRepository.Remove(item);
789 811
                 res += 1;
790 812
             }
791 813
             if (res == arrStr.Length)
@@ -853,8 +875,8 @@ namespace TestUserTypeApi.Controllers
853 875
                     return Error("该类型模板已存在请选择相应模板进行编辑");
854 876
                 }
855 877
             }
856
-           
857
-           
878
+
879
+
858 880
 
859 881
         }
860 882
 
@@ -885,12 +907,12 @@ namespace TestUserTypeApi.Controllers
885 907
             //发送给哪个手机号
886 908
             var Mobile = tps.telcode;
887 909
             //定时发送还是立即发送
888
-            var  SendTime = tps.SendTime;
910
+            var SendTime = tps.SendTime;
889 911
             string result1 = HttpUtility.UrlEncode(str, Encoding.GetEncoding("GB2312"));
890 912
             var ifsend = false;
891 913
             var aaa = " ";
892
-            string url = "https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile="+Mobile+"&Content=" + result1 + "&Cell=&SendTime=";
893
-            
914
+            string url = "https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=" + Mobile + "&Content=" + result1 + "&Cell=&SendTime=";
915
+
894 916
             //?CorpID=DYRMYY011170&Pwd=xxk@80188&Mobile=13935966971&Content="+ result1 + "&Cell=&SendTime=
895 917
 
896 918
             //Encoding encoding = Encoding.GetEncoding("GB2312");
@@ -902,14 +924,14 @@ namespace TestUserTypeApi.Controllers
902 924
             parameters.Add("Mobile", Mobile);
903 925
             parameters.Add("Content", result1);
904 926
             parameters.Add("Cell", "");
905
-            parameters.Add("SendTime",SendTime.ToString());
927
+            parameters.Add("SendTime", SendTime.ToString());
906 928
             HttpWebResponse response = PostHttps(url, parameters, encoding);
907 929
             //打印返回值
908 930
             Stream stream = response.GetResponseStream();   //获取响应的字符串流
909 931
             StreamReader sr = new StreamReader(stream); //创建一个stream读取流
910 932
 
911 933
             //返回的信息
912
-             string html = sr.ReadToEnd();
934
+            string html = sr.ReadToEnd();
913 935
 
914 936
             if (Convert.ToInt32(html) > 0)
915 937
             {
@@ -973,13 +995,14 @@ namespace TestUserTypeApi.Controllers
973 995
             {
974 996
                 return Error("IP未导白");
975 997
             }
976
-            else {
998
+            else
999
+            {
977 1000
                 return Error("调用接口失败");
978 1001
             }
979 1002
 
980 1003
         }
981 1004
 
982
-        
1005
+
983 1006
 
984 1007
         /// <summary>
985 1008
         /// 获取发送短信记录更改回复内容
@@ -994,12 +1017,12 @@ namespace TestUserTypeApi.Controllers
994 1017
 
995 1018
             //string replycent = GetFunction("https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188");//
996 1019
             //var replycent1 = DoGet("https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188");
997
-            
1020
+
998 1021
             string url = "https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=DYRMYY011170&Pwd=xxk@80188";
999
-            
1022
+
1000 1023
             Encoding encoding = Encoding.GetEncoding("GBK");
1001 1024
 
1002
-           // var replycent = GetHttpPost(url, "gb2312");
1025
+            // var replycent = GetHttpPost(url, "gb2312");
1003 1026
 
1004 1027
 
1005 1028
             IDictionary<string, string> parameters = new Dictionary<string, string>();
@@ -1061,7 +1084,7 @@ namespace TestUserTypeApi.Controllers
1061 1084
                         return Error("失败");
1062 1085
                     }
1063 1086
                 }
1064
-              
1087
+
1065 1088
             }
1066 1089
             else
1067 1090
             {
@@ -1074,7 +1097,7 @@ namespace TestUserTypeApi.Controllers
1074 1097
         /// </summary>
1075 1098
         /// <returns></returns>
1076 1099
         [HttpGet("getmassage")]
1077
-        public async Task<IActionResult> Getmassage(int PageIndex,int PageSize)
1100
+        public async Task<IActionResult> Getmassage(int PageIndex, int PageSize)
1078 1101
         {
1079 1102
             //排序字段
1080 1103
             var sort = Builders<MassageInfo>.Sort.Descending("senddate");
@@ -1086,7 +1109,7 @@ namespace TestUserTypeApi.Controllers
1086 1109
 
1087 1110
             var list = await _IMassageInfoRepository.GetByPage(filter, PageIndex, PageSize, sort);
1088 1111
             var redCount = await _IMassageInfoRepository.CountAsync(filter);   //获取总数
1089
-            
1112
+
1090 1113
             var listmodel = new List<MassageInfo>();
1091 1114
             foreach (var item in list)
1092 1115
             {
@@ -1105,7 +1128,7 @@ namespace TestUserTypeApi.Controllers
1105 1128
             };
1106 1129
             return Success("成功", obj);
1107 1130
         }
1108
-        
1131
+
1109 1132
         private static readonly string DefaultUserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36";
1110 1133
 
1111 1134
         private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
@@ -1138,7 +1161,7 @@ namespace TestUserTypeApi.Controllers
1138 1161
                 {
1139 1162
                     if (i > 0)
1140 1163
                     {
1141
-                        if (key== "Content")
1164
+                        if (key == "Content")
1142 1165
                         {
1143 1166
                             buffer.AppendFormat("&{0}={1}", key, HttpUtility.UrlEncode(parameters[key], Encoding.GetEncoding("GB2312"))); //
1144 1167
                         }
@@ -1146,7 +1169,7 @@ namespace TestUserTypeApi.Controllers
1146 1169
                         {
1147 1170
                             buffer.AppendFormat("&{0}={1}", key, WebUtility.UrlEncode(parameters[key])); //Encoding.GetEncoding("GBK").GetBytes(parameters[key])
1148 1171
                         }
1149
-                        
1172
+
1150 1173
                     }
1151 1174
                     else
1152 1175
                     {
@@ -1207,7 +1230,7 @@ namespace TestUserTypeApi.Controllers
1207 1230
             }
1208 1231
             return responseBody;
1209 1232
         }
1210
-        public string  GetFunction(string url)
1233
+        public string GetFunction(string url)
1211 1234
         {
1212 1235
             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
1213 1236
             request.Method = "GET";
@@ -1219,5 +1242,165 @@ namespace TestUserTypeApi.Controllers
1219 1242
             return retString;
1220 1243
         }
1221 1244
 
1245
+        #endregion
1246
+        #region 在线客服模块
1247
+        /// <summary>
1248
+        /// 根据编号删除聊天记录
1249
+        /// </summary>
1250
+        /// <param name="id"></param>
1251
+        /// <returns></returns>
1252
+        [HttpGet("delonlinservice")]
1253
+        public async Task<IActionResult> Delonlinservice(string id)
1254
+        {
1255
+            var result = _ImsgonlineRepository.Remove(id);
1256
+            if (result.Result)
1257
+            {
1258
+                return Success("成功");
1259
+            }
1260
+            else
1261
+            {
1262
+                return Error("失败");
1263
+            }
1264
+        }
1265
+        /// <summary>
1266
+        /// 获取聊天记录
1267
+        /// </summary>
1268
+        /// <param name="PageIndex"></param>
1269
+        /// <param name="PageSize"></param>
1270
+        /// <returns></returns>
1271
+        [HttpGet("getListonlineservice")]
1272
+        public async Task<IActionResult> GetListOnlineservice(int PageIndex, int PageSize)
1273
+        {
1274
+
1275
+            //排序字段
1276
+            var sort = Builders<T_Msg_Chat>.Sort.Descending("createdatatime");
1277
+            //根据条件查询集合
1278
+            var listApp = new List<FilterDefinition<T_Msg_Chat>>();
1279
+            listApp.Add(Builders<T_Msg_Chat>.Filter.Eq("isdelete", 0));
1280
+
1281
+            var filter = Builders<T_Msg_Chat>.Filter.And(listApp);
1282
+
1283
+            var list = await _ImsgonlineRepository.GetByPage(filter, PageIndex, PageSize, sort);
1284
+            var redCount = await _ImsgonlineRepository.CountAsync(filter);   //获取总数
1285
+            var listmodel = new List<T_Msg_Chat>();
1286
+
1287
+
1288
+            foreach (var item in list)
1289
+            {
1290
+                var model = new T_Msg_Chat();
1291
+                model.id = item.id;
1292
+                model.Msgcontent = item.Msgcontent;//信息内容
1293
+                model.fromuserid = item.fromuserid;//消息来源
1294
+                model.touserid = item.touserid;//发送给谁
1295
+                model.createtime = item.createtime;//创建时间
1296
+                model.isdelete = item.isdelete;//是否禁用
1297
+                listmodel.Add(model);
1298
+            }
1299
+            var obj = new
1300
+            {
1301
+                rows = listmodel,
1302
+                total = redCount
1303
+            };
1304
+            return Success("成功", obj);
1305
+        }
1306
+        /// <summary>
1307
+        /// 添加聊天记录表信息
1308
+        /// </summary>
1309
+        /// <param name="tps"></param>
1310
+        /// <returns></returns>
1311
+        [HttpGet("addonlineservice")]
1312
+        public async Task<IActionResult> AddOnlineservice(Model.Dto.T_Msg_Chat tps)
1313
+        {
1314
+            T_Msg_Chat tp = new T_Msg_Chat();
1315
+            tp.Msgcontent = tps.Msgcontent;//信息内容
1316
+            tp.fromuserid = tps.fromuserid;//消息来源
1317
+            tp.touserid = tps.touserid;//发送给谁
1318
+            tp.isdelete = 0;
1319
+            tp.createtime = DateTime.Now;
1320
+            var a = _ImsgonlineRepository.AddRetID(tp);
1321
+            if (a.Result != null || a.Result != "")
1322
+            {
1323
+                T_Msg_Chat_Map tmp = new T_Msg_Chat_Map();
1324
+                tmp.chatid = a.Result;//聊天记录的编号
1325
+                tmp.fromuserid = tps.fromuserid;
1326
+                tmp.touserid = tps.touserid;
1327
+                tmp.isdelete = 0;
1328
+                tmp.isread = 0;//是否查看过
1329
+                tmp.createtime = DateTime.Now;
1330
+                var b = _ImsgonlinemapRepository.AddRetID(tmp);
1331
+                if (b.Result != null || b.Result != "")
1332
+                {
1333
+                    return Success("成功", a.Result);
1334
+                }
1335
+                else
1336
+                {
1337
+                    return Error("添加关联记录失败");
1338
+                }
1339
+                    
1340
+            }
1341
+            else
1342
+            {
1343
+                return Error("添加聊天记录失败");
1344
+            }
1345
+
1346
+        }
1347
+        /// <summary>
1348
+        /// 根据编号获取聊天记录信息详情
1349
+        /// </summary>
1350
+        /// <param name="id"></param>
1351
+        /// <returns></returns>
1352
+        [HttpGet("getonlineservicetinfo")]
1353
+        public async Task<IActionResult> GetOnlineservicetinfo(string id)
1354
+        {
1355
+            var mapmode = await _ImsgonlinemapRepository.GetSingle(p => p.id == id);
1356
+            mapmode.isread = 1;//修改成已读
1357
+            var resua = _ImsgonlinemapRepository.Update(mapmode);//修改数据库数据
1358
+
1359
+            var model = await _ImsgonlineRepository.GetSingle(p => p.id == mapmode.chatid);
1360
+            return Success("成功", model);
1361
+        }
1362
+        /// <summary>
1363
+        /// 获取未读消息列表
1364
+        /// </summary>
1365
+        /// <param name="PageIndex"></param>
1366
+        /// <param name="PageSize"></param>
1367
+        /// <returns></returns>
1368
+        [HttpGet("getListonlineservice")]
1369
+        public async Task<IActionResult> GetListOnlineservicemap(int PageIndex, int PageSize)
1370
+        {
1371
+
1372
+            //排序字段
1373
+            var sort = Builders<T_Msg_Chat_Map>.Sort.Descending("createdatatime");
1374
+            //根据条件查询集合
1375
+            var listApp = new List<FilterDefinition<T_Msg_Chat_Map>>();
1376
+            listApp.Add(Builders<T_Msg_Chat_Map>.Filter.Eq("isdelete", 0));
1377
+
1378
+            var filter = Builders<T_Msg_Chat_Map>.Filter.And(listApp);
1379
+
1380
+            var list = await _ImsgonlinemapRepository.GetByPage(filter, PageIndex, PageSize, sort);
1381
+            var redCount = await _ImsgonlinemapRepository.CountAsync(filter);   //获取总数
1382
+            var listmodel = new List<T_Msg_Chat_Map>();
1383
+
1384
+
1385
+            foreach (var item in list)
1386
+            {
1387
+                var model = new T_Msg_Chat_Map();
1388
+                model.id = item.id;
1389
+                model.chatid = item.chatid;//聊天记录编号
1390
+                model.isread = item.isread;//是否阅读
1391
+                model.fromuserid = item.fromuserid;//消息来源
1392
+                model.touserid = item.touserid;//发送给谁
1393
+                model.createtime = item.createtime;//创建时间
1394
+                model.isdelete = item.isdelete;//是否禁用
1395
+                listmodel.Add(model);
1396
+            }
1397
+            var obj = new
1398
+            {
1399
+                rows = listmodel,
1400
+                total = redCount
1401
+            };
1402
+            return Success("成功", obj);
1403
+        }
1404
+        #endregion
1222 1405
     }
1223 1406
 }