Explorar el Código

IVR欢迎词上传音频文件删除多余代码

zhengbingbing %!s(int64=8) %!d(string=hace) años
padre
commit
53ad8622ea

+ 11 - 28
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IVRWordsController.cs

170
                     HttpPostedFile _upFile = RequestString.GetFile("upFile");
170
                     HttpPostedFile _upFile = RequestString.GetFile("upFile");
171
                     if (_upFile != null)
171
                     if (_upFile != null)
172
                     {
172
                     {
173
-                        //string datename = DateTime.Now.ToString("yyyyMMddHHMMss");
174
-                        //string fullFileName = datename + "_" + _upFile.FileName;
175
-                        //string ffmpegLocation = Server.MapPath("~/");
176
-                        //string dirpath = Server.MapPath(this.Request.ApplicationPath + "\\auoupload");
177
-                        //string temp_filename = "";
178
-                        //if (!System.IO.Directory.Exists(dirpath))
179
-                        //{
180
-                        //    System.IO.Directory.CreateDirectory(dirpath);
181
-                        //}
182
-                        //string path = this.Request.ApplicationPath + "/auoupload/" + fullFileName;
183
-                        //string physicalpath = Server.MapPath(path);
184
-                        //_upFile.SaveAs(physicalpath);
185
 
173
 
186
                         string datename = DateTime.Now.ToString("yyyyMMddHHMMss");
174
                         string datename = DateTime.Now.ToString("yyyyMMddHHMMss");
187
                         string fullFileName = datename + "_" + _upFile.FileName;
175
                         string fullFileName = datename + "_" + _upFile.FileName;
188
                         string ffmpegLocation = Server.MapPath("~/");
176
                         string ffmpegLocation = Server.MapPath("~/");
189
-                        string dirpath = Server.MapPath(this.Request.ApplicationPath + "\\auoupload");
190
-                        //string dirpath = Configs.GetValue("saveloc");
191
-                        if (!System.IO.Directory.Exists(dirpath))
177
+
178
+                        #region 读取配置的上传路径-原文件和修改过格式的文件均上传至此
179
+                        string savedir = Configs.GetValue("saveloc");
180
+                        if (!System.IO.Directory.Exists(savedir))
192
                         {
181
                         {
193
-                            System.IO.Directory.CreateDirectory(dirpath);
182
+                            System.IO.Directory.CreateDirectory(savedir);
194
                         }
183
                         }
195
-                        string path = this.Request.ApplicationPath + "/auoupload/" + fullFileName;
196
-                        //string physicalpath = dirpath + fullFileName;
197
-                        string physicalpath = Server.MapPath(path);
184
+                        #endregion
185
+                        
186
+                        #region 保存原文件
187
+                        string physicalpath = Server.MapPath(savedir + fullFileName);
198
                         _upFile.SaveAs(physicalpath);
188
                         _upFile.SaveAs(physicalpath);
189
+                        #endregion
199
 
190
 
200
                         #region 修改音频格式
191
                         #region 修改音频格式
201
                         if (!string.IsNullOrEmpty(physicalpath))
192
                         if (!string.IsNullOrEmpty(physicalpath))
210
                             p.StartInfo.CreateNoWindow = true;
201
                             p.StartInfo.CreateNoWindow = true;
211
 
202
 
212
                             string temp_filename = physicalpath.Split('\\').Last().Split('.')[0] + "_temp";
203
                             string temp_filename = physicalpath.Split('\\').Last().Split('.')[0] + "_temp";
213
-                            string savedir = Configs.GetValue("saveloc");
214
-                            if (!System.IO.Directory.Exists(savedir))
215
-                            {
216
-                                System.IO.Directory.CreateDirectory(savedir);
217
-                            }
218
-
204
+                            
219
                             p.Start();
205
                             p.Start();
220
                             p.StandardInput.WriteLine("cd " + ffmpegLocation);
206
                             p.StandardInput.WriteLine("cd " + ffmpegLocation);
221
                             p.StandardInput.WriteLine(ffmpegLocation.Split('\\').First());
207
                             p.StandardInput.WriteLine(ffmpegLocation.Split('\\').First());
222
                             p.StandardInput.WriteLine("ffmpeg.exe");
208
                             p.StandardInput.WriteLine("ffmpeg.exe");
223
-                            //string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + dirpath + "\\" + temp_filename + ".wav";
224
                             string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + savedir + "\\" + temp_filename + ".wav";
209
                             string changefile = "ffmpeg -i " + physicalpath + " -acodec pcm_u8 -ab 64 -ar 8000 -ac 1 " + savedir + "\\" + temp_filename + ".wav";
225
                             p.StandardInput.WriteLine(changefile);
210
                             p.StandardInput.WriteLine(changefile);
226
                             Thread.Sleep(3000);
211
                             Thread.Sleep(3000);
239
                             upfile.ftpUserID = _acc;
224
                             upfile.ftpUserID = _acc;
240
                             upfile.ftpPassword = _pwd;
225
                             upfile.ftpPassword = _pwd;
241
                             FileInfo fi = new FileInfo(physicalpath);
226
                             FileInfo fi = new FileInfo(physicalpath);
242
-                            //string uploadres = upfile.UploadLocalToFtp(dirpath + "\\" + temp_filename + ".wav");
243
                             string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
227
                             string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
244
                             if (uploadres == "上传成功!")
228
                             if (uploadres == "上传成功!")
245
                             {
229
                             {
263
                                 }
247
                                 }
264
                                 dModel.F_WavOldName = fullFileName;
248
                                 dModel.F_WavOldName = fullFileName;
265
                                 dModel.F_WavNewName = temp_filename + ".wav";
249
                                 dModel.F_WavNewName = temp_filename + ".wav";
266
-                                //dModel.F_WavPath = dirpath + "\\" + temp_filename + ".wav";
267
                                 dModel.F_WavPath = savedir + "\\" + temp_filename + ".wav";
250
                                 dModel.F_WavPath = savedir + "\\" + temp_filename + ".wav";
268
                             }
251
                             }
269
                             #endregion
252
                             #endregion