zhangkun 5 years ago
parent
commit
b3e0016cde

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

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

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

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

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

121
             return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
121
             return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
122
             //return CurrentCurrentDB.InsertReturnIdentity(obj);
122
             //return CurrentCurrentDB.InsertReturnIdentity(obj);
123
         }
123
         }
124
-
125
         /// <summary>
124
         /// <summary>
126
         /// 插入并返回实体
125
         /// 插入并返回实体
127
         /// </summary>
126
         /// </summary>
128
         /// <param name="obj"></param>
127
         /// <param name="obj"></param>
128
+        /// <param name="UpdateColumns">更新字段  null全部</param>
129
         /// <returns></returns>
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
         /// <summary>
138
         /// <summary>
135
         /// 插入并返回实体
139
         /// 插入并返回实体
136
         /// </summary>
140
         /// </summary>
137
-        /// <param name="obj"></param>
141
+        /// <param name="obj">更新插入实体</param>
142
+        /// <param name="UpdateColumns">更新字段  null全部</param>
138
         /// <returns></returns>
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
         /// <summary>
152
         /// <summary>

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

137
         /// </summary>
137
         /// </summary>
138
         /// <param name="obj"></param>
138
         /// <param name="obj"></param>
139
         /// <returns></returns>
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
         /// <summary>
148
         /// <summary>
146
         /// 插入并返回实体
149
         /// 插入并返回实体
147
         /// </summary>
150
         /// </summary>
148
-        /// <param name="obj"></param>
151
+        /// <param name="obj">更新插入实体</param>
152
+        /// <param name="UpdateColumns">更新字段  null全部</param>
149
         /// <returns></returns>
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
         /// <summary>
161
         /// <summary>
155
         /// 添加排除某列
162
         /// 添加排除某列

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

375
                     };
375
                     };
376
                     modelRecordList.Add(modelRecord);                  
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
             return Success($"同步情况  成功/总数 = {n}/{totle}");
381
             return Success($"同步情况  成功/总数 = {n}/{totle}");
382
         }
382
         }

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

95
             });
95
             });
96
             #endregion
96
             #endregion
97
             #region 配置数据库
97
             #region 配置数据库
98
-            BaseContext.DB_ConnectionString = Configuration.GetConnectionString("DefaultConnection");
98
+            BaseContext.DB_ConnectionString = Configuration.GetConnectionString("MySqlConnection");
99
             BaseMysqlContext.DB_ConnectionString = Configuration.GetConnectionString("MySqlConnection");
99
             BaseMysqlContext.DB_ConnectionString = Configuration.GetConnectionString("MySqlConnection");
100
             #endregion
100
             #endregion
101
 
101
 
146
             services.AddTransient<IBus_SMSTemplateRepository, Bus_SMSTemplateRepository>();
146
             services.AddTransient<IBus_SMSTemplateRepository, Bus_SMSTemplateRepository>();
147
             services.AddTransient<ICall_CallRecordsRepository, Call_CallRecordsRepository>();
147
             services.AddTransient<ICall_CallRecordsRepository, Call_CallRecordsRepository>();
148
             services.AddTransient<ICDRRepository, CDRRepository>();
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
             //GlobalConfiguration.Configuration.UseStorage(
160
             //GlobalConfiguration.Configuration.UseStorage(
161
-            //      new MySqlStorage(BaseContext.DB_ConnectionString, new MySqlStorageOptions
161
+            //      new MySqlStorage(BaseMysqlContext.DB_ConnectionString, new MySqlStorageOptions
162
             //      {
162
             //      {
163
             //          TransactionIsolationLevel = IsolationLevel.ReadCommitted,
163
             //          TransactionIsolationLevel = IsolationLevel.ReadCommitted,
164
             //          QueuePollInterval = TimeSpan.FromSeconds(15),
164
             //          QueuePollInterval = TimeSpan.FromSeconds(15),
167
             //          PrepareSchemaIfNecessary = true,
167
             //          PrepareSchemaIfNecessary = true,
168
             //          DashboardJobListLimit = 50000,
168
             //          DashboardJobListLimit = 50000,
169
             //          TransactionTimeout = TimeSpan.FromMinutes(1),
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
             services.AddTransient<ICus_VipInfoRepository, Cus_VipInfoRepository>();
174
             services.AddTransient<ICus_VipInfoRepository, Cus_VipInfoRepository>();
175
             services.AddTransient<ICus_VipLabelInfoRepository, Cus_VipLabelInfoRepository>();
175
             services.AddTransient<ICus_VipLabelInfoRepository, Cus_VipLabelInfoRepository>();
238
             {
238
             {
239
                 Queues = new[] { "birthday", "minutely" },//队列名称,只能为小写
239
                 Queues = new[] { "birthday", "minutely" },//队列名称,只能为小写
240
                 WorkerCount = Environment.ProcessorCount * 3, //并发任务数
240
                 WorkerCount = Environment.ProcessorCount * 3, //并发任务数
241
-                ServerName = "hangfire1",//服务器名称
241
+                ServerName = "hangfireMysql",//服务器名称
242
             });//启动Hangfire服务  有可选参数
242
             });//启动Hangfire服务  有可选参数
243
             app.UseHangfireDashboard("/hangfire",
243
             app.UseHangfireDashboard("/hangfire",
244
                 new DashboardOptions
244
                 new DashboardOptions

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

17
   },
17
   },
18
   "ConnectionStrings": {
18
   "ConnectionStrings": {
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;",
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
   "Jwt": {
22
   "Jwt": {
23
     "Issuer": "HnjySignToken",
23
     "Issuer": "HnjySignToken",