コード例 #1
0
		private void InitBoard()
		{
			//setup the loop intervals
			//Probably need to do this on a different thread
			do
			{
				try
				{
					_boardLock.EnterWriteLock();
					_board = _api.GetBoard(_boardId);
					//_boardIdentifiers = _api.GetBoardIdentifiers(_boardId);
				}
				finally
				{
					_boardLock.ExitWriteLock();
				}
			} while (SetupCheckForUpdatesLoop() != CheckForUpdatesLoopResult.Exit);
			// SetupBoardRefreshLoop();
		}
コード例 #2
0
		private CheckForUpdatesLoopResult SetupCheckForUpdatesLoop()
		{
			const int pulse = 1000;
			var pollingInterval = (long) _integrationSettings.CheckForUpdatesIntervalSeconds*1000;

			var stopWatch = new System.Diagnostics.Stopwatch();
			stopWatch.Start();

			do
			{
				if (!stopWatch.IsRunning) stopWatch.Restart();
				if (ShouldContinue)
				{
					while (stopWatch.ElapsedMilliseconds < pollingInterval)
					{
						if (!ShouldContinue) return CheckForUpdatesLoopResult.Exit;
						Thread.Sleep(pulse);
					}
				}
				try
				{
					stopWatch.Stop();

					//Now do the work
					var checkResults = _api.CheckForUpdates(_board.Id, _board.Version);

					if (checkResults == null) continue;

					OnBoardStatusChecked(new BoardStatusCheckedEventArgs {HasChanges = checkResults.HasUpdates});

					if (!checkResults.HasUpdates) continue;

					try
					{
						_boardLock.EnterUpgradeableReadLock();

						var boardChangedEventArgs = new BoardChangedEventArgs();

						if (checkResults.Events.Any(x => x.RequiresBoardRefresh))
						{
							boardChangedEventArgs.BoardWasReloaded = true;
							OnBoardChanged(boardChangedEventArgs);
							return CheckForUpdatesLoopResult.Continue;
						}

						//Now we need to spin through and update the board
						//and create the information to event
						foreach (var boardEvent in checkResults.Events)
						{
							try
							{
								switch (GetEventType(boardEvent.EventType))
								{
									case EventType.CardCreation:
										var addCardEvent = CreateCardAddEvent(boardEvent, checkResults.AffectedLanes);
										if (addCardEvent != null) boardChangedEventArgs.AddedCards.Add(addCardEvent);
										break;
									case EventType.CardMove:
										var movedCardEvent = CreateCardMoveEvent(boardEvent, checkResults.AffectedLanes);
										if (movedCardEvent != null) boardChangedEventArgs.MovedCards.Add(movedCardEvent);
										break;
									case EventType.CardFieldsChanged:
										var changedFieldsEvent = CreateCardUpdateEvent(boardEvent, checkResults.AffectedLanes);
										if (changedFieldsEvent != null) boardChangedEventArgs.UpdatedCards.Add(changedFieldsEvent);
										break;
									case EventType.CardDeleted:
										boardChangedEventArgs.DeletedCards.Add(CreateCardDeletedEvent(boardEvent));
										break;
									case EventType.CardBlocked:
										if (boardEvent.IsBlocked)
											boardChangedEventArgs.BlockedCards.Add(CreateCardBlockedEvent(boardEvent,
												checkResults.AffectedLanes));
										else
											boardChangedEventArgs.UnBlockedCards.Add(CreateCardUnBlockedEvent(boardEvent,
												checkResults.AffectedLanes));
										break;
									case EventType.UserAssignment:
										if (boardEvent.IsUnassigning)
											boardChangedEventArgs.UnAssignedUsers.Add(CreateCardUserUnAssignmentEvent(boardEvent,
												checkResults.AffectedLanes));
										else
											boardChangedEventArgs.AssignedUsers.Add(CreateCardUserAssignmentEvent(boardEvent,
												checkResults.AffectedLanes));
										break;
									case EventType.CommentPost:
										boardChangedEventArgs.PostedComments.Add(CreateCommentPostedEvent(boardEvent));
										break;
									case EventType.WipOverride:
										boardChangedEventArgs.WipOverrides.Add(CreateWipOverrideEvent(boardEvent,
											checkResults.AffectedLanes));
										break;
									case EventType.UserWipOverride:
										boardChangedEventArgs.UserWipOverrides.Add(CreateUserWipOverrideEvent(boardEvent));
										break;
									case EventType.AttachmentChange:
										var attachmentEvent = CreateAttachmentEvent(boardEvent);
										if (attachmentEvent != null) boardChangedEventArgs.AttachmentChangedEvents.Add(attachmentEvent);
										break;

									case EventType.CardMoveToBoard:
										boardChangedEventArgs.CardMoveToBoardEvents.Add(CreateCardMoveToBoardEvent(boardEvent));
										break;

									case EventType.CardMoveFromBoard:
										boardChangedEventArgs.CardMoveFromBoardEvents.Add(CreateCardMoveFromBoardEvent(boardEvent));
										break;

									case EventType.BoardEdit:
										boardChangedEventArgs.BoardEditedEvents.Add(CreateBoardEditedEvent(boardEvent));
										boardChangedEventArgs.BoardStructureChanged = true;
										break;

									case EventType.BoardCardTypesChanged:
										boardChangedEventArgs.BoardCardTypesChangedEvents.Add(new BoardCardTypesChangedEvent(boardEvent.EventDateTime));
										boardChangedEventArgs.BoardStructureChanged = true;
										break;

									case EventType.BoardClassOfServiceChanged:
										boardChangedEventArgs.BoardClassOfServiceChangedEvents.Add(
											new BoardClassOfServiceChangedEvent(boardEvent.EventDateTime));
										boardChangedEventArgs.BoardStructureChanged = true;
										break;

									case EventType.Unrecognized:
										//Console.Beep();
										break;
								}
							}
							catch (Exception ex)
							{
								OnClientError(new ClientErrorEventArgs
								{
									Exception = ex,
									Message = "Error processing board change event. " + ex.Message
								});
							}
						}

						OnBoardChanged(boardChangedEventArgs);

						_boardLock.EnterWriteLock();
						try
						{
							//we need to check to see if there is a need to refresh the entire board
							//if so, we need to refresh the entire board and raise the board refreshed event
							if (!checkResults.RequiresRefesh())
							{
								//since the board does not require a refresh, then just change the effected lanes
								ApplyBoardChanges(checkResults.CurrentBoardVersion, checkResults.AffectedLanes);
							}
							else
							{
								_board = checkResults.NewPayload;
								OnBoardRefresh(new BoardInfoRefreshedEventArgs {FromBoardChange = true});
							}
						}
						catch (Exception ex)
						{
							OnClientError(new ClientErrorEventArgs
							{
								Exception = ex,
								Message = "Error applying board changes or raising board refresh."
							});
						}
						finally
						{
							_boardLock.ExitWriteLock();
						}
					}
					catch (Exception ex)
					{
						OnClientError(new ClientErrorEventArgs {Exception = ex, Message = "Error processing board events."});
					}
					finally
					{
						_boardLock.ExitUpgradeableReadLock();
					}
				}
				catch (Exception ex)
				{
					OnClientError(new ClientErrorEventArgs {Exception = ex, Message = "Error checking for board events."});
				}
			} while (ShouldContinue);

			stopWatch.Stop();

			return CheckForUpdatesLoopResult.Exit;
		}
コード例 #3
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.LaneToStatesMap.Add(1, new List<string> {"open"});
			_mapping.LaneToStatesMap.Add(2, new List<string> {"closed"});
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #4
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_mapping = Test<BoardMapping>.Item;
			_testCardAddResult1 = Test<CardAddResult>.Item;
			_testCardAddResult1.CardId = 1;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.LaneToStatesMap.Add(1, new List<string> {"open"});
			TestConfig = Test<Configuration>.Item;
			TestConfig.PollingFrequency = 5000;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #5
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			foreach (var cardType in _testBoard.CardTypes)
				cardType.IsDefault = false;
			_testBoard.CardTypes.Last().IsDefault = true;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #6
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			int ctr = 0;
			foreach (var boardUser in _testBoard.BoardUsers)
			{
				if (ctr == 0)
				{
					boardUser.UserName = "******";
					boardUser.FullName = "Johnny Cash";
					boardUser.EmailAddress = "*****@*****.**";
					boardUser.Id = 101;
				}
				ctr++;
			}
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #7
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			int x = 0;
			foreach (var lane in _testBoard.Lanes)
			{
				lane.Active = true;
				lane.ClassType = LaneClassType.Active;
				lane.Index = x++;
			}

			// assign an arbitrary archive lane as the top level archive
			var lastArchiveItem = _testBoard.Archive.Last();
			lastArchiveItem.ParentLaneId = 0;
			_testBoard.ArchiveTopLevelLaneId = lastArchiveItem.Id;

			activeLaneCount = _testBoard.Lanes.Count;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #8
0
		protected override void OnStartFixture() 
		{
			_testBoard = Test<Board>.Item;
			foreach (var cardType in _testBoard.CardTypes)
				cardType.IsDefault = false;
			_testBoard.CardTypes.Add(new CardType() { Id = 999, Name = "Willy", IsDefault = false });
			_testBoard.CardTypes.Last().IsDefault = true;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.Types = new List<WorkItemType>() { new WorkItemType() { LeanKit = "Willy", Target = "Roger"}};
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> { _mapping };
		}
コード例 #9
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			allLaneCount = _testBoard.AllLanes().Count(x => x.ClassType != LaneClassType.Archive);
			// insure at least 1 active lane for testing
			if (allLaneCount == 0)
			{
				_testBoard.Lanes[0].ClassType = LaneClassType.Active;
				allLaneCount = 1;
			}
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #10
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			int x = 0;
			foreach (var lane in _testBoard.Lanes)
			{
				lane.Active = true;
				lane.ClassType = LaneClassType.Active;
				lane.ChildLaneIds = null;
				lane.ParentLaneId = 0;
				lane.Index = x++;
			}

			allLaneCount = _testBoard.AllLanes().Count(y => y.ClassType != LaneClassType.Archive);
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.ArchiveLaneId = 0;
			_testBoard.ArchiveTopLevelLaneId = null;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #11
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_testBoard.ArchiveTopLevelLaneId = null;
			var archiveLane = _testBoard.AllLanes().FirstOrDefault(x => x.ClassType == LaneClassType.Archive);
			archiveLane.ParentLaneId = 0;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.ArchiveLaneId = 0;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #12
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_testBoard.ArchiveTopLevelLaneId = null;
			_testBoard.Archive[0].ParentLaneId = 0;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #13
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}
コード例 #14
0
		public ValidationService(Board board)
		{
			_board = board;
			_validationResults = new List<ValidationResult>();
		}
コード例 #15
0
		protected override void OnStartFixture()
		{
			_testBoard = Test<Board>.Item;
			_mapping = Test<BoardMapping>.Item;
			_mapping.Identity.LeanKit = _testBoard.Id;
			_mapping.LaneToStatesMap.Add(1, new List<string> {"open"});
			_mapping.LaneToStatesMap.Add(2, new List<string> {"closed"});
			_mapping.ValidCardTypes = new List<CardType>() {new CardType() {Id = 1, Name = "Bug"}};
			_mapping.CreateTargetItems = true;
			TestConfig = Test<Configuration>.Item;
			TestConfig.Mappings = new List<BoardMapping> {_mapping};
		}