|
|
@@ -5,7 +5,9 @@ using CallCenterApi.Interface.Controllers.Base;
|
|
5
|
5
|
using System;
|
|
6
|
6
|
using System.Collections.Generic;
|
|
7
|
7
|
using System.Data;
|
|
|
8
|
+using System.IO;
|
|
8
|
9
|
using System.Linq;
|
|
|
10
|
+using System.Net;
|
|
9
|
11
|
using System.Web;
|
|
10
|
12
|
using System.Web.Mvc;
|
|
11
|
13
|
|
|
|
@@ -126,6 +128,210 @@ namespace CallCenterApi.Interface.Controllers.tel
|
|
126
|
128
|
}
|
|
127
|
129
|
|
|
128
|
130
|
/// <summary>
|
|
|
131
|
+ /// 批量下载录音文件 - 调用接口
|
|
|
132
|
+ /// </summary>
|
|
|
133
|
+ /// <param name="phone"></param>
|
|
|
134
|
+ /// <param name="usercode"></param>
|
|
|
135
|
+ /// <returns></returns>
|
|
|
136
|
+ public ActionResult Sound(string phone, string usercode, int seartgroupid)
|
|
|
137
|
+ {
|
|
|
138
|
+ string sql = "";
|
|
|
139
|
+ string callstate = HttpUtility.UrlDecode(RequestString.GetQueryString("callstate"));
|
|
|
140
|
+ string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
|
|
|
141
|
+ string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
|
|
|
142
|
+ string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
|
|
|
143
|
+ string dept = HttpUtility.UrlDecode(RequestString.GetQueryString("dept"));
|
|
|
144
|
+ string dealtype = HttpUtility.UrlDecode(RequestString.GetQueryString("dealtype"));
|
|
|
145
|
+
|
|
|
146
|
+ Model.T_Sys_SeatGroup groupModel = new BLL.T_Sys_SeatGroup().GetModel(seartgroupid);
|
|
|
147
|
+
|
|
|
148
|
+ if (groupModel != null)
|
|
|
149
|
+ {
|
|
|
150
|
+ if (!string.IsNullOrEmpty(groupModel.F_ZXZCode))
|
|
|
151
|
+ {
|
|
|
152
|
+ sql += " and groupcode = '" + groupModel.F_ZXZCode + "' ";
|
|
|
153
|
+ }
|
|
|
154
|
+ }
|
|
|
155
|
+ //if (!string.IsNullOrEmpty(groupcode))
|
|
|
156
|
+ //{
|
|
|
157
|
+ // sql += " and groupcode = '" + groupcode + "' ";
|
|
|
158
|
+ //}
|
|
|
159
|
+ if (usercode != null && usercode.Trim() != "")
|
|
|
160
|
+ {
|
|
|
161
|
+ sql += " and UserCode='" + usercode + "'";
|
|
|
162
|
+ }
|
|
|
163
|
+ if (dept != null && dept.Trim() != "")
|
|
|
164
|
+ {
|
|
|
165
|
+ sql += " and F_DeptId='" + dept.Trim() + "'";
|
|
|
166
|
+ }
|
|
|
167
|
+ if (dealtype != null && dealtype.Trim() != "")
|
|
|
168
|
+ {
|
|
|
169
|
+ //处理方式
|
|
|
170
|
+ sql += " and DealType = " + dealtype + " ";
|
|
|
171
|
+ }
|
|
|
172
|
+ if (phone != null && phone.Trim() != "")
|
|
|
173
|
+ {
|
|
|
174
|
+ sql += " and CallNumber like '%" + phone + "%'";
|
|
|
175
|
+ }
|
|
|
176
|
+ if (callstate.Trim() != "")
|
|
|
177
|
+ {
|
|
|
178
|
+ sql += " and CallState='" + callstate + "'";
|
|
|
179
|
+ }
|
|
|
180
|
+ if (calltype.Trim() != "")
|
|
|
181
|
+ {
|
|
|
182
|
+ sql += " and CallType='" + calltype + "'";
|
|
|
183
|
+ }
|
|
|
184
|
+ if (starttime.Trim() != "")
|
|
|
185
|
+ {
|
|
|
186
|
+ sql += " and datediff(day,BeginTime,'" + starttime + "')<=0 ";
|
|
|
187
|
+ }
|
|
|
188
|
+ if (endtime.Trim() != "")
|
|
|
189
|
+ {
|
|
|
190
|
+ sql += " and datediff(day,BeginTime,'" + endtime + "')>=0 ";
|
|
|
191
|
+ }
|
|
|
192
|
+ var CallList = new BLL.T_Call_CallRecords().GetModelList("FilePath !='' " + sql);
|
|
|
193
|
+ var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
|
|
|
194
|
+ var obj = new
|
|
|
195
|
+ {
|
|
|
196
|
+ state = "success",
|
|
|
197
|
+ message = "成功",
|
|
|
198
|
+ CallList,
|
|
|
199
|
+ config
|
|
|
200
|
+ };
|
|
|
201
|
+ return Content(obj.ToJson());
|
|
|
202
|
+ }
|
|
|
203
|
+
|
|
|
204
|
+ /// <summary>
|
|
|
205
|
+ /// 批量下载录音文件
|
|
|
206
|
+ /// </summary>
|
|
|
207
|
+ /// <param name="filePath"></param>
|
|
|
208
|
+ /// <param name="phone"></param>
|
|
|
209
|
+ /// <param name="usercode"></param>
|
|
|
210
|
+ /// <returns></returns>
|
|
|
211
|
+ public ActionResult ExitSound(string filePath, string phone, string usercode)
|
|
|
212
|
+ {
|
|
|
213
|
+ // string filePath = Configs.GetValue("Sound_recording");
|
|
|
214
|
+ System.IO.DriveInfo[] allDrives = System.IO.DriveInfo.GetDrives();
|
|
|
215
|
+ filePath = filePath + "CallCenter_Sound";
|
|
|
216
|
+ filePath = Configs.GetValue("Sound_recording");
|
|
|
217
|
+ // int userId = CurrentUser.UserData.F_UserId;
|
|
|
218
|
+ // Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
|
219
|
+
|
|
|
220
|
+ string sql = "";
|
|
|
221
|
+
|
|
|
222
|
+ string callstate = HttpUtility.UrlDecode(RequestString.GetQueryString("callstate"));
|
|
|
223
|
+ string calltype = HttpUtility.UrlDecode(RequestString.GetQueryString("calltype"));
|
|
|
224
|
+ string starttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
|
|
|
225
|
+ string endtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
|
|
|
226
|
+ string dept = HttpUtility.UrlDecode(RequestString.GetQueryString("dept"));
|
|
|
227
|
+ string dealtype = HttpUtility.UrlDecode(RequestString.GetQueryString("dealtype"));
|
|
|
228
|
+ //if (!string.IsNullOrEmpty(userModel.groupcode))
|
|
|
229
|
+ //{
|
|
|
230
|
+ // sql += " and groupcode = '" + userModel.groupcode + "' ";
|
|
|
231
|
+ //}
|
|
|
232
|
+
|
|
|
233
|
+ if (usercode != null && usercode.Trim() != "")
|
|
|
234
|
+ {
|
|
|
235
|
+ sql += " and UserCode='" + usercode + "'";
|
|
|
236
|
+ }
|
|
|
237
|
+ if (dept != null && dept.Trim() != "")
|
|
|
238
|
+ {
|
|
|
239
|
+ sql += " and F_DeptId='" + dept.Trim() + "'";
|
|
|
240
|
+ }
|
|
|
241
|
+ if (dealtype != null && dealtype.Trim() != "")
|
|
|
242
|
+ {
|
|
|
243
|
+ //处理方式
|
|
|
244
|
+ sql += " and DealType = " + dealtype + " ";
|
|
|
245
|
+ }
|
|
|
246
|
+ if (phone != null && phone.Trim() != "")
|
|
|
247
|
+ {
|
|
|
248
|
+ sql += " and CallNumber like '%" + phone + "%'";
|
|
|
249
|
+ }
|
|
|
250
|
+ if (callstate.Trim() != "")
|
|
|
251
|
+ {
|
|
|
252
|
+ sql += " and CallState='" + callstate + "'";
|
|
|
253
|
+ }
|
|
|
254
|
+ if (calltype.Trim() != "")
|
|
|
255
|
+ {
|
|
|
256
|
+ sql += " and CallType='" + calltype + "'";
|
|
|
257
|
+ }
|
|
|
258
|
+ if (starttime.Trim() != "")
|
|
|
259
|
+ {
|
|
|
260
|
+ sql += " and datediff(day,BeginTime,'" + starttime + "')<=0 ";
|
|
|
261
|
+ }
|
|
|
262
|
+ if (endtime.Trim() != "")
|
|
|
263
|
+ {
|
|
|
264
|
+ sql += " and datediff(day,BeginTime,'" + endtime + "')>=0 ";
|
|
|
265
|
+ }
|
|
|
266
|
+ var CallList = new BLL.T_Call_CallRecords().GetModelList("FilePath !='' "+ sql);
|
|
|
267
|
+ var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='PlayPath' ").FirstOrDefault();
|
|
|
268
|
+ // 如果文件不存在,创建文件; 如果存在,跳过
|
|
|
269
|
+ try
|
|
|
270
|
+ {
|
|
|
271
|
+ if (!Directory.Exists(filePath))
|
|
|
272
|
+ {
|
|
|
273
|
+ Directory.CreateDirectory(filePath);
|
|
|
274
|
+ }
|
|
|
275
|
+ if (CallList!=null )
|
|
|
276
|
+ {
|
|
|
277
|
+ foreach (var it in CallList)
|
|
|
278
|
+ {
|
|
|
279
|
+ string FilePath = "";
|
|
|
280
|
+ if (it.FilePath != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
|
|
|
281
|
+ {
|
|
|
282
|
+ var ym = config.F_ParamValue;
|
|
|
283
|
+ if (ym.Substring(ym.Length - 1) == "/")
|
|
|
284
|
+ {
|
|
|
285
|
+ ym = ym.Substring(0, ym.Length - 1);
|
|
|
286
|
+ }
|
|
|
287
|
+ FilePath = ym + it.FilePath.Substring(it.FilePath.IndexOf(':') + 1).Replace('\\', '/');
|
|
|
288
|
+ }
|
|
|
289
|
+
|
|
|
290
|
+
|
|
|
291
|
+ string filename = "l"+ it.FilePath.Split ('l')[1];
|
|
|
292
|
+ filename = filename.Split('.')[0] + "_" + it.CallNumber + ".mp3";
|
|
|
293
|
+ try
|
|
|
294
|
+ {
|
|
|
295
|
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(FilePath);
|
|
|
296
|
+ HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
|
|
297
|
+ Stream responseStream = response.GetResponseStream();
|
|
|
298
|
+ string[] sArray = filename.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
299
|
+ string flie = filePath +"\\"+ sArray[0] + "\\" + sArray[1] + "\\" + sArray[2];
|
|
|
300
|
+ if (!Directory.Exists(flie))
|
|
|
301
|
+ {
|
|
|
302
|
+ Directory.CreateDirectory(flie);
|
|
|
303
|
+ }
|
|
|
304
|
+ if (System.IO.File.Exists(flie + "\\" + sArray[3]))
|
|
|
305
|
+ {
|
|
|
306
|
+ continue;
|
|
|
307
|
+ }
|
|
|
308
|
+ Stream stream = new FileStream(flie + "\\"+ sArray[3], FileMode.Create);
|
|
|
309
|
+ byte[] bArr = new byte[1024];
|
|
|
310
|
+ int size = responseStream.Read(bArr, 0, bArr.Length);
|
|
|
311
|
+ while (size > 0)
|
|
|
312
|
+ {
|
|
|
313
|
+ stream.Write(bArr, 0, size);
|
|
|
314
|
+ size = responseStream.Read(bArr, 0, bArr.Length);
|
|
|
315
|
+ }
|
|
|
316
|
+ stream.Close();
|
|
|
317
|
+ responseStream.Close();
|
|
|
318
|
+ }
|
|
|
319
|
+ catch (Exception e)
|
|
|
320
|
+ {
|
|
|
321
|
+ continue;
|
|
|
322
|
+ }
|
|
|
323
|
+ }
|
|
|
324
|
+ }
|
|
|
325
|
+ return Success("导出成功");
|
|
|
326
|
+ }
|
|
|
327
|
+
|
|
|
328
|
+ catch (Exception e)
|
|
|
329
|
+ {
|
|
|
330
|
+ throw;
|
|
|
331
|
+ }
|
|
|
332
|
+ }
|
|
|
333
|
+
|
|
|
334
|
+ /// <summary>
|
|
129
|
335
|
/// 获取实体
|
|
130
|
336
|
/// </summary>
|
|
131
|
337
|
/// <param name="id"></param>
|