private void OnTransactionCompleted(object sender, Service.CompleteTransactionCompletedEventArgs e)
{
TransactionFramework.ISoapTransactionLinkExecutor executor = null;
lock (_executionThreadsLock)
{
if (e.Error != null)
{
/// An error occurred so let's retry the transaction.
executor = ExecutionThreads.CurrentChain;
}
while (executor == null && ExecutionThreads.Count > 0)
{
_isInProcess = true;
executor = ExecutionThreads.MoveToNextChain();
executor.UpdateDependencies();
if (executor.Dependencies.IsCompleted)
{
executor.TransactionFailed += OnTransactionFailed;
executor.TransactionCompleted += OnTransactionCompleted;
}
else
{
IncompleteExecutionThreads.Add(executor);
executor.Dependencies.FacadesCompleted += OnTransactionChainFacadesCompleted;
executor = null;
}
}
}
if (executor != null)
{
/// TODO: Remove the following
TransactionFramework.TransactionChain chain = executor as TransactionFramework.TransactionChain;
if (chain != null)
{
System.Diagnostics.Debug.WriteLine(chain.ChainId);
}
///
if (MapManagerActivityStatusUpdated != null)
{
Proxy.MapManagerActivityEventArgs status = new Proxy.MapManagerActivityEventArgs();
status.TransactionsLeft = ExecutionThreads.Count + 1;
status.Status = Proxy.ActivityStatusEnum.Busy;
MapManagerActivityStatusUpdated.Invoke(this, status);
}
executor.ExecuteTransaction(Guid.Empty, ServiceProxy);
}
else
{
_isInProcess = false;
if (MapManagerActivityStatusUpdated != null)
{
Proxy.MapManagerActivityEventArgs status = new Proxy.MapManagerActivityEventArgs();
status.TransactionsLeft = 0;
status.Status = Proxy.ActivityStatusEnum.Idle;
MapManagerActivityStatusUpdated.Invoke(this, status);
}
}
}