Example #1
0
        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);
            }
        }
Example #2
0
        public void ForceTransactionReExecution()
        {
            TransactionFramework.ISoapTransactionLinkExecutor executor = null;

            if (_executionThreadsLock == null || ExecutionThreads == null || ExecutionThreads.CurrentChain == null || ExecutionThreads.CurrentChain.End == null)
            {
                return;
            }

            TransactionFramework.TransactionChain transactionChain = ExecutionThreads.CurrentChain;
            transactionChain.Reset();

            /// If the last transaction is in one of the post execution states and the user has requested to force the commit,
            /// then it means we should attempt to do the current transaction again as something appears to have happened to
            /// cause the previous attempt to hang.
            if (transactionChain.End.TransactionStatus == TransactionFramework.ServerStatus.TransactionCompleted || transactionChain.End.TransactionStatus == TransactionFramework.ServerStatus.TransactionReceived || transactionChain.End.TransactionStatus == TransactionFramework.ServerStatus.TransactionFailed)
            {
                executor = ExecutionThreads.CurrentChain;

                /// Debug lines
                /// TODO: Remove the following
                if (transactionChain != null)
                {
                    System.Diagnostics.Debug.WriteLine(transactionChain.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);
            }
        }
Example #3
0
        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);
                }
            }
        }