Преглед на файлове

将原文件也保存到FTP 并删除本地文件

machenyang преди 8 години
родител
ревизия
07b654be32
променени са 1 файла, в които са добавени 15 реда и са изтрити 9 реда
  1. 15 9
      codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IVRWordsController.cs

+ 15 - 9
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IVRWordsController.cs

@@ -135,7 +135,7 @@ namespace CallCenterApi.Interface.Controllers
135 135
 
136 136
                 Model.T_Sys_IVRWords dModel = dBLL.GetModel(int.Parse(id.Trim()));
137 137
                 var config = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='IVRWavPath' ").FirstOrDefault();
138
-                
138
+
139 139
                 if (dModel.F_WavNewName != "" && config != null && !string.IsNullOrEmpty(config.F_ParamValue))
140 140
                 {
141 141
                     dModel.F_WavPath = config.F_ParamValue + dModel.F_WavNewName;
@@ -158,9 +158,9 @@ namespace CallCenterApi.Interface.Controllers
158 158
         }
159 159
 
160 160
         //添加IVR欢迎词
161
-        public ActionResult AddIVRWords(string id, string title, string content, 
162
-            string isstate, string sdate, string edate, string remark,int type,
163
-            string oldname,string newname,string path)
161
+        public ActionResult AddIVRWords(string id, string title, string content,
162
+            string isstate, string sdate, string edate, string remark, int type,
163
+            string oldname, string newname, string path)
164 164
         {
165 165
             bool res = false;
166 166
             int iss = returnisadd(id, sdate, edate);
@@ -380,8 +380,9 @@ namespace CallCenterApi.Interface.Controllers
380 380
 
381 381
                 #region 保存原文件到本地指定目录
382 382
                 //string physicalpath = Server.MapPath(savedir + fullFileName);
383
-                string physicalpath = savedir + "\\" + fullFileName;
384
-                _upFile.SaveAs(physicalpath);
383
+                string physicalpath = savedir + fullFileName;
384
+                //20180207 本地不再保存
385
+                //_upFile.SaveAs(physicalpath);
385 386
                 #endregion
386 387
 
387 388
                 #region 修改音频格式
@@ -402,7 +403,7 @@ namespace CallCenterApi.Interface.Controllers
402 403
                     p.StandardInput.WriteLine("cd " + ffmpegLocation);
403 404
                     p.StandardInput.WriteLine(ffmpegLocation.Split('\\').First());
404 405
                     p.StandardInput.WriteLine("ffmpeg.exe");
405
-                    string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + savedir + "\\" + temp_filename + ".wav";
406
+                    string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + savedir + temp_filename + ".wav";
406 407
                     p.StandardInput.WriteLine(changefile);
407 408
                     Thread.Sleep(3000);
408 409
                     p.StandardInput.WriteLine("exit");
@@ -420,8 +421,10 @@ namespace CallCenterApi.Interface.Controllers
420 421
                     upfile.ftpUserID = _acc;
421 422
                     upfile.ftpPassword = _pwd;
422 423
                     FileInfo fi = new FileInfo(physicalpath);
424
+                    //20180207 原文件同时保存
423 425
                     string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
424
-                    if (uploadres == "上传成功!")
426
+                    string uploadBeforres = upfile.UploadLocalToFtp(physicalpath);
427
+                    if (uploadres == "上传成功!" && uploadBeforres == "上传成功!")
425 428
                     {
426 429
                         //写入日志
427 430
                         string logfile = Server.MapPath("~/log.txt");
@@ -441,11 +444,14 @@ namespace CallCenterApi.Interface.Controllers
441 444
                             if (ua != null)
442 445
                                 ucode = ua.F_UserCode;
443 446
                         }
447
+                        //删除本地文件
448
+                        System.IO.File.Delete(savedir + fullFileName);
449
+                        System.IO.File.Delete(savedir + temp_filename + ".wav");
444 450
                         var obj = new
445 451
                         {
446 452
                             oldname = fullFileName,
447 453
                             newname = temp_filename + ".wav",
448
-                            wavpath = savedir + "\\" + temp_filename + ".wav"
454
+                            wavpath = savedir + temp_filename + ".wav"
449 455
                         };
450 456
                         return Success("文件上传成功", obj);
451 457
                     }