|
|
@@ -187,97 +187,6 @@ namespace CallCenterApi.Interface.Controllers
|
|
187
|
187
|
dModel.F_WavOldName = oldname;
|
|
188
|
188
|
dModel.F_WavNewName = newname;
|
|
189
|
189
|
dModel.F_WavPath = path;
|
|
190
|
|
- #region 上传语音文件
|
|
191
|
|
- //HttpPostedFile _upFile = RequestString.GetFile("upFile");
|
|
192
|
|
- //if (_upFile != null)
|
|
193
|
|
- //{
|
|
194
|
|
-
|
|
195
|
|
- // string datename = DateTime.Now.ToString("yyyyMMddHHMMss");
|
|
196
|
|
- // string fullFileName = datename + "_" + _upFile.FileName;
|
|
197
|
|
- // string ffmpegLocation = Server.MapPath("~/");
|
|
198
|
|
-
|
|
199
|
|
- // #region 读取配置的上传路径-原文件和修改过格式的文件均上传至此
|
|
200
|
|
- // string savedir = Configs.GetValue("saveloc");
|
|
201
|
|
- // if (!System.IO.Directory.Exists(savedir))
|
|
202
|
|
- // {
|
|
203
|
|
- // System.IO.Directory.CreateDirectory(savedir);
|
|
204
|
|
- // }
|
|
205
|
|
- // #endregion
|
|
206
|
|
-
|
|
207
|
|
- // #region 保存原文件
|
|
208
|
|
- // string physicalpath = Server.MapPath(savedir + fullFileName);
|
|
209
|
|
- // _upFile.SaveAs(physicalpath);
|
|
210
|
|
- // #endregion
|
|
211
|
|
-
|
|
212
|
|
- // #region 修改音频格式
|
|
213
|
|
- // if (!string.IsNullOrEmpty(physicalpath))
|
|
214
|
|
- // {
|
|
215
|
|
- // //通过cmd执行ffmpeg改变音频采样率
|
|
216
|
|
- // Process p = new Process();
|
|
217
|
|
- // p.StartInfo.FileName = "cmd.exe";
|
|
218
|
|
- // p.StartInfo.UseShellExecute = false;
|
|
219
|
|
- // p.StartInfo.RedirectStandardOutput = true;
|
|
220
|
|
- // p.StartInfo.RedirectStandardInput = true;
|
|
221
|
|
- // p.StartInfo.RedirectStandardError = true;
|
|
222
|
|
- // p.StartInfo.CreateNoWindow = true;
|
|
223
|
|
-
|
|
224
|
|
- // string temp_filename = physicalpath.Split('\\').Last().Split('.')[0] + "_temp";
|
|
225
|
|
-
|
|
226
|
|
- // p.Start();
|
|
227
|
|
- // p.StandardInput.WriteLine("cd " + ffmpegLocation);
|
|
228
|
|
- // p.StandardInput.WriteLine(ffmpegLocation.Split('\\').First());
|
|
229
|
|
- // p.StandardInput.WriteLine("ffmpeg.exe");
|
|
230
|
|
- // string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + savedir + "\\" + temp_filename + ".wav";
|
|
231
|
|
- // p.StandardInput.WriteLine(changefile);
|
|
232
|
|
- // Thread.Sleep(3000);
|
|
233
|
|
- // p.StandardInput.WriteLine("exit");
|
|
234
|
|
- // //Kill 是终止没有图形化界面的进程的唯一方法。
|
|
235
|
|
- // p.Kill();
|
|
236
|
|
-
|
|
237
|
|
- // #region 上传
|
|
238
|
|
- // uploadFile upfile = new uploadFile();
|
|
239
|
|
- // //通过读取配置文件,获取数据库
|
|
240
|
|
- // string _ftp = Configs.GetValue("ftp");
|
|
241
|
|
- // string _acc = Configs.GetValue("account");
|
|
242
|
|
- // string _pwd = Configs.GetValue("password");
|
|
243
|
|
-
|
|
244
|
|
- // upfile.ftpPath = _ftp;
|
|
245
|
|
- // upfile.ftpUserID = _acc;
|
|
246
|
|
- // upfile.ftpPassword = _pwd;
|
|
247
|
|
- // FileInfo fi = new FileInfo(physicalpath);
|
|
248
|
|
- // string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
|
|
249
|
|
- // if (uploadres == "上传成功!")
|
|
250
|
|
- // {
|
|
251
|
|
- // //写入日志
|
|
252
|
|
- // string logfile = Server.MapPath("~/log.txt");
|
|
253
|
|
- // if (!System.IO.File.Exists(logfile))
|
|
254
|
|
- // {
|
|
255
|
|
- // System.IO.File.Create(logfile);
|
|
256
|
|
- // }
|
|
257
|
|
- // //开始写入
|
|
258
|
|
- // string str = DateTime.Now.ToString() + " 文件" + fullFileName + "上传成功";
|
|
259
|
|
- // System.IO.File.AppendAllLines(logfile, new string[] { str }, Encoding.GetEncoding("gb2312"));
|
|
260
|
|
-
|
|
261
|
|
- // int userId = CurrentUser.UserData.F_UserId;
|
|
262
|
|
- // string ucode = "";
|
|
263
|
|
- // if (userId != 0)
|
|
264
|
|
- // {
|
|
265
|
|
- // Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
266
|
|
- // if (ua != null)
|
|
267
|
|
- // ucode = ua.F_UserCode;
|
|
268
|
|
- // }
|
|
269
|
|
- // dModel.F_WavOldName = fullFileName;
|
|
270
|
|
- // dModel.F_WavNewName = temp_filename + ".wav";
|
|
271
|
|
- // dModel.F_WavPath = savedir + "\\" + temp_filename + ".wav";
|
|
272
|
|
- // }
|
|
273
|
|
- // #endregion
|
|
274
|
|
- // }
|
|
275
|
|
- // #endregion
|
|
276
|
|
-
|
|
277
|
|
- //}
|
|
278
|
|
- //else
|
|
279
|
|
- // return Error("参数传入失败");
|
|
280
|
|
- #endregion
|
|
281
|
190
|
}
|
|
282
|
191
|
if (id != null && id.Trim() != "")
|
|
283
|
192
|
{
|
|
|
@@ -379,16 +288,11 @@ namespace CallCenterApi.Interface.Controllers
|
|
379
|
288
|
#endregion
|
|
380
|
289
|
|
|
381
|
290
|
#region 保存原文件到本地指定目录
|
|
382
|
|
- //string physicalpath = Server.MapPath(savedir + fullFileName);
|
|
383
|
|
- //string physicalpath = savedir + fullFileName;
|
|
384
|
|
- //20180207 本地不再保存 保存到项目中
|
|
385
|
|
- //_upFile.SaveAs(physicalpath);
|
|
386
|
|
- string dirpath = Server.MapPath(this.Request.ApplicationPath + "\\auoupload");
|
|
387
|
|
- if (!System.IO.Directory.Exists(dirpath))
|
|
|
291
|
+ string path = this.Request.ApplicationPath + "/auoupload/" + fullFileName;
|
|
|
292
|
+ if (!System.IO.Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "/auoupload/")))
|
|
388
|
293
|
{
|
|
389
|
|
- System.IO.Directory.CreateDirectory(dirpath);
|
|
|
294
|
+ System.IO.Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "/auoupload/"));
|
|
390
|
295
|
}
|
|
391
|
|
- string path = this.Request.ApplicationPath + "/auoupload/" + fullFileName;
|
|
392
|
296
|
string physicalpath = Server.MapPath(path);
|
|
393
|
297
|
_upFile.SaveAs(physicalpath);
|
|
394
|
298
|
#endregion
|
|
|
@@ -396,6 +300,7 @@ namespace CallCenterApi.Interface.Controllers
|
|
396
|
300
|
#region 修改音频格式
|
|
397
|
301
|
if (!string.IsNullOrEmpty(physicalpath))
|
|
398
|
302
|
{
|
|
|
303
|
+ # region 修改音频格式
|
|
399
|
304
|
//通过cmd执行ffmpeg改变音频采样率
|
|
400
|
305
|
Process p = new Process();
|
|
401
|
306
|
p.StartInfo.FileName = "cmd.exe";
|
|
|
@@ -417,7 +322,7 @@ namespace CallCenterApi.Interface.Controllers
|
|
417
|
322
|
p.StandardInput.WriteLine("exit");
|
|
418
|
323
|
//Kill 是终止没有图形化界面的进程的唯一方法。
|
|
419
|
324
|
p.Kill();
|
|
420
|
|
-
|
|
|
325
|
+ #endregion
|
|
421
|
326
|
#region 上传
|
|
422
|
327
|
uploadFile upfile = new uploadFile();
|
|
423
|
328
|
//通过读取配置文件,获取数据库
|
|
|
@@ -428,30 +333,22 @@ namespace CallCenterApi.Interface.Controllers
|
|
428
|
333
|
upfile.ftpPath = _ftp;
|
|
429
|
334
|
upfile.ftpUserID = _acc;
|
|
430
|
335
|
upfile.ftpPassword = _pwd;
|
|
431
|
|
- FileInfo fi = new FileInfo(physicalpath);
|
|
432
|
336
|
//20180207 原文件同时保存
|
|
433
|
|
- string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
|
|
|
337
|
+ string uploadres = upfile.UploadLocalToFtp(savedir + temp_filename + ".wav");
|
|
434
|
338
|
string uploadBeforres = upfile.UploadLocalToFtp(physicalpath);
|
|
435
|
339
|
if (uploadres == "上传成功!" && uploadBeforres == "上传成功!")
|
|
436
|
340
|
{
|
|
437
|
341
|
//写入日志
|
|
438
|
|
- string logfile = Server.MapPath("~/log.txt");
|
|
439
|
|
- if (!System.IO.File.Exists(logfile))
|
|
440
|
|
- {
|
|
441
|
|
- System.IO.File.Create(logfile);
|
|
442
|
|
- }
|
|
443
|
|
- //开始写入
|
|
444
|
|
- string str = DateTime.Now.ToString() + " 文件" + fullFileName + "上传成功";
|
|
445
|
|
- System.IO.File.AppendAllLines(logfile, new string[] { str }, Encoding.GetEncoding("gb2312"));
|
|
446
|
|
-
|
|
447
|
|
- int userId = CurrentUser.UserData.F_UserId;
|
|
448
|
|
- string ucode = "";
|
|
449
|
|
- if (userId != 0)
|
|
450
|
|
- {
|
|
451
|
|
- Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
|
|
452
|
|
- if (ua != null)
|
|
453
|
|
- ucode = ua.F_UserCode;
|
|
454
|
|
- }
|
|
|
342
|
+ //string logfile = Server.MapPath("~/log.txt");
|
|
|
343
|
+ //if (!System.IO.File.Exists(logfile))
|
|
|
344
|
+ //{
|
|
|
345
|
+ // System.IO.File.Create(logfile);
|
|
|
346
|
+ //}
|
|
|
347
|
+ ////开始写入
|
|
|
348
|
+ //string str = DateTime.Now.ToString() + " 文件" + fullFileName + "上传成功";
|
|
|
349
|
+ //System.IO.File.AppendAllLines(logfile, new string[] { str }, Encoding.GetEncoding("gb2312"));
|
|
|
350
|
+
|
|
|
351
|
+
|
|
455
|
352
|
//删除本地文件
|
|
456
|
353
|
System.IO.File.Delete(savedir + fullFileName);
|
|
457
|
354
|
System.IO.File.Delete(savedir + temp_filename + ".wav");
|
|
|
@@ -465,7 +362,7 @@ namespace CallCenterApi.Interface.Controllers
|
|
465
|
362
|
return Success("文件上传成功", obj);
|
|
466
|
363
|
}
|
|
467
|
364
|
else
|
|
468
|
|
- return Error("文件上传失败,请重新上传");
|
|
|
365
|
+ return Error("文件上传失败,请重新上传:::uploadres:" + uploadres + ":::::uploadBeforres::" + uploadBeforres);
|
|
469
|
366
|
#endregion
|
|
470
|
367
|
}
|
|
471
|
368
|
else
|