private void Window_Loaded(object sender, RoutedEventArgs e) { #region 日志 LogModel log = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_OutIn, FunctionName = "视频监控窗体_Window_Loaded", Level = LogConstParam.LogLevel_Info, Msg = "开始加载视频监控窗体" }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion VideoMonitorViewModel vm = (VideoMonitorViewModel)this.DataContext; vm.init(); LoadVideoList(); }
private void btnClose_Click(object sender, RoutedEventArgs e) { try { VideoMonitorViewModel vm = (VideoMonitorViewModel)this.DataContext; #region 关闭语音对讲 if (vm.audioController != null) { vm.audioController.Stop(); vm.audioController.Close(); } VoiceRemindHelper.SendVoiceTalkEndToMeasure(vm.CurClientModel.ClientId); #region 写日志 LogModel log = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Info, Msg = "关闭【语音对讲】,同时通知任务服务器", Origin = LoginUser.Role.Name, Data = new { clientid = vm.CurClientModel.ClientId, cmd = ParamCmd.Voice_Prompt, msg = "语音对讲结束" }, IsDataValid = LogConstParam.DataValid_Ok, ParamList = new List <DataParam>() { new DataParam() { ParamName = "cmd", ParamValue = SeatSendCmdEnum.cmd2client } }, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log)); #endregion #endregion #region 关闭视频 if (_curVideoController != null) { _curVideoController.Stop(); _curVideoController.Close(); #region 写日志 LogModel log1 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Info, Msg = "关闭视频成功", Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1)); #endregion } _curVideoController = null; #endregion #region 关闭视频回放 if (_curVideoPlayBackController != null) { _curVideoPlayBackController.PlayStop(); #region 写日志 LogModel log2 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Info, Msg = "关闭历史回放视频成功", Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log2)); #endregion } _curVideoPlayBackController = null; #endregion #region 释放视频监控资源 try { #region 内存日志 long memorySize = GetMemoryAmount(); LogModel log3 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), FunctionName = "视频监控_释放WindowsFormsHost前", Msg = "释放WindowsFormsHost前,当前线程使用内存大小:" + memorySize + "字节(" + Math.Round((double)memorySize / (1024 * 1024), 2) + "M)" }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log3)); #endregion this.formHostBig.Dispose(); this.formHostBig = null; #region 内存日志 memorySize = GetMemoryAmount(); LogModel log4 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), FunctionName = "视频监控_释放WindowsFormsHost后", Msg = "释放WindowsFormsHost后,当前线程使用内存大小:" + memorySize + "字节(" + Math.Round((double)memorySize / (1024 * 1024), 2) + "M)" }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log4)); #endregion } catch (Exception ex) { #region 写日志 LogModel log1 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Error, Msg = "释放视频资源时异常:" + ex.Message, Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1)); #endregion } #endregion #region 释放历史回放监控资源 try { this.formHis.Dispose(); this.formHis = null; #region 写日志 LogModel log2 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Info, Msg = "释放历史回放视频资源成功", Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log2)); #endregion } catch (Exception ex) { #region 写日志 LogModel log1 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Error, Msg = "释放历史回放视频资源时异常:" + ex.Message, Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1)); #endregion } #endregion this.Close(); } catch (Exception ex) { #region 写日志 LogModel log1 = new LogModel() { CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Direction = LogConstParam.Directions_Out, FunctionName = "视频监控窗体_窗体关闭事件", Level = LogConstParam.LogLevel_Error, Msg = "窗体关闭时异常:" + ex.Message, Origin = LoginUser.Role.Name, OperateUserName = LoginUser.Name }; Talent.ClinetLog.SysLog.Log(JsonConvert.SerializeObject(log1)); #endregion } }