瀏覽代碼

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

mengjie 8 年之前
父節點
當前提交
c4b2dc7b69

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

295
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
295
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
296
     </Content>
296
     </Content>
297
     <Content Include="Configs\log4net.config" />
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
     <None Include="Properties\PublishProfiles\1q.pubxml" />
301
     <None Include="Properties\PublishProfiles\1q.pubxml" />
300
     <None Include="Properties\PublishProfiles\ddr.pubxml" />
302
     <None Include="Properties\PublishProfiles\ddr.pubxml" />
301
     <None Include="Properties\PublishProfiles\my.pubxml" />
303
     <None Include="Properties\PublishProfiles\my.pubxml" />

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

33
   <!-- 设置密码 -->
33
   <!-- 设置密码 -->
34
   <add key="password" value="Bing123456" />
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
 </appSettings>
37
 </appSettings>

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

187
                     dModel.F_WavOldName = oldname;
187
                     dModel.F_WavOldName = oldname;
188
                     dModel.F_WavNewName = newname;
188
                     dModel.F_WavNewName = newname;
189
                     dModel.F_WavPath = path;
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
                 if (id != null && id.Trim() != "")
191
                 if (id != null && id.Trim() != "")
283
                 {
192
                 {
379
                 #endregion
288
                 #endregion
380
 
289
 
381
                 #region 保存原文件到本地指定目录
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
                 string physicalpath = Server.MapPath(path);
296
                 string physicalpath = Server.MapPath(path);
393
                 _upFile.SaveAs(physicalpath);
297
                 _upFile.SaveAs(physicalpath);
394
                 #endregion
298
                 #endregion
396
                 #region 修改音频格式
300
                 #region 修改音频格式
397
                 if (!string.IsNullOrEmpty(physicalpath))
301
                 if (!string.IsNullOrEmpty(physicalpath))
398
                 {
302
                 {
303
+                    # region 修改音频格式
399
                     //通过cmd执行ffmpeg改变音频采样率
304
                     //通过cmd执行ffmpeg改变音频采样率
400
                     Process p = new Process();
305
                     Process p = new Process();
401
                     p.StartInfo.FileName = "cmd.exe";
306
                     p.StartInfo.FileName = "cmd.exe";
417
                     p.StandardInput.WriteLine("exit");
322
                     p.StandardInput.WriteLine("exit");
418
                     //Kill 是终止没有图形化界面的进程的唯一方法。
323
                     //Kill 是终止没有图形化界面的进程的唯一方法。
419
                     p.Kill();
324
                     p.Kill();
420
-
325
+                    #endregion
421
                     #region 上传
326
                     #region 上传
422
                     uploadFile upfile = new uploadFile();
327
                     uploadFile upfile = new uploadFile();
423
                     //通过读取配置文件,获取数据库
328
                     //通过读取配置文件,获取数据库
428
                     upfile.ftpPath = _ftp;
333
                     upfile.ftpPath = _ftp;
429
                     upfile.ftpUserID = _acc;
334
                     upfile.ftpUserID = _acc;
430
                     upfile.ftpPassword = _pwd;
335
                     upfile.ftpPassword = _pwd;
431
-                    FileInfo fi = new FileInfo(physicalpath);
432
                     //20180207 原文件同时保存
336
                     //20180207 原文件同时保存
433
-                    string uploadres = upfile.UploadLocalToFtp(savedir + "\\" + temp_filename + ".wav");
337
+                    string uploadres = upfile.UploadLocalToFtp(savedir +  temp_filename + ".wav");
434
                     string uploadBeforres = upfile.UploadLocalToFtp(physicalpath);
338
                     string uploadBeforres = upfile.UploadLocalToFtp(physicalpath);
435
                     if (uploadres == "上传成功!" && uploadBeforres == "上传成功!")
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
                         System.IO.File.Delete(savedir + fullFileName);
353
                         System.IO.File.Delete(savedir + fullFileName);
457
                         System.IO.File.Delete(savedir + temp_filename + ".wav");
354
                         System.IO.File.Delete(savedir + temp_filename + ".wav");
465
                         return Success("文件上传成功", obj);
362
                         return Success("文件上传成功", obj);
466
                     }
363
                     }
467
                     else
364
                     else
468
-                        return Error("文件上传失败,请重新上传");
365
+                        return Error("文件上传失败,请重新上传:::uploadres:" + uploadres + ":::::uploadBeforres::" + uploadBeforres);
469
                     #endregion
366
                     #endregion
470
                 }
367
                 }
471
                 else
368
                 else

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

36
             reqFTP.KeepAlive = false;// 默认为true,连接不会被关闭 // 在一个命令之后被执行  
36
             reqFTP.KeepAlive = false;// 默认为true,连接不会被关闭 // 在一个命令之后被执行  
37
             reqFTP.Method = WebRequestMethods.Ftp.UploadFile;// 指定执行什么命令  
37
             reqFTP.Method = WebRequestMethods.Ftp.UploadFile;// 指定执行什么命令  
38
             reqFTP.UseBinary = true;// 指定数据传输类型  
38
             reqFTP.UseBinary = true;// 指定数据传输类型  
39
+            reqFTP.UsePassive = true;
39
             reqFTP.ContentLength = fileInf.Length;// 上传文件时通知服务器文件的大小  
40
             reqFTP.ContentLength = fileInf.Length;// 上传文件时通知服务器文件的大小  
40
             int buffLength = 2048;// 缓冲大小设置为2kb  
41
             int buffLength = 2048;// 缓冲大小设置为2kb  
41
             byte[] buff = new byte[buffLength];
42
             byte[] buff = new byte[buffLength];
45
             FileStream fs = fileInf.OpenRead();
46
             FileStream fs = fileInf.OpenRead();
46
             try
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
                 while (contentLen != 0)// 流内容没有结束  
52
                 while (contentLen != 0)// 流内容没有结束  
52
                 {
53
                 {
53
                     // 把内容从file stream 写入 upload stream  
54
                     // 把内容从file stream 写入 upload stream  
61
             }
62
             }
62
             catch (Exception ex)
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
             return res;
67
             return res;
67
         }
68
         }