public void Maximize(IHistoryItem toMaximizedTarget) { if (!Captured.IsEmpty()) { toMaximizedTarget.Captured = Captured.ToMaximized(); } }
protected override void Context() { base.Context(); _macroCommand = A.Fake <IMacroCommand>(); _macroCommand.Description = "_macroCommand"; _macroCommand.Visible = true; _subCommand1 = A.Fake <IMacroCommand>(); _subCommand1.Description = "_subCommand1"; _subCommand2 = A.Fake <ICommand>(); _subCommand2.Description = "_subCommand2"; _subCommand3 = A.Fake <ICommand>(); _subCommand3.Description = "_subCommand3"; _subCommand1.Visible = true; _subCommand2.Visible = false; _subCommand3.Visible = false; _subCommand11 = A.Fake <ICommand>(); _subCommand11.Description = "_subCommand11"; _subCommand11.Visible = false; _subCommand12 = A.Fake <IMacroCommand>(); _subCommand12.Description = "_subCommand12"; _subCommand12.Visible = true; _subCommand121 = A.Fake <ICommand>(); _subCommand121.Description = "_subCommand121"; _subCommand121.Visible = false; _subCommand122 = A.Fake <ICommand>(); _subCommand122.Description = "_subCommand122"; _subCommand122.Visible = true; _historyItem = A.Fake <IHistoryItem>(); A.CallTo(() => _historyItem.Command).Returns(_macroCommand); A.CallTo(() => _macroCommand.All()).Returns(new[] { _subCommand1, _subCommand2, _subCommand3 }); A.CallTo(() => _subCommand1.All()).Returns(new[] { _subCommand11, _subCommand12 }); A.CallTo(() => _subCommand12.All()).Returns(new[] { _subCommand121, _subCommand122 }); }
private void saveNewHistoryItem(IHistoryItem historyItem, int sequence, ISession session) { var metaData = _historyItemMetaDataMapper.MapFrom(historyItem); metaData.Sequence = sequence; _historyItemMetaDataRepository.Save(metaData, session); }
public void PopStack(IHistoryItem action = null) { _stacks.Pop(); if (action != null) { AddHistoryItem(action); } }
public void PopStack(IHistoryItem action = null) { _stacks.Pop(); if (action != null) { AddHistoryItem(action); } }
private void GetDataFromTfs(int?lastId, int itemSize, bool isFullCall = false) { IEnumerable <TFSCore.IHistoryItem> historyItems; Debug.WriteLine($"Getting HistoryItems from TFS {lastId} {itemSize}"); historyItems = Tfs.GetHistory(TeamProject.ServerItem, lastId, itemSize); IList <TFSCore.IHistoryItem> modifiedHistoryItems = new List <IHistoryItem>(); foreach (HistoryItem historyItem in historyItems) { if (CancellationTokenSource.IsCancellationRequested) { return; } modifiedHistoryItems.Add(HistoryItems.AddOrUpdateWithoutNotification(historyItem, (item, item1) => item.ChangeSetId == item1.ChangeSetId, (items, index, newItem) => { // make sure we keep our "ExtendedProperties" IHistoryItem.CopyTo(items[index], newItem); })); } HistoryItems.NotifyReset(); Debug.WriteLine($"Got {historyItems.Count()} HistoryItems from TFS"); SaveDataToCache(true, false); Debug.WriteLine($"Resolving Workitems for {historyItems.Count()}"); foreach (HistoryItem historyItem in modifiedHistoryItems) { if (CancellationTokenSource.IsCancellationRequested) { return; } foreach (WorkItem workItem in historyItem.WorkItems) { if (CancellationTokenSource.IsCancellationRequested) { return; } Debug.WriteLine($"Resolved Workitems for {historyItem.ChangeSetId}"); workItem.UpdateIndexedWords(true); WorkItems.AddOrUpdate(workItem, (item, item1) => item.Id == item1.Id, (items, index, newItem) => items[index] = newItem); } // Updating Cache historyItem.UpdateIndexedWords(true); } SaveDataToCache(true, true); if (!isFullCall) { GetDataFromTfs(null, Int32.MaxValue, true); } }
public HistoryItemMetaData MapFrom(IHistoryItem historyItem) { return(new HistoryItemMetaData { Id = historyItem.Id, DateTime = historyItem.DateTime, User = historyItem.User, State = historyItem.State, Command = _commandMetaDataMapper.MapFrom(historyItem.Command) }); }
public GameNode(IHistoryItem item, IBoard board, bool isMaxPlayer) { if (item != null) { Move = new HistoryItemMinified(); Move.Minify(item, board); IsMaxPlayer = isMaxPlayer; } Clear(); }
public async void Update(IHistoryItem obj) { HistoryEntity he = await this.genericRepository.GetById(obj.Id); if (he == null) { throw new ArgumentException("Image not in db. Nothing to update"); } this.genericRepository.Update(he); }
public void HistoryItemAdded(IHistoryItem historyItem) { var historyItemDTO = _mapper.MapFrom(historyItem); if (historyItemDTO.IsAnImplementationOf <NullHistoryItemDTO>()) { return; } _historyItemDtoList.AddAtFront(historyItemDTO); View.BindTo(_historyItemDtoList); }
public void Insert(IHistoryItem obj) { HistoryEntity he = new HistoryEntity(); he.DeviceId = obj.DeviceId; he.Duration = obj.Duration; he.ScheduleId = obj.ScheduleId; he.StartTime = obj.StartTime; this.genericRepository.Insert(he); }
public void AddHistoryItem(IHistoryItem item) { var stack = _stacks.Peek(); stack.Add(item); if (_stacks.Count == 1) { TotalActionsSinceLastSave++; TotalActionsSinceLastAutoSave++; } Mediator.Publish(EditorMediator.HistoryChanged); }
public void Minify(IHistoryItem fromMaximizedSource, IBoard board) { IsPieceChangeType = fromMaximizedSource.IsPieceChangeType; From = fromMaximizedSource.Move.From; To = fromMaximizedSource.Move.To; if (fromMaximizedSource.Captured != null) { Captured = ((Piece)fromMaximizedSource.Captured).ToMinified(); } Player = board.Player1 == fromMaximizedSource.Player; }
public void AddHistoryItem(IHistoryItem item) { var stack = _stacks.Peek(); stack.Add(item); if (_stacks.Count == 1 && item.ModifiesState) { TotalActionsSinceLastSave++; TotalActionsSinceLastAutoSave++; } Mediator.Publish(EditorMediator.HistoryChanged); }
public static HistoricalTransactionContract ToHistoricalContract(this IHistoryItem self) { return(new HistoricalTransactionContract { Amount = Conversions.CoinsToContract(self.Amount, Constants.Assets[self.AssetId].DecimalPlaces), AssetId = self.AssetId, FromAddress = self.FromAddress, Hash = self.Hash, Timestamp = self.TimestampUtc, ToAddress = self.ToAddress, TransactionType = null }); }
protected override void Context() { base.Context(); _historyItemId = "tutu"; _historyItem = A.Fake <IHistoryItem>(); _historyList.Add(_historyItem); _historyItemDTO = A.Fake <IHistoryItemDTO>(); _historyItemDTO.Id = _historyItemId; _historyItemDTO.State = 5; A.CallTo(() => _mapper.MapFrom(_historyItem)).Returns(_historyItemDTO); A.CallTo(() => _historyItemDTOList.ItemById(_historyItemId)).Returns(_historyItemDTO); sut.UpdateHistory(); }
private static void InsertNewFor(IDbConnection conn, IHistoryItem item) { conn.Execute( $@"replace into { Table.NAME } ({ Columns.PATH }, { Columns.SIZE }, { Columns.MODIFIED }) values (@Path, @Size, datetime('now'));", item); }
protected override void Context() { base.Context(); _historyItem = A.Fake <IHistoryItem>(); _macroCommand = A.Fake <IMacroCommand>(); _macroCommand.Visible = true; _subCommand1 = A.Fake <ICommand>(); _subCommand2 = A.Fake <ICommand>(); _subCommand3 = A.Fake <ICommand>(); _subCommand1.Visible = true; _subCommand2.Visible = false; _subCommand3.Visible = true; A.CallTo(() => _historyItem.Command).Returns(_macroCommand); A.CallTo(() => _macroCommand.All()).Returns(new[] { _subCommand1, _subCommand2, _subCommand3 }); }
protected override void Context() { base.Context(); _simpleHistoryItem = A.Fake <IHistoryItem>(); _command = new MySimpleCommand(); _command.Visible = true; _simpleHistoryItem.State = 1; A.CallTo(() => _simpleHistoryItem.User).Returns("toto"); A.CallTo(() => _simpleHistoryItem.Command).Returns(_command); _command.CommandType = "CommandType"; _command.ObjectType = "ObjectType"; _command.Description = "Description"; _command.Comment = "One comment"; _command.ExtendedDescription = "One LongDescription"; _command.AddExtendedProperty("p1", "one value for p1"); _command.AddExtendedProperty("p2", "one value for p2"); }
private static void UpdateExisting(IDbConnection conn, IHistoryItem existing, IHistoryItem updated) { conn.Execute( $@"update { Table.NAME } set Size = @Size, Modified = datetime('now') where id = @Id;", new { updated.Size, existing.Id } ); }
public void SaveHistory(IHistoryItem history, string inputFileFullname) { var previousHistory = LoadHistory(inputFileFullname); previousHistory.Add(history); using (var jsonTextWriter = new JsonTextWriter(new StreamWriter(File.Open(inputFileFullname, FileMode.Create), Encoding.GetEncoding("Windows-1252")))) { jsonTextWriter.Formatting = Formatting.Indented; var jsonSerializer = new JsonSerializer() { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }; jsonSerializer.Serialize(jsonTextWriter, previousHistory); } }
public void Undo(IBoard board, IHistoryItem toUndo, IHistoryItem lastMoveBeforeUndo) { var minBoard = board.ToMinified(); var minToUndo = new HistoryItemMinified(); minToUndo.Minify(toUndo, board); HistoryItemMinified minLastMove = null; if (lastMoveBeforeUndo != null) { minLastMove = new HistoryItemMinified(); minLastMove.Minify(lastMoveBeforeUndo, board); } minBoard = ChainOfRules.UndoRule(minBoard, minToUndo, minLastMove); minBoard.ToMaximized(board); }
public void Add(IHistoryItem item) { // Delete the redo stack if required if (_currentIndex < _items.Count - 1) { _items.GetRange(_currentIndex + 1, _items.Count - _currentIndex - 1).ForEach(x => x.Dispose()); _items.RemoveRange(_currentIndex + 1, _items.Count - _currentIndex - 1); } // Remove extra entries if required while (_items.Count > _maximumSize - 1) { _items[0].Dispose(); _items.RemoveAt(0); _currentIndex--; } // Add the new entry _items.Add(item); _currentIndex = _items.Count - 1; }
public void Add(IHistoryItem item) { // Delete the redo stack if required if (_currentIndex < _items.Count - 1) { _items.GetRange(_currentIndex + 1, _items.Count - _currentIndex - 1).ForEach(x => x.Dispose()); _items.RemoveRange(_currentIndex + 1, _items.Count - _currentIndex - 1); } // Remove extra entries if required while (_items.Count > _maximumSize - 1) { _items[0].Dispose(); _items.RemoveAt(0); _currentIndex--; } // Add the new entry _items.Add(item); _currentIndex = _items.Count - 1; }
public void Save(IHistoryItem item) { var doubleResult = item.Result.HasValue ? item.Result.Value.ToString(CultureInfo.InvariantCulture) : "null"; string queryString = item.Id > 0 ? "UPDATE * FROM [dbo].[History]" : "INSERT INTO [dbo].[History] ([Operation], [Args], [Result], [ExecDate])" + $" VALUES (N'{item.Operation}', N'{item.Args}', {doubleResult}, N'{item.ExecDate}') "; using (var connection = new SqlConnection(connectionString)) { var command = new SqlCommand(queryString, connection); connection.Open(); var count = command.ExecuteNonQuery(); } }
public Task <object> Add(IHistoryItem entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var model = new HistoryItem { Data = entity.Data, DateModified = entity.DateModified, ObjectId = entity.ObjectId, ObjectType = entity.ObjectType, UserId = entity.UserId }; base.Add(model); return(Task.FromResult <object>(model.Id)); }
protected override void Context() { base.Context(); _notALabelItemId = "_notALabelItemId"; _aLabelItemId = "_aLabelItemId"; _labelHistoryItem = A.Fake <IHistoryItem>(); A.CallTo(() => _labelHistoryItem.Command).Returns(A.Fake <ILabelCommand>()); _notALabelHistoryItem = A.Fake <IHistoryItem>(); A.CallTo(() => _notALabelHistoryItem.Command).Returns(A.Fake <ICommand>()); _historyList.Add(_labelHistoryItem); _historyList.Add(_notALabelHistoryItem); _labelHistoryItemDTO = A.Fake <IHistoryItemDTO>().WithId(_aLabelItemId); A.CallTo(() => _labelHistoryItemDTO.Command).Returns(_labelHistoryItem.Command); _notALabelHistoryItemDTO = A.Fake <IHistoryItemDTO>().WithId(_notALabelItemId); A.CallTo(() => _notALabelHistoryItemDTO.Command).Returns(_notALabelHistoryItem.Command); A.CallTo(() => _mapper.MapFrom(_labelHistoryItem)).Returns(_labelHistoryItemDTO); A.CallTo(() => _mapper.MapFrom(_notALabelHistoryItem)).Returns(_notALabelHistoryItemDTO); A.CallTo(() => _historyItemDTOList.ItemById(_aLabelItemId)).Returns(_labelHistoryItemDTO); sut.UpdateHistory(); }
private IHistoryItemDTO mapFrom(IHistoryItem historyItem, ICommand command) { if (!command.Visible) { return(new NullHistoryItemDTO()); } var historyDto = new HistoryItemDTO(command); historyDto.Id = Guid.NewGuid().ToString(); historyDto.State = historyItem.State; historyDto.User = historyItem.User; historyDto.DateTime = historyItem.DateTime; historyDto.ObjectType = command.ObjectType; historyDto.CommandType = command.CommandType; historyDto.Description = command.Description; historyDto.Loaded = command.Loaded; historyDto.ExtendedDescription = command.ExtendedDescription; foreach (var dynamicColumn in _historyBrowserConfiguration.AllDynamicColumnNames) { historyDto.ExtendedProperties.Add(command.ExtendedPropertyValueFor(dynamicColumn)); } //Add sub commands in the reverse order to display them in the chronological order var macroCommand = command as IMacroCommand; if (macroCommand == null) { return(historyDto); } macroCommand.All().Reverse().Where(subCommand => subCommand.Visible) .Each(subCommand => historyDto.AddSubHistory(mapFrom(historyItem, subCommand))); return(historyDto); }
public IPlayer MakeMove(IBoard board, IHistoryItem move) { var minBoard = board.ToMinified(); var minMove = new HistoryItemMinified(); minMove.Minify(move, board); minBoard = MakeMove(minBoard, minMove); minBoard.ToMaximized(board); minMove.Maximize(move); if (minBoard.Player1PiecesCount == 0) { return(board.Player1); } if (minBoard.Player2PiecesCount == 0) { return(board.Player2); } return(null); }
public void SaveHistory(IHistoryItem history) { converter.SaveHistory(history, historyPath); }
private void updateComment(HistoryItemMetaData savedHistoryItemMetaData, IHistoryItem historyItem, ISession session) { savedHistoryItemMetaData.Command.Comment = historyItem.Command.Comment; _historyItemMetaDataRepository.SaveCommand(savedHistoryItemMetaData, session); }
private bool commentHasChanged(HistoryItemMetaData savedHistoryItem, IHistoryItem historyItem) { return(!string.Equals(savedHistoryItem.Command.Comment, historyItem.Command.Comment)); }
private bool canUndo(IHistoryItem historyItem) { return(historyItem != null && historyItem.Command.Loaded); }
private void addToHistory(IHistoryItem historyItem, int state) { historyItem.State = state; _history.Add(historyItem); CommandAdded(historyItem); }
public HistoryWindow(IHistoryItem historyItem) { InitializeComponent(); historyContainer.Navigated += historyContainer_Navigated; historyContainer.Push(historyItem); }
public void SaveHistory(IHistoryItem history, string inputFileFullname) { var previousHistory = LoadHistory(inputFileFullname); previousHistory.Add(history); using (var jsonTextWriter = new JsonTextWriter(new StreamWriter(File.Open(inputFileFullname, FileMode.Create), Encoding.GetEncoding("Windows-1252")))) { jsonTextWriter.Formatting = Formatting.Indented; var jsonSerializer = new JsonSerializer() { MissingMemberHandling = MissingMemberHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }; jsonSerializer.Serialize(jsonTextWriter, previousHistory); } }
public void Push(IHistoryItem historyItem) { _breadCrumbs.Go(historyItem); UpdateAfterForwardOrPush(); }
private void Push(List<IHistoryItem> items, IHistoryItem item) { items.Add(item); }