Exemple #1
0
 /// <summary>
 /// 将4个Unicode字符转换成一个汉字----方案二
 /// 比如  “9EC4”可以转换为  “黄”
 /// </summary>
 /// <param name="unicodeStr"></param>
 /// <returns></returns>
 public static string Change4UnicodeTo1Word_2(string unicodeStr)
 {
     try
     {
         if (unicodeStr != null && unicodeStr.Length >= 4)
         {
             byte[] codes = new byte[2];
             int    code  = Convert.ToInt32(unicodeStr.Substring(0, 2), 16);
             int    code2 = Convert.ToInt32(unicodeStr.Substring(2), 16);
             codes[0] = (byte)code;
             codes[1] = (byte)code2;
             return(Encoding.Unicode.GetString(codes));
         }
     }
     catch (Exception ex)
     {
         Log4NetHelper.WriteErrorLog(ex);
     }
     return(null);
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //处理视图引擎
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //系统其他初始化
            var configRootPath = Server.MapPath("~/Config/");

            //IOC
            AutofacHelper.InitAutofacContainer(Path.Combine(configRootPath, "Autofac/AutofacConfig.xml"));
            //日志
            Log4NetHelper.InitLog4Net(Path.Combine(configRootPath, "Log4net/Log4Net.xml"));
        }
Exemple #3
0
 public static bool Restart(string jobName, string triggerId, string cronExpr, string triggerUrl)
 {
     if (RemoveJob(jobName))
     {
         if (AddJob(jobName, triggerId, cronExpr, triggerUrl))
         {
             Log4NetHelper.WriteRunLog("ShopQuartz job【" + jobName + "】重启成功");
             return(true);
         }
         else
         {
             Log4NetHelper.WriteExceptionLog("ShopQuartz job【" + jobName + "】重启时新增作业失败");
         }
     }
     else
     {
         Log4NetHelper.WriteExceptionLog("ShopQuartz job【" + jobName + "】重启时移除作业失败");
     }
     return(false);
 }
Exemple #4
0
 private void VoiceVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     try
     {
         if (GlobalUser.WavePlayer != null)
         {
             GlobalUser.AudioVolume       = (float)VoiceVolumeSlider.Value * 0.01f;
             GlobalUser.WavePlayer.Volume = GlobalUser.AudioVolume;
         }
         //vol.ChangeAudioVolume(new DeviceInfo()
         //{
         //    Volume = VoiceVolumeSlider.Value,
         //    Muted = false,
         //});
     }
     catch (Exception ex)
     {
         Log4NetHelper.ErrorFormat(this.Name, "VoiceVolumeSlider_ValueChanged  加载默认声音音量失败", ex);
     }
 }
Exemple #5
0
 public void Intercept(IInvocation invocation)
 {
     try
     {
         invocation.Proceed();
     }
     catch (Exception exception)
     {
         if (exception is BusinessException)
         {
             throw;
         }
         var message = new {
             exception        = exception.Message,
             exceptionContext = new { method = invocation.Method.ToString(), arguments = invocation.Arguments, returnValue = invocation.ReturnValue }
         };
         Log4NetHelper.Error(LoggerType.ServiceExceptionLog, message, exception);
         throw;
     }
 }
        public IActionResult  Uploads([FromForm] IFormCollection formCollection)
        {
            CommonResult       result      = new CommonResult();
            FormFileCollection filelist    = (FormFileCollection)formCollection.Files;
            string             belongApp   = formCollection["belongApp"].ToString();
            string             belongAppId = formCollection["belongAppId"].ToString();

            try
            {
                result.ResData = Adds(filelist, belongApp, belongAppId);
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("", ex);
                result.ErrCode = "500";
                result.ErrMsg  = ex.Message;
            }

            return(ToJsonContent(result));
        }
Exemple #7
0
 /// <summary>
 /// 获得禁止的ip
 /// </summary>
 /// <param name="id">id</param>
 /// <returns></returns>
 public static BannedIPInfo GetBannedIPById(int id)
 {
     if (Commons.DirectConnected)
     {
         return(NStore.Data.BannedIPs.GetBannedIPById(id));
     }
     else
     {
         var result = httpHelper.HttpGet <BannedIPInfo>(string.Format("api/GetBannedIPById/{0}", id));
         if (result.Code == 0)
         {
             return(result.Data);
         }
         else
         {
             Log4NetHelper.Error(string.Format("GetBannedIPById请求失败,错误信息:{0}", result.Msg));
             return(null);
         }
     }
 }
Exemple #8
0
        public async Task <IActionResult> GetAllCategoryTreeTable(string keyword)
        {
            CommonResult result = new CommonResult();

            try
            {
                List <ArticlecategoryOutputDto> list = await iService.GetAllArticlecategoryTreeTable(keyword);

                result.Success = true;
                result.ErrCode = ErrCode.successCode;
                result.ResData = list;
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("获取分类异常", ex);
                result.ErrMsg  = ErrCode.err40110;
                result.ErrCode = "40110";
            }
            return(ToJsonContent(result));
        }
Exemple #9
0
        ///  <summary>
        /// 执行一个不需要返回值的SqlCommand命令,通过指定专用的连接字符串。
        ///  使用参数数组形式提供参数列表
        ///  </summary>
        ///  <param name="connectionString">一个有效的数据库连接字符串</param>
        ///  <param name="cmdType">SqlCommand命令类型 (存储过程, T-SQL语句, 等等。)</param>
        ///  <param name="cmdText">存储过程的名字或者 T-SQL 语句</param>
        /// <param name="commandParameters">以数组形式提供SqlCommand命令中用到的参数列表</param>
        /// <returns>返回一个数值表示此SqlCommand命令执行后影响的行数</returns>
        public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
        {
            var cmd = new SqlCommand();

            try
            {
                using (var conn = new SqlConnection(connectionString))
                {
                    //通过PrePareCommand方法将参数逐个加入到SqlCommand的参数集合中
                    PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
                    int val = cmd.ExecuteNonQuery();
                    return(val);
                }
            }
            catch (Exception exx)
            {
                Log4NetHelper.WriteError(exx);
                return(0);
            }
        }
        public override void OnException(HttpActionExecutedContext context)
        {
            Log4NetHelper log = Log4NetHelper.CreateInstance();

            log.WriteLog(HttpContext.Current.Request.Url.LocalPath, context.Exception);

            var message = context.Exception.Message;

            if (context.Exception.InnerException != null)
            {
                message = context.Exception.InnerException.Message;
            }

            context.Response = new HttpResponseMessage()
            {
                Content = new StringContent(message)
            };

            base.OnException(context);
        }
Exemple #11
0
 //change avatar
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (!this.ofd.FileName.Equals(string.Empty))
         {
             MemoryStream ms = new MemoryStream();
             this.pbShowPhoto.Image.Save(ms, ImageFormat.Jpeg);
             ms.Position = 0;
             UserService.UserServiceClient userManager = new UserService.UserServiceClient();
             userManager.UpdatePhoto(RememberUserParameter.userId, ms.ToArray());
             this.pbuserPhoto.Image = Image.FromFile(this.ofd.FileName);
             this.pnlPhoto.Hide();
         }
     }
     catch (Exception ex)
     {
         Log4NetHelper.WriteErrorLog(typeof(UserProfileForm), ex);
     }
 }
Exemple #12
0
 private void OpenFileNoDes(string fileName)
 {
     try
     {
         var inputStream = new AudioFileReader(fileName);
         fileStream = inputStream;
         var aggregator = new SampleAggregator(inputStream);
         aggregator.NotificationCount  = inputStream.WaveFormat.SampleRate / 100;
         aggregator.PerformFFT         = true;
         aggregator.FftCalculated     += (s, a) => OnFftCalculated(a);
         aggregator.MaximumCalculated += (s, a) => OnMaximumCalculated(a);
         playbackDevice.Init(aggregator);
     }
     catch (Exception e)
     {
         Log4NetHelper.ErrorFormat("OpenFileNoDes文件打开失败. cause by:{0}", e.Message);
         //MessageBox.Show(e.Message, "Problem opening file");
         CloseFile();
     }
 }
        public IActionResult CheckOpenId(string openId)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (string.IsNullOrEmpty(openId) && !ValidateUserLogin(openId))
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err50001;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("检查微信用户的OpenId", ex);
                result.ErrMsg  = "检查微信用户的OpenId:" + ex.Message;
                result.ErrCode = ErrCode.failCode;
            }
            return(ToJsonContent(result));
        }
Exemple #14
0
        /// <summary>
        /// 删除多条数据
        /// </summary>
        /// <param name="entitys"></param>
        /// <returns></returns>
        public bool DeleteEntities(List <T> entitys)
        {
            int saveCount = 0;

            try
            {
                foreach (T entity in entitys)
                {
                    OrcDB.Set <T>().Attach(entity);
                    OrcDB.Entry <T>(entity).State = EntityState.Deleted;
                }
                saveCount = OrcDB.SaveChanges();
                Dispose();
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error(this, "DB Delete Save Error", ex);
            }
            return(saveCount > 0);
        }
Exemple #15
0
        /// <summary>
        /// windows时间日志写入文本
        /// </summary>
        /// <returns></returns>
        public ActionResult LogWindows()
        {
            //初始化日志信息
            LogMessage message = new LogMessage();

            message.SystemID    = "LJ-12334";
            message.RequestIP   = "127.0.0.1";
            message.RequestDate = DateTime.Now;
            message.MethodCode  = "NGBOSS接口命令字编码";
            message.MethodName  = "Log4Net控制器下LogWindows方法";
            message.Content     = "测试一下 ====写Windows事件日志==== 这个方法";
            message.Remark      = "这只是一个测试。";
            //调 Log4NetHelper 写入windows日志到文本
            Log4NetHelper.WriteEventLog(message);
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<li>外围系统编号:{0}</li><li>客户端请求的IP地址:{1}</li><li>客户端请求的时间:{2}</li><li>NGBOSS:{3}</li><li>客户端发起请求的操作内容:{4}</li><li>备注:{5}</li>", message.SystemID, message.RequestIP, message.RequestDate, message.MethodCode + " " + message.MethodName, message.Content, message.Remark);
            ViewData["EventList"] = sb.ToString();
            return(View());
        }
        public async Task <IActionResult> GetAllFunctionTree()
        {
            CommonResult result = new CommonResult();

            try
            {
                List <ModuleFunctionOutputDto> list = await iService.GetAllFunctionTree();

                result.Success = true;
                result.ErrCode = ErrCode.successCode;
                result.ResData = list;
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("获取菜单异常", ex);
                result.ErrMsg  = ErrCode.err40110;
                result.ErrCode = "40110";
            }
            return(ToJsonContent(result));
        }
Exemple #17
0
        protected void Application_End(object sender, EventArgs e)
        {
            if (scheduler != null)
            {
                scheduler.Shutdown(true);
            }
            Log4NetHelper.WriteInfo("网站关闭,系统资源回收。");

            try
            {
                HttpWebRequest  req  = (HttpWebRequest)WebRequest.Create("http://localhost:20170/");
                HttpWebResponse rsp  = (HttpWebResponse)req.GetResponse();
                string          desc = rsp.StatusDescription;
                Log4NetHelper.WriteInfo(desc);
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteExcepetion(ex);
            }
        }
Exemple #18
0
        private void btnReply_Click(object sender, EventArgs e)
        {
            if (dgrdMsgList.SelectedItem == null || dgrdMsgList.SelectedItems == null)
            {
                return;
            }
            var           item      = dgrdMsgList.SelectedItem as MessageInfo;
            SendMsgWindow msgWindow = new SendMsgWindow(item.WorkNo);

            msgWindow.ShowDialog();
            if (msgWindow.IsConfirm)
            {
                string res = BusinessAdapter.GetBusinessInstance().SendNote(Int32.Parse(msgWindow.WorkNo), msgWindow.TxtContent);
                Log4NetHelper.ActionLog("Common", "Vc_SendNote", res);
                if (!res.Equals(AGWErrorCode.OK))
                {
                    MessageBox.Show(LanguageResource.FindResourceMessageByKey("msgview_fail"));
                }
            }
        }
Exemple #19
0
        public IActionResult DeleteFile(string id)
        {
            CommonResult result = new CommonResult();

            try
            {
                UploadFile uploadFile = new UploadFileApp().Get(id);

                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                SysSetting        sysSetting        = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
                string            localpath         = _hostingEnvironment.WebRootPath;
                if (uploadFile != null)
                {
                    string filepath = (localpath + "/" + uploadFile.FilePath).ToFilePath();
                    if (System.IO.File.Exists(filepath))
                    {
                        System.IO.File.Delete(filepath);
                    }
                    string filepathThu = (localpath + "/" + uploadFile.Thumbnail).ToFilePath();
                    if (System.IO.File.Exists(filepathThu))
                    {
                        System.IO.File.Delete(filepathThu);
                    }

                    result.ErrCode = ErrCode.successCode;
                    result.Success = true;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.Success = false;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("", ex);
                result.ErrCode = "500";
                result.ErrMsg  = ex.Message;
            }
            return(ToJsonContent(result));
        }
        public async Task <ActionResult> Edit([Bind(Include = "WidgetId,Description,MainBusCode,TestPassDateTime,WidgetStatus,CurrentWorkerId")] Widget widget, string command)
        {
            if (ModelState.IsValid)
            {
                PromotionResult promotionResult = new PromotionResult();
                if (command == "Save")
                {
                    promotionResult.Success = true;
                    promotionResult.Message = String.Format("Changes to widget {0} have been successfully saved.", widget.WidgetId);
                    Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, widget.EntityFormalNamePlural, widget.WidgetId, User.Identity.Name, null);
                }
                else if (command == "Claim")
                {
                    promotionResult = widget.ClaimWorkListItem(User.Identity.GetUserId());
                }
                else if (command == "Relinquish")
                {
                    promotionResult = widget.RelinquishWorkListItem();
                }
                else
                {
                    promotionResult = widget.PromoteWorkListItem(command);
                }

                if (promotionResult.Success)
                {
                    TempData["MessageToClient"] = promotionResult.Message;
                }

                db.Entry(widget).State = EntityState.Modified;
                await db.SaveChangesAsync();

                if (command == "Claim" && promotionResult.Success)
                {
                    return(RedirectToAction("Edit", widget.WidgetId));
                }
                return(RedirectToAction("Index", "WorkList"));
            }
            //ViewBag.CurrentWorkerId = new SelectList(db.ApplicationUsers, "Id", "FirstName", widget.CurrentWorkerId);
            return(View(widget));
        }
        /// <summary>
        /// qry button click
        /// </summary>
        /// <param name="sender">button</param>
        /// <param name="e">click event</param>
        private void btn_qry_Click(object sender, EventArgs e)
        {
            tb_msgshow.Text = string.Empty;
            if (string.IsNullOrEmpty(tb_pageNo.Text) || string.IsNullOrEmpty(tb_pageSize.Text))
            {
                return;
            }

            try
            {
                if (BusinessAdapter.CurrentBusinessType == BusinessType.OCX)
                {
                    Log4NetHelper.BaseLog("Instance is ocx");
                    return;
                }
                if (null == BusinessAdapter.GetBusinessInstance())
                {
                    Log4NetHelper.BaseLog("Instance is null");
                    return;
                }

                var res = ((AgentGatewayBusiness)BusinessAdapter.GetBusinessInstance()).QryCallContent(tb_callID.Text, tb_pageSize.Text, tb_pageNo.Text);
                if (null == res)
                {
                    MessageBox.Show(LanguageResource.FindResourceMessageByKey("textchat_qryfailed"));
                    return;
                }
                Log4NetHelper.ActionLog("Agw", "QryCallContent", res.retcode);
                if (null == res.result)
                {
                    return;
                }
                lbl_totalPage.Content  = res.result.totalPageNo;
                lbl_totalCount.Content = res.result.totalCount;
                UIViewHelper.SelectorResetSource(dgrd_callcontent, res.result.weccCallContentList);
            }
            catch (Exception exc)
            {
                Log4NetHelper.BaseLog(exc.Message);
            }
        }
Exemple #22
0
        /// <summary>
        /// 实现文件上传到服务器保存,并生成缩略图
        /// </summary>
        /// <param name="fileName">文件名称</param>
        /// <param name="fileBuffers">文件字节流</param>
        private void UploadFile(string fileName, byte[] fileBuffers)
        {
            string folder = DateTime.Now.ToString("yyyyMMdd");

            //判断文件是否为空
            if (string.IsNullOrEmpty(fileName))
            {
                Log4NetHelper.Error("文件名不能为空");
                throw new Exception("文件名不能为空");
            }

            //判断文件是否为空
            if (fileBuffers.Length < 1)
            {
                Log4NetHelper.Error("文件不能为空");
                throw new Exception("文件不能为空");
            }
            var _tempfilepath = "/upload/" + _belongApp + "/" + folder + "/";
            var uploadPath    = _filePath + _tempfilepath;

            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            var    ext     = Path.GetExtension(fileName).ToLower();
            string newName = GuidUtils.CreateNo() + ext;

            using (var fs = new FileStream(uploadPath + newName, FileMode.Create))
            {
                fs.Write(fileBuffers, 0, fileBuffers.Length);
                fs.Close();
                //生成缩略图
                if (ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".png") || ext.Contains(".bmp") || ext.Contains(".gif"))
                {
                    string thumbnailName = GuidUtils.CreateNo() + ext;
                    ImgHelper.MakeThumbnail(uploadPath + newName, uploadPath + thumbnailName);
                    _dbThumbnail = folder + "/" + thumbnailName;
                }
                _dbFilePath = _tempfilepath + "/" + newName;
            }
        }
        public static void MakeThumbnail(string originalImagePath, string thumbnailPath, ThumbnailSize size)
        {
            try
            {
                ImageUtil.MakeThumbnail(originalImagePath, thumbnailPath,
                                        size.Width,
                                        size.Height,
                                        size.Mode,
                                        size.AddWaterMarker,
                                        size.WaterMarkerPosition,
                                        size.WaterMarkerPath,
                                        size.Quality);

                Console.WriteLine("生成成功:{0}", thumbnailPath);
            }
            catch (Exception e)
            {
                //Console.WriteLine("生成失败,非标准图片:{0}", thumbnailPath);
                Log4NetHelper.Error(LoggerType.WebExceptionLog, string.Format("{0} 生成失败,非标准图片", thumbnailPath), e);
            }
        }
        void OnAudioPlayStopped(object sender, StoppedEventArgs e)
        {
            if (e.Exception != null)
            {
                Log4NetHelper.InfoFormat("播放异常停止. cause by:{0}", e.Exception.ToString());
            }

            Stop();
            CloseFile();

            if (OnPlayFinished != null)
            {
                OnPlayFinished.Invoke();
            }
            else
            {
                Log4NetHelper.Info("no play finished handler...");
            }

            //Cleanup();
        }
Exemple #25
0
        private void btnSet_Click(Object sender, EventArgs e)
        {
            if (m_CallInfo == null)
            {
                return;
            }
            if (dgrdCallList.SelectIndex == -1)
            {
                MessageBox.Show(LanguageResource.FindResourceMessageByKey("setdata_selecttalk"));
                return;
            }

            var item = m_CallInfo[dgrdCallList.SelectIndex];
            var res  = BusinessAdapter.GetBusinessInstance().SetData(item.CallId + "", txtBoxData.Text, 5);

            Log4NetHelper.ActionLog("Common", "Vc_SetData", res);
            if (res.Equals(AGWErrorCode.OK))
            {
                MessageBox.Show(LanguageResource.FindResourceMessageByKey("setDataSucc"));
            }
        }
Exemple #26
0
        static void RunProcess()
        {
            Application app = new Application();

            app.DispatcherUnhandledException += (s, e) =>
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendFormat("应用程序出现了未捕获的异常,{0}/n", e.Exception.Message);
                if (e.Exception.InnerException != null)
                {
                    stringBuilder.AppendFormat("/n {0}", e.Exception.InnerException.Message);
                }
                stringBuilder.AppendFormat("/n {0}", e.Exception.StackTrace);
                Log4NetHelper.WriteLog(stringBuilder.ToString());
                MessageBox.Show(stringBuilder.ToString());
                e.Handled = true;
            };
            Login mainWindow = new Login();

            app.Run(mainWindow);
        }
Exemple #27
0
 /// <summary>
 /// 查询
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="sql"></param>
 /// <param name="param"></param>
 /// <param name="transaction"></param>
 /// <returns></returns>
 public static List <T> Query <T>(string sql, object param = null, IDbTransaction transaction = null)
 {
     try
     {
         using (IDbConnection conn = new SQLiteConnection(DapperManager.connectionString))
         {
             lock (_lock)
             {
                 conn.Open();
                 var list = conn.Query <T>(sql, param, transaction);
                 return(list as List <T>);
             }
         }
     }
     catch (Exception ex)
     {
         Log4NetHelper.Error("执行Query方法时出错", ex);
         return(null);
         //throw new Exception("执行Query方法时出错", ex);
     }
 }
Exemple #28
0
 private void LoginForm_Load(object sender, EventArgs e)
 {
     try
     {
         using (FileStream fs = new FileStream(passwordFilePath, FileMode.OpenOrCreate))
         {
             if (fs.Length > 0)
             {
                 BinaryFormatter bf   = new BinaryFormatter();
                 UserInfo        user = bf.Deserialize(fs) as UserInfo;
                 this.txtUsername.Text         = user.UserName;
                 this.txtPassword.PasswordChar = DOT;
                 this.txtPassword.Text         = user.Password;
             }
         }
     }
     catch (Exception ex)
     {
         Log4NetHelper.WriteErrorLog(typeof(LoginForm), ex);
     }
 }
        // GET: Authorize
        public async Task <ActionResult> Index(string code, string state)
        {
            var entity = _service.GetAuthorizeEntity(code);

            Log4NetHelper.WriteDebug("Authorize result=" + entity.ToJson());
            //var entity = new AuthorizeAccessTokenResult();
            //entity.openid = "opKrYwas6Lx4_qRK9s9-NHLV-izo";

            var user = await _userService.GetUser(entity.openid);

            if (user != null)
            {
                var userData = user.ToJson();
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.Name, DateTime.Now,
                                                                                 DateTime.Now.AddMinutes(30), false, userData);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                //加密身份信息,保存至Cookie
                Response.Cookies.Add(cookie);
            }
            return(Redirect(state.UrlDecode()));
        }
        public VolumeDetectorVista()
        {
            devEnum = new MMDeviceEnumerator();
            try
            {
                defaultDevice =
                  devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);

                defaultDevice.AudioEndpointVolume.OnVolumeNotification += DelegateNotification;


                defaultMicroDevice =
                    devEnum.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);

                defaultMicroDevice.AudioEndpointVolume.OnVolumeNotification += DelegateNotification;
            }
            catch(Exception ex)
            {
                Log4NetHelper.Error("获取录音[播放]设备失败", ex);
            }
        }