コード例 #1
0
        /// <summary>
        /// Get Paged Records
        /// </summary>
        /// <param name="query"></param>
        /// <param name="source"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="cursorType"></param>
        /// <param name="lockType"></param>
        /// <param name="options"></param>
        /// <param name="cursorLocation"></param>
        /// <returns></returns>
        public Recordset GetPagedRecords(string query,
                                         DataSource source,
                                         int pageIndex,
                                         int pageSize = 100,
                                         CursorTypeEnum cursorType         = CursorTypeEnum.adOpenDynamic,
                                         LockTypeEnum lockType             = LockTypeEnum.adLockOptimistic,
                                         CommandTypeEnum options           = CommandTypeEnum.adCmdText,
                                         CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient)
        {
            _connection = new Connection();

            var cnStr = GetConnectionString(source);

            _connection.Open(cnStr, null, null, 0);

            _recordSet = new Recordset
            {
                CursorLocation = cursorLocation,
                CacheSize      = pageSize,
                PageSize       = pageSize
            };

            //_recordSet.Open(query,_connection, cursorType, lockType, (int)options);
            _recordSet.Open(query, _connection);

            if (_recordSet.RecordCount != 0)
            {
                _recordSet.AbsolutePage = (PositionEnum)pageIndex;
            }
            return(_recordSet);
        }
コード例 #2
0
        protected ADODB.Command GenerateCommand(CommandTypeEnum eCmdType, SqlFrag frag)
        {
            ADODB.Command SqlCmd   = new Command();
            string        strQuery = "";

            if (frag.SqlParams.Count < 2040)
            {
                ProcessParameters(SqlCmd, frag);

                // replace our tags
                strQuery = frag.m_strSql.Replace("{", "");
                strQuery = strQuery.Replace("}", "");
            }
            else
            {
                strQuery = frag.Flatten();
            }

            // ensure we have a valid connections
            Ensure();

            // set up the object
            SqlCmd.ActiveConnection = m_pConnection;
            SqlCmd.CommandText      = strQuery;
            SqlCmd.CommandType      = eCmdType;

            return(SqlCmd);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: eksotama/rdl-engine
        protected override void ParseAttribute(XmlNode attr)
        {
            switch (attr.Name.ToLower())
            {
            case "datasourcename":
                _dataSourceName = attr.InnerText;
                break;

            case "commandtype":
                _commandType = (CommandTypeEnum)Enum.Parse(typeof(CommandTypeEnum), attr.InnerText, true);
                break;

            case "commandtext":
                _commandText = new Expression(attr, this);
                break;

            case "queryparameters":
                foreach (XmlNode child in attr.ChildNodes)
                {
                    _queryParameters.Add(new QueryParameter(child, this));
                }
                break;

            case "timeout":
                _timeout = Int32.Parse(attr.InnerText);
                break;

            default:
                break;
            }
        }
コード例 #4
0
 public CommandModelBase(string name, CommandTypeEnum type)
 {
     this.ID        = Guid.NewGuid();
     this.IsEnabled = true;
     this.Name      = name;
     this.Type      = type;
 }
コード例 #5
0
ファイル: CommandBase.cs プロジェクト: Sanw0/mixer-mixitup
 public CommandBase(string name, CommandTypeEnum type, IEnumerable <string> commands)
     : this()
 {
     this.Name = name;
     this.Type = type;
     this.Commands.AddRange(commands);
 }
コード例 #6
0
        private void ParseCommand()
        {
            var words = _reader.ReadLine().Split('/')[0].Split(' ');

            if (words.Count() == 1 && words[0] != "return")
            {
                _commandType = CommandTypeEnum.C_ARITHMETIC;
                _arg1        = words[0];
            }
            else if (words[0] == "push")
            {
                _commandType = CommandTypeEnum.C_PUSH;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else if (words[0] == "pop")
            {
                _commandType = CommandTypeEnum.C_POP;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
コード例 #7
0
#pragma warning restore CS0612 // Type or member is obsolete

        protected ChatCommandModel(string name, CommandTypeEnum type, HashSet <string> triggers, bool includeExclamation, bool wildcards)
            : base(name, type)
        {
            this.Triggers           = triggers;
            this.IncludeExclamation = includeExclamation;
            this.Wildcards          = wildcards;
        }
コード例 #8
0
        public CommandEditorWindow(CommandTypeEnum commandType, string name = null)
            : this()
        {
            switch (commandType)
            {
            case CommandTypeEnum.Chat:
                this.editorDetailsControl = new ChatCommandEditorDetailsControl();
                this.viewModel            = new ChatCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.Timer:
                this.editorDetailsControl = new TimerCommandEditorDetailsControl();
                this.viewModel            = new TimerCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.TwitchChannelPoints:
                this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl();
                this.viewModel            = new TwitchChannelPointsCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.ActionGroup:
                this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl();
                this.viewModel            = new ActionGroupCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.Custom:
                this.editorDetailsControl = new CustomCommandEditorDetailsControl();
                this.viewModel            = (!string.IsNullOrEmpty(name)) ? new CustomCommandEditorWindowViewModel(name) : new CustomCommandEditorWindowViewModel();
                break;
            }
            this.DataContext = this.ViewModel = this.viewModel;

            this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); };
            this.ViewModel.EndLoadingOperationOccurred   += (sender, eventArgs) => { this.EndLoadingOperation(); };
        }
コード例 #9
0
 public CommandBase(string name, CommandTypeEnum type, IEnumerable <string> commands)
     : this()
 {
     this.Name     = name;
     this.Type     = type;
     this.Commands = new HashSet <string>(commands);
 }
コード例 #10
0
        protected string GenerateCommand(CommandTypeEnum commandType, DigitalPortEnum port, int value)
        {
            StringBuilder generateCommand = new StringBuilder();

            generateCommand.Append("C=");
            switch (commandType)
            {
            case CommandTypeEnum.READ:
                generateCommand.Append("R");
                break;

            case CommandTypeEnum.WRITE:
                generateCommand.Append("W");
                break;
            }


            generateCommand.Append(",");
            generateCommand.Append("P=");
            generateCommand.Append((int)port);
            generateCommand.Append(",");
            generateCommand.Append("V=");
            generateCommand.Append(value.ToString());
            generateCommand.Append("|");

            return(generateCommand.ToString());
        }
コード例 #11
0
        private void CommandTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.CommandNameComboBox.Visibility         = Visibility.Collapsed;
            this.SingleActionNameComboBox.Visibility    = Visibility.Collapsed;
            this.ActionControlContentControl.Visibility = Visibility.Collapsed;

            if (this.CommandTypeComboBox.SelectedIndex >= 0)
            {
                string selection = (string)this.CommandTypeComboBox.SelectedItem;
                if (selection.Equals(SingleActionCommandType))
                {
                    this.Command = null;

                    this.SingleActionNameComboBox.SelectedIndex = -1;
                    this.SingleActionNameComboBox.Visibility    = Visibility.Visible;
                }
                else
                {
                    this.SingleActionNameComboBox.SelectedIndex = -1;
                    this.ActionControlContentControl.Content    = this.actionContentContainerControl = null;

                    CommandTypeEnum           commandType = EnumHelper.GetEnumValueFromString <CommandTypeEnum>((string)this.CommandTypeComboBox.SelectedItem);
                    IEnumerable <CommandBase> commands    = ChannelSession.AllEnabledCommands.Where(c => c.Type == commandType);
                    if (commandType == CommandTypeEnum.Chat)
                    {
                        commands = commands.Where(c => !(c is PreMadeChatCommand));
                    }
                    this.CommandNameComboBox.ItemsSource = commands.OrderBy(c => c.Name);
                    this.CommandNameComboBox.Visibility  = Visibility.Visible;
                }
            }
        }
コード例 #12
0
        private void CommandTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.CommandTypeComboBox.SelectedIndex >= 0)
            {
                string          typeString = (string)this.CommandTypeComboBox.SelectedItem;
                CommandTypeEnum type       = EnumHelper.GetEnumValueFromString <CommandTypeEnum>(typeString);
                if (typeString.Equals(PreMadeCommandType))
                {
                    type = CommandTypeEnum.Chat;
                }

                IEnumerable <CommandBase> commands = ChannelSession.AllCommands.Where(c => c.Type == type).OrderBy(c => c.Name);
                if (type == CommandTypeEnum.Chat)
                {
                    if (typeString.Equals(PreMadeCommandType))
                    {
                        commands = commands.Where(c => c is PreMadeChatCommand);
                    }
                    else
                    {
                        commands = commands.Where(c => !(c is PreMadeChatCommand));
                    }
                }
                this.CommandNameComboBox.ItemsSource = commands;
            }
            else
            {
                this.CommandNameComboBox.ItemsSource = null;
            }
        }
コード例 #13
0
 public PermissionsCommandBase(string name, CommandTypeEnum type, IEnumerable <string> commands, UserRole lowestAllowedRole, int cooldown, UserCurrencyRequirementViewModel currencyRequirement, UserCurrencyRequirementViewModel rankRequirement)
     : base(name, type, commands)
 {
     this.Permissions         = lowestAllowedRole;
     this.Cooldown            = cooldown;
     this.CurrencyRequirement = currencyRequirement;
     this.RankRequirement     = rankRequirement;
 }
コード例 #14
0
        public static CommandHandler Create(CommandTypeEnum commandType)
        {
            if (CommandHandlerDictionary.All.ContainsKey(commandType) == false)
            {
                throw new ArgumentOutOfRangeException("commandType");
            }

            return((CommandHandler)Activator.CreateInstance(CommandHandlerDictionary.All[commandType]));
        }
コード例 #15
0
 public void TrackCommand(CommandTypeEnum type)
 {
     if (!ChannelSession.Settings.OptOutTracking)
     {
         this.telemetryClient.TrackEvent("Command", new Dictionary <string, string> {
             { "Type", EnumHelper.GetEnumName(type) }
         });
     }
 }
コード例 #16
0
        public int ExecuteSql(CommandTypeEnum eCmdType, SqlFrag frag)
        {
            ADODB.Command sqlCmd         = GenerateCommand(eCmdType, frag);
            object        obRecsAffected = 0;

            sqlCmd.Execute(out obRecsAffected);

            return((int)obRecsAffected);
        }
コード例 #17
0
 private void TypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.TypeComboBox.SelectedIndex >= 0)
     {
         CommandTypeEnum           type     = (CommandTypeEnum)this.TypeComboBox.SelectedItem;
         IEnumerable <CommandBase> commands = ChannelSession.AllCommands.Where(c => c.Type == type && !(c is PreMadeChatCommand)).OrderBy(c => c.Name);
         this.CommandComboBox.ItemsSource = commands;
     }
 }
コード例 #18
0
 public void TrackCommand(CommandTypeEnum type, bool IsBasic)
 {
     this.TrySendEvent(() => this.telemetryClient.TrackEvent("Command", new Dictionary <string, string> {
         { "Type", EnumHelper.GetEnumName(type) }, { "Is Basic", IsBasic.ToString() }
     }));
     this.SendPlayFabEvent("Command", new Dictionary <string, object>()
     {
         { "Type", EnumHelper.GetEnumName(type) }, { "IsBasic", IsBasic.ToString() }
     });
 }
コード例 #19
0
        public Recordset CreateRecordset(SqlFrag frag, CommandTypeEnum eCmdType = CommandTypeEnum.adCmdText,
                                         CursorLocationEnum eCursorLoc          = CursorLocationEnum.adUseClient, CursorTypeEnum eCursorType = CursorTypeEnum.adOpenDynamic,
                                         LockTypeEnum eLockType = LockTypeEnum.adLockOptimistic, ExecuteOptionEnum eExecOptions              = ExecuteOptionEnum.adOptionUnspecified)
        {
            ADODB.Command SqlCmd   = GenerateCommand(eCmdType, frag);
            Recordset     rRecords = new Recordset();

            rRecords.CursorLocation = eCursorLoc;

            rRecords.Open(SqlCmd, Type.Missing, eCursorType, eLockType, (int)eExecOptions);
            return(rRecords);
        }
コード例 #20
0
        private void ParseCommand()
        {
            var words = _reader.ReadLine().Split('/')[0].Split(' ');

            if (words[0] == "push")
            {
                _commandType = CommandTypeEnum.C_PUSH;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else if (words[0] == "pop")
            {
                _commandType = CommandTypeEnum.C_POP;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else if (words[0] == "if-goto")
            {
                _commandType = CommandTypeEnum.C_IF;
                _arg1        = words[1];
            }
            else if (words[0] == "goto")
            {
                _commandType = CommandTypeEnum.C_GOTO;
                _arg1        = words[1];
            }
            else if (words[0] == "label")
            {
                _commandType = CommandTypeEnum.C_LABEL;
                _arg1        = words[1];
            }
            else if (words[0] == "function")
            {
                _commandType = CommandTypeEnum.C_FUNCTION;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else if (words[0] == "call")
            {
                _commandType = CommandTypeEnum.C_CALL;
                _arg1        = words[1];
                _arg2        = Int32.Parse(words[2]);
            }
            else if (words[0] == "return")
            {
                _commandType = CommandTypeEnum.C_RETURN;
            }
            else
            {
                _commandType = CommandTypeEnum.C_ARITHMETIC;
                _arg1        = words[0];
            }
        }
コード例 #21
0
 public void TrackCommand(CommandTypeEnum type, string details = null)
 {
     if (string.IsNullOrEmpty(details))
     {
         details = "None";
     }
     this.TrySendEvent(() => this.telemetryClient.TrackEvent("Command", new Dictionary <string, string> {
         { "Type", EnumHelper.GetEnumName(type) }, { "Details", details }
     }));
     this.SendPlayFabEvent("Command", new Dictionary <string, object>()
     {
         { "Type", EnumHelper.GetEnumName(type) }, { "Details", details }
     });
 }
コード例 #22
0
 private void CommandTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.CommandTypeComboBox.SelectedIndex >= 0)
     {
         CommandTypeEnum           commandType = EnumHelper.GetEnumValueFromString <CommandTypeEnum>((string)this.CommandTypeComboBox.SelectedItem);
         IEnumerable <CommandBase> commands    = ChannelSession.AllCommands.Where(c => c.Type == commandType);
         if (commandType == CommandTypeEnum.Chat)
         {
             commands = commands.Where(c => !(c is PreMadeChatCommand));
         }
         this.CommandNameComboBox.ItemsSource   = commands.OrderBy(c => c.Name);
         this.CommandNameComboBox.SelectedIndex = -1;
         this.CommandNameComboBox.IsEnabled     = true;
     }
 }
コード例 #23
0
        public CommandEditorWindow(CommandTypeEnum commandType, Guid id)
            : this()
        {
            switch (commandType)
            {
            case CommandTypeEnum.UserOnlyChat:
                this.editorDetailsControl = new ChatCommandEditorDetailsControl();
                this.viewModel            = new UserOnlyChatCommandEditorWindowViewModel(id);
                break;
            }
            this.DataContext = this.ViewModel = this.viewModel;

            this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); };
            this.ViewModel.EndLoadingOperationOccurred   += (sender, eventArgs) => { this.EndLoadingOperation(); };
        }
コード例 #24
0
        public CommandEditorWindow(CommandTypeEnum commandType, string name = null, IEnumerable <ActionModelBase> actions = null)
            : this()
        {
            switch (commandType)
            {
            case CommandTypeEnum.Chat:
                this.editorDetailsControl = new ChatCommandEditorDetailsControl();
                this.viewModel            = new ChatCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.Timer:
                this.editorDetailsControl = new TimerCommandEditorDetailsControl();
                this.viewModel            = new TimerCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.TwitchChannelPoints:
                this.editorDetailsControl = new TwitchChannelPointsCommandEditorDetailsControl();
                this.viewModel            = new TwitchChannelPointsCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.ActionGroup:
                this.editorDetailsControl = new ActionGroupCommandEditorDetailsControl();
                this.viewModel            = new ActionGroupCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.StreamlootsCard:
                this.editorDetailsControl = new StreamlootsCardCommandEditorDetailsControl();
                this.viewModel            = new StreamlootsCardCommandEditorWindowViewModel();
                break;

            case CommandTypeEnum.Custom:
                this.editorDetailsControl = new CustomCommandEditorDetailsControl();
                this.viewModel            = new CustomCommandEditorWindowViewModel();
                break;
            }

            if (!string.IsNullOrEmpty(name))
            {
                this.viewModel.Name = name;
            }
            this.importedActions = actions;

            this.DataContext = this.ViewModel = this.viewModel;

            this.ViewModel.StartLoadingOperationOccurred += (sender, eventArgs) => { this.StartLoadingOperation(); };
            this.ViewModel.EndLoadingOperationOccurred   += (sender, eventArgs) => { this.EndLoadingOperation(); };
        }
コード例 #25
0
 public void WritePushPop(CommandTypeEnum commandType, string segment, int index)
 {
     // string comment = "//";
     // string assembly = "";
     if (commandType == CommandTypeEnum.C_PUSH)
     {
         WritePush(segment, index);
     }
     else if (commandType == CommandTypeEnum.C_POP)
     {
         WritePop(segment, index);
     }
     else
     {
         throw new InvalidOperationException("WritePushPop() should be called only when CommandType is C_PUSH or C_POP");
     }
 }
コード例 #26
0
ファイル: SshService.cs プロジェクト: szyman/smartbian.api
        private string _getCommand(CommandTypeEnum CommandType, string scriptFileName)
        {
            switch (CommandType)
            {
            case CommandTypeEnum.TestConnection:
                return("python -V");

            case CommandTypeEnum.RunScript:
                if (String.IsNullOrEmpty(scriptFileName))
                {
                    return("");
                }
                return("python " + scriptFileName);

            default:
                return("");
            }
        }
コード例 #27
0
        /// <summary>
        /// 返回执行结果。
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        public static object ExecuteScalar(string strSql, CommandTypeEnum sqlType, ParameterCollection pc)
        {
            Stopwatch sw     = new Stopwatch();
            object    result = 0;

            sw.Start();
            result = DbUtil.Current.IData.ExecuteScalar(strSql, sqlType, pc);

            sw.Stop();
            LogUtil.Debug("数据库操作执行完毕,共耗时(毫秒):" + sw.ElapsedMilliseconds);

            if (ConfigUtil.GetSimpleTraceContent() == "false")
            {
                LogUtil.Debug(strSql);
            }


            return(result);
        }
コード例 #28
0
        /// <summary>
        /// Get Records
        /// </summary>
        /// <param name="query"></param>
        /// <param name="source"></param>
        /// <param name="cursorType"></param>
        /// <param name="lockType"></param>
        /// <param name="options"></param>
        /// <param name="cursorLocation"></param>
        /// <returns>RecordSet</returns>
        public Recordset GetRecords(string query,
                                    DataSource source,
                                    CursorTypeEnum cursorType         = CursorTypeEnum.adOpenDynamic,
                                    LockTypeEnum lockType             = LockTypeEnum.adLockOptimistic,
                                    CommandTypeEnum options           = CommandTypeEnum.adCmdText,
                                    CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient)
        {
            _connection = new Connection();

            var cnStr = GetConnectionString(source);

            _connection.Open(cnStr, null, null, 0);

            _recordSet = new Recordset {
                CursorLocation = cursorLocation
            };

            _recordSet.Open(query, _connection, cursorType, lockType, (int)options);
            return(_recordSet);
        }
コード例 #29
0
ファイル: SshService.cs プロジェクト: szyman/smartbian.api
        public String executeCommand(SshClient client, CommandTypeEnum commandType, string scriptFileName)
        {
            try
            {
                var commandText = this._getCommand(commandType, scriptFileName);
                if (String.IsNullOrEmpty(commandText))
                {
                    return("Empty");
                }

                SshCommand command = client.CreateCommand(commandText);
                command.Execute();

                return(command.Result + command.Error);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #30
0
        public new object GetDynamicParameters()
        {
            RuntimeDefinedParameterDictionary dynamicParams = null;

            if (commandTypeSet)
            {
                CommandTypeEnum type = CommandType;
                switch (type)
                {
                case CommandTypeEnum.CompleteSqlDBSync:
                    commandCmdlet = new CompleteCommandCmdlet(this.MyInvocation);
                    break;

                case CommandTypeEnum.CancelMongoDB:
                    commandCmdlet = new MongoDbObjectCommandCmdlet(this.MyInvocation, CommandTypeEnum.CancelMongoDB);
                    break;

                case CommandTypeEnum.RestartMongoDB:
                    commandCmdlet = new MongoDbObjectCommandCmdlet(this.MyInvocation, CommandTypeEnum.RestartMongoDB);
                    break;

                case CommandTypeEnum.FinishMongoDB:
                    commandCmdlet = new MongoDbObjectCommandCmdlet(this.MyInvocation, CommandTypeEnum.FinishMongoDB);
                    break;

                case CommandTypeEnum.CompleteSqlMiSync:
                    commandCmdlet = new CompleteMiSyncCommandCmdlet(this.MyInvocation);
                    break;

                default:
                    throw new PSArgumentException();
                }

                dynamicParams = commandCmdlet.RuntimeDefinedParams;
            }

            return(dynamicParams);
        }
コード例 #31
0
ファイル: BattleEngine.cs プロジェクト: sakseichek/homm
        public void ProcessMouseClick(int x, int y, MouseButtons buttons, bool isDoubleClick, CommandTypeEnum cmdType,
            Heroes.Core.Spell currentSpell)
        {
            if (buttons == MouseButtons.Left)
            {
                if (isDoubleClick)
                {
                    #region Mouse Double Click
                    if (_disableControl) return;

                    Cell cell = _battleTerrain.FindCell(x, y);
                    if (cell == null) return;

                    if (cmdType == CommandTypeEnum.Move)
                    {
                        // move
                        if (cell.Equals(_turn._currentCharacter._cell)) return;     // cannot move to self
                        if (!cell.HasPassability()) return;    // cannot move to cell if has life character

                        // get path
                        ArrayList path = new ArrayList();
                        _battleTerrain.FindPathAdjBest(_turn._currentCharacter._cell, cell, false, false, out path);

                        // cannot move if destination is more than movement range
                        if (path.Count > _turn._currentCharacter._speed) return;

                        // set flag to disable control
                        _disableControl = true;

                        // reset defend and wait
                        Heroes.Core.Battle.Characters.Armies.Army army
                            = (Heroes.Core.Battle.Characters.Armies.Army)_turn._currentCharacter;
                        army._isWait = false;
                        army._isDefend = false;

                        // set movement animation
                        Action action = Action.CreateMoveAction(_turn._currentCharacter, path);
                        _actions.Add(action);

                        // set dest cell
                        SetDestCell(_turn._currentCharacter, cell);
                    }
                    else if (cmdType == CommandTypeEnum.AttackLeft
                        || cmdType == CommandTypeEnum.AttackRight
                        || cmdType == CommandTypeEnum.AttackLowerLeft
                        || cmdType == CommandTypeEnum.AttackLowerRight
                        || cmdType == CommandTypeEnum.AttackUpperLeft
                        || cmdType == CommandTypeEnum.AttackUpperRight)
                    {
                        // attack
                        if (cell.Equals(_turn._currentCharacter._cell)) return;     // cannot attack self
                        if (cell._character == null) return;    // cannot attack if don't has character
                        if (cell._character._isDead) return;    // cannot attack dead character

                        StandardCharacter targetCharacter = (StandardCharacter)cell._character;

                        // get next cell
                        {
                            CellPartEnum direction = GetAttackCellDirection(cmdType);

                            cell = _battleTerrain.GetNextCell(cell, direction);
                            if (cell == null) return;
                        }

                        // get path
                        ArrayList path = new ArrayList();
                        _battleTerrain.FindPathAdjBest(_turn._currentCharacter._cell, cell, false, false, out path);
                        // cannot move if destination is more than movement range
                        if (path != null && path.Count > _turn._currentCharacter._speed) return;

                        // set flag to disable control
                        _disableControl = true;

                        // commit damage and do animation
                        CellPartEnum attackDirection = GetAttackCommandDirection(cmdType);
                        SetAttackNAnimate(_turn._currentCharacter, targetCharacter, attackDirection, path);

                        // set dest cell
                        SetDestCell(_turn._currentCharacter, cell);
                    }
                    else if (cmdType == CommandTypeEnum.RangeAttack)
                    {
                        // range attack
                        if (cell._character == null) return;    // cannot attack if don't has character
                        if (cell._character._isDead) return;    // cannot attack dead character

                        StandardCharacter targetCharacter = (StandardCharacter)cell._character;

                        // set flag to disable control
                        _disableControl = true;

                        CellPartEnum attackDirection = BattleTerrain.FindDirection(_turn._currentCharacter._cell.GetCenterPoint(),
                            cell._character._cell.GetCenterPoint());

                        SetRangeAttackNAnimate(_turn._currentCharacter, targetCharacter, attackDirection, cell);
                    }
                    else if (cmdType == CommandTypeEnum.Spell)
                    {
                        StandardCharacter targetCharacter = (StandardCharacter)cell._character;

                        Heroes.Core.Battle.Characters.Hero hero = FindHero(_turn._currentCharacter._heroId);
                        if (hero == null) return;
                        if (!hero._canCastSpell) return;

                        // set spell
                        hero._currentSpell = currentSpell;

                        if (hero._spellPointLeft < hero._currentSpell._cost)
                        {
                            // no enough spell points
                            return;
                        }

                        if (hero._currentSpell._targetType == SpellTargetTypeEnum.Enermy)
                        {
                            // cannot damage ally
                            if (targetCharacter._playerId == hero._playerId) return;
                        }
                        else if (hero._currentSpell._targetType == SpellTargetTypeEnum.Ally)
                        {
                            // cannot cast on enermy
                            if (targetCharacter._playerId != hero._playerId) return;
                        }

                        // reduce sp
                        hero._spellPointLeft -= hero._currentSpell._cost;
                        hero._originalHero._spellPointLeft = hero._spellPointLeft;

                        // can only cast once per round
                        hero._canCastSpell = false;

                        // set damage
                        if (hero._currentSpell._isDamage)
                        {
                            SetSpellDamage(hero._currentSpell, targetCharacter);
                        }
                        else
                        {
                            SetSpellEffect(hero._currentSpell, targetCharacter);
                        }

                        // set movement animation
                        {
                            ArrayList targets = new ArrayList();
                            targets.Add(cell._character);

                            Heroes.Core.Battle.Characters.Spells.Spell spell =
                                (Heroes.Core.Battle.Characters.Spells.Spell)_spells[hero._currentSpell._id];
                            spell._cell = _battleTerrain._cells[0, 0];
                            spell._destCell = cell;
                            spell._command = _inputCommand;
                            _spellActions.Add(spell);

                            Action action = Action.CreateCastSpellAction(hero, spell,
                                CellPartEnum.CenterRight, targets, cell);
                            _actions.Add(action);
                        }
                    }
                    #endregion
                }
                else
                {
                    #region Mouse Click
                    _battleTerrain.ClearHover();

                    Cell cell = _battleTerrain.FindCell(x, y);
                    if (cell == null) return;
                    if (cell.Equals(_turn._currentCharacter._cell)) return;     // click on self

                    if (cmdType == CommandTypeEnum.Move)
                    {
                        // move
                        if (_disableControl) return;
                        if (!cell.HasPassability()) return;    // cannot move to cell if has character

                        // get path
                        ArrayList path = new ArrayList();
                        _battleTerrain.FindPathAdjBest(_turn._currentCharacter._cell, cell, false, false, out path);
                        //_battleTerrain.FindPath(_turn._currentCharacter._cell, cell, path);

                        // Show path
                        if (path != null)
                        {
                            foreach (Cell cellPath in path)
                            {
                                cellPath._isHover = true;
                            }
                        }
                    }
                    else if (cmdType == CommandTypeEnum.AttackLeft
                        || cmdType == CommandTypeEnum.AttackRight
                        || cmdType == CommandTypeEnum.AttackLowerLeft
                        || cmdType == CommandTypeEnum.AttackLowerRight
                        || cmdType == CommandTypeEnum.AttackUpperLeft
                        || cmdType == CommandTypeEnum.AttackUpperRight)
                    {
                        // attack
                        if (_disableControl) return;
                        if (cell._character == null) return;    // cannot move to cell if has character
                        if (cell._character._isDead) return;    // cannot attack dead character

                        StandardCharacter targetCharacter = (StandardCharacter)cell._character;

                        // get next cell
                        {
                            CellPartEnum direction = GetAttackCellDirection(cmdType);

                            cell = _battleTerrain.GetNextCell(cell, direction);
                            if (cell == null) return;
                        }

                        // get path
                        ArrayList path = new ArrayList();
                        _battleTerrain.FindPathAdjBest(_turn._currentCharacter._cell, cell, false, false, out path);

                        // Show path
                        if (path != null)
                        {
                            foreach (Cell cellPath in path)
                            {
                                cellPath._isHover = true;
                            }
                        }
                    }
                    #endregion
                }
            }
            else if (buttons == MouseButtons.Right)
            {
            }
        }
コード例 #32
0
ファイル: BattleEngine.cs プロジェクト: sakseichek/homm
        private CellPartEnum GetAttackCommandDirection(CommandTypeEnum cmdType)
        {
            CellPartEnum direction = CellPartEnum.Center;
            {
                if (cmdType == CommandTypeEnum.AttackLeft)
                    direction = CellPartEnum.CenterLeft;
                else if (cmdType == CommandTypeEnum.AttackRight)
                    direction = CellPartEnum.CenterRight;
                else if (cmdType == CommandTypeEnum.AttackLowerLeft)
                    direction = CellPartEnum.LowerLeft;
                else if (cmdType == CommandTypeEnum.AttackLowerRight)
                    direction = CellPartEnum.LowerRight;
                else if (cmdType == CommandTypeEnum.AttackUpperLeft)
                    direction = CellPartEnum.UpperLeft;
                else if (cmdType == CommandTypeEnum.AttackUpperRight)
                    direction = CellPartEnum.UpperRight;
            }

            return direction;
        }
コード例 #33
0
 /// <summary>
 /// Executes the command reader.
 /// </summary>
 /// <param name="sCommand">The s command.</param>
 /// <param name="asParams">As params.</param>
 /// <param name="atParamTypes">At param types.</param>
 /// <param name="aoValues">The ao values.</param>
 /// <param name="nRowsAffected">The n rows affected.</param>
 /// <param name="oTable">The o table.</param>
 /// <param name="eType">Type of the e.</param>
 /// <returns></returns>
 public int ExecuteCommandReader(string sCommand, string[] asParams, DbType[] atParamTypes, object[] aoValues, out int nRowsAffected, ref DataTable oTable, CommandTypeEnum eType)
 {
     return ExecuteCommand(2, sCommand, asParams, atParamTypes, aoValues, out nRowsAffected, ref oTable, eType);
 }
コード例 #34
0
 public int ExecuteCommandScalar(string sCommand, string[] asParams, DbType[] atParamTypes, object[] aoValues, out int nRowsAffected, CommandTypeEnum eType)
 {
     DataTable oDataTable = new DataTable();
     return ExecuteCommand(1, sCommand, asParams, atParamTypes, aoValues, out nRowsAffected, ref oDataTable, eType);
 }
コード例 #35
0
        /// <summary>
        /// Executes a parameterized command 
        /// </summary>
        /// <param name="sCommand">parameterized query or stored procedure name</param>
        /// <param name="asParams">parameter names</param>
        /// <param name="atParamTypes">parameter types</param>
        /// <param name="anParamSizes"></param>
        /// <param name="aoValues">values</param>
        /// <returns>integer result of the query</returns>
        private int ExecuteCommand(int nMode, string sCommand, string[] asParams, DbType[] atParamTypes, object[] aoValues, out int nRowsAffected, ref DataTable oTable, CommandTypeEnum eType)
        {
            if (m_oConn != null)
            {
                if (m_oConn.State == ConnectionState.Open)
                {
                    using (SqlCommand oCmd = new SqlCommand())
                    {
                        oCmd.CommandText = sCommand;
                        switch (eType)
                        {
                            case CommandTypeEnum.StoredProcedure:
                                oCmd.CommandType = CommandType.StoredProcedure;
                                break;
                            case CommandTypeEnum.Text:
                                oCmd.CommandType = CommandType.Text;
                                break;
                        }

                        for (int i = 0; i < asParams.Length; i++)
                        {
                            SqlParameter oParam = new SqlParameter(asParams[i], aoValues[i]);
                            oParam.DbType = atParamTypes[i];
                            if (atParamTypes[i] == DbType.Binary)
                            {
                                oParam.SqlDbType = SqlDbType.Image;
                            }
                            //if (anParamSizes[i] != 0)
                            //{
                            //    oParam.Size = anParamSizes[i];
                            //}
                            oCmd.Parameters.Add(oParam);
                        }
                        //add return value parameter
                        SqlParameter oRetParam = new SqlParameter("RETURN_VALUE", DBNull.Value);
                        oRetParam.Direction = ParameterDirection.ReturnValue;

                        oCmd.Parameters.Add(oRetParam);

                        oCmd.Connection = m_oConn;
                        if (m_oTrans != null)
                        {
                            oCmd.Transaction = m_oTrans;
                        }

                        nRowsAffected = 0;
                        switch (nMode)
                        {
                            case 0: //NonQuery
                                nRowsAffected = oCmd.ExecuteNonQuery();
                                break;
                            case 1: //Scalar
                                nRowsAffected = oCmd.ExecuteNonQuery();
                                break;
                            case 2: //Reader
                                SqlDataAdapter oAdapter = new SqlDataAdapter(oCmd);
                                if (oTable != null)
                                {
                                    oAdapter.Fill(oTable);
                                    nRowsAffected = 0;
                                }
                                break;
                        }

                        return Convert.ToInt32(oCmd.Parameters["RETURN_VALUE"].Value);
                    }
                }
                else throw new DataException("Connection not open");
            }
            else throw new DataException("Connection not open");
        }
コード例 #36
0
ファイル: BaseCallback.cs プロジェクト: GavinHome/REVOLUTION
 public static void NoticeObservers(CommandTypeEnum typeEnum, JObject jobj)
 {
 }
コード例 #37
0
 public void Subscribe(CommandTypeEnum type, Action<JObject> action)
 {
     if (type == CommandTypeEnum.Connect)
     {
         SubscriptionEvent.DoConnect(action);
     }
     else if (type == CommandTypeEnum.Conversation)
     {
         SubscriptionEvent.DoConversation(action);
     }
     else if (type == CommandTypeEnum.HistoryMessage)
     {
         SubscriptionEvent.DoHistoryMessage(action);
     }
     else if (type == CommandTypeEnum.Receive)
     {
         SubscriptionEvent.DoReceive(action);
     }
     else if (type == CommandTypeEnum.SendMessage)
     {
         SubscriptionEvent.DoSendMessage(action);
     }
     else if (type == CommandTypeEnum.CreateConversation)
     {
         SubscriptionEvent.DoCreateConversation(action);
     }
     else if (type == CommandTypeEnum.StartDiscussion)
     {
         SubscriptionEvent.DoStartDiscussion(action);
     }
     else if (type == CommandTypeEnum.ExitAccount)
     {
         SubscriptionEvent.DoExitAccount(action);
     }
     else if (type == CommandTypeEnum.Exception)
     {
         SubscriptionEvent.DoExceptionExecute(action);
     }
     else if (type == CommandTypeEnum.GetDiscussionInfo)
     {
         SubscriptionEvent.DoGetDiscussionInfo(action);
     }
 }