void ISoapTransactionLinkExecutor.ExecuteBulkTransactions(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy, ref Service.OPS bulkOperations) { SessionId = sessionId; ServiceProxy = serviceProxy; ResponseParameter = new Service.MP(); ResponseParameter.I = Guid.NewGuid(); ResponseParameter.S = sessionId; ResponseParameter.V = Guid.Empty; ResponseParameter.D = true; ResponseParameter.T = Service.MapParameterType.Node; Service.BMA metadataBulkOperation = new Service.BMA(); metadataBulkOperation.I = TransactionLinkId; metadataBulkOperation.D = DomainParameter.GetParameterValue(sessionId); metadataBulkOperation.RM = RootMapParameter.GetParameterValue(sessionId); metadataBulkOperation.N = NodeParameter.GetParameterValue(sessionId); metadataBulkOperation.R = RelationshipParameter.GetParameterValue(sessionId); metadataBulkOperation.DT = MapManager.ConnectionTypes.ConvertProxyToService(ConnectionType); metadataBulkOperation.T = MapManager.MetadataTypes.ConvertProxyToService(MetadataType); metadataBulkOperation.MN = Name; metadataBulkOperation.MV = Value; metadataBulkOperation.RI = ResponseParameter.I; bulkOperations.O.Add(metadataBulkOperation); 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 (bulkOperations.O.Count < 200) { if (!_onCompletedBound) { executor.TransactionFailed += OnTransactionFailed; executor.TransactionCompleted += OnTransactionCompleted; _onCompletedBound = true; } DebugLogger.Instance.LogMsg("Executing add metadata transaction. Name - '{0}'; Value - '{1}';", Name, Value); executor.ExecuteBulkTransactions(SessionId, ServiceProxy, ref bulkOperations); } else { ServiceProxy.BOCCompleted += new EventHandler<Service.BOCCompletedEventArgs>(OnSubmitBulkOperationCompleted); ServiceProxy.SubmitBulkOperationsAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, bulkOperations, this); } }
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.N != null) { DebugLogger.Instance.LogMsg("Load node transaction completed. ResponseParameter Id - '{0}'; ClientId - '{1}'; Returned NodeUid - '{2}';", ResponseParameter.I, _inProcessResponse.ClientId, change.N.N); ServerObjects.Node soNode = MapManager.ServerObjectConverter.ToNode(change.N); MapManager.NodeFactory.UpgradeFacade(this, soNode); } } } } if (InternalTransactionCompleted != null) { InternalTransactionCompleted(this, e); } }
void ISoapTransactionLinkExecutor.ExecuteTransaction(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy) { SessionId = sessionId; ServiceProxy = serviceProxy; ServiceProxy.MACompleted += OnAddMetadataCompleted; ServiceProxy.MAAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, DomainParameter.GetParameterValue(sessionId), RootMapParameter.GetParameterValue(sessionId), NodeParameter.GetParameterValue(sessionId), RelationshipParameter.GetParameterValue(sessionId), MapManager.ConnectionTypes.ConvertProxyToService(ConnectionType), MapManager.MetadataTypes.ConvertProxyToService(MetadataType), Name, Value, this); }
void ISoapTransactionLinkExecutor.ExecuteTransaction(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy) { TransactionStatus = ServerStatus.SendingTransaction; SessionId = sessionId; ServiceProxy = serviceProxy; ServiceProxy.NACompleted += OnAddNodeCompleted; ServiceProxy.NAAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, DomainParameter.GetParameterValue(sessionId), RootMapParameter.GetParameterValue(sessionId), MapManager.NodeTypes.ConvertProxyToService(NodeType), OriginalId, this); }
void ISoapTransactionLinkExecutor.ExecuteBulkTransactions(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy, ref Service.OPS bulkOperations) { TransactionStatus = ServerStatus.SendingTransaction; SessionId = sessionId; ServiceProxy = serviceProxy; ResponseParameter = new Service.MP(); ResponseParameter.I = Guid.NewGuid(); ResponseParameter.S = sessionId; ResponseParameter.V = Guid.Empty; ResponseParameter.D = true; ResponseParameter.T = Service.MapParameterType.Node; Service.BNA nodeBulkOperation = new Service.BNA(); nodeBulkOperation.I = TransactionLinkId; nodeBulkOperation.D = DomainParameter.GetParameterValue(sessionId); nodeBulkOperation.RM = RootMapParameter.GetParameterValue(sessionId); nodeBulkOperation.T = MapManager.NodeTypes.ConvertProxyToService(NodeType); nodeBulkOperation.O = OriginalId; nodeBulkOperation.RI = ResponseParameter.I; bulkOperations.O.Add(nodeBulkOperation); 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 (bulkOperations.O.Count < 200) { TransactionStatus = ServerStatus.TransactionReceived; if (!_onCompletedBound) { executor.TransactionFailed += OnTransactionFailed; executor.TransactionCompleted += OnTransactionCompleted; _onCompletedBound = true; } TransactionStatus = ServerStatus.TransactionExecuting; DebugLogger.Instance.LogMsg("Executing add node transaction. ClientId - '{0}';", _inProcessResponse.ClientId); executor.ExecuteBulkTransactions(SessionId, ServiceProxy, ref bulkOperations); } else { ServiceProxy.BOCCompleted += new EventHandler<Service.BOCCompletedEventArgs>(OnSubmitBulkOperationCompleted); ServiceProxy.SubmitBulkOperationsAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, bulkOperations, this); } }
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 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 OnQueryMapByDomainCompleted(object sender, Service.QueryMapByDomainCompletedEventArgs e) { if (e != null && e.Result != null) { e.Result.DecompressResponse(); } if (QueryMapByDomainCompleted != null) { Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs(); ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(e.Result); Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships); Proxy.INode nodeContext = Graph.FindNode(soQueryResponse.NodeContext); QueryMapByDomainCompleted.FireEvent(nodeContext.DomainId, this, eventArgs); } }
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 OnQueryMapCompleted(object sender, Service.QueryMapCompletedEventArgs e) { if (e != null && e.Result != null) { e.Result.DecompressResponse(); } Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs(); Service.QueryResponse soapServiceQueryResponse = e.Result; QueryMapResponseStateInfo callerInfo = e.UserState as QueryMapResponseStateInfo; if (soapServiceQueryResponse.FinalObjectIndex <= 0) { ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(soapServiceQueryResponse); Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships); if (e.Result.NodeContext != null) { Proxy.INode context = eventArgs.Nodes[e.Result.NodeContext.N]; if (callerInfo.ResponseType == QueryMapResponseStateType.ById) { QueryMapByIdCompleted.FireEvent(context.Id, this, eventArgs); } else if (callerInfo.ResponseType == QueryMapResponseStateType.ByNode) { QueryMapByNodeCompleted.FireEvent(context, this, eventArgs); } } else { /// TODO: Need to find a nicer way of handling this exception rather than just ignoring it altogether. //throw new NodeNotFoundException("The given node wasn't found"); } } else { Service.QueryResponse aggregatedResponse = new Service.QueryResponse(); aggregatedResponse.Domain = soapServiceQueryResponse.Domain; aggregatedResponse.NodeContext = soapServiceQueryResponse.NodeContext; aggregatedResponse.Nodes = new Dictionary<Guid, Service.NO>(); aggregatedResponse.Relationships = new Dictionary<Guid, Service.RE>(); foreach (KeyValuePair<Guid, Service.NO> nodePair in soapServiceQueryResponse.Nodes) { aggregatedResponse.Nodes[nodePair.Key] = nodePair.Value; } foreach (KeyValuePair<Guid, Service.RE> relationshipPair in soapServiceQueryResponse.Relationships) { aggregatedResponse.Relationships[relationshipPair.Key] = relationshipPair.Value; } //ServiceProxy.QueryMapPagedCompleted += OnQueryMapByIdPagedCompleted; QueryMapResponseStateInfo info = new QueryMapResponseStateInfo(); info.AggregatedResponse = aggregatedResponse; info.ResponseType = callerInfo.ResponseType; ServiceProxy.QueryMapPagedAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), aggregatedResponse.Domain.DomainUid, aggregatedResponse.NodeContext.N, 1, null, null, soapServiceQueryResponse.LastObjectIndex + 1, info); } }
private void OnQueryMapPagedCompleted(object sender, Service.QueryMapPagedCompletedEventArgs e) { if (e != null && e.Result != null) { e.Result.DecompressResponse(); } //ServiceProxy.QueryMapPagedCompleted -= OnQueryMapByIdPagedCompleted; Service.QueryResponse queryResponse = e.Result; QueryMapResponseStateInfo callerInfo = e.UserState as QueryMapResponseStateInfo; Service.QueryResponse aggregatedResponse = callerInfo.AggregatedResponse;//e.UserState as Service.QueryResponse; if (aggregatedResponse == null) { aggregatedResponse.Domain = queryResponse.Domain; aggregatedResponse.NodeContext = queryResponse.NodeContext; aggregatedResponse.Nodes = new Dictionary<Guid, Service.NO>(); aggregatedResponse.Relationships = new Dictionary<Guid, Service.RE>(); } foreach (KeyValuePair<Guid, Service.NO> nodePair in queryResponse.Nodes) { aggregatedResponse.Nodes[nodePair.Key] = nodePair.Value; } foreach (KeyValuePair<Guid, Service.RE> relationshipPair in queryResponse.Relationships) { aggregatedResponse.Relationships[relationshipPair.Key] = relationshipPair.Value; } if (queryResponse.LastObjectIndex >= queryResponse.FinalObjectIndex) { ServerObjects.QueryResponse soAggregatedResponse = ServerObjectConverter.ToQueryResponse(aggregatedResponse); Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs(); Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soAggregatedResponse.Nodes, soAggregatedResponse.Relationships); Proxy.INode context = eventArgs.Nodes[e.Result.NodeContext.N]; if (callerInfo.ResponseType == QueryMapResponseStateType.ById) { QueryMapByIdCompleted.FireEvent(context.Id, this, eventArgs); } else if (callerInfo.ResponseType == QueryMapResponseStateType.ByNode) { QueryMapByNodeCompleted.FireEvent(context, this, eventArgs); } } else { QueryMapResponseStateInfo info = new QueryMapResponseStateInfo(); info.AggregatedResponse = aggregatedResponse; info.ResponseType = callerInfo.ResponseType; ServiceProxy.QueryMapPagedAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), aggregatedResponse.Domain.DomainUid, aggregatedResponse.NodeContext.N, 1, null, null, queryResponse.LastObjectIndex + 1, info); } }
private void OnQueryDomainsCompleted(object sender, Service.QueryDomainsCompletedEventArgs e) { Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs(); foreach (Service.QueryResponse soapServiceQueryResponse in e.Result.Values) { ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(soapServiceQueryResponse); Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships); } QueryDomainsCompleted.FireEvent(this, eventArgs); }
private void GetAllMapTypesCompleted(object sender, Service.GetAllMapTypesCompletedEventArgs eventArgs) { ServiceProxy.GetAllMapTypesCompleted -= GetAllMapTypesCompleted; TypeManager.AddNodeTypes(eventArgs.Result.NodeTypes.Values); TypeManager.AddRelationshipTypes(eventArgs.Result.RelationshipTypes.Values); TypeManager.AddConnectionTypes(eventArgs.Result.DescriptorTypes.Values); TypeManager.AddMetadataTypes(eventArgs.Result.MetadataTypes.Values); IsMapTypesLoaded = true; Proxy.InitialiseMapManagerEventArgs initialisationEventArgs = new Proxy.InitialiseMapManagerEventArgs(true); InitialiseMapManagerCompleted(this, initialisationEventArgs); }
private void GetGlymaVersionCompleted(object sender, Service.GetApplicationVersionCompletedEventArgs eventArgs) { ServiceProxy.GetApplicationVersionCompleted -= GetGlymaVersionCompleted; Service.GlymaVersion serverVersion = eventArgs.Result; if (GlymaClientVersion.RequiresRefresh(serverVersion)) { Proxy.InitialiseMapManagerEventArgs initialisationEventArgs = new Proxy.InitialiseMapManagerEventArgs(false); initialisationEventArgs.ErrorMessage = "The version of Glyma your browser is using is out-of-date. Please clear your browser's cache and refresh your browser to download the latest version of Glyma."; InitialiseMapManagerCompleted(this, initialisationEventArgs); } else { ServiceProxy.GetAllMapTypesCompleted += GetAllMapTypesCompleted; ServiceProxy.GetAllMapTypesAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString()); } }
void OnSubmitBulkOperationCompleted(object sender, Service.BOCCompletedEventArgs 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.BOCCompleted -= OnSubmitBulkOperationCompleted; if (e.Error != null) { TransactionStatus = ServerStatus.TransactionFailed; if (InternalTransactionFailed != null) { InternalTransactionFailed(this, e); } return; } OriginChain.FillBulkOperations(e.DecompressedResult); Service.OPS newBulkOperationsSet = new Service.OPS(); newBulkOperationsSet.O = new System.Collections.ObjectModel.ObservableCollection<object>(); ISoapTransactionLinkExecutor executor = _firstLink as 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.ExecuteBulkTransactions(SessionId, ServiceProxy, ref newBulkOperationsSet); }
void OnCreateDomainCompleted(object sender, Service.CreateDomainCompletedEventArgs e) { Proxy.DomainEventArgs domainEventArgs = new Proxy.DomainEventArgs(); foreach (Service.CH mapChange in e.Result.C) { if (mapChange.N != null) { domainEventArgs.Domain = mapChange.N.D; break; } } CreateDomainCompleted.FireEvent(Guid.Empty, this, domainEventArgs); }
void ISoapTransactionLinkExecutor.ConsumeBulkOperationResponse(Service.BOR bulkOperationResponse) { if (bulkOperationResponse.I == TransactionLinkId) { ResponseParameter = bulkOperationResponse.R; } else { DebugLogger.Instance.LogMsg("The provided bulk operation response has an ID that does not match this transaction link."); } }
void OnCreateRootMapCompleted(object sender, Service.CreateRootMapCompletedEventArgs e) { if (CreateRootMapCompleted != null) { Proxy.NodesEventArgs eventArgs = new Proxy.NodesEventArgs(); ServerObjects.QueryResponse soQueryResponse = ServerObjectConverter.ToQueryResponse(e.Result); Graph.NodesAndRelationshipBuildEventArgs(eventArgs, soQueryResponse.Nodes, soQueryResponse.Relationships); CreateRootMapCompleted.FireEvent(this, eventArgs); } }
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); } }
void ISoapTransactionLinkExecutor.ExecuteTransaction(Guid sessionId, Service.TransactionalMappingToolServiceClient serviceProxy) { TransactionStatus = ServerStatus.SendingTransaction; SessionId = sessionId; ServiceProxy = serviceProxy; Dictionary<Service.DT, Service.MP> nodeConnections = new Dictionary<Service.DT, Service.MP>(); foreach (KeyValuePair<Service.DT, SoapTransactionLinkParameter> keyValuePair in TransactionLinkConnections) { Service.DT descriptorType = keyValuePair.Key; Service.MP parameter = keyValuePair.Value.GetParameterValue(sessionId); nodeConnections[descriptorType] = parameter; } ServiceProxy.RACompleted += OnAddRelationshipCompleted; ServiceProxy.RAAsync(System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString(), SessionId, DomainParameter.GetParameterValue(sessionId), RootMapParameter.GetParameterValue(sessionId), nodeConnections, MapManager.RelationshipTypes.ConvertProxyToService(RelationshipType), OriginalId, this); }