Example #1
0
        private static bool NegotiateAssociation(AssociationParameters cp, ServerAssociationParameters sp)
        {
            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                TransferSyntax selectedSyntax = null;
                foreach (DicomPresContext serverContext in sp.GetPresentationContexts())
                {
                    if (clientContext.AbstractSyntax.Uid.Equals(serverContext.AbstractSyntax.Uid))
                    {
                        foreach (TransferSyntax ts in serverContext.GetTransfers())
                        {
                            if (clientContext.HasTransfer(ts))
                            {
                                selectedSyntax = ts;
                                break;
                            }
                        }
                    }

                    if (selectedSyntax != null)
                    {
                        break;
                    }
                }

                if (selectedSyntax != null)
                {
                    clientContext.ClearTransfers();
                    clientContext.AddTransfer(selectedSyntax);
                    clientContext.SetResult(DicomPresContextResult.Accept);
                }
                else
                {
                    // No contexts accepted, set if abstract or transfer syntax reject
                    clientContext.SetResult(0 == sp.FindAbstractSyntax(clientContext.AbstractSyntax)
                                                ? DicomPresContextResult.RejectAbstractSyntaxNotSupported
                                                : DicomPresContextResult.RejectTransferSyntaxesNotSupported);
                }
            }
            bool anyValidContexts = false;

            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                if (clientContext.Result == DicomPresContextResult.Accept)
                {
                    anyValidContexts = true;
                    break;
                }
            }
            if (anyValidContexts == false)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        private static bool NegotiateAssociation(AssociationParameters cp, ServerAssociationParameters sp)
        {
            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                TransferSyntax selectedSyntax = null;
				foreach (DicomPresContext serverContext in sp.GetPresentationContexts())
				{
					if (clientContext.AbstractSyntax.Uid.Equals(serverContext.AbstractSyntax.Uid))
					{
						foreach (TransferSyntax ts in serverContext.GetTransfers())
						{
							if (clientContext.HasTransfer(ts))
							{
								selectedSyntax = ts;
								break;
							}
						}						
					}

					if (selectedSyntax != null)
						break;
				}

                if (selectedSyntax != null)
                {
                    clientContext.ClearTransfers();
                    clientContext.AddTransfer(selectedSyntax);
                    clientContext.SetResult(DicomPresContextResult.Accept);
                }
                else
                {
                    // No contexts accepted, set if abstract or transfer syntax reject
                    clientContext.SetResult(0 == sp.FindAbstractSyntax(clientContext.AbstractSyntax)
                                                ? DicomPresContextResult.RejectAbstractSyntaxNotSupported
                                                : DicomPresContextResult.RejectTransferSyntaxesNotSupported);
                }
            }
            bool anyValidContexts = false;

            foreach (DicomPresContext clientContext in cp.GetPresentationContexts())
            {
                if (clientContext.Result == DicomPresContextResult.Accept)
                {
                    anyValidContexts = true;
                    break;
                }
            }
            if (anyValidContexts == false)
            {
                return false;
            }      

            return true;
        }