/// <summary>
        /// 开始上传文件
        /// </summary>
        /// <param name="ftpHelper">ftp辅助对象(针对ftp的相关操作)</param>
        /// <param name="amrAudioFullName">语音文件地址</param>
        /// <param name="amrAudioName">语音名称</param>
        /// <param name="guid">序列号</param>
        public void BeginUpload(FtpManage ftpHelper, string amrAudioFullName, string amrAudioName, int guid)
        {
            //将语音文件上传到服务器
            ftpHelper.UploadFtp(amrAudioFullName, amrAudioName, IMMCodeEnterEntity.ConferenceFtpWebAddressFront + IMMCodeEnterEntity.FtpServerceAudioName, "/",
                                IMMCodeEnterEntity.FtpUserName, IMMCodeEnterEntity.FtpPassword, delegate(long Length, double progress)
            {
            }, delegate(System.Exception error, bool result)
            {
                //this.wave.StreamDispose();

                //可以再次执行录音、语音转换
                this.isInTransfer = false;

                if (File.Exists(this.wave.SavedFile))
                {
                    File.Delete(this.wave.SavedFile);
                }
                ModelManage.ConferenceAudio.UploadAudioCompleate(IMMCodeEnterEntity.ConferenceName, new ConferenceAudioItemTransferEntity()
                {
                    Guid = guid
                }, new Action <bool>((isSuccessed) =>
                {
                }));
            });
        }
 /// <summary>
 /// 语音加文本模式
 /// </summary>
 public void AudioAndTextModel()
 {
     try
     {
         //生成一个ftp辅助类()
         FtpManage ftpHelper = new FtpManage();
         //获取文件名称
         string newFileName = System.IO.Path.GetFileName(this.wave.SavedFile);
         //设置ftp文件地址
         string newFileFullName = IMMCodeEnterEntity.ConferenceFtpWebAddressFront + IMMCodeEnterEntity.FtpServerceAudioName + newFileName;
         //ftp文件地址包含ftp的前部分地址
         if (newFileFullName.Contains(IMMCodeEnterEntity.ConferenceFtpWebAddressFront))
         {
             //使用异步委托
             base.Dispatcher.BeginInvoke(new Action(() =>
             {
                 //添加语音节点
                 this.AddDiscussInformation(string.Empty, newFileFullName.Replace(IMMCodeEnterEntity.ConferenceFtpWebAddressFront, IMMCodeEnterEntity.TreeServiceAddressFront), newFileName, new Action <int>((guid) =>
                 {
                     this.BeginUpload(ftpHelper, this.wave.SavedFile, newFileName, guid);
                 }));
             }), new object[0]);
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
     finally
     {
     }
 }
 /// <summary>
 /// 当前用户手动删除节点
 /// </summary>
 /// <param name="academicReviewItem">语音实体</param>
 public void DeleteDiscussInformation(ConferenceAudioItem academicReviewItem)
 {
     try
     {
         //把需要删除的语音几点交给服务器,让服务器去通知其他终端进行删除的操作
         ModelManage.ConferenceAudio.Delete(IMMCodeEnterEntity.ConferenceName, academicReviewItem.AcademicReviewItemTransferEntity, new Action <bool>((result) =>
         {
             if (result)
             {
                 //验证是否包含语音
                 if (!String.IsNullOrEmpty(academicReviewItem.AudioUrl))
                 {
                     string url = string.Empty;
                     //将其转为ftp的地址,才可以进行ftp的移除(将保存到服务器的语音文件进行删除)
                     if (academicReviewItem.AudioUrl.Contains(IMMCodeEnterEntity.TreeServiceAddressFront))
                     {
                         //htp路径转成ftp路径
                         url = academicReviewItem.AudioUrl.Replace(IMMCodeEnterEntity.TreeServiceAddressFront, IMMCodeEnterEntity.ConferenceFtpWebAddressFront);
                     }
                     ThreadPool.QueueUserWorkItem((o) =>
                     {
                         //删除子节点所包含的语音文件
                         FtpManage.DeleteFile(url, IMMCodeEnterEntity.FtpUserName, IMMCodeEnterEntity.FtpPassword);
                     });
                 }
             }
         }));
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(typeof(ConferenceAudio_View), ex);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 上传图片
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void imgUPload(string UploadImg)
 {
     try
     {
         if (string.IsNullOrEmpty(UploadImg))
         {
             return;
         }
         //生成一个ftp辅助类()
         FtpManage ftpHelper = new FtpManage();
         //头像地址
         string personImgUri = Constant.ConferenceFtpWebAddressFront + Constant.FtpServercePersonImgName;
         //删除文件
         FtpManage.DeleteFile(personImgUri, Constant.FtpUserName, Constant.FtpPassword);
         //上传头像
         ftpHelper.UploadFtp(UploadImg, Constant.LoginUserName + ".png", Constant.ConferenceFtpWebAddressFront + Constant.FtpServercePersonImgName, "/", Constant.FtpUserName, Constant.FtpPassword, delegate(long Length, double progress)
         {
         }, delegate(System.Exception error, bool result)
         {
             if (result)
             {
                 //使用异步委托
                 this.Dispatcher.BeginInvoke(new Action(() =>
                 {
                     try
                     {
                         //显示状态
                         this.txtUPloadTip.Visibility = System.Windows.Visibility.Visible;
                         //过渡一端时间隐藏提示状态
                         TimerJob.StartRun(new Action(() =>
                         {
                             this.txtUPloadTip.Visibility = System.Windows.Visibility.Collapsed;
                         }), 2000);
                     }
                     catch (Exception ex)
                     {
                         LogManage.WriteLog(this.GetType(), ex);
                     }
                     finally
                     {
                     }
                 }));
             }
         });
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
     finally
     {
     }
 }
        /// <summary>
        /// 鼠标释放结束录音
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AudioTransfer_Up()
        {
            try
            {
                if (this.wave.IsRecord)
                {
                    //停止录音
                    this.wave.Stop();
                    //语音转文字按钮样式恢复默认
                    this.btnAudioTransfer.Style = (base.Resources["btnAudioStyle"] as Style);

                    ThreadPool.QueueUserWorkItem((o) =>
                    {
                        try
                        {
                            //判断录音文件是否存在
                            if (System.IO.File.Exists(this.wave.SavedFile))
                            {
                                //获取当前时间
                                //string dateNow = System.DateTime.Now.ToLongTimeString();
                                //查看存储文件,若大于20MB移除(录音故障)
                                if (File.Exists(this.wave.SavedFile))
                                {
                                    FileInfo fileInfo = new FileInfo(this.wave.SavedFile);
                                    if (fileInfo.Length > 1024 * 1024 * 20)
                                    {
                                        fileInfo.Delete();
                                        //可以再次执行录音、语音转换
                                        this.isInTransfer = false;
                                        return;
                                    }
                                }
                                //查看存储文件,若大于20MB移除(录音故障)
                                if (File.Exists(this.wave.RecordTmpFile))
                                {
                                    FileInfo fileInfo = new FileInfo(this.wave.RecordTmpFile);
                                    if (fileInfo.Length > 1024 * 1024 * 20)
                                    {
                                        fileInfo.Delete();
                                        //可以再次执行录音、语音转换
                                        this.isInTransfer = false;
                                        return;
                                    }
                                }
                                this.wave.StreamDispose();

                                //string AudioName = Constant.AudioFile_Name + dateNow + Constant.AudioFile_Extention;
                                //string amrAudioFullName = Constant.AudioFile_Root + amrAudioName;

                                //toamr.ConvertToAmr(System.Windows.Forms.Application.StartupPath, this.wave.SavedFile, amrAudioFullName);

                                //生成一个ftp辅助类()
                                FtpManage ftpHelper = new FtpManage();
                                //获取文件名称
                                string newFileName = System.IO.Path.GetFileName(this.wave.SavedFile);
                                //设置ftp文件地址
                                string newFileFullName = Constant.ConferenceFtpWebAddressFront + Constant.FtpServerceAudioName + newFileName;
                                //ftp文件地址包含ftp的前部分地址
                                if (newFileFullName.Contains(Constant.ConferenceFtpWebAddressFront))
                                {
                                    //使用异步委托
                                    base.Dispatcher.BeginInvoke(new Action(() =>
                                    {
                                        //添加语音节点
                                        this.AddDiscussInformation(string.Empty, newFileFullName.Replace(Constant.ConferenceFtpWebAddressFront, Constant.TreeServiceAddressFront), newFileName, new Action <int>((guid) =>
                                        {
                                            this.BeginUpload(ftpHelper, this.wave.SavedFile, newFileName, guid);
                                        }));
                                    }), new object[0]);
                                }
                            }
                            else
                            {
                                //可以再次执行录音、语音转换
                                this.isInTransfer = false;
                            }
                        }
                        catch (Exception ex)
                        {
                            LogManage.WriteLog(this.GetType(), ex);
                        };
                    });
                }
            }
            catch (System.Exception ex)
            {
                //可以再次执行录音、语音转换
                this.isInTransfer = false;
                LogManage.WriteLog(base.GetType(), ex);
            }
        }