Selaa lähdekoodia

Merge branch 'master' of http://192.168.1.222:3000/zhengbingbing/NewCallCenter5.1_API

mengjie 8 vuotta sitten
vanhempi
commit
c4b2dc7b69

+ 3 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -295,7 +295,9 @@
295 295
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
296 296
     </Content>
297 297
     <Content Include="Configs\log4net.config" />
298
-    <Content Include="Configs\system.config" />
298
+    <Content Include="Configs\system.config">
299
+      <SubType>Designer</SubType>
300
+    </Content>
299 301
     <None Include="Properties\PublishProfiles\1q.pubxml" />
300 302
     <None Include="Properties\PublishProfiles\ddr.pubxml" />
301 303
     <None Include="Properties\PublishProfiles\my.pubxml" />

+ 1 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

@@ -33,5 +33,5 @@
33 33
   <!-- 设置密码 -->
34 34
   <add key="password" value="Bing123456" />
35 35
   <!-- 文件保存位置 -->
36
-  <add key="saveloc" value="d:\upload_wav\" />
36
+  <add key="saveloc" value="d:\\upload_wav\" />
37 37
 </appSettings>

+ 17 - 120
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IVRWordsController.cs

@@ -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

+ 5 - 4
codegit/CallCenterCommon/CallCenter.Utility/uploadFile.cs

@@ -36,6 +36,7 @@ namespace CallCenter.Utility
36 36
             reqFTP.KeepAlive = false;// 默认为true,连接不会被关闭 // 在一个命令之后被执行  
37 37
             reqFTP.Method = WebRequestMethods.Ftp.UploadFile;// 指定执行什么命令  
38 38
             reqFTP.UseBinary = true;// 指定数据传输类型  
39
+            reqFTP.UsePassive = true;
39 40
             reqFTP.ContentLength = fileInf.Length;// 上传文件时通知服务器文件的大小  
40 41
             int buffLength = 2048;// 缓冲大小设置为2kb  
41 42
             byte[] buff = new byte[buffLength];
@@ -45,9 +46,9 @@ namespace CallCenter.Utility
45 46
             FileStream fs = fileInf.OpenRead();
46 47
             try
47 48
             {
48
-                Stream strm = reqFTP.GetRequestStream();// 把上传的文件写入流  
49
-                contentLen = fs.Read(buff, 0, buffLength);// 每次读文件流的2kb  
50
-
49
+                res += uri+localFile;
50
+                Stream strm = reqFTP.GetRequestStream();// 把上传的文件写入流
51
+                contentLen = fs.Read(buff, 0, buffLength);// 每次读文件流的2kb 
51 52
                 while (contentLen != 0)// 流内容没有结束  
52 53
                 {
53 54
                     // 把内容从file stream 写入 upload stream  
@@ -61,7 +62,7 @@ namespace CallCenter.Utility
61 62
             }
62 63
             catch (Exception ex)
63 64
             {
64
-                res = "上传文件【" + ftpPath + "/" + fileInf.Name + "】时,发生错误:" + ex.Message + "<br/>";
65
+                res += "上传文件【" + ftpPath + "/" + fileInf.Name + "】时,发生错误:" + ex.Message + "<br/>。路径:"+localFile;
65 66
             }
66 67
             return res;
67 68
         }