Пример #1
0
        private void TakeCommands()
        {
            do
            {
                CurrentCommand = Console.ReadLine();

                switch (CurrentCommand.ToLower())
                {
                case "quit":
                    break;

                case "edit":
                    RunNewEditor();
                    break;

                case "save":
                    SaveCurrentFile();
                    break;

                case "currentfile":
                    PrintCurrentFile();
                    break;

                case "clear":
                    ClearScreen();
                    break;

                default:
                    Console.Write("\nCommand not understood, try:\nCurrentFile\nSave\nQuit\nEdit\n\n>");
                    break;
                }
            }while (CurrentCommand.ToLower() != "quit");
        }
Пример #2
0
        protected List <T> FillToListTest <T>()
        {
            DateTime start = DateTime.Now;

            IDataReader dataReader = CurrentCommand.ExecuteReader();

            DateTime end1 = DateTime.Now;

            Debug.Print(String.Format("Elapsed: {0} miliseconds.", (end1 - start).TotalMilliseconds));

            List <T> result = CBO.Instance.FillCollection <T>(dataReader);

            DateTime end2 = DateTime.Now;

            Debug.Print(String.Format("Elapsed: {0} miliseconds.", (end2 - start).TotalMilliseconds));

            if (!dataReader.IsClosed)
            {
                dataReader.Close();
            }

            dataReader.Dispose();

            return(result);
        }
Пример #3
0
 private void HandleEnterKey()
 {
     if (!_inMultiLineEdit)
     {
         if (!CurrentCommand.IsNullOrEmpty())
         {
             if (!this.IsCommandComplete)
             {
                 _inMultiLineEdit = true;
                 ShowPromptContinuation();
                 return;
             }
             ProcessCurrentCommand(CurrentCommand);
         }
         ShowPrompt();
     }
     else
     {
         string curLine = GetLastLine(CurrentCommand);
         if (curLine.IsNullOrEmptyOrWhiteSpace())
         {
             _inMultiLineEdit = false;
             ProcessCurrentCommand(CurrentCommand);
             ShowPrompt();
         }
         else
         {
             ShowPromptContinuation();
         }
     }
 }
Пример #4
0
    private void FixedUpdate()
    {
        m_Status = CheckStatus();

        if (m_Status != TankStatus.Normal)
        {
            if (CurrentCommand != null && !CurrentCommand.IsBlocking)
            {
                m_CommandQueue.Remove(CurrentCommand);
            }
            else if (CurrentCommand != null && CurrentCommand.IsRunning && CurrentCommand.IsFinished())
            {
                m_CommandQueue.Remove(CurrentCommand);
            }
        }
        else if (CurrentCommand != null)
        {
            if (!CurrentCommand.IsRunning) // Execute the first command.
            {
                CurrentCommand.Execute();
            }
            else if (CurrentCommand.IsFinished()) // Current command finished, switch to next.
            {
                m_CommandQueue.Remove(CurrentCommand);
            }
        }
    }
Пример #5
0
 private void dumpSourceFileFolderDialogBtn_Click(object sender, EventArgs e)
 {
     var selectedItem = dumpsourceProviderBox.SelectedItem.ToString();
     if (selectedItem == SourceProvider.contentPath ||
         selectedItem == SourceProvider.filePath)
     {
         using (CommonOpenFileDialog dialog = new CommonOpenFileDialog())
         {
             //                        dialog.IsFolderPicker = true;
             if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
             {
                 dumpsourcePathToPOBox.Text = dialog.FileName;
                 CurrentCommand?.RefreshCommandBox(commandBox);
             }
         }
     }
     else if (selectedItem == SourceProvider.dirPath)
     {
         using (var fbd = new FolderBrowserDialog())
         {
             if (fbd.ShowDialog() == DialogResult.OK)
             {
                 dumpsourcePathToPOBox.Text = fbd.SelectedPath;
                 CurrentCommand?.RefreshCommandBox(commandBox);
             }
         }
     }
 }
Пример #6
0
        protected T FillToObject <T>()
        {
            try
            {
                if (typeof(T).FullName.StartsWith("System."))
                {
                    var tmpResult = CurrentCommand.ExecuteScalar();

                    if (tmpResult == null || Convert.IsDBNull(tmpResult))
                    {
                        return(default(T));
                    }

                    return((T)Convert.ChangeType(tmpResult, typeof(T)));
                }

                IDataReader dataReader = CurrentCommand.ExecuteReader();

                var result = CBO.Instance.FillObject <T>(dataReader);

                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }

                dataReader.Dispose();

                return(result);
            }
            catch (Exception ex)
            {
                throw new ManagedException(ex.Message, false);
            }
        }
Пример #7
0
 public override void AbortTask()
 {
     foreach (Command command in CommandQueue)
     {
         command.Abort();
     }
     CurrentCommand?.Abort();
     Finish(false);
 }
Пример #8
0
 protected void StoreCommandHeaders(IHeadersAccessor headersAccessor)
 {
     foreach (var key in CurrentCommand.AllContextKeys)
     {
         headersAccessor.Add(key, CurrentCommand.GetContextData(key));
     }
     headersAccessor.Add(ChangesetCommonHeaders.Command, CurrentCommand);
     headersAccessor.Add(ChangesetCommonHeaders.Timestamp, DateTime.UtcNow);
     OnStoreCommandHeaders(headersAccessor);
 }
Пример #9
0
 protected object ExecuteScalar(string commandText, params object[] paramValues)
 {
     try
     {
         CreateCommand(commandText, paramValues);
         return(CurrentCommand.ExecuteScalar());
     }
     catch (Exception ex)
     {
         throw new ManagedException(ex.Message, false, commandText, paramValues);
     }
 }
Пример #10
0
 private void dumpsourceProviderBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     ComboBox box = sender as ComboBox;
     if (box?.SelectedItem.ToString() == SourceProvider.webServer)
     {
         dumpSourceFileFolderDialogBtn.Enabled = false;
     }
     else
     {
         dumpSourceFileFolderDialogBtn.Enabled = true;
     }
     CurrentCommand?.RefreshCommandBox(commandBox);
 }
Пример #11
0
 public void TextInputCommand(KeyEventArgs args)
 {
     if (args != null && args.Key == Key.Enter)
     {
         ExecuteCurrentCommand();
     }
     if (args != null && args.Key == Key.Back)
     {
         if (CurrentCommand.Length > 0)
         {
             CurrentCommand = CurrentCommand.Substring(0, CurrentCommand.Length - 1);
         }
     }
 }
Пример #12
0
 public void BackLine()
 {
     if (CurrentCommand.Length <= 0)
     {
         return;
     }
     if (m_CaretIndex == 0)
     {
         return;
     }
     m_CaretIndex--;
     CurrentCommand = CurrentCommand.Remove(m_CaretIndex, 1);
     IsDirty        = true;
 }
        public MainViewModel()
        {
            _dataGrid = new ObservableCollection <DataGrid>();
            _dataGrid = dataGridService.GetCurrent();

            CurrentCommand      = new CurrentCommand(this);
            ReservationCommand  = new ReservationCommand(this);
            HistoryCommand      = new HistoryCommand(this);
            DeleteCommand       = new DeleteCommand(this);
            UpdateCommand       = new UpdateCommand(this);
            AvaibleRoomsCommand = new AvaibleRoomsCommand(this);

            SetButtons(true, false, false, true, true);
        }
        protected virtual void OnExecute()
        {
            using (Traffic.AcquireLock())
            {
                Traffic.Clear();
            }
            ErrorText = String.Empty;

            if (CurrentCommand != null)
            {
                var commandDocument = CurrentCommand.GetCommand();
                EventAggregatorContext.Current.GetEvent <SendDataEvent>().Publish(new SendDataEventArgs(commandDocument.ToString(), this, CurrentCommand.Cookie));
            }
        }
        public ConsoleEntry PreviousCommand()
        {
            ConsoleEntry cmd;

            if (CurrentCommand != null)
            {
                cmd            = CurrentCommand?.Value;
                CurrentCommand = CurrentCommand.PreviousOrLast();
            }
            else
            {
                CurrentCommand = CommandsCache.Last;
                cmd            = CurrentCommand?.Value;
            }

            return(cmd);
        }
        public ConsoleEntry NextCommand()
        {
            ConsoleEntry cmd;

            if (CurrentCommand != null)
            {
                cmd            = CurrentCommand?.Value;
                CurrentCommand = CurrentCommand.NextOrFirst();
            }
            else
            {
                CurrentCommand = CommandsCache.First;
                cmd            = CurrentCommand?.Value;
            }

            return(cmd);
        }
        public PodRacerRaceState Copy()
        {
            PodRacerRaceState copy;

            copy = new PodRacerRaceState(PodRacer.Copy())
            {
                CurrentCommand             = CurrentCommand.Copy(),
                ShieldPenaltyRoundsCounter = ShieldPenaltyRoundsCounter,
                HasBoosted         = HasBoosted,
                Failed             = Failed,
                CurrentCheckPoint  = CurrentCheckPoint.Copy(),
                RoundsFinished     = RoundsFinished,
                CheckPointsReached = CheckPointsReached
            };

            return(copy);
        }
Пример #18
0
        bool IKeyboardReader.KeyIsPressed()
        {
            if (UnityEngine.Input.GetKeyDown(KeyCode.Backspace))
            {
                CurrentCommand = CurrentCommand.Substring(0, CurrentCommand.Length - 1);
                Content        = Content.Substring(0, Content.Length - 1);
            }
            else if (UnityEngine.Input.GetKeyDown(KeyCode.Return))
            {
                WriteCommand("\n");
            }
            else
            {
                WriteCommand(UnityEngine.Input.inputString);
            }

            return(true);
        }
Пример #19
0
        public void ParseInputLine(string line)
        {
            Console.WriteLine($"< '{line}'");

            line = line.Trim();

            if (line.StartsWith("notify") || line.StartsWith("channel"))
            {
                ReceivedEvcent(line);
                return;
            }

            if (CurrentCommand != null)
            {
                if (line.StartsWith("error"))
                {
                    Response = Response.Trim();

                    if (line.EndsWith("ok"))
                    {
                        CurrentCommand.Invoke(null, Response);
                    }
                    else
                    {
                        Console.WriteLine($"Command did not execute successfully (last line '{line}'). Leftover response: {Response}");
                        CommandException = new TeamspeakCommandException($"Command did not execute successfully (last line '{line}'). Leftover response: {Response}");
                        CurrentCommand.Invoke(CommandException, Response);
                    }

                    Response       = "";
                    CurrentCommand = null;
                    if (CommandCallbacks.Count > 0)
                    {
                        (string cmd, Action <Exception, string> callback) = CommandCallbacks.Dequeue();
                        DoSendCommand(cmd, callback);
                    }
                }
                else
                {
                    Response += $"{line}\n\r";
                }
            }
        }
Пример #20
0
        protected void FillToCsv(ref string tableName)
        {
            try
            {
                IDataReader dataReader = CurrentCommand.ExecuteReader();

                CBO.Instance.FillToCsv(dataReader, String.IsNullOrEmpty(tableName), ref tableName);

                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }

                dataReader.Dispose();
            }
            catch (Exception ex)
            {
                throw new ManagedException(ex.Message, false);
            }
        }
Пример #21
0
        /**
         * UPDATE & COMMON METHODS
         */
        public override void Update(float frameDelta)
        {
            UpdateActions(frameDelta);

            if (Controller == null)
            {
                AutoSetController();
            }
            Controller.Update();
            //Controller should target and trigger actions.

            if (CurrentCommand != null && CurrentCommand.Action != null)
            {
                //Once action is set and targeted, agent is responsible for carrying it out
                CurrentCommand.TryExecute();
                SetAnimationStates();
            }

            Mobility?.Update(frameDelta);
        }
Пример #22
0
        protected int ExecuteNoneQuery()
        {
            try
            {
                int resultAffected = CurrentCommand.ExecuteNonQuery();
                if (UseCaching && !String.IsNullOrEmpty(CRUDTableName) &&
                    (CurrentCommand.CommandText.ToLower().EndsWith("insert") ||
                     CurrentCommand.CommandText.ToLower().EndsWith("update") ||
                     CurrentCommand.CommandText.ToLower().EndsWith("delete")))
                {
                    ClearCg(CRUDTableName.GetHashCode().ToString());
                }

                return(resultAffected);
            }
            catch (Exception ex)
            {
                throw new ManagedException(ex.Message, false);
            }
        }
Пример #23
0
        /// <summary>Commits current command and saves changes into history</summary>
        public void Commit(string caption)
        {
            AssertCurrentCommand();
            log.Add("    [Commit]");

            Command commitedCommand = PopCommand();

            if (commitedCommand.HasChanges)
            {
                commitedCommand.Commit(caption);

                if (IsAnyParentCommand())
                {                       // this is nested command - merge with parent
                    CurrentCommand.Merge(commitedCommand);
                }
                else
                {                       // put command into the history
                                        // remove all redo records
                    int count = history.Count - currentPosition - 1;
                    history.RemoveRange(currentPosition + 1, count);

                    // add command to history
                    if (commitedCommand.Visible)
                    {
                        history.Add(commitedCommand);
                        currentPosition++;
                        TruncateHistory();
                    }
                    else
                    {
                        // merge with previous command
                        if (currentPosition >= 0)
                        {
                            history[currentPosition].Merge(commitedCommand);
                        }
                    }

                    OnCommandDone(commitedCommand, CommandDoneType.Commit);
                }
            }
        }
Пример #24
0
        protected List <T> FillToList <T>()
        {
            try
            {
                IDataReader dataReader = CurrentCommand.ExecuteReader();

                List <T> result = CBO.Instance.FillCollection <T>(dataReader);

                if (!dataReader.IsClosed)
                {
                    dataReader.Close();
                }

                dataReader.Dispose();

                return(result);
            }
            catch (Exception ex)
            {
                throw new ManagedException(ex.Message, false);
            }
        }
Пример #25
0
 public void ResetCurrentCommand() =>
 CurrentCommand?.Reset();
 private bool ActionIsComplete()
 {
     return(CurrentCommand.IsComplete());
 }
Пример #27
0
 public void UseCommand(params BattleEntity[] victims)
 {
     CurrentCommand.PerformAction(this, victims);
     EndTurn();
 }
Пример #28
0
            public void AssertSafeToSwitchProcessingContext()
            {
                if (!ProcessingOrderedOptions || AllOrderedOptionsProcessed)
                {
                    ProcessedClusteredOptions         = null;
                    NextArgumentIsForClusteredOptions = false;
                    return;
                }

                logger.LogDebug("Not all ordered options where processed before switching to a new context. The current context is '{ctx}' with {amount} of options left unprocessed", CurrentCommand.ToString(), orderedOptions.Count);

                foreach (var unprocessedOption in orderedOptions)
                {
                    logger.LogDebug("{Option} was unprocessed", unprocessedOption);
                }

                throw new InvalidOperationException("Not all ordered options where processed before switching to another option/command context!");
            }
 private void InitializeNewCommand()
 {
     CurrentCommand.Begin();
 }
Пример #30
0
        public StoryBoardCommandString(StoryBoardCommandString last, string commandStr, int level, out bool failed)
        {
            failed = false;
            if (!IsInvalidCommand(commandStr))
            {
                Level = level;
                if (last == null)
                {
                    Parent = null;
                }
                else if (last.Parent == null || last.Level == 0)
                {
                    Parent        = last;
                    ParentCommand = last.CurrentCommand;
                }
                else if (last.Level < Level)
                {
                    Parent            = last;
                    ParentCommand     = last.CurrentCommand;
                    IsFirstSubCommand = true;
                }
                else if (last.Level == Level)
                {
                    Parent        = last.Parent;
                    ParentCommand = last.ParentCommand;
                }
                else if (last.Level > level)
                {
                    Parent        = last.Parent.Parent;
                    ParentCommand = last.Parent.ParentCommand;
                }
                var curTmp = StoryBoardTools.GetEventClassByString(commandStr);
                if (curTmp != null)
                {
                    CurrentCommand = curTmp;
                }
                else
                {
                    CurrentCommand = new StoryBoardMainCommand();
                }
                CurrentCommand.Parse(commandStr);
                if (CurrentCommand is StoryBoardMainCommand mainCommand)
                {
                    if (mainCommand.Resource is null)
                    {
                        failed = true;
                    }
                }
                if (Parent != null)
                {
                    if (ParentCommand is null)
                    {
                        var tmp = StoryBoardTools.GetEventClassByString(Parent.Command);
                        if (tmp != null)
                        {
                            ParentCommand = tmp;
                        }
                        else
                        {
                            ParentCommand = new StoryBoardMainCommand();
                        }
                    }

                    ParentCommand.Parse(Parent.Command);
                    if (CurrentCommand is IStoryBoardSubCommand subCmd)
                    {
                        ParentCommand.SubCommands.Add(subCmd);
                        subCmd.ParentCommand = ParentCommand;
                    }
                }
                Command = commandStr;
            }
            else
            {
                failed  = true;
                Command = null;
            }
        }