public void ExecuteTransaction(TransactionFramework.TransactionChain transactionChain) { /// TODO: Need to figure why this is happening for the re-alignment code. /// TODO: Probably should add a warning in the debugger to indicate there is a potential performance problem if there are too many chains with empty transactions. if (transactionChain.NumOfTransactions <= 0) { return; } TransactionFramework.ISoapTransactionLinkExecutor executor = transactionChain; if (executor == null) { throw new NotSupportedException("This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor."); } lock (_executionThreadsLock) { ExecutionThreads.AddTransactionChain(transactionChain); if (_isInProcess) { executor = null; } else { ExecutionThreads.MoveToNextChain(); _isInProcess = true; } } if (MapManagerActivityStatusUpdated != null) { Proxy.MapManagerActivityEventArgs status = new Proxy.MapManagerActivityEventArgs(); status.TransactionsLeft = ExecutionThreads.Count + 1; status.Status = Proxy.ActivityStatusEnum.Busy; MapManagerActivityStatusUpdated.Invoke(this, status); } if (executor != null) { /// TODO: Remove the following TransactionFramework.TransactionChain chain = executor as TransactionFramework.TransactionChain; if (chain != null) { System.Diagnostics.Debug.WriteLine(chain.ChainId); } /// executor.TransactionFailed += OnTransactionFailed; executor.TransactionCompleted += OnTransactionCompleted; executor.ExecuteTransaction(Guid.Empty, ServiceProxy); } }
public void ExecuteTransactions(Queue <TransactionFramework.TransactionChain> chains) { TransactionFramework.TransactionChain firstChain = null; lock (_executionThreadsLock) { while (chains.Count > 0) { TransactionFramework.TransactionChain chain = chains.Dequeue(); /// TODO: Need to figure why this is happening for the re-alignment code. /// TODO: Probably should add a warning in the debugger to indicate there is a potential performance problem if there are too many chains with empty transactions. if (chain.NumOfTransactions <= 0) { continue; } if (firstChain == null) { firstChain = chain; ExecutionThreads.AddTransactionChain(firstChain); if (_isInProcess) { firstChain = null; } else { ExecutionThreads.MoveToNextChain(); _isInProcess = true; } } else { ExecutionThreads.AddTransactionChain(chain); } } } if (firstChain != null) { firstChain.TransactionFailed += OnTransactionFailed; firstChain.TransactionCompleted += OnTransactionCompleted; firstChain.ExecuteTransaction(Guid.Empty, ServiceProxy); } }
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); } } }