当前位置: 首页>>代码示例>>C#>>正文


C# IEngine.Kick方法代码示例

本文整理汇总了C#中IEngine.Kick方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.Kick方法的具体用法?C# IEngine.Kick怎么用?C# IEngine.Kick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEngine的用法示例。


在下文中一共展示了IEngine.Kick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transit

        public void Transit(WorkItem workItem, IEngine engine)
        {
            var exceptionId = workItem.ExceptionId.Value;
            var exception = _dataStore.Get(exceptionId);
            var current = workItem;
            current = _repository.GetParent(current);

            while (current != null)
            {
                if (current.Status.IsFinal())
                    return;

                if (current.Type == WorkflowType.Retry) //todo: add unit test
                {
                    engine.Kick(current.Id);
                    return;
                }

                if (TryRescure(current, exception, exceptionId))
                    break;

                current = _repository.GetParent(current);
            }

            if (current == null)
            {
                engine.Kick(null);
                return;
            }

            engine.Kick(current.ParentId);
        }
开发者ID:mikezhuyuan,项目名称:simpleflow,代码行数:32,代码来源:ExceptionStateMachine.cs

示例2: Transit

        public void Transit(WorkItem workItem, IEngine engine)
        {
            if (workItem == null) throw new ArgumentNullException("workItem");
            if (workItem.Type != WorkflowType.Sequence) throw new ArgumentException("type must be sequence");

            var status = workItem.Status;

            switch (status)
            {
                case WorkItemStatus.Created:
                    _repository.DeleteChildren(workItem.Id);

                    var children = _workItemBuilder.BuildChildren(workItem);

                    _repository.AddAll(children);

                    workItem.Status = WorkItemStatus.WaitingForChildren;
                    _repository.Update(workItem);

                    engine.Kick(workItem.Id);

                    break;
                case WorkItemStatus.WaitingForChildren:
                    if (_repository.HasFailedChildren(workItem.Id))
                        return;

                    var inProgress = _repository.CountInProgressChildren(workItem.Id);

                    if (inProgress == 0)
                    {
                        var next = _repository.FindRunnableChildrenByOrder(workItem.Id, 1).SingleOrDefault();

                        if (next == null) // all complete
                        {
                            var last = _repository.GetLastChildByOrder(workItem.Id);

                            workItem.OutputId = last.OutputId;

                            workItem.Status = WorkItemStatus.Completed;
                            _repository.Update(workItem);

                            engine.Kick(workItem.ParentId);
                        }
                        else
                        {
                            if (next.Order > 0)
                            {
                                var previous = _repository.GetChildByOrder(workItem.Id, next.Order - 1);
                                next.InputId = previous.OutputId;
                                _repository.Update(next);
                            }

                            engine.Kick(next.Id);
                        }
                    }

                    break;
            }
        }
开发者ID:mikezhuyuan,项目名称:simpleflow,代码行数:59,代码来源:SequenceStateMachine.cs

示例3: Transit

        public void Transit(WorkItem workItem, IEngine engine)
        {
            if (workItem == null) throw new ArgumentNullException("workItem");
            if (workItem.Type != WorkflowType.Fork) throw new ArgumentException("type must be fork");

            var status = workItem.Status;
            var definition = (ForkBlock) _workflowPathNavigator.Find(workItem.WorkflowPath);

            switch (status)
            {
                case WorkItemStatus.Created:
                    _repository.DeleteChildren(workItem.Id);

                    var children = _workItemBuilder.BuildChildren(workItem);

                    _repository.AddAll(children);

                    workItem.Status = WorkItemStatus.WaitingForChildren;
                    _repository.Update(workItem);

                    engine.Kick(workItem.Id);

                    break;
                case WorkItemStatus.WaitingForChildren:
                    if (_repository.HasFailedChildren(workItem.Id))
                        return;

                    var inProgress = _repository.CountInProgressChildren(workItem.Id);
                    var newWorkers = definition.MaxWorkers - inProgress;

                    if (newWorkers > 0)
                    {
                        var workItems = _repository.FindRunnableChildrenByOrder(workItem.Id, newWorkers);
                        if (workItems.Count > 0)
                        {
                            foreach (var runnable in workItems)
                            {
                                engine.Kick(runnable.Id);
                            }
                        }
                        else if (inProgress == 0)
                        {
                            var ids = _repository.LoadChildOutputIds(workItem.Id);
                            workItem.OutputId = _dataStore.AddReferences(workItem.JobId, ids,
                                definition.Child.OutputType);
                            workItem.Status = WorkItemStatus.Completed;
                            _repository.Update(workItem);

                            engine.Kick(workItem.ParentId);
                        }
                    }

                    break;
            }
        }
开发者ID:mikezhuyuan,项目名称:simpleflow,代码行数:55,代码来源:ForkStateMachine.cs

示例4: Transit

        public void Transit(WorkItem workItem, IEngine engine)
        {
            if (workItem == null) throw new ArgumentNullException("workItem");
            if (workItem.Type != WorkflowType.Retry) throw new ArgumentException("type must be retry");

            var status = workItem.Status;

            switch (status)
            {
                case WorkItemStatus.Created:
                    _repository.DeleteChildren(workItem.Id);

                    var children = _workItemBuilder.BuildChildren(workItem);

                    _repository.AddAll(children);

                    workItem.Status = WorkItemStatus.WaitingForChildren;
                    _repository.Update(workItem);

                    engine.Kick(workItem.Id);
                    break;
                case WorkItemStatus.WaitingForChildren:
                    var last = _repository.GetLastChildByOrder(workItem.Id);
                    var definition = (RetryBlock) _navigator.Find(workItem.WorkflowPath);

                    switch (last.Status)
                    {
                        case WorkItemStatus.Created:
                            engine.Kick(last.Id);
                            break;
                        case WorkItemStatus.Completed:
                            workItem.OutputId = last.OutputId;
                            workItem.Status = WorkItemStatus.Completed;

                            _repository.Update(workItem);

                            engine.Kick(workItem.ParentId);
                            break;
                        case WorkItemStatus.Failed:
                            if (last.Order < definition.RetryCount)
                            {
                                var newItem = last.Retry();

                                _repository.Add(newItem);

                                engine.Kick(newItem.Id);
                            }
                            else
                            {
                                workItem.ExceptionId = last.ExceptionId;
                                workItem.Status = WorkItemStatus.Failed;

                                _repository.Update(workItem);

                                engine.Rescure(workItem.Id);
                            }
                            break;
                    }
                    break;
            }
        }
开发者ID:mikezhuyuan,项目名称:simpleflow,代码行数:61,代码来源:RetryStateMachine.cs


注:本文中的IEngine.Kick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。