コード例 #1
0
ファイル: FormDVDevControl.cs プロジェクト: yuanliya/Auto
        /// <summary>
        /// 控制命令无法执行的事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void UpdateCommandErrorInfo(Object sender, CommandExceptionEventArgs args)
        {
            string info = string.Empty;

            if (args.Exception is ControlCheckException)
            {
                // 系统无法进入控制引发的异常
                info = string.Format("无法控制{0}区系统:{1}", args.DevNo, args.Exception.Message);

                UpdateClipBoardInfo(info);

                return;
            }

            if (args.Exception is TimeoutException)
            {
                // 与节点通信发生超时错误
                info = string.Format("{0}区系统:通信超时无响应!", args.DevNo);

                UpdateClipBoardInfo(info);

                return;
            }

            // 操作未完成:通信错误、节点无响应、
            info = string.Format("{0}区系统:通信收到错误回帧!", args.DevNo);

            UpdateClipBoardInfo(info);
        }
コード例 #2
0
        private static void OnCommandException(CommandExceptionEventArgs e)
        {
            Exception        ex      = e.Exception;
            CommandEventArgs command = e.Command;

            DateTime now       = DateTime.Now;
            string   nowString = "[" + now.ToShortTimeString() + "]";

            StringBuilder messageBuilder = new StringBuilder();

            messageBuilder.Append(
                nowString +
                "An error occured in the command \"" +
                command.Message.RawText +
                "\" by " +
                command.User.Name + ": ");

            messageBuilder.Append(e.Exception.ToString());
            messageBuilder.Append("In channel " + command.Channel.Name);
            messageBuilder.Append("");

            BotDebug.Log(messageBuilder.ToString(), "Error", ConsoleColor.Red);

            command.Channel.SendMessage("```Une erreur s'est produite à l'exécution de la commande.```");
        }
コード例 #3
0
        /// <commondoc select='ViewModels/Methods/OnUnhandledCommandException/*' />
        protected virtual void OnUnhandledCommandException(CommandExceptionEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException();
            }

            this.UnhandledCommandException?.ReverseInvoke(this, e);
        }
コード例 #4
0
 public void OnInvokeException(CommandExceptionEventArgs e)
 {
     foreach (IPerformanceCounter c in PerformanceCounterRegistry.Fetch(e.CommandType))
     {
         var counter = (IPerformanceCounter)c;
         switch (counter.CounterType)
         {
         case PerformanceCounterType.AverageOperationTime:
         case PerformanceCounterType.OperationSuccessRatio:
         case PerformanceCounterType.OperationsPerSecond:
             counter.Increment();
             break;
         }
     }
 }
コード例 #5
0
        /// <summary>
        ///   Handles the <see cref="WallpaperManager.ViewModels.WallpaperChangerVM.UnhandledCommandException" /> event of a
        ///   <see cref="WallpaperManager.ViewModels.WallpaperChangerVM" /> instance and handles the thrown exception if
        ///   possible.
        /// </summary>
        /// <commondoc select='All/Methods/EventHandlers[@Params="Object,+EventArgs"]/*' />
        private void WallpaperChangerVM_UnhandledCommandException(object sender, CommandExceptionEventArgs e)
        {
            if (e.IsHandled)
            {
                return;
            }

            WallpaperChangerVM wallpaperChangerVM = (WallpaperChangerVM)sender;

            if (e.Command == wallpaperChangerVM.StartCyclingCommand || e.Command == wallpaperChangerVM.CycleNextCommand)
            {
                if (this.HandleCycleException(e.Exception))
                {
                    e.IsHandled = true;
                }
            }
        }
コード例 #6
0
        /// <summary>
        ///   Handles the <see cref="ConfigWallpaperVM.UnhandledCommandException" /> event of a <see cref="ConfigWallpaperVM" />
        ///   instance and handles the thrown exception if possible.
        /// </summary>
        /// <commondoc select='All/Methods/EventHandlers[@Params="Object,+EventArgs"]/*' />
        private void ConfigWallpaperVM_UnhandledCommandException(object sender, CommandExceptionEventArgs e)
        {
            if (e.IsHandled)
            {
                return;
            }

            ConfigWallpaperVM configWallpaperVM = (ConfigWallpaperVM)sender;

            if (e.Command == configWallpaperVM.ApplySettingsCommand)
            {
                if (e.Exception is InvalidOperationException)
                {
                    DialogManager.ShowWallpapers_MultiscreenWallpaperOnDisabledScreens(null);
                }

                e.IsHandled = true;
            }
        }