public IWorkResult Execute(IWorkItem workItem) { var workResult = new MatrixMultiplicationWorkResult(); workResult.Success = false; try { var concreteWorkItem = workItem as MatrixMultiplicationWorkItem; if (concreteWorkItem != null) { workResult.Result = concreteWorkItem.GridAValue * concreteWorkItem.GridBValue; workResult.Success = true; } else { workResult.Error = new ArgumentNullException(string.Concat("The workItem was either null or could not be cast to a instance of ", typeof(MatrixMultiplicationWorkItem).Name)); } } catch (Exception e) { workResult.Error = e; } return workResult; }
public override ScopeMatchResult Matches(IWorkItem item) { var res = new ScopeMatchResult(); res.Add(item.TypeName); res.Success = this.ApplicableTypes.Any(type => type.SameAs(item.TypeName)); return res; }
/// <summary> /// Notification of failure /// </summary> /// <param name="workItem">Work item that failed</param> /// <param name="failureInfo">Failure information (usually exception)</param> public void WorkFailed( IWorkItem workItem, object failureInfo ) { foreach ( IWorkItemProgressMonitor monitor in m_Monitors ) { monitor.WorkFailed( workItem, failureInfo ); } }
/// <summary> /// Notification of work completion /// </summary> /// <param name="workItem">Work item that completed</param> public void WorkComplete( IWorkItem workItem ) { foreach ( IWorkItemProgressMonitor monitor in m_Monitors ) { monitor.WorkComplete( workItem ); } }
private static WorkItemRepositoryMock MakeRepository(out IWorkItem startPoint) { var repository = new WorkItemRepositoryMock(); var grandParent = new WorkItemMock(repository); grandParent.Id = 1; grandParent.TypeName = "Feature"; var parent = new WorkItemMock(repository); parent.Id = 2; parent.TypeName = "Use Case"; var firstChild = new WorkItemMock(repository); firstChild.Id = 3; firstChild.TypeName = "Task"; var secondChild = new WorkItemMock(repository); secondChild.Id = 4; secondChild.TypeName = "Task"; firstChild.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ParentRelationship, parent.Id, repository)); secondChild.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ParentRelationship, parent.Id, repository)); parent.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ParentRelationship, grandParent.Id, repository)); grandParent.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ChildRelationship, parent.Id, repository)); parent.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ChildRelationship, firstChild.Id, repository)); parent.WorkItemLinks.Add(new WorkItemLinkMock(WorkItemImplementationBase.ChildRelationship, secondChild.Id, repository)); repository.SetWorkItems(new[] { grandParent, parent, firstChild, secondChild }); startPoint = grandParent; return repository; }
/// <summary> /// Notification of work completion /// </summary> /// <param name="workItem">Work item that completed</param> public void WorkComplete( IWorkItem workItem ) { if ( m_WorkQueue.NumberOfWorkItemsInQueue == 0 ) { Close( ); } }
/// <summary> /// İşçi Thread'i iş parçası işini bitirdi olay argümanları inşacı metodu. /// </summary> /// <param name="workItem">İş parçası nesnesi.</param> public WorkerThreadWorkItemFinishedEventArgs(IWorkItem workItem) { if (workItem == null) { throw new ArgumentNullException("workItem"); } WorkItem = workItem; }
public IWorkItem MakeNewWorkItem(IWorkItem inSameProjectAs, string workItemTypeName) { if (inSameProjectAs == null) { throw new ArgumentNullException(nameof(inSameProjectAs)); } return this.MakeNewWorkItem(workItemTypeName, inSameProjectAs[CoreFieldReferenceNames.TeamProject] as string); }
/// <summary> /// İşçi Thread havuzu yeni bir iş parçasını iş parcası kuyruğuna sokuyor olay argümanları sınıfı inşacı metodu. /// </summary> /// <param name="workItem">İş parçası.</param> public WorkerThreadPoolEnqueuingNewWorkItemEventArgs(IWorkItem workItem) { if (workItem == null) { throw new ArgumentNullException("workItem"); } m_WorkItem = workItem; }
/// <summary> /// Notification of progress in a work item /// </summary> /// <param name="workItem">Work item that has progressed</param> /// <param name="progress">Normalized progress</param> /// <returns>Returns true if the process should continue, false if the process should cancel.</returns> public bool UpdateProgress( IWorkItem workItem, float progress ) { bool cancel = false; foreach ( IWorkItemProgressMonitor monitor in m_Monitors ) { cancel |= !monitor.UpdateProgress( workItem, progress ); } return !cancel; }
public void Add(IWorkItem item_) { if (item_ == null) return; lock (m_queue) m_queue.Enqueue(item_); m_autoResetEvent.Set(); }
public override bool Matches(IWorkItem item) { var trigger = this.FieldNames; var fields = item.Fields.ToArray(); var available = fields.Select(f => f.Name).Concat(fields.Select(f => f.ReferenceName)); return trigger.All(t => available.Contains(t, StringComparer.OrdinalIgnoreCase)); }
public static void TransitionToState(IWorkItem workItem, string state, string commentPrefix, ILogEvents logger) { // Set the sourceWorkItem's state so that it is clear that it has been moved. string originalState = (string)workItem.Fields["State"].Value; // Try to set the state of the source work item to the "Deleted/Moved" state (whatever is defined in the file). // We need an open work item to set the state workItem.TryOpen(); // See if we can go directly to the planned state. workItem.Fields["State"].Value = state; if (workItem.Fields["State"].Status != FieldStatus.Valid) { // Revert back to the original value and start searching for a way to our "MovedState" workItem.Fields["State"].Value = workItem.Fields["State"].OriginalValue; // If we can't then try to go from the current state to another state. Saving each time till we get to where we are going. foreach (string curState in FindNextState(workItem.Type, (string)workItem.Fields["State"].Value, state)) { string comment; if (curState == state) { comment = string.Format( "{0}{1} State changed to {2}", commentPrefix, Environment.NewLine, state); } else { comment = string.Format( "{0}{1} State changed to {2} as part of move toward a state of {3}", commentPrefix, Environment.NewLine, curState, state); } bool success = ChangeWorkItemState(workItem, originalState, curState, comment, logger); // If we could not do the incremental state change then we are done. We will have to go back to the original... if (!success) { break; } } } else { // Just save it off if we can. string comment = commentPrefix + "\n State changed to " + state; ChangeWorkItemState(workItem, originalState, state, comment, logger); } }
public void Enqueue(IWorkItem item) { var priority = (int)item.Priority; if (priority >= _queues.Count) { throw new ArgumentException(string.Format("Invalid TaskItemPriority: {0}", item.Priority)); } _queues[priority].Enqueue(item); _workItemCount++; }
protected override void EnqueueCore(IWorkItem item) { lock (_locker) { _taskQueue.Enqueue(item); if (_consumersWaiting > 0) { Monitor.PulseAll(_locker); } } }
public bool Setup(string serverType, string bootstrapUri, string assemblyImportRoot, IServerConfig config, ProviderFactoryInfo[] factories) { m_AssemblyImporter = new AssemblyImport(assemblyImportRoot); var serviceType = Type.GetType(serverType); m_AppServer = (IWorkItem)Activator.CreateInstance(serviceType); var bootstrap = (IBootstrap)Activator.GetObject(typeof(IBootstrap), bootstrapUri); return m_AppServer.Setup(bootstrap, config, factories); }
/// <summary> /// Add a task object to the test queue. For a test that is currently /// executing, all tasks contained within the queue are executed to /// completion (unless an Exception is thrown) -before- moving on to /// the next test. /// /// The test task queue replaces the PumpMessages(...) system that /// permitted a single callback. This enables specialized tasks, such /// as DOM bridge tasks, sleep tasks, and conditional continue tasks. /// </summary> /// <param name="testTaskObject">Asynchronous test task /// instance.</param> public virtual void EnqueueWorkItem(IWorkItem testTaskObject) { if (UnitTestHarness.DispatcherStack.CurrentCompositeWorkItem != null) { UnitTestHarness.DispatcherStack.CurrentCompositeWorkItem.Enqueue(testTaskObject); } else { throw new InvalidOperationException(Properties.UnitTestMessage.WorkItemTest_EnqueueWorkItem_AsynchronousFeatureUnavailable); } }
private static void RunWorkItemTask(IWorkItem todo, TaskScheduler sched) { try { RuntimeContext.SetExecutionContext(todo.SchedulingContext, sched); todo.Execute(); } finally { RuntimeContext.ResetExecutionContext(); } }
public PerformanceMonitor(IRootConfig config, IEnumerable<IWorkItem> appServers, IWorkItem serverManager, ILogFactory logFactory) { m_PerfLog = logFactory.GetLog("Performance"); m_AppServers = appServers.ToArray(); m_ServerManager = serverManager; m_Helper = new ProcessPerformanceCounterHelper(Process.GetCurrentProcess()); m_TimerInterval = config.PerformanceDataCollectInterval * 1000; m_PerformanceTimer = new Timer(OnPerformanceTimerCallback); }
public override ScopeMatchResult Matches(IWorkItem item) { var res = new ScopeMatchResult(); var trigger = this.FieldNames; var fields = item.Fields.ToArray(); var available = fields.Select(f => f.Name).Concat(fields.Select(f => f.ReferenceName)); res.AddRange(available); res.Success = trigger.All(t => available.Contains(t, StringComparer.OrdinalIgnoreCase)); return res; }
/// <summary> /// İşçi Thread'i iş parçası hata aldı olay argümanları inşacı metodu. /// </summary> /// <param name="workItem">İş parçası nesnesi.</param> /// <param name="exception">İş parçası hatası.</param> public WorkerThreadWorkItemExceptionEventArgs(IWorkItem workItem, Exception exception) { if (exception == null) { throw new ArgumentNullException("exception"); } if (workItem == null) { throw new ArgumentNullException("workItem"); } WorkItem = workItem; Exception = exception; }
public WorkItem(IWorkItem wo) { _entity = wo; Actions = new List<IWorkItemAction>(); foreach (Sage.Entity.Interfaces.IWorkItemAction act in wo.WorkItemActions) { Actions.Add(ActionFactory.CreateAction(act)); } Targets = new List<IWorkItemTarget>(); foreach (Sage.Entity.Interfaces.IWorkItemTarget target in wo.WorkItemTargets) { Targets.Add(TargetFactory.CreateTarget(target)); } DataSource = DataSourceFactory.CreateDataSource(wo.WorkItemDataSource); LastExecuted = wo.LastExecuted ?? DateTime.UtcNow; }
protected override void EnqueueCore(IWorkItem item) { lock (_locker) { while (_taskQueue.Count == (_maxTasksCount - 1) && !_isDisposed) { _producersWaiting++; Monitor.Wait(_locker); _producersWaiting--; } _taskQueue.Enqueue(item); if (_consumersWaiting > 0) { Monitor.PulseAll(_locker); } } }
public bool Setup(string serverType, string bootstrapUri, string assemblyImportRoot, IServerConfig config, ProviderFactoryInfo[] factories) { m_AssemblyImporter = new AssemblyImport(assemblyImportRoot); var serviceType = Type.GetType(serverType); m_AppServer = (IWorkItem)Activator.CreateInstance(serviceType); var bootstrap = (IBootstrap)Activator.GetObject(typeof(IBootstrap), bootstrapUri); var ret = m_AppServer.Setup(bootstrap, config, factories); if (ret) { m_Log = ((IAppServer)m_AppServer).Logger; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } return ret; }
private IWorkItemRepository SetupFakeRepository_Short() { this.repository = Substitute.For<IWorkItemRepository>(); this.workItem = Substitute.For<IWorkItem>(); this.workItem.Id.Returns(1); this.workItem.TypeName.Returns("Task"); this.workItem["Estimated Dev Work"].Returns(1.0D); this.workItem["Estimated Test Work"].Returns(2.0D); this.workItem["Finish Date"].Returns(new DateTime(2010, 1, 1)); this.workItem.IsValid().Returns(true); // triggers save this.workItem.IsDirty.Returns(true); this.repository.GetWorkItem(1).Returns(this.workItem); this.repository.LoadedWorkItems.Returns(new ReadOnlyCollection<IWorkItem>(new List<IWorkItem>() { this.workItem })); this.repository.CreatedWorkItems.Returns(new ReadOnlyCollection<IWorkItem>(new List<IWorkItem>())); return this.repository; }
public override void Run(string scriptName, IWorkItem workItem) { string script = this.scripts[scriptName]; var config = RunspaceConfiguration.Create(); using (var runspace = RunspaceFactory.CreateRunspace(config)) { runspace.Open(); runspace.SessionStateProxy.SetVariable("self", workItem); runspace.SessionStateProxy.SetVariable("store", this.Store); Pipeline pipeline = runspace.CreatePipeline(); pipeline.Commands.AddScript(script); // execute var results = pipeline.Invoke(); this.Logger.ResultsFromScriptRun(scriptName, results); } }
public void Add(IWorkItem workItem) { workItem.TimeQueued = DateTime.UtcNow; try { #if PRIORITIZE_SYSTEM_TASKS if (workItem.IsSystemPriority) { #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectShedulerQueuesStats) systemQueueTracking.OnEnQueueRequest(1, systemQueue.Count); #endif systemQueue.Add(workItem); } else { #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectShedulerQueuesStats) mainQueueTracking.OnEnQueueRequest(1, mainQueue.Count); #endif mainQueue.Add(workItem); } #else #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectQueueStats) mainQueueTracking.OnEnQueueRequest(1, mainQueue.Count); #endif mainQueue.Add(task); #endif #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectGlobalShedulerStats) SchedulerStatisticsGroup.OnWorkItemEnqueue(); #endif } catch (InvalidOperationException) { // Queue has been stopped; ignore the exception } }
public void GetActionsHistory_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.GetActionsHistory(); }
public void OnException(IWorkItem item, Exception e) { throw new NotImplementedException(); }
/// <summary>分配, 按照当前任务的参与者插入工单</summary> /// <param name="currentSession"></param> /// <param name="processInstance"></param> /// <param name="runtimeContext"></param> /// <param name="taskInstance"></param> /// <param name="formTask"></param> /// <param name="part"></param> /// <param name="dynamicAssignmentHandler"></param> protected void assign(IWorkflowSession currentSession, IProcessInstance processInstance, RuntimeContext runtimeContext, ITaskInstance taskInstance, FormTask formTask, Participant part, DynamicAssignmentHandler dynamicAssignmentHandler)// throws EngineException, KernelException { //如果有指定的Actor,则按照指定的Actor分配任务 if (dynamicAssignmentHandler != null) { dynamicAssignmentHandler.assign((IAssignable)taskInstance, part.Name); } else { IPersistenceService persistenceService = runtimeContext.PersistenceService; List <ITaskInstance> taskInstanceList = persistenceService.FindTaskInstancesForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId); ITaskInstance theLastCompletedTaskInstance = null; for (int i = 0; taskInstanceList != null && i < taskInstanceList.Count; i++) { ITaskInstance tmp = (ITaskInstance)taskInstanceList[i]; if (tmp.Id.Equals(taskInstance.Id)) { continue; } if (!tmp.TaskId.Equals(taskInstance.TaskId)) { continue; } if (tmp.State != TaskInstanceStateEnum.COMPLETED) { continue; } if (theLastCompletedTaskInstance == null) { theLastCompletedTaskInstance = tmp; } else { if (theLastCompletedTaskInstance.StepNumber < tmp.StepNumber) { theLastCompletedTaskInstance = tmp; } } } //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员 if (theLastCompletedTaskInstance != null && (LoopStrategyEnum.REDO == formTask.LoopStrategy || currentSession.isInWithdrawOrRejectOperation())) { List <IWorkItem> workItemList = persistenceService.FindCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.Id); ITaskInstanceManager taskInstanceMgr = runtimeContext.TaskInstanceManager; for (int k = 0; k < workItemList.Count; k++) { IWorkItem completedWorkItem = (IWorkItem)workItemList[k]; IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession, processInstance, taskInstance, completedWorkItem.ActorId); newFromWorkItem.claim();//并自动签收 } } else { IBeanFactory beanFactory = runtimeContext.BeanFactory; //从spring中获取到对应任务的Performer,创建工单 //201004 add lwz 参与者通过业务接口实现默认获取用户 switch (part.AssignmentType) { case AssignmentTypeEnum.Current: runtimeContext.AssignmentBusinessHandler.assignCurrent( currentSession, processInstance, (IAssignable)taskInstance); break; case AssignmentTypeEnum.Role: runtimeContext.AssignmentBusinessHandler.assignRole( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Agency: runtimeContext.AssignmentBusinessHandler.assignAgency( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Fixed: runtimeContext.AssignmentBusinessHandler.assignFixed( currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue); break; case AssignmentTypeEnum.Superiors: runtimeContext.AssignmentBusinessHandler.assignSuperiors( currentSession, processInstance, (IAssignable)taskInstance); break; default: IAssignmentHandler assignmentHandler = (IAssignmentHandler)beanFactory.GetBean(part.AssignmentHandler); //modified by wangmj 20090904 ((IAssignmentHandler)assignmentHandler).assign((IAssignable)taskInstance, part.PerformerValue); break; } } } }
public static void LoadAndRun(this ScriptEngine engine, string scriptName, string script, IWorkItem workItem) { engine.Load(scriptName, script); engine.LoadCompleted(); engine.Run(scriptName, workItem); }
/// <summary> /// Enqueue the work item. /// </summary> /// <param name="item">The work item.</param> public void Enqueue(IWorkItem item) { _queue.Enqueue(item); }
public void ApplyRules_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.ApplyRules(); }
/// <summary> /// Gets the latest synchronize data_ unit test. /// </summary> // [TestMethod] // [Ignore] public void GetLatestSyncData_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.GetLatestSyncData(); }
internal WorkitemFocusStrategy(ContextService currentContextService, IWorkItem workItem) { CurrentContextService = currentContextService; Workitem = workItem; TaskManager = CommonServiceLocator.ServiceLocator.Current.GetInstance <ITaskManager>(); }
public abstract bool Matches(IWorkItem item);
public void IsValid_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.IsValid(); }
public void PartialOpen_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.PartialOpen(); }
/// <summary> /// Raises the <see cref="RunningWorkItem"/> event. /// </summary> /// <param name="workItem"> /// The <see cref="IWorkItem"/> that has started. /// </param> /// <remarks> /// The <b>OnRunningWorkItem</b> method allows derived classes to handle the <see cref="RunningWorkItem"/> /// event without attaching a delegate. This is the preferred technique for handling the event in a derived class. /// <para> /// When a derived class calls the <b>OnStartedWorkItem</b> method, it raises the <see cref="RunningWorkItem"/> event by /// invoking the event handler through a delegate. For more information, see /// <a href="ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpguide/html/cpconProvidingEventFunctionality.htm">Raising an Event</a>. /// </para> /// </remarks> protected virtual void OnRunningWorkItem(IWorkItem workItem) { WorkItemEventHandler handler; lock (eventLock) { handler = runningWorkItem; } if (handler != null) { handler (this, new WorkItemEventArgs(workItem)); } }
public void Save_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.Save(); }
/// <summary> /// Gets the field value external_ unit test. /// </summary> // [TestMethod] // [Ignore] public void GetFieldValueExternal_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.GetFieldValueExternal(null, 0); }
/// <summary> /// Get the startegy to focus the workitem /// The focus startegy should be obtained from /// here and never be instaciated outside of this method /// </summary> /// <param name="contextService">ContextService</param> /// <param name="workItem">Workitem to open</param> public static WorkitemFocusStrategy GetFocusStrategy(ContextService currentContextService, IWorkItem workItem) { if (workItem == null || workItem is NullWorkitem) { return(new WorkitemUnfocusStrategy(currentContextService, workItem)); } else if (workItem.IsModal) { return(new ModalWorkitemFocusStrategy(currentContextService, workItem)); } else if (workItem.Parent != null) { return(new ChildWorkitemFocusStrategy(currentContextService, workItem)); } else { return(new RootWorkitemFocusStrategy(currentContextService, workItem)); } }
public void GetFieldValue_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.GetFieldValue(0, 0); }
public Module(IWorkItem rootWorkItem) : base(rootWorkItem, "Module.EarlyRedemption") { }
public void GetNextState_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.GetNextState("Save"); }
public void SyncToLatest_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.SyncToLatest(); }
public void Open_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.Open(); }
public ChildWorkitemLaunchStrategy(ContextService currentContextService, IWorkItem workItem, IWorkItem parent = null, object data = null) : base(currentContextService, workItem, parent, data) { }
public void Reset_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.Reset(); }
internal override bool SetupWorkItemInstance(IWorkItem workItem, WorkItemFactoryInfo factoryInfo) { return(workItem.Setup(m_Bootstrap, factoryInfo.Config, factoryInfo.ProviderFactories.ToArray())); }
public void SetDirty_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.SetDirty(false); }
public string Execute() { Console.WriteLine("Please enter the name of the team responsible for the workitem whose description you want to change:"); Console.WriteLine("List of teams:" + Environment.NewLine + HelperMethods.ListTeams(this.engine.Teams)); string teamName = Console.ReadLine(); bool ifTeamExists = HelperMethods.IfExists(teamName, engine.Teams); if (ifTeamExists == false) { return("Team with such name does not exist."); } ITeam team = HelperMethods.ReturnExisting(teamName, engine.Teams); Console.Clear(); Console.WriteLine("Please enter board where the workitem features:"); Console.WriteLine("List of boards:" + Environment.NewLine + HelperMethods.ListBoards(team.Boards)); string boardName = Console.ReadLine(); bool ifBoardExists = HelperMethods.IfExists(boardName, team.Boards); if (ifBoardExists == false) { return($"Board with name {boardName} does not exist in team {team.Name}."); } IBoard board = HelperMethods.ReturnExisting(boardName, team.Boards); Console.Clear(); Console.WriteLine("Please enter the id of the workitem that you wish to change:"); Console.WriteLine($"List of workitems in team {board.Name}:" + Environment.NewLine + HelperMethods.ListWorkItems(board.WorkItems)); bool workItemIDTry = int.TryParse(Console.ReadLine(), out int resultParse); int workItemID; if (workItemIDTry == false) { return("invalid command"); } else { workItemID = resultParse; } bool ifWorkItemExists = HelperMethods.IfExists(workItemID, board.WorkItems); if (ifWorkItemExists == false) { return($"WorkItem with id {workItemID} does not exist in board {board.Name}."); } IWorkItem workItem = HelperMethods.ReturnExisting(workItemID, board.WorkItems); Console.Clear(); Console.WriteLine("Please enter the new description of the workItem that you wish to change:"); Console.WriteLine($"The current description of {workItem.Title} is: {workItem.Description}"); string description = Console.ReadLine(); HelperMethods.ValidateWorkItemDescription(description); string result = HelperMethods.TimeStamp() + $"WorkItem with id {workItemID} changed it's description."; workItem.Description = description; workItem.History.Add(result); board.History.Add(result); team.History.Add(result); if (workItem is IAssignableItem) { foreach (var item in team.Members) { if (item.WorkItems.Contains(workItem)) { item.History.Add(result); break; } } } return(result); }
public void WorkItemWrapper_UnitTest() { IWorkItem instance = GetTestWorkItem(); Assert.IsNotNull(instance); }
public string Execute() { Console.WriteLine("Please enter the name of the team responsible for the workitem whose rating you want to change:"); Console.WriteLine("List of teams:" + Environment.NewLine + HelperMethods.ListTeams(this.engine.Teams)); string teamName = Console.ReadLine(); bool ifTeamExists = HelperMethods.IfExists(teamName, engine.Teams); if (ifTeamExists == false) { return("Team with such name does not exist."); } ITeam team = HelperMethods.ReturnExisting(teamName, engine.Teams); Console.Clear(); Console.WriteLine("Please enter board where the workitem features:"); Console.WriteLine("List of boards:" + Environment.NewLine + HelperMethods.ListBoards(team.Boards)); string boardName = Console.ReadLine(); bool ifBoardExists = HelperMethods.IfExists(boardName, team.Boards); if (ifBoardExists == false) { return($"Board with name {boardName} does not exist in team {team.Name}."); } IBoard board = HelperMethods.ReturnExisting(boardName, team.Boards); Console.Clear(); Console.WriteLine("Please enter the id of the workitem that you wish to change:"); Console.WriteLine($"List of workitems in team {board.Name}:" + Environment.NewLine + HelperMethods.ListWorkItems(board.WorkItems)); int workItemID = int.Parse(Console.ReadLine()); bool ifWorkItemExists = HelperMethods.IfExists(workItemID, board.WorkItems); if (ifWorkItemExists == false) { return($"WorkItem with id {workItemID} does not exist in board {board.Name}."); } IWorkItem workItem = HelperMethods.ReturnExisting(workItemID, board.WorkItems); if (workItem is IFeedback == false) { return($"The selected WorkItem is not of type feedback. Only feedbacks have rating."); } IFeedback feedback = workItem as IFeedback; Console.Clear(); Console.WriteLine("Please enter new rating for the feedback from 1 to 10:"); Console.WriteLine($"The current size of {feedback.Title} is: {feedback.Rating}"); bool ratingTry = int.TryParse(Console.ReadLine(), out int resultParse); int rating; if (ratingTry == false) { return("invalid command"); } else { rating = resultParse; } HelperMethods.ValidateFeedbackRating(rating); if (rating == feedback.Rating) { return($"The selected WorkItem is already rated with {rating}."); } string result = HelperMethods.TimeStamp() + $"WorkItem with id {feedback.ID} changed it's rating to {rating}."; feedback.Rating = rating; feedback.History.Add(result); board.History.Add(result); team.History.Add(result); return(result); }
public void CalculateFieldLists_UnitTest() { IWorkItem instance = GetTestWorkItem(); instance.CalculateFieldLists(0); }
public override bool Matches(IWorkItem item) { return(this.ApplicableTypes.Contains(item.TypeName, StringComparer.OrdinalIgnoreCase)); }
/// <summary> /// Raises the <see cref="ChangedWorkItemState"/> event. /// </summary> /// <param name="workItem"> /// The <see cref="IWorkItem"/> that has changed <see cref="IWorkItem.State"/>. /// </param> /// <param name="previousState"> /// One of the <see cref="WorkItemState"/> values indicating the previous state of the <paramref name="workItem"/>. /// </param> /// <remarks> /// The <b>OnChangedWorkItemState</b> method allows derived classes to handle the event without attaching a delegate. This /// is the preferred technique for handling the event in a derived class. /// <para> /// When a derived class calls the <b>OnChangedWorkItemState</b> method, it raises the <see cref="ChangedWorkItemState"/> event by /// invoking the event handler through a delegate. For more information, see /// <a href="ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpguide/html/cpconProvidingEventFunctionality.htm">Raising an Event</a>. /// </para> /// </remarks> protected virtual void OnChangedWorkItemState(IWorkItem workItem, WorkItemState previousState) { ChangedWorkItemStateEventHandler handler; lock (eventLock) { handler = changedWorkItemState; } if (handler != null) { handler (this, new ChangedWorkItemStateEventArgs(workItem, previousState)); } }
/// <summary> /// The background task to execute. /// </summary> /// <param name="work">The unit of work to execute as task.</param> public void ExecuteWorkItem(IWorkItem work) { work.ExecuteWorkItem(); }
public void Enqueue(IWorkItem item) { shortTaskQueue.Add(item); }
public string Execute() { Console.WriteLine("Please enter the name of the team responsible for the workitem where you want to add a comment"); Console.WriteLine("List of teams:" + Environment.NewLine + HelperMethods.ListTeams(this.engine.Teams)); string teamName = Console.ReadLine(); bool ifTeamExists = HelperMethods.IfExists(teamName, engine.Teams); if (ifTeamExists == false) { return("Team with such name does not exist."); } ITeam team = HelperMethods.ReturnExisting(teamName, engine.Teams); Console.Clear(); Console.WriteLine("Please enter board where the workitem features:"); Console.WriteLine("List of boards:" + Environment.NewLine + HelperMethods.ListBoards(team.Boards)); string boardName = Console.ReadLine(); bool ifBoardExists = HelperMethods.IfExists(boardName, team.Boards); if (ifBoardExists == false) { return($"Board with name {boardName} does not exist in team {team.Name}."); } IBoard board = HelperMethods.ReturnExisting(boardName, team.Boards); Console.Clear(); Console.WriteLine("Please enter the id of the workitem where you want to add a comment:"); Console.WriteLine($"List of workitems in team {board.Name}:" + Environment.NewLine + HelperMethods.ListWorkItems(board.WorkItems)); int workItemID = int.Parse(Console.ReadLine()); bool ifWorkItemExists = HelperMethods.IfExists(workItemID, board.WorkItems); if (ifWorkItemExists == false) { return($"WorkItem with id {workItemID} does not exist in board {board.Name}."); } IWorkItem workItem = HelperMethods.ReturnExisting(workItemID, board.WorkItems); Console.Clear(); Console.WriteLine("Please enter id of the member who wants to add a comment:"); Console.WriteLine("- List of members:" + Environment.NewLine + HelperMethods.ListMembers(team.Members)); bool tryMemberId = int.TryParse(Console.ReadLine(), out int resultParse); int memberId; if (tryMemberId == false) { return("invalid command"); } else { memberId = resultParse; } bool ifMemberExists = HelperMethods.IfExists(memberId, team.Members); if (ifMemberExists == false) { return($"Member with id {memberId} does not exist in team {teamName}."); } IMember member = HelperMethods.ReturnExisting(memberId, team.Members); string author = $"{workItem.Comments.Count+1}." + HelperMethods.TimeStamp() + " " + member.Name; Console.Clear(); Console.WriteLine("Please enter a comment:"); string comment = Console.ReadLine(); workItem.Comments.Add(author, comment); return("Comment was sucessfully added."); }