Ejemplo n.º 1
0
        /// <summary>
        /// 执行配置的执行接口
        /// </summary>
        /// <param name="commandParam"></param>
        /// <returns></returns>
        protected CommandResult ExecuteCommands(CommandParam commandParam)
        {
            var biz      = commandParam.UiBiz;
            var uiHelper = commandParam.UiHelper;

            #region 参数格式化接口
            CommandResult result = new CommandResult();
            foreach (Command command in biz.TrimCommands)
            {
                if (command != null && command.Instance != null)
                {
                    result = command.Execute(commandParam);
                    if (result.isBreak)
                    {
                        X.MessageBox.Show(new MessageBoxConfig()
                        {
                            Title = "提示", Message = result.sResult, Icon = MessageBox.Icon.WARNING
                        });
                        return(result);
                    }
                }
            }
            #endregion
            #region 参数校验接口
            foreach (Command command in biz.VerifyCommands)
            {
                if (command != null && command.Instance != null)
                {
                    result = command.Execute(commandParam);
                    if (result.isBreak)
                    {
                        X.MessageBox.Show(new MessageBoxConfig()
                        {
                            Title = "提示", Message = result.sResult, Icon = MessageBox.Icon.WARNING
                        });
                        return(result);
                    }
                }
            }
            #endregion
            #region 执行接口
            if (true)
            {
                Command command = biz.ExcuteCommand;
                {
                    if (command != null && command.Instance != null)
                    {
                        result = command.Execute(commandParam);
                        if (result.isBreak)
                        {
                            if (!string.IsNullOrWhiteSpace(result.sResult))
                            {
                                X.MessageBox.Show(new MessageBoxConfig()
                                {
                                    Title = "提示", Message = result.sResult, Icon = MessageBox.Icon.WARNING
                                });
                            }
                            else if (result.Exception != null)
                            {
                                X.MessageBox.Show(new MessageBoxConfig()
                                {
                                    Title = "提示", Message = result.Exception.ToString(), Icon = MessageBox.Icon.WARNING
                                });
                            }
                            return(result);
                        }
                    }
                }
            }
            #endregion
            return(result);
        }