private void OnTransactionCompleted(object sender, Service.CompleteTransactionCompletedEventArgs e)
        {
            TransactionStatus = ServerStatus.TransactionCompleted;

            if (e.Error == null)
            {
                foreach (Service.CH change in e.Result.C)
                {
                    if (change.P == ResponseParameter.I)
                    {
                        if (change.R != null)
                        {
                            DebugLogger.Instance.LogMsg("Load relationship transaction completed. ResponseParameter Id - '{0}'; ClientId - '{1}'; Returned NodeUid - '{2}';", ResponseParameter.I, CreateInProcessObjects().ClientId, change.R.R);
                            ServerObjects.Relationship soRelationship = MapManager.ServerObjectConverter.ToRelationship(change.R);
                            MapManager.RelationshipFactory.UpgradeFacade(this, soRelationship);
                        }
                    }
                }
            }

            if (InternalTransactionCompleted != null)
            {
                InternalTransactionCompleted(this, e);
            }
        }
        private void OnAddRelationshipCompleted(object sender, Service.RACompletedEventArgs e)
        {
            if (e.UserState != this)
            {
                // This event is for a different object so don't execute.
                return;
            }

            TransactionStatus = ServerStatus.TransactionReceived;

            // The following line must be done so that the transaction isn't executed again.
            ServiceProxy.RACompleted -= OnAddRelationshipCompleted;

            if (e.Error != null)
            {
                TransactionStatus = ServerStatus.TransactionCompleted;

                Service.CompleteTransactionCompletedEventArgs completedEventArgs = new Service.CompleteTransactionCompletedEventArgs(null, e.Error, false, null);

                if (InternalTransactionCompleted != null)
                {
                    InternalTransactionCompleted(this, completedEventArgs);
                }

                return;
            }

            ResponseParameter = e.Result;

            ISoapTransactionLinkExecutor executor = _firstLink as ISoapTransactionLinkExecutor;

            if (executor == null)
            {
                DebugLogger.Instance.LogMsg("Exception: This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
                throw new NotSupportedException("The next link in the chain is not a supported type of link or the next link is null. This link does not implement ISoapTransactionLinkExecutor.");
            }

            TransactionStatus = ServerStatus.TransactionExecuting;

            if (!_onCompletedBound)
            {
                executor.TransactionFailed    += OnTransactionFailed;
                executor.TransactionCompleted += OnTransactionCompleted;

                _onCompletedBound = true;
            }

            DebugLogger.Instance.LogMsg("Executing add relationship transaction. ResponseParameter Id - '{0}'; ClientId - '{1}';", ResponseParameter.I, CreateInProcessObjects().ClientId);
            executor.ExecuteTransaction(SessionId, ServiceProxy);
        }
        private void OnAddMetadataCompleted(object sender, Service.MACompletedEventArgs e)
        {
            if (e.UserState != this)
            {
                // This event is for a different object so don't execute.
                return;
            }

            // The following lines must be done so that the transaction isn't executed again.
            ServiceProxy.MACompleted -= OnAddMetadataCompleted;

            if (e.Error != null)
            {
                Service.CompleteTransactionCompletedEventArgs completedEventArgs = new Service.CompleteTransactionCompletedEventArgs(null, e.Error, false, null);

                if (InternalTransactionCompleted != null)
                {
                    InternalTransactionCompleted(this, completedEventArgs);
                }

                return;
            }

            ResponseParameter = e.Result;

            ISoapTransactionLinkExecutor executor = _firstLink as ISoapTransactionLinkExecutor;

            if (executor == null)
            {
                DebugLogger.Instance.LogMsg("Exception: This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
                throw new NotSupportedException("This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
            }

            if (!_onCompletedBound)
            {
                executor.TransactionFailed    += OnTransactionFailed;
                executor.TransactionCompleted += OnTransactionCompleted;

                _onCompletedBound = true;
            }

            DebugLogger.Instance.LogMsg("Executing add metadata transaction. ResponseParameter Id - '{0}'; Name - '{1}'; Value - '{2}';", ResponseParameter.I, Name, Value);
            executor.ExecuteTransaction(SessionId, ServiceProxy);
        }
        private void OnTransactionCompleted(object sender, Service.CompleteTransactionCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                foreach (Service.CH change in e.Result.C)
                {
                    if (change.P == ResponseParameter.I)
                    {
                        if (change.M != null)
                        {
                            DebugLogger.Instance.LogMsg("Load metadata transaction completed. ResponseParameter Id - '{0}'; Name - '{1}'; Value - '{2}'; Returned MetadataId - '{3}'", ResponseParameter.I, Name, Value, change.M.M);
                            ServerObjects.Metadata soMetadata = MapManager.ServerObjectConverter.ToMetadata(change.M);
                            Proxy.MetadataSetFactory.GetInstance(MapManager).UpgradeFacade(this, soMetadata);
                        }
                    }
                }
            }

            if (InternalTransactionCompleted != null)
            {
                InternalTransactionCompleted(this, e);
            }
        }
        private void OnAddMetadataCompleted(object sender, Service.MACompletedEventArgs e)
        {
            if (e.UserState != this)
            {
                // This event is for a different object so don't execute.
                return;
            }

            // The following lines must be done so that the transaction isn't executed again.
            ServiceProxy.MACompleted -= OnAddMetadataCompleted;

            if (e.Error != null)
            {
                Service.CompleteTransactionCompletedEventArgs completedEventArgs = new Service.CompleteTransactionCompletedEventArgs(null, e.Error, false, null);

                if (InternalTransactionCompleted != null)
                {
                    InternalTransactionCompleted(this, completedEventArgs);
                }

                return;
            }

            ResponseParameter = e.Result;

            ISoapTransactionLinkExecutor executor = _firstLink as ISoapTransactionLinkExecutor;

            if (executor == null)
            {
                DebugLogger.Instance.LogMsg("Exception: This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
                throw new NotSupportedException("This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
            }

            if (!_onCompletedBound)
            {
                executor.TransactionFailed += OnTransactionFailed;
                executor.TransactionCompleted += OnTransactionCompleted;

                _onCompletedBound = true;
            }

            DebugLogger.Instance.LogMsg("Executing add metadata transaction. ResponseParameter Id - '{0}'; Name - '{1}'; Value - '{2}';", ResponseParameter.I, Name, Value);
            executor.ExecuteTransaction(SessionId, ServiceProxy);
        }
Esempio n. 6
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);
                }
            }
        }
        private void OnAddRelationshipCompleted(object sender, Service.RACompletedEventArgs e)
        {
            if (e.UserState != this)
            {
                // This event is for a different object so don't execute.
                return;
            }

            TransactionStatus = ServerStatus.TransactionReceived;

            // The following line must be done so that the transaction isn't executed again.
            ServiceProxy.RACompleted -= OnAddRelationshipCompleted;

            if (e.Error != null)
            {
                TransactionStatus = ServerStatus.TransactionCompleted;

                Service.CompleteTransactionCompletedEventArgs completedEventArgs = new Service.CompleteTransactionCompletedEventArgs(null, e.Error, false, null);

                if (InternalTransactionCompleted != null)
                {
                    InternalTransactionCompleted(this, completedEventArgs);
                }

                return;
            }

            ResponseParameter = e.Result;

            ISoapTransactionLinkExecutor executor = _firstLink as ISoapTransactionLinkExecutor;

            if (executor == null)
            {
                DebugLogger.Instance.LogMsg("Exception: This is not a supported type of link. This link does not implement ISoapTransactionLinkExecutor.");
                throw new NotSupportedException("The next link in the chain is not a supported type of link or the next link is null. This link does not implement ISoapTransactionLinkExecutor.");
            }

            TransactionStatus = ServerStatus.TransactionExecuting;

            if (!_onCompletedBound)
            {
                executor.TransactionFailed += OnTransactionFailed;
                executor.TransactionCompleted += OnTransactionCompleted;

                _onCompletedBound = true;
            }

            DebugLogger.Instance.LogMsg("Executing add relationship transaction. ResponseParameter Id - '{0}'; ClientId - '{1}';", ResponseParameter.I, CreateInProcessObjects().ClientId);
            executor.ExecuteTransaction(SessionId, ServiceProxy);
        }