70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
|
|
using MainShell.Common;
|
|||
|
|
using MW.WorkFlow;
|
|||
|
|
using System;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace MainShell.Process
|
|||
|
|
{
|
|||
|
|
public class ChipPreparationWaitActivity : ActivityAbstractBase
|
|||
|
|
{
|
|||
|
|
private readonly TimeSpan _timeout;
|
|||
|
|
private readonly bool _consumeOnSuccess;
|
|||
|
|
|
|||
|
|
public ChipPreparationWaitActivity(string name, TimeSpan? timeout = null, bool consumeOnSuccess = false)
|
|||
|
|
: base(name)
|
|||
|
|
{
|
|||
|
|
_timeout = timeout ?? TimeSpan.FromSeconds(30);
|
|||
|
|
_consumeOnSuccess = consumeOnSuccess;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override async Task<ActivityResult> OnExecuteAsync(WorkflowContext context, ActivityControl activityControl)
|
|||
|
|
{
|
|||
|
|
PreparationAreaService preparationAreaService;
|
|||
|
|
if (!context.TryGetData<PreparationAreaService>(WorkflowContextKeys.PreparationAreaService, out preparationAreaService) || preparationAreaService == null)
|
|||
|
|
{
|
|||
|
|
throw new InvalidOperationException("δ<>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ChipPreparationWaitResult waitResult = await preparationAreaService.WaitUntilReadyAsync(_timeout, activityControl.CancellationToken).ConfigureAwait(false);
|
|||
|
|
if (!waitResult.Success)
|
|||
|
|
{
|
|||
|
|
if (waitResult.IsCanceled)
|
|||
|
|
{
|
|||
|
|
SetWorkflowFailure(context, string.IsNullOrWhiteSpace(waitResult.ErrorMessage) ? "<22>ȴ<EFBFBD>оƬ<D0BE><C6AC>̨<CCA8><D7BC><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>" : waitResult.ErrorMessage);
|
|||
|
|
return ActivityResult.Canceled;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Fail(
|
|||
|
|
context,
|
|||
|
|
MessageKey.ProcessStepFailedWithReason,
|
|||
|
|
new object[]
|
|||
|
|
{
|
|||
|
|
Name,
|
|||
|
|
string.IsNullOrWhiteSpace(waitResult.ErrorMessage) ? "<22>ȴ<EFBFBD>оƬ<D0BE><C6AC>̨<CCA8><D7BC>ʧ<EFBFBD>ܡ<EFBFBD>" : waitResult.ErrorMessage
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!_consumeOnSuccess)
|
|||
|
|
{
|
|||
|
|
return ActivityResult.Success;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string rejectReason;
|
|||
|
|
if (preparationAreaService.TryConsumeReady(out rejectReason))
|
|||
|
|
{
|
|||
|
|
context.SetData(WorkflowContextKeys.PreparationAreaStatus, preparationAreaService.CurrentStatus);
|
|||
|
|
return ActivityResult.Success;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Fail(
|
|||
|
|
context,
|
|||
|
|
MessageKey.ProcessStepFailedWithReason,
|
|||
|
|
new object[]
|
|||
|
|
{
|
|||
|
|
Name,
|
|||
|
|
string.IsNullOrWhiteSpace(rejectReason) ? "оƬ<D0BE><C6AC>̨<CCA8><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>" : rejectReason
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|