zhangkun 5 年之前
父節點
當前提交
b3e0016cde

+ 1 - 1
代码/System.Common/Context/BaseContext.cs

@@ -13,7 +13,7 @@ namespace System.Common
13 13
             Db = new SqlSugarClient(new ConnectionConfig()
14 14
             {
15 15
                 ConnectionString = DB_ConnectionString,
16
-                DbType = DbType.SqlServer,
16
+                DbType = DbType.MySql,
17 17
                 IsAutoCloseConnection = true,
18 18
                 InitKeyType = InitKeyType.SystemTable,
19 19
                 IsShardSameThread = false

+ 2 - 2
代码/System.Common/IRepositories/IRepository.cs

@@ -44,13 +44,13 @@ namespace System.Common
44 44
         /// </summary>
45 45
         /// <param name="obj"></param>
46 46
         /// <returns></returns>
47
-        Task<T> AddAndUpdate(T obj);
47
+        Task<T> AddAndUpdate(T obj,Expression<Func<T, object>> UpdateColumns= null);
48 48
         /// <summary>
49 49
         /// 插入并返回实体
50 50
         /// </summary>
51 51
         /// <param name="obj"></param>
52 52
         /// <returns></returns>
53
-        Task<T> AddAndUpdateList(List<T> obj);
53
+        Task<T> AddAndUpdateList(List<T> obj,Expression<Func<T, object>> UpdateColumns= null);
54 54
         /// <summary>
55 55
         /// 插入并返回影响行数
56 56
         /// </summary>

+ 14 - 6
代码/System.Common/Repositories/BaseMysqlRepository.cs

@@ -121,24 +121,32 @@ namespace System.Common
121 121
             return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
122 122
             //return CurrentCurrentDB.InsertReturnIdentity(obj);
123 123
         }
124
-
125 124
         /// <summary>
126 125
         /// 插入并返回实体
127 126
         /// </summary>
128 127
         /// <param name="obj"></param>
128
+        /// <param name="UpdateColumns">更新字段  null全部</param>
129 129
         /// <returns></returns>
130
-        public async Task<T> AddAndUpdate(T obj)
130
+        public async Task<T> AddAndUpdate(T obj, Expression<Func<T, object>> UpdateColumns = null)
131 131
         {
132
-            return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
132
+            if (UpdateColumns == null)
133
+                return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
134
+            else
135
+                return await Db.Saveable<T>(obj).UpdateColumns(UpdateColumns).ExecuteReturnEntityAsync();
133 136
         }
137
+
134 138
         /// <summary>
135 139
         /// 插入并返回实体
136 140
         /// </summary>
137
-        /// <param name="obj"></param>
141
+        /// <param name="obj">更新插入实体</param>
142
+        /// <param name="UpdateColumns">更新字段  null全部</param>
138 143
         /// <returns></returns>
139
-        public async Task<T> AddAndUpdateList(List<T> obj)
144
+        public async Task<T> AddAndUpdateList(List<T> obj, Expression<Func<T, object>> UpdateColumns = null)
140 145
         {
141
-            return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
146
+            if (UpdateColumns == null)
147
+                return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
148
+            else
149
+                return await Db.Saveable<T>(obj).UpdateColumns(UpdateColumns).ExecuteReturnEntityAsync();
142 150
         }
143 151
 
144 152
         /// <summary>

+ 13 - 6
代码/System.Common/Repositories/BaseRepository.cs

@@ -137,19 +137,26 @@ namespace System.Common
137 137
         /// </summary>
138 138
         /// <param name="obj"></param>
139 139
         /// <returns></returns>
140
-        public async Task<T> AddAndUpdate(T obj)
141
-        {             
142
-            return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
140
+        public async Task<T> AddAndUpdate(T obj, Expression<Func<T, object>> UpdateColumns = null)
141
+        {
142
+            if (UpdateColumns == null)
143
+                return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
144
+            else
145
+                return await Db.Saveable<T>(obj).UpdateColumns(UpdateColumns).ExecuteReturnEntityAsync();
143 146
         }
144 147
 
145 148
         /// <summary>
146 149
         /// 插入并返回实体
147 150
         /// </summary>
148
-        /// <param name="obj"></param>
151
+        /// <param name="obj">更新插入实体</param>
152
+        /// <param name="UpdateColumns">更新字段  null全部</param>
149 153
         /// <returns></returns>
150
-        public async Task<T> AddAndUpdateList(List<T> obj)
154
+        public async Task<T> AddAndUpdateList(List<T> obj, Expression<Func<T, object>> UpdateColumns=null)
151 155
         {
152
-            return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
156
+            if(UpdateColumns==null)
157
+                return await Db.Saveable<T>(obj).ExecuteReturnEntityAsync();
158
+            else
159
+                return await Db.Saveable<T>(obj).UpdateColumns(UpdateColumns).ExecuteReturnEntityAsync();
153 160
         }
154 161
         /// <summary>
155 162
         /// 添加排除某列

+ 2 - 2
代码/TVShoppingCallCenter_ZLJ/Controllers/hangfire/HangfireController.cs

@@ -375,8 +375,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.hangfire
375 375
                     };
376 376
                     modelRecordList.Add(modelRecord);                  
377 377
                 }
378
-                T_Call_CallRecords modelreturn= await busCallRecordsRepository.AddAndUpdateList(modelRecordList);
379
-
378
+                //T_Call_CallRecords modelreturn= await busCallRecordsRepository.AddAndUpdateList(modelRecordList,s=>new {s.EndTime,s.TalkEndTime,s.IvrEndTime });
379
+                T_Call_CallRecords modelreturn = await busCallRecordsRepository.AddAndUpdateList(modelRecordList);
380 380
             }
381 381
             return Success($"同步情况  成功/总数 = {n}/{totle}");
382 382
         }

+ 16 - 16
代码/TVShoppingCallCenter_ZLJ/Startup.cs

@@ -95,7 +95,7 @@ namespace TVShoppingCallCenter_ZLJ
95 95
             });
96 96
             #endregion
97 97
             #region 配置数据库
98
-            BaseContext.DB_ConnectionString = Configuration.GetConnectionString("DefaultConnection");
98
+            BaseContext.DB_ConnectionString = Configuration.GetConnectionString("MySqlConnection");
99 99
             BaseMysqlContext.DB_ConnectionString = Configuration.GetConnectionString("MySqlConnection");
100 100
             #endregion
101 101
 
@@ -146,19 +146,19 @@ namespace TVShoppingCallCenter_ZLJ
146 146
             services.AddTransient<IBus_SMSTemplateRepository, Bus_SMSTemplateRepository>();
147 147
             services.AddTransient<ICall_CallRecordsRepository, Call_CallRecordsRepository>();
148 148
             services.AddTransient<ICDRRepository, CDRRepository>();
149
-            //services.AddHangfire(x => x.UseStorage(new MySqlStorage(BaseMysqlContext.DB_ConnectionString, new MySqlStorageOptions
150
-            //{
151
-            //    TransactionIsolationLevel = IsolationLevel.ReadCommitted,
152
-            //    QueuePollInterval = TimeSpan.FromSeconds(15),
153
-            //    JobExpirationCheckInterval = TimeSpan.FromHours(1),
154
-            //    CountersAggregateInterval = TimeSpan.FromMinutes(5),
155
-            //    PrepareSchemaIfNecessary = true,
156
-            //    DashboardJobListLimit = 50000,
157
-            //    TransactionTimeout = TimeSpan.FromMinutes(1),
158
-            //    TablePrefix = "Hangfire"
159
-            //})));
149
+            services.AddHangfire(x => x.UseStorage(new MySqlStorage(BaseMysqlContext.DB_ConnectionString, new MySqlStorageOptions
150
+            {
151
+                TransactionIsolationLevel = IsolationLevel.ReadCommitted,
152
+                QueuePollInterval = TimeSpan.FromSeconds(15),
153
+                JobExpirationCheckInterval = TimeSpan.FromHours(1),
154
+                CountersAggregateInterval = TimeSpan.FromMinutes(5),
155
+                PrepareSchemaIfNecessary = true,
156
+                DashboardJobListLimit = 50000,
157
+                TransactionTimeout = TimeSpan.FromMinutes(1),
158
+                TablePrefix = "Hangfire_"
159
+            })));
160 160
             //GlobalConfiguration.Configuration.UseStorage(
161
-            //      new MySqlStorage(BaseContext.DB_ConnectionString, new MySqlStorageOptions
161
+            //      new MySqlStorage(BaseMysqlContext.DB_ConnectionString, new MySqlStorageOptions
162 162
             //      {
163 163
             //          TransactionIsolationLevel = IsolationLevel.ReadCommitted,
164 164
             //          QueuePollInterval = TimeSpan.FromSeconds(15),
@@ -167,9 +167,9 @@ namespace TVShoppingCallCenter_ZLJ
167 167
             //          PrepareSchemaIfNecessary = true,
168 168
             //          DashboardJobListLimit = 50000,
169 169
             //          TransactionTimeout = TimeSpan.FromMinutes(1),
170
-            //          TablePrefix = "Hangfire"
170
+            //          TablePrefix = "Hangfire_"
171 171
             //      }));
172
-            services.AddHangfire(x => x.UseSqlServerStorage(BaseContext.DB_ConnectionString));
172
+            //services.AddHangfire(x => x.UseSqlServerStorage(BaseContext.DB_ConnectionString));
173 173
 
174 174
             services.AddTransient<ICus_VipInfoRepository, Cus_VipInfoRepository>();
175 175
             services.AddTransient<ICus_VipLabelInfoRepository, Cus_VipLabelInfoRepository>();
@@ -238,7 +238,7 @@ namespace TVShoppingCallCenter_ZLJ
238 238
             {
239 239
                 Queues = new[] { "birthday", "minutely" },//队列名称,只能为小写
240 240
                 WorkerCount = Environment.ProcessorCount * 3, //并发任务数
241
-                ServerName = "hangfire1",//服务器名称
241
+                ServerName = "hangfireMysql",//服务器名称
242 242
             });//启动Hangfire服务  有可选参数
243 243
             app.UseHangfireDashboard("/hangfire",
244 244
                 new DashboardOptions

+ 1 - 1
代码/TVShoppingCallCenter_ZLJ/appsettings.json

@@ -17,7 +17,7 @@
17 17
   },
18 18
   "ConnectionStrings": {
19 19
     "DefaultConnection": "Data Source=192.168.8.3;User ID=sa;pwd=800100;Initial Catalog=TVCallCenter_ZLJ;MultipleActiveResultSets=true;Pooling=true;Min Pool Size=15;Max Pool Size=100;",
20
-    "MySqlConnection": "server=192.168.8.18;User ID=root;Password=mysql;database=freeswitch;charset=utf8mb4;Allow User Variables=true;"
20
+    "MySqlConnection": "server=192.168.8.18;User ID=root;Password=mysql;database=TVCallCenter_ZLJ;charset=utf8mb4;Allow User Variables=true;"
21 21
   },
22 22
   "Jwt": {
23 23
     "Issuer": "HnjySignToken",