public override void SaveNew(TaskInstance ti) { var ph = GetProcessRecord(ti.ProcessInstanceId, true); if (ph == null) { //new instance ph = new ProcessHolder { ProcessInstance = ti.ProcessInstanceId, State = RecordState.New, IsForUpdate = true, DbVersion = null, TaskInstances = new List <TaskInstance>() }; ph.TaskInstances.Add(ti); _cache[ph.ProcessInstance] = ph; } else { var i2 = ph.TaskInstances.FindIndex(x => x.InstanceId == ti.InstanceId); if (i2 >= 0) { throw new Exception("Task already exists: " + ti.InstanceId); } ph.TaskInstances.Add(ti); if (ph.State == RecordState.Unmodified) { ph.State = RecordState.Modified; } } }
public static void ExecutePdf(TaskInstance taskInstance) { try { // //Console.WriteLine("Execute pdf task"); IEnumerable <DataBaseDomian.Orm.TaskSelection> taskSelections = TaskSystemDataRepository.Instance. GetSelectionsTasks(taskInstance.TaskInstanceID); foreach (var taskSelection in taskSelections) { // var pdm = PdmFactory.CreateSolidWorksPdmAdapter(); // add conditions: which of pdm systems will be initialised. //recomended using PdmType with namespace PDM { SolidWorksPdm, Ips } //var fileModel = SolidWorksPdmAdapter.Instance.GetFileById((int)eachTaskSelections.DocumentID, true); //string pathToTempFile = // string pathToPdmFile = (pdm as SolidWorksPdmAdapter).AddToPdm(pathToTempFile, dataModel.FolderPath); // (pdm as SolidWorksPdmAdapter).CheckInOutPdm(pathToPdmFile, true); } TaskSystemDataRepository.Instance.ApplyCompleted(taskInstance.TaskInstanceID); } catch //(Exception exception) { // //Console.WriteLine(exception.ToString()); TaskSystemDataRepository.Instance.ApplyError(taskInstance.TaskInstanceID); } }
private EntityResult CreateOccurrence(TaskInstance instance) { Data.Model.Occurrence occurrence = new Occurrence() { AsEarlyAsDate = instance.AsEarlyAsDate, AssetId = instance.AssetId, Date = instance.Date, FormModel = instance.FormModel, ScheduleId = instance.ScheduleId, TaskId = instance.TaskId, UserId = instance.UserId, TimeSpent = 0 }; occurrence.Logs.Add(new OccurrenceLog() { Type = "Created" }); _context.Occurrences.Add(occurrence); var result = _context.SaveChanges(); if (!result.Succeeded) { _context.Entry(occurrence).Reference(o => o.Asset).Load(); _context.Entry(occurrence).Reference(o => o.User).Load(); SignalRHub.NotifyOccurrenceCreate(null, occurrence.ToDto()); return(EntityResult.Failed(result.Errors.ToArray())); } return(EntityResult.Succeded(1)); }
public void FinishTask(Guid taskInstanceID, int taskActionId, string userName, string newPerformerID, string comment) { TaskAction action = wfs.GetTaskActionByID(taskActionId); TaskInstance ts = wfs.GetTaskInstanceByID(taskInstanceID); FinishTask(ts, action, userName, newPerformerID, comment, null); }
/// <summary> /// Waits for the task instance status to change or timeout /// </summary> /// <param name="id"></param> /// <param name="process"></param> /// <param name="currentStatus"></param> /// <param name="timeout"></param> /// <returns></returns> private TaskInstanceStatues WaitForStatusChange(Guid id, Process process, TaskInstanceStatues currentStatus, TimeSpan timeout) { var timeNow = DateTime.UtcNow; var waitTimeout = timeNow.Add(timeout); TaskInstanceStatues newStatus = currentStatus; do { // Wait a bit before we check the status if (!process.HasExited) { Thread.Sleep(2000); } using var scope = _repositoryFactory.BeginRepositoryScope(); var taskInstanceRepository = scope.CreateRepository <ITaskInstanceRepository>(); TaskInstance taskInstance = taskInstanceRepository.Get(id); newStatus = taskInstance.Status; } while (currentStatus == newStatus && DateTime.UtcNow < waitTimeout && !process.HasExited); _auditEventRepository.Insert(AuditEventFactory.CreateAuditEventForInformationMessage(0, 0, string.Format("WaitForStatusChange [TID: {0}] Waited for {1}", id, DateTime.UtcNow - timeNow))); return(newStatus); }
/// <summary> /// 实现任务分配工作,该方法一般的实现逻辑是: /// 首先根据performerName查询出所有的操作员,可以把performerName当作角色名称。 /// 然后调用asignable.asignToActor(String actorId,Boolean needSign)或者 /// asignable.asignToActor(String actorId)或者asignable.asignToActorS(List actorIds) /// 进行任务分配。 /// </summary> /// <param name="asignable">IAssignable实现类,在FireWorkflow中实际上就是TaskInstance对象。</param> /// <param name="performerName">角色名称</param> public void assign(IAssignable asignable, String performerName)// throws EngineException, KernelException { if (ActorIdsList == null || ActorIdsList.Count == 0) { TaskInstance taskInstance = (TaskInstance)asignable; throw new EngineException(taskInstance.ProcessInstanceId, taskInstance.WorkflowProcess, taskInstance.TaskId, "actorIdsList can not be empty"); } List <IWorkItem> workItems = asignable.assignToActors(ActorIdsList); ITaskInstance taskInst = (ITaskInstance)asignable; //如果不需要签收,这里自动进行签收,(FormTask的strategy="all"或者=any并且工作项数量为1) if (!IsNeedClaim) { if (FormTaskEnum.ALL == taskInst.AssignmentStrategy || (FormTaskEnum.ANY == taskInst.AssignmentStrategy && ActorIdsList.Count == 1)) { for (int i = 0; i < workItems.Count; i++) { IWorkItem wi = workItems[i]; wi.claim(); } } } }
public async void BubblesCancellation() { try { //Arrange Setup(); var bingTask = new TaskInstance() { Enabled = true, Name = "Bing", Version = "0.1.2", Id = Guid.NewGuid() }; var pingTask = new TaskInstance() { Enabled = true, Name = "Ping", Version = "0.1.1", Id = Guid.NewGuid() }; var bingVersion = new TaskVersion(bingTask.Version); var pingVersion = new TaskVersion(pingTask.Version); _taskServer .Setup(x => x.GetTaskContentZipAsync(It.IsAny<Guid>(), It.IsAny<TaskVersion>(), _ec.Object.CancellationToken)) .Returns((Guid taskId, TaskVersion taskVersion, CancellationToken token) => { _ecTokenSource.Cancel(); return Task.FromResult<Stream>(GetZipStream()); }); var tasks = new List<TaskInstance>(new TaskInstance[] { bingTask, pingTask }); //Act //should initiate a download with a mocked IJobServer, which sets a cancellation token and //download task is expected to be in cancelled state Task downloadTask = _taskManager.DownloadAsync(_ec.Object, tasks); Task[] taskToWait = { downloadTask, Task.Delay(2000) }; //wait for the task to be cancelled to exit await Task.WhenAny(taskToWait); //Assert //verify task completed in less than 2sec and it is in cancelled state Assert.True(downloadTask.IsCompleted, $"{nameof(_taskManager.DownloadAsync)} timed out."); Assert.True(!downloadTask.IsFaulted, downloadTask.Exception?.ToString()); Assert.True(downloadTask.IsCanceled); //check if the task.json was not downloaded for ping and bing tasks Assert.Equal( 0, Directory.GetFiles(IOUtil.GetTasksPath(_hc), "*", SearchOption.AllDirectories).Length); //assert download was invoked only once, because the first task cancelled the second task download _taskServer .Verify(x => x.GetTaskContentZipAsync(It.IsAny<Guid>(), It.IsAny<TaskVersion>(), _ec.Object.CancellationToken), Times.Once()); } finally { Teardown(); } }
protected override object LoadInternal(Call call, bool lazy, TaskInstance taskInstance) { string json = File.ReadAllText(DataPath); object obj = JsonConvert.DeserializeObject(json); return(obj); }
public override void Load(Call call, TabModel model) { TaskInstance = new TaskInstance(); TaskInstance.Log.Add("Double Tag Test", new Tag("Double", 0.5)); _sampleCall = new Call(Label); _counter = 0; model.Items = new List <ListItem>() { new("Task Instance Log", TaskInstance.Log), new("Sample Call", _sampleCall), new("Sample Call Log", _sampleCall.Log), new("Log Entry", new LogEntry(null, LogLevel.Info, "test", null)), }; model.Actions = new List <TaskCreator>() { new TaskAction("Add 1 Entry", () => AddEntries(1)), new TaskAction("Add 10 Entries", () => AddEntries(10)), new TaskAction("Add 100 Entries", () => AddEntries(100)), new TaskAction("Add 1,000 Entries", () => AddEntries(1000)), new TaskAction("Add 10,000 Entries", () => AddEntries(10000)), new TaskDelegate("Reset", Reset), // Tests different threading contexts new TaskAction("System.Timer: Log 1 Entry / second", () => StartSystemTimer()), //new TaskAction("Threading.Timer: Log 1 Entry / second", () => StartThreadTimer()), new TaskDelegate("Task Delegate Thread: Log 1 Entry / second", SubTaskInstances, true), }; //actions.Add(new TaskAction("Add Child Entry", () => AddChildEntry())); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,InputParams,Finished,Resoult")] TaskInstance taskInstance) { if (id != taskInstance.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(taskInstance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskInstanceExists(taskInstance.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(taskInstance)); }
private void InitTask() { int taskInstanceId = Intent.GetIntExtra("TASK_INSTANCE_ID", 0); if (taskInstanceId != 0) { m_TaskInstance = DBController.Instance.GetTaskInstance(taskInstanceId); InitTaskHeader(m_TaskInstance.Task); foreach (TaskItem taskItem in m_TaskInstance.Task.TaskItems.OrderBy(x => x.SeqNo)) { if (taskItem.UITypeId == UIType.uiSelect) { InitTaskItemSelect(taskItem); } else if (taskItem.UITypeId == UIType.uiFormula) { InitTaskItemFormula(taskItem); } else if (taskItem.UITypeId == UIType.uiText) { InitTaskItemText(taskItem); } } } }
public async Task <IActionResult> Edit(long id, [Bind("LastExecutionStatus,TaskInstanceId,TaskMasterId,ScheduleInstanceId,ExecutionUid,Adfpipeline,TaskInstanceJson,LastExecutionComment,NumberOfRetries,ActiveYn,CreatedOn,TaskRunnerId,UpdatedOn")] TaskInstance taskInstance) { if (id != taskInstance.TaskInstanceId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(taskInstance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskInstanceExists(taskInstance.TaskInstanceId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(IndexDataTable))); } ViewData["ScheduleInstanceId"] = new SelectList(_context.ScheduleInstance.OrderBy(x => x.ScheduleInstanceId), "ScheduleInstanceId", "ScheduleInstanceId", taskInstance.ScheduleInstanceId); ViewData["TaskMasterId"] = new SelectList(_context.TaskMaster.OrderBy(x => x.TaskMasterName), "TaskMasterId", "TaskMasterName", taskInstance.TaskMasterId); return(View(taskInstance)); }
public List <SystemTestResult> Execute(SystemTestCategories systemTestCategory) { var results = new List <SystemTestResult>(); try { // Create test task instance TaskInstance taskInstance = TaskInstanceFactory.CreateTestTaskInstance(0, 3); // Execute task, wait for completion, will fail if exe missing, insufficient folder/file permissions //taskResult not used anywhere in this test - so commented out //TaskResult taskResult = new ProcessTaskExecutor(_rootFolder, _repositoryFactory, TimeSpan.FromSeconds(10)).Execute(taskInstance); if (taskInstance.Status != TaskInstanceStatues.CompletedSuccess) { results.Add(new SystemTestResult(SystemTestResult.ResultTypes.Error, _category, "Error testing task executor. It may cause runs to fail.", "")); } } catch (System.Exception exception) { results.Add(new SystemTestResult(SystemTestResult.ResultTypes.Error, _category, string.Format("Error {0} testing task executor. It may cause runs to fail.", exception.Message), "")); } if (!results.Where(r => r.ResultType == SystemTestResult.ResultTypes.Error).Any()) { results.Add(new SystemTestResult(SystemTestResult.ResultTypes.Information, _category, "Task executor test OK", "")); } return(results); }
private void SelectLastItem() { _tabControlDataGrid.MinHeight = _tabControlDataGrid.DesiredSize.Height; MinHeight = _tabControlDataGrid.MinHeight; _tabControlDataGrid.InvalidateMeasure(); IsVisible = ShowTasks; if (AutoSelectNew && TabInstance.Model.Tasks.Count > 0) { TaskInstance taskInstance = TabInstance.Model.Tasks.Last(); if (_tabControlDataGrid.SelectedItem == taskInstance) { UpdateSelection(); } else { _tabControlDataGrid.SelectedItem = taskInstance; } // use lock internally? if (taskInstance.Finished) { TaskCompleted(taskInstance); } else { taskInstance.OnComplete = () => Dispatcher.UIThread.Post(() => TaskCompleted(taskInstance), DispatcherPriority.SystemIdle); } _tabControlDataGrid.MinHeight = Math.Min(TabInstance.Model.Tasks.Count * LineHeight + LineHeight, 6 * LineHeight); } }
// Creates, Starts, and returns a new Task public TaskInstance Start(Call call) { TimesRun++; Context = SynchronizationContext.Current ?? new SynchronizationContext(); call.Log.Settings.Context = Context; var taskInstance = new TaskInstance() { Call = call, Creator = this, }; call.TaskInstance = taskInstance; Action action = CreateAction(call); if (UseTask) { taskInstance.Task = new Task(action); //currentTask.CreationOptions = TaskCreationOptions. taskInstance.Task.ContinueWith(task => taskInstance.SetFinished()); taskInstance.Task.Start(); } else { action.Invoke(); taskInstance.SetFinished(); } return(taskInstance); }
public ITaskInstance createTaskInstance(IWorkflowSession currentSession, RuntimeContext runtimeContxt, IProcessInstance processInstance, Task task, Activity activity)// throws EngineException { TaskInstance taskInstance = new TaskInstance(); return(taskInstance); }
public void SetTaskScriptContext(TaskInstance task, Dictionary <string, object> inputData, Dictionary <string, object> outputData) { throw new NotImplementedException(); //_pd.SetTaskInstanceInfo(task, ctx); _pd.SetInputData(inputData); _pd.SetOutputData(outputData); }
private T FillTaskEvent <T>(TaskInstance ti, T ev) where T : TaskExecEvent { ev.FromProcessInstanceId = ti.ProcessInstanceId; ev.FromTaskInstanceId = ti.InstanceId; ev.ParentTaskInstanceId = ti.ParentTaskInstanceId; return(ev); }
public RoutingTaskSolver(TaskInstance taskInstance) { task = taskInstance; n = taskInstance.Customers.Count; t = new int[n, n]; d = new double[n, n]; demand = new int[n]; startTime = new int[n]; endTime = new int [n]; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { int ind1 = taskInstance.Customers[i].Id; int ind2 = taskInstance.Customers[j].Id; d[ind1, ind2] = Distance(taskInstance.Customers[i].X, taskInstance.Customers[i].Y, taskInstance.Customers[j].X, taskInstance.Customers[j].Y); t[ind1, ind2] = (int)d[ind1, ind2]; d[ind2, ind1] = d[ind1, ind2]; t[ind2, ind1] = t[ind1, ind2]; } } foreach (Customer x in taskInstance.Customers) { demand[x.Id] = x.Demand; startTime[x.Id] = x.StartTime; endTime[x.Id] = x.EndTime; } q = taskInstance.Capacities.ToArray(); q0 = taskInstance.Q0; }
public static bool RunTask(TaskInstance ti) { Console.WriteLine("------- Задание " + ti.SeqNo + " -------\n"); Console.WriteLine("Дано предложение:\n" + ti.Task.Text + "\n"); foreach (TaskItem taskItem in ti.Task.TaskItems) { int? valueInt = null; string valueString = null; int[] valuesInt = null; string[] valuesString = null; if (taskItem.UITypeId == UIType.uiSelect) { valueInt = RunSubTaskSelect(taskItem); } else if (taskItem.UITypeId == UIType.uiFormula) { valuesInt = RunSubTaskFormula(taskItem); } else if (taskItem.UITypeId == UIType.uiText) { valueString = RunSubTaskText(taskItem); } ShowResult(ti.AddAnswer(taskItem.LangItemId, valueInt, valueString, valuesInt, valuesString)); } Console.WriteLine("------- Задание окончено -------\n------------------------------------"); return(ti.IncorrectAnswerAmount == 0); }
public TaskResult Execute(TaskInstance taskInstance) { TaskResult taskResult = new TaskResult(); try { using (var scope = _repositoryFactory.BeginRepositoryScope()) { StartActiveNotifier(taskInstance.Id); TaskUtilities.UpdateTaskInstanceStatus(taskInstance.Id, _repositoryFactory, TaskInstanceStatues.InProgress, null); var autoBookRepository = scope.CreateRepository <IAutoBookRepository>(); string autoBookId = taskInstance.Parameters["AutoBookId"].ToString(); var autoBook = autoBookRepository.Get(autoBookId); _autoBooks.Delete(autoBook); TaskUtilities.UpdateTaskInstanceStatus(taskInstance.Id, _repositoryFactory, TaskInstanceStatues.CompletedSuccess, DateTime.UtcNow); taskResult.Status = TaskInstanceStatues.CompletedSuccess; } } catch (System.Exception exception) { TaskUtilities.UpdateTaskInstanceStatus(taskInstance.Id, _repositoryFactory, TaskInstanceStatues.CompletedError, DateTime.UtcNow); taskResult.Status = TaskInstanceStatues.CompletedError; taskResult.Exception = exception; } finally { StopActiveNotifier(); } return(taskResult); }
public async void BubblesCancellation() { try { //Arrange Setup(); var bingTask = new TaskInstance() { Enabled = true, Name = "Bing", Version = "0.1.2", Id = Guid.NewGuid() }; var pingTask = new TaskInstance() { Enabled = true, Name = "Ping", Version = "0.1.1", Id = Guid.NewGuid() }; var bingVersion = new TaskVersion(bingTask.Version); var pingVersion = new TaskVersion(pingTask.Version); _jobServer .Setup(x => x.GetTaskContentZipAsync(It.IsAny <Guid>(), It.IsAny <TaskVersion>(), _ec.Object.CancellationToken)) .Returns((Guid taskId, TaskVersion taskVersion, CancellationToken token) => { _ecTokenSource.Cancel(); return(Task.FromResult <Stream>(GetZipStream())); }); var tasks = new List <TaskInstance>(new TaskInstance[] { bingTask, pingTask }); //Act //should initiate a download with a mocked IJobServer, which sets a cancellation token and //download task is expected to be in cancelled state Task downloadTask = _taskManager.DownloadAsync(_ec.Object, tasks); Task[] taskToWait = { downloadTask, Task.Delay(2000) }; //wait for the task to be cancelled to exit await Task.WhenAny(taskToWait); //Assert //verify task completed in less than 2sec and it is in cancelled state Assert.True(downloadTask.IsCompleted, $"{nameof(_taskManager.DownloadAsync)} timed out."); Assert.True(!downloadTask.IsFaulted, downloadTask.Exception?.ToString()); Assert.True(downloadTask.IsCanceled); //check if the task.json was not downloaded for ping and bing tasks Assert.Equal( 0, Directory.GetFiles(IOUtil.GetTasksPath(_hc), "*", SearchOption.AllDirectories).Length); //assert download was invoked only once, because the first task cancelled the second task download _jobServer .Verify(x => x.GetTaskContentZipAsync(It.IsAny <Guid>(), It.IsAny <TaskVersion>(), _ec.Object.CancellationToken), Times.Once()); } finally { Teardown(); } }
/// <summary> /// Resumes a <see cref="Altask.Data.Model.Occurrence"/>. /// </summary> /// <param name="occurrenceId"></param> /// <param name="userId"></param> /// <returns>Returns a <see cref="Altask.Data.EntityResult"/> indicating success or failure.</returns> public virtual async Task <ActionResult> Resume(long occurrenceId, int userId) { ThrowIfDisposed(); var userEntity = await Context.Users.FindAsync(userId); if (userEntity == null) { return(BadRequest(ErrorDescriber.DoesNotExist("User"))); } var occurrenceEntity = await Context.Occurrences.FindAsync(occurrenceId); if (occurrenceEntity == null) { return(BadRequest(ErrorDescriber.DoesNotExist("Occurrence"))); } if (!occurrenceEntity.Started.GetValueOrDefault(false)) { return(BadRequest(ErrorDescriber.DefaultError("Occurrence has not been started."))); } if (occurrenceEntity.Completed.GetValueOrDefault(false)) { return(BadRequest(ErrorDescriber.DefaultError("Occurrence has already been completed."))); } if (!occurrenceEntity.StoppedOn.HasValue) { return(BadRequest(ErrorDescriber.DefaultError("Occurrence cannot be resumed. The occurrence was not stopped."))); } occurrenceEntity.ResumedBy = userEntity.UserName; occurrenceEntity.ResumedOn = DateTime.Now; occurrenceEntity.Logs.Add(new Data.Model.OccurrenceLog() { Type = "Resumed" }); Context.Entry(occurrenceEntity).State = EntityState.Modified; var result = await Context.SaveChangesAsync(); if (result.Succeeded) { await AfterUpdateAsync(occurrenceEntity); var taskEntity = await Context.Tasks.FindAsync(occurrenceEntity.TaskId); var scheduleEntity = await Context.Schedules.FindAsync(occurrenceEntity.ScheduleId); var instance = TaskInstance.FromSchedule(taskEntity, occurrenceEntity.Date, scheduleEntity).MergeOccurrence(occurrenceEntity); SignalRHub.NotifyOccurrenceCreate(null, instance, occurrenceEntity.ToDto()); return(Ok(new { instance = instance })); } else { return(BadRequest(result)); } }
public string Serialize(TaskInstance ti, out string taskTypeId) { StringWriter sw = new StringWriter(); _ser.Serialize(new JsonTextWriter(sw), ti); taskTypeId = ti.GetType().FullName; return(sw.ToString()); }
public T Load <T>(Call call = null, bool lazy = false, TaskInstance taskInstance = null) { call ??= new Call(); object obj = Load(call, lazy, taskInstance); if (obj == null) { return(default);
private void InitTaskInstance() { int taskInstanceId = Intent.GetIntExtra("TASK_INSTANCE_ID", 0); if (taskInstanceId != 0) { m_TaskInstance = DBController.Instance.GetTaskInstance(taskInstanceId); } }
// GET: TaskInstance/Create public IActionResult Create() { ViewData["ScheduleInstanceId"] = new SelectList(_context.ScheduleInstance.OrderBy(x => x.ScheduleInstanceId), "ScheduleInstanceId", "ScheduleInstanceId"); ViewData["TaskMasterId"] = new SelectList(_context.TaskMaster.OrderBy(x => x.TaskMasterName), "TaskMasterId", "TaskMasterName"); TaskInstance taskInstance = new TaskInstance(); taskInstance.ActiveYn = true; return(View(taskInstance)); }
private async Task <EntityResult <TaskInstance> > AddSingleOccurrence(Data.Model.Task task, Data.Model.Schedule scheduleEntity, int?assetId, int?userId, DateTime date) { date = date.LessSeconds(); Context.Entry(task).Reference(t => t.Form).Load(); var newOccurrence = new Altask.Data.Model.Occurrence() { AsEarlyAsDate = date, Date = date, FormModel = task.Form.PublishedModel, TaskId = task.Id, TimeSpent = 0, ScheduleId = scheduleEntity.Id, }; var assetEntity = await Context.Assets.FindAsync(assetId); if (assetEntity != null) { newOccurrence.AssetId = assetEntity.Id; } var userEntity = await Context.Users.FindAsync(userId); if (userEntity != null) { newOccurrence.UserId = userEntity.Id; } if (assetEntity == null && userEntity == null) { return(EntityResult <TaskInstance> .Failed(ErrorDescriber.DefaultError("An occurrence must have either and asset or user associated to it."))); } newOccurrence.Logs.Add(new Data.Model.OccurrenceLog() { Type = "Created" }); Context.Occurrences.Add(newOccurrence); BeforeCreate(newOccurrence, newOccurrence.ToDto()); var result = await Context.SaveChangesAsync(); if (result.Succeeded) { await AfterCreateAsync(newOccurrence, true); var instance = TaskInstance.FromSchedule(task, newOccurrence.Date, scheduleEntity).MergeOccurrence(newOccurrence); SignalRHub.NotifyOccurrenceCreate(null, instance, newOccurrence.ToDto()); return(EntityResult <TaskInstance> .Succeded(instance)); } else { return(EntityResult <TaskInstance> .Failed(result.Errors.ToArray())); } }
public TenantModule( IConfiguration applicationConfiguration, IFeatureManager featureManager, TaskInstance taskInstance, Tenant tenant) { _applicationConfiguration = applicationConfiguration; _featureManager = featureManager; _taskInstance = taskInstance; _tenant = tenant; }
public bool EvalFlowCondition(TaskInstance ti, ProcessModel.FlowDef fd, ITaskExecutionContext ctx) { _pd.SetTaskInstanceInfo(ti, ctx); string k = DslUtil.FlowConditionKey(fd.Parent.Id, fd.From, fd.To); if (!_pd._flowConditions.ContainsKey(k)) { throw new Exception("!no flow cond.."); } _pd.SetTaskInstanceInfo(ti, ctx); return(_pd._flowConditions[k]()); }
public async Task <IActionResult> Create([Bind("Id,InputParams,Finished,Resoult")] TaskInstance taskInstance) { if (ModelState.IsValid) { taskInstance.Id = Guid.NewGuid(); _context.Add(taskInstance); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(taskInstance)); }
public void Another(TaskInstance taskInstance) { Console.WriteLine("Another Method entered!"); }
private void CreateTask(string jsonContent, out TaskInstance instance, out string directory) { const string TaskName = "SomeTask"; const string TaskVersion = "1.2.3"; Guid taskGuid = Guid.NewGuid(); directory = Path.Combine(_workFolder, Constants.Path.TasksDirectory, $"{TaskName}_{taskGuid}", TaskVersion); string file = Path.Combine(directory, Constants.Path.TaskJsonFile); Directory.CreateDirectory(Path.GetDirectoryName(file)); File.WriteAllText(file, jsonContent); instance = new TaskInstance() { Id = taskGuid, Name = TaskName, Version = TaskVersion, }; }
public void Queue(TaskInstance taskInstance) { // Do something with my taskInstance Console.WriteLine("Queue Method entered!"); }
public async void BubblesNetworkException() { try { // Arrange. Setup(); var pingTask = new TaskInstance() { Enabled = true, Name = "Ping", Version = "0.1.1", Id = Guid.NewGuid() }; var pingVersion = new TaskVersion(pingTask.Version); Exception expectedException = new System.Net.Http.HttpRequestException("simulated network error"); _taskServer .Setup(x => x.GetTaskContentZipAsync(It.IsAny<Guid>(), It.IsAny<TaskVersion>(), _ec.Object.CancellationToken)) .Returns((Guid taskId, TaskVersion taskVersion, CancellationToken token) => { throw expectedException; }); var tasks = new List<TaskInstance>(new TaskInstance[] { pingTask }); //Act Exception actualException = null; try { await _taskManager.DownloadAsync(_ec.Object, tasks); } catch (Exception ex) { actualException = ex; } //Assert //verify task completed in less than 2sec and it is in failed state state Assert.Equal(expectedException, actualException); //see if the task.json was not downloaded Assert.Equal( 0, Directory.GetFiles(IOUtil.GetTasksPath(_hc), "*", SearchOption.AllDirectories).Length); } finally { Teardown(); } }
public void Post(TaskInstance taskInstance) { // Do something with my taskInstance Console.WriteLine("REST Post Method entered!"); }