public async Task <ActionResult <WorkItemDto> > CreateWorkItem([FromBody] WorkItemCreateDto dto) { var workItemStatus = new WorkItemStatus(dto.Status); var workItem = new WorkItem(dto.ProjectId, dto.Title, dto.Description, workItemStatus); workItem = await _workItemsRepository.SaveWorkItem(workItem); var createdDto = _mapper.Map <WorkItemDto>(workItem); return(CreatedAtAction(nameof(GetWorkItem), new { id = createdDto.Id }, createdDto)); }
public async Task <IActionResult> GetById(Guid id) { WorkItemStatus workItemStatus = await _repository.GetByIdAsync(id); if (workItemStatus == null) { return(NotFound()); } return(Ok(_mapper.Map(workItemStatus))); }
public async Task SetStatus(IWorkItem item, WorkItemStatus status) { GdbTableIdentity tableId = item.Proxy.Table; ISourceClass source = GeodatabaseBySourceClasses.Keys.FirstOrDefault(s => s.Uses(tableId)); Assert.NotNull(source); // todo daro: read / restore item again from db? restore pattern in case of failure? await SetStatusCoreAsync(item, source); }
private WorkItem(string id, string path, IEnumerable <string> workItemClasses, WorkItemStatus status, WorkItemParent parent, int?ordinal, NameValueCollection properties, DateTime?lastUpdated, DateTime?lastMoved) { Id = id; Path = path; Classes = workItemClasses; Status = status; Parent = parent; Timestamp = lastUpdated; LastMoved = lastMoved; _ordinal = ordinal; _properties = properties; }
private WorkItem(string id, string path, IEnumerable<string> workItemClasses, WorkItemStatus status, WorkItemParent parent, int? ordinal, NameValueCollection properties, DateTime? lastUpdated, DateTime? lastMoved) { Id = id; Path = path; Classes = workItemClasses; Status = status; Parent = parent; Timestamp = lastUpdated; LastMoved = lastMoved; _ordinal = ordinal; _properties = properties; }
// If your activity returns a value, derive from CodeActivity<TResult> // and return the value from the Execute method. protected override void Execute(CodeActivityContext context) { context.Track( new CustomTrackingRecord(WorkItemStatus.Get(context)) { Data = { { CustomProgressTrackingDataKey.Target, Item.Get(context) }, { CustomProgressTrackingDataKey.Message, ProgressMessage.Get(context) } } }); }
/// <summary> /// Return a WorkItemStatus by the given WorkItemStatusID /// </summary> /// <param name="workItemStatusID"></param> /// <returns></returns> private WorkItemStatus GetWorkItemStatus(int workItemStatusID) { WorkItemStatus rValue = null; foreach (WorkItemStatus wis in WorkItemStatuses) { if (wis.WorkItemStatusID == workItemStatusID) { rValue = wis; } } return(rValue); }
public void Execute() { this.Status = WorkItemStatus.Running; WorkItemStatusUpdated.Invoke(this, new WorkItemStatusUpdatedEventArgs(this.Status)); for (int i = 0; i < Duration; i++) { Thread.Sleep(100); } this.Status = WorkItemStatus.Completed; WorkItemStatusUpdated.Invoke(this, new WorkItemStatusUpdatedEventArgs(this.Status)); }
private static char TaskIcon(WorkItemStatus status) { switch (status) { case WorkItemStatus.Running: return('~'); case WorkItemStatus.Done: return('+'); default: return('!'); } }
/// <summary> /// Creates WorkItem /// </summary> /// <returns>True if successful</returns> private static async Task <dynamic> CreateWorkItem(String bucketkey) { string nickName = ConsumerKey; Bearer bearer = (await Get2LeggedTokenAsync(new Scope[] { Scope.CodeAll })).ToObject <Bearer>(); string downloadUrl = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketkey, inputFileName); string uploadUrl = string.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketkey, inputFileName); JObject iptFile = new JObject { new JProperty("url", downloadUrl), new JProperty("headers", new JObject { new JProperty("Authorization", "Bearer " + InternalToken.access_token) }) }; JObject resultIpt = new JObject { new JProperty("verb", "put"), new JProperty("url", uploadUrl), new JProperty("headers", new JObject { new JProperty("Authorization", "Bearer " + InternalToken.access_token) }) }; WorkItem workItemSpec = new WorkItem( null, string.Format("{0}.{1}+{2}", nickName, ACTIVITY_NAME, ALIAS), new Dictionary <string, JObject>() { { "InputIPT", iptFile }, { "ResultIPT", resultIpt } }, null); WorkItemsApi workItemApi = new WorkItemsApi(); workItemApi.Configuration.AccessToken = bearer.AccessToken; WorkItemStatus newWorkItem = await workItemApi.WorkItemsCreateWorkItemsAsync(null, null, workItemSpec); for (int i = 0; i < 1000; i++) { System.Threading.Thread.Sleep(1000); WorkItemStatus workItemStatus = await workItemApi.WorkItemsGetWorkitemsStatusAsync(newWorkItem.Id); if (workItemStatus.Status == WorkItemStatus.StatusEnum.Pending || workItemStatus.Status == WorkItemStatus.StatusEnum.Inprogress) { continue; } break; } await CheckintoVault(uploadUrl); return(new Output(Output.StatusEnum.Sucess, "Activity created")); }
/// <summary> /// Prepares a list of distinct WorkItemStatuses of the selected items. /// </summary> private void PreparePotentialStatusImports() { _importStatuses = new List <WorkItemStatus>(); if (LoadList.SelectedItems.Count > 0) { foreach (WorkItemImportListEntry item in LoadList.SelectedItems) { WorkItemStatus status = GetStatusByLabel(item.Status); if (_importStatuses.Contains(status) == false) { _importStatuses.Add(status); } } } }
protected void AddItem(IMitigation mitigation, WorkItemStatus status, string assignedTo) { var index = _captions.IndexOf(status.GetEnumLabel()); if (mitigation != null && index >= 0) { var item = new KanbanItem(mitigation, index); if (!string.IsNullOrWhiteSpace(assignedTo)) { item.SetInfo("Assigned To", assignedTo); } item.MoveRequired += ItemOnMoveRequired; Add(item, index); } }
protected void MoveItem(IMitigation mitigation, WorkItemStatus initialStatus, WorkItemStatus finalStatus) { var indexInitial = _captions.IndexOf(initialStatus.GetEnumLabel()); var indexFinal = _captions.IndexOf(finalStatus.GetEnumLabel()); var item = GetItem(mitigation, indexInitial); if (item != null && indexInitial >= 0 && indexFinal >= 0) { Remove(item, indexInitial); Add(item, indexFinal); RefreshPalette(indexInitial); RefreshPalette(indexFinal); } }
/// <summary> /// Given a specified label, return the WorkItemStatus. /// </summary> /// <param name="status"></param> /// <returns></returns> private WorkItemStatus GetStatusByLabel(string status) { WorkItemStatus rValue = null; foreach (WorkItemStatus wis in _statuses) { if (wis.Status == status) { rValue = wis; break; } } return(rValue); }
public async Task <IActionResult> Post(WorkItemStatusRequest request) { try { WorkItemStatus workItemStatus = _mapper.Map(request); workItemStatus = await _repository.AddAsync(workItemStatus); return(CreatedAtAction(nameof(GetById), new { id = workItemStatus.Id }, _mapper.Map(workItemStatus))); } catch (DataStoreException e) { _logger.LogError(e.Message, e, request); return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "workitem/{workItemId}")] HttpRequest req, //[Queue("completedworkitems", Connection = "StorageConnectionString")] IAsyncCollector<WorkItemStatus> completedWorkItemsQueue, string workItemId, ILogger log) { log.LogInformation("C# HTTP trigger function processed the GetWorkItemStatus request."); try { Autodesk.Forge.Core.ApiResponse <WorkItemStatus> workItemResponse = await _workItemApi.GetWorkitemStatusAsync(workItemId); WorkItemStatus workItemStatus = workItemResponse.Content; if (workItemStatus.Status == Status.Pending || workItemStatus.Status == Status.Inprogress) { // check if the workItem run for less than a hour TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Dateline Standard Time"); DateTime now = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo); TimeSpan? duration = now - workItemStatus.Stats.TimeDownloadStarted; TimeSpan maxDuration = new TimeSpan(0, 20, 0); if (duration != null) { TimeSpan durationNNull = duration ?? default(TimeSpan); int result = TimeSpan.Compare(durationNNull, maxDuration); if (result == 1) { await _workItemApi.DeleteWorkItemAsync(workItemId); } } } // else // { // await completedWorkItemsQueue.AddAsync(workItemStatus); // } return(new OkObjectResult(workItemStatus)); } catch (Exception ex) { return(new BadRequestObjectResult(ex)); } }
public void WorkComplete_ShouldUpdateWorkItemWithCorrectStatus( TaskExecutionResult.TaskExecutionStatus taskStatus, WorkItemStatus workItemStatus) { var taskResult = new TaskExecutionResult(taskStatus, 1, null); var workItem = AutoFixture.Create <WorkItem>(); workItem.AssignTo(AutoFixture.Create <WorkerRegistration>()); _mockRepository.Setup(r => r.Get <WorkItem>(taskResult.WorkItemId)).Returns(workItem); _mockRepository.Setup(r => r.Put(It.Is <WorkItem>(wi => wi.Status.Equals(workItemStatus)))).Verifiable(); _taskServiceWithMockRepository.WorkComplete(new WorkerRequest <TaskExecutionResult>(Guid.NewGuid()) { Body = taskResult }); _mockRepository.VerifyAll(); }
public virtual object GetValue(WorkItemStatus status) { switch (status) { case WorkItemStatus.Done: return(_statusSchema.DoneValue); case WorkItemStatus.Todo: return(_statusSchema.TodoValue); case WorkItemStatus.Unknown: return(DBNull.Value); default: throw new ArgumentException( $@"Illegal status value: {status}", nameof(status)); } }
public void AddStatus(int id, [FromBody] WorkItemStatus domain) { domain.MindWorkId = id; var set = _dbContext.Set <WorkItemStatus>(); if (set.FirstOrDefault(e => e.Name == domain.Name && e.MindWorkId == id) != null) { ModelState.AddModelError("Name", "名称重复了"); } if (!ModelState.IsValid) { throw this.Exception(ModelState); } set.Add(domain); _dbContext.SaveChanges(); }
public async Task HandleStatus(WorkItemStatus wiStatus) { if (_saveReport == SaveReport.Off) { return; } if (_saveReport == SaveReport.ErrorsOnly && wiStatus.Status == Status.Success) { return; } // TODO: make it in background var reportName = $"{DateTime.UtcNow:yyyy-MM-dd_HH-mm-ss}_{wiStatus.Id}.txt"; string reportFullname = Path.Combine(_lazyReportDir.Value, reportName); _logger.LogInformation($"Saving {wiStatus.Id} report to {reportName}"); try { // download and save report HttpClient client = _clientFactory.CreateClient(); await using var reportStream = await client.GetStreamAsync(wiStatus.ReportUrl); await using var reportFileStream = new FileStream(reportFullname, FileMode.CreateNew); await reportStream.CopyToAsync(reportFileStream); // save statistics if (wiStatus.Stats != null) { var statsFullName = Path.ChangeExtension(reportFullname, ".stats.json"); await using var statsFileStream = new FileStream(statsFullName, FileMode.CreateNew); await using var jsonWriter = new Utf8JsonWriter(statsFileStream); JsonSerializer.Serialize(jsonWriter, wiStatus.Stats); } } catch (Exception e) { // downloading report should not stop site functionality, // so write log error message and swallow the exception _logger.LogError(e, $"Failed to download report for {wiStatus.Id}"); } }
private WorkItemInfo[] QueryWorkItems(WorkItemStatus status, string type) { WorkItemQueryResult workItemQueryResult = new WorkItemQueryResult(); List <WorkItemInfo> list = new List <WorkItemInfo>(); base.Context.Logger.Log(MigrationEventType.Information, "Querying for workitems of Type: {0} Status: {1}", new object[] { type, status }); try { do { workItemQueryResult = this.symphonyProxy.QueryWorkItems(this.ForestName, null, type, status, 1000, workItemQueryResult.Bookmark); list.AddRange(workItemQueryResult.WorkItems); }while (workItemQueryResult.HasMoreResults); } catch (Exception ex) { if (ex is MigrationTransientException || ex is MigrationPermanentException || ex is InvalidOperationException) { base.Context.Logger.Log(MigrationEventType.Error, "Error querying workitems. Forest: {0} Type: {1} Status: {2} Exception: {3}", new object[] { this.ForestName, type, status, ex }); throw new ErrorQueryingWorkItemException(ex); } throw; } base.Context.Logger.Log(MigrationEventType.Information, "Found {0} workitems for query of Forest: {1} Type: {2} Status: {3}", new object[] { list.Count, this.ForestName, type, status }); this.queriedCount += list.Count; return(list.ToArray()); }
public void UpdateStatus([FromBody] WorkItemStatus domain) { var set = _dbContext.Set <WorkItemStatus>(); if (set.FirstOrDefault(e => e.Name == domain.Name && e.MindWorkId == domain.MindWorkId) != null) { ModelState.AddModelError("Name", "名称重复了"); } if (!ModelState.IsValid) { throw this.Exception(ModelState); } var old = set.Find(domain.Id); old.Name = domain.Name; old.Order = domain.Order; _dbContext.SaveChanges(); }
public async Task <WorkItemStatus> RunWorkItemAsync(Dictionary <string, IArgument> workItemArgs, IForgeAppBase config) { // create work item var wi = new WorkItem { ActivityId = await GetFullActivityId(config), Arguments = workItemArgs }; // run WI and wait for completion var sw = Stopwatch.StartNew(); WorkItemStatus status = await LaunchAndWait(wi); _logger.LogInformation($"WI {status.Id} completed with {status.Status} in {sw.ElapsedMilliseconds} ms"); _logger.LogInformation($"{status.ReportUrl}"); await _postProcessing.HandleStatus(status); return(status); }
private static string GetOperationDescription(WorkItemStatus status) { string operationDescription; switch (status) { case WorkItemStatus.Todo: operationDescription = "Set status of work item to 'Not Corrected'"; break; case WorkItemStatus.Done: operationDescription = "Set status of work item to 'Corrected'"; break; default: throw new ArgumentException($"Invalid status for operation: {status}"); } return(operationDescription); }
private void SetWorkItemReady() { // check if there is something Ready or in Process Then just wait for their Ready Call if (WorkItems.Any(x => x.Status == Status.Ready || x.Status == Status.Processed)) { return; } // get next ready WorkItem // TODO Return Queing Status ? or Move method to Machine var nextItem = WorkItems.Where(x => x.Status == Status.InQueue || x.Status == Status.Created) .OrderBy(x => x.WorkSchedule.HierarchyNumber) .FirstOrDefault(); if (nextItem == null) { DebugMessage("Cannot start next."); return; } var comunicationAgent = ComunicationAgents.FirstOrDefault(x => x.ContractType == nextItem.WorkSchedule.MachineGroup.Name); DebugMessage("SetFirstWorkItemReady From Status " + nextItem.Status + " Time " + Context.TimePeriod); nextItem.Status = Status.Ready; nextItem.WasSetReady = true; // create StatusMsg var message = new WorkItemStatus { WorkItemId = nextItem.Id, CurrentPriority = nextItem.Priority(Context.TimePeriod), // TODO MAY NEED TO RECALCULATE IN FUTURE Status = Status.Ready, // TODO: MAybe need to change to an Extra Field -> bool IsReady }; // tell Item in Queue to set it ready. CreateAndEnqueueInstuction(methodName: ComunicationAgent.InstuctionsMethods.SetWorkItemStatus.ToString(), objectToProcess: message, targetAgent: comunicationAgent); // ,waitFor: 1); // Start Production during the next time period }
private bool IsVisible([NotNull] IWorkItem item, WorkItemVisibility visibility) { WorkItemStatus status = item.Status; switch (visibility) { case WorkItemVisibility.None: return(false); case WorkItemVisibility.Todo: return((status & WorkItemStatus.Todo) != 0); case WorkItemVisibility.Done: return((status & WorkItemStatus.Done) != 0); case WorkItemVisibility.All: return(true); default: throw new ArgumentOutOfRangeException(nameof(visibility), visibility, null); } }
public async Task <IActionResult> Delete(Guid id) { try { WorkItemStatus workItemStatus = await _repository.GetByIdAsync(id); if (workItemStatus == null) { return(NotFound()); } await _repository.DeleteAsync(workItemStatus); return(Ok(id)); } catch (DataStoreException e) { _logger.LogError(e.Message, e, id); return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public (bool, string) ChangestateofWorkItem(int id, WorkItemStatus status) { try { var item = db.WorkItem.Find(id); if (item == null) { return(false, "Item not found"); } else { item.Status = status; db.Entry(item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true, "Item updated"); } } catch (Exception ex) { return(false, ex.Message); } }
private async Task <dynamic> GetWorkItemId(XrefTreeArgument inputFileArgument, XrefTreeArgument outputFileArgument, XrefTreeArgument inputJsonArgument, string callbackUrl, string ActivityId) { WorkItem workItemSpec = new WorkItem() { ActivityId = ActivityId, Arguments = new Dictionary <string, IArgument>() { { "inputFile", inputFileArgument }, { "inputJson", inputJsonArgument }, { "outputFile", outputFileArgument }, { "onComplete", new XrefTreeArgument { Verb = Verb.Post, Url = callbackUrl } } } }; WorkItemStatus workItemStatus = await _repository.CreateWorkItem(workItemSpec); return(new { WorkItemId = workItemStatus.Id }); }
private void ChangeStatus(WorkItemStatus newStatus) { ThrowIfWorkItemTerminated(); WorkItemStatus oldStatus = status; if (oldStatus != newStatus) { CancelEventArgs args = new CancelEventArgs(); FireIfActivating(newStatus, args); FireIfDeactivating(newStatus, args); FireIfTerminating(newStatus); if (args.Cancel == false) { status = newStatus; if (ActivationService != null) { ActivationService.ChangeStatus(this); } FireStatusEvents(); } } }
private void UpdateWIStatus(WorkItemInfo workItem, WorkItemStatus newStatus, string comment) { if (workItem.WorkItemStatus.Status == newStatus && string.Equals(workItem.WorkItemStatus.Comment, comment)) { base.Context.Logger.Log(MigrationEventType.Information, "workItem '{0}' status is already set to {1} so skipping update-WI", new object[] { workItem.WorkItemId, newStatus }); return; } if (workItem.WorkItemStatus.Status != WorkItemStatus.InProgress && newStatus != WorkItemStatus.ForceComplete) { base.Context.Logger.Log(MigrationEventType.Information, "First forcing WI status from {0} to InProgress", new object[] { workItem.WorkItemStatus.Status }); workItem.WorkItemStatus.Status = WorkItemStatus.InProgress; this.symphonyProxy.UpdateWorkItem(workItem.WorkItemId, workItem.WorkItemStatus); } base.Context.Logger.Log(MigrationEventType.Information, "updating workItem '{0}' status from {1} to {2} Comment: '{3}'", new object[] { workItem.WorkItemId, workItem.WorkItemStatus.Status, newStatus, string.IsNullOrEmpty(comment) ? "<none>" : comment }); workItem.WorkItemStatus.Status = newStatus; if (comment != null && comment.Length > 4000) { base.Context.Logger.Log(MigrationEventType.Information, "Truncating Comment reported to Symphony", new object[0]); comment = comment.Substring(0, 3997) + "..."; } workItem.WorkItemStatus.Comment = comment; this.symphonyProxy.UpdateWorkItem(workItem.WorkItemId, workItem.WorkItemStatus); this.workItemUpdatedCount++; }
private DefaultHumanFinishRuleAsserter.Execution E(string action, WorkItemStatus status) { return new DefaultHumanFinishRuleAsserter.Execution(action, status); }
public void ShouldNotContinueIfParentIsFinalState(WorkItemStatus state) { var parent = new WorkItem { JobId = Helpers.Integer(), WorkflowPath = "parent", Status = state }; var parentId = _workItemRepo.Add(parent); var child = new WorkItem { ParentId = parentId, WorkflowPath = "child", Status = WorkItemStatus.Failed, ExceptionId = Helpers.Integer() }; _navigator.Find(parent.WorkflowPath).Returns(Helpers.BuildFork()); _dataStore.Add(parent.JobId, 1, typeof (int)).ReturnsForAnyArgs(1); _stateMachine.Transit(child, _engine); _engine.DidNotReceiveWithAnyArgs().Kick(null); }
/// <summary> /// 修改工作项状态 /// </summary> /// <param name="workItemID">工作项ID</param> /// <param name="status">工作项状态</param> public void UpdateWorkItemStatus(string workItemID, WorkItemStatus status) { WorkItem workItem = repository.GetDomain<WorkItem>(workItemID); if (workItem == null) { log.Warn("UpdateWorkItemStatus error workitem is null"); return; } workItem.CurrentState = (short)status; repository.Update(workItem); }
private void DoneWork() { this.status = WorkItemStatus.DONE; }
public WorkItem UpdateStatus(WorkItemStatus status) { return new WorkItem(Id, Path, Classes, status, Parent, _ordinal, _properties, Timestamp, LastMoved); }
//WorkItem public static void ChangeWorkItemStatus(WorkItem w, WorkItemStatus status) { w.ChangeStatus(status); }
public WorkItem( int parameter ) { this.status = WorkItemStatus.CREATED; this.parameter = parameter; }
public void DoWork() { this.status = WorkItemStatus.PROGRESS; }
private void RestoredWork() { this.status = WorkItemStatus.CREATED; }
public Execution(string result, WorkItemStatus status) { this.Status = status; this.Result = result; }