Beispiel #1
0
 public void OnResponseRecieved(CFindResponse resp, Association asc)
 {
     asc.Logger.LogInformation("<-- DIMSE" + resp.GetLogString());
     asc.LastActive = DateTime.Now;
     dms.RaiseDIMSEResponseReceived(resp, asc);
     resp.LogData(asc);
     if (resp.Status != (ushort)Status.PENDING)
     {
         AssociationMessenger.SendReleaseRequest(asc);
     }
 }
Beispiel #2
0
        public void OnResponseReceived(NActionResponse resp, Association asc)
        {
            asc.Logger.LogInformation("<-- DIMSE" + resp.GetLogString());
            resp.LogData(asc);
            asc.LastActive = DateTime.Now;
            _dms.RaiseDIMSEResponseReceived(resp, asc);

            //STORAGE COMMITMENT PUSH
            if (resp.AffectedSOPClassUID == AbstractSyntax.StorageCommitment_Push)
            {
                asc.State = NetworkState.ASSOCIATION_ESTABLISHED_WAITING_ON_DATA;
            }
            else
            {
                //Abstract syntax not supported
                if (resp.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            }
        }
 private void HandleAbort()
 {
     AssociationMessenger.SendAbort(this);
     State = NetworkState.CLOSING_ASSOCIATION;
 }
        public void SetDefaultActions()
        {
            AbortReceivedAction = (abort, asc) =>
            {
                asc.Logger.Log("<-- " + abort);
                RaiseAbortRequestReceived(abort, asc);
                asc.Release();
            };

            AssociationRequestReceivedAction = (req, asc) =>
            {
                asc.Logger.Log("<-- " + req);
                RaiseAssociationRequestReceived(req, asc);
                var ctxs = asc.GetResponseContexts(req.PresentationContexts);
                if (ctxs.Any())
                {
                    var accept = Accept.Generate(req, ctxs);
                    asc.UserInfo             = req.UserInfo;
                    asc.LastActive           = DateTime.Now;
                    asc.PresentationContexts = ctxs; //Simplified agreed contexts
                    AssociationMessenger.SendAccept(accept, asc);
                    asc.State = NetworkState.ASSOCIATION_ESTABLISHED_WAITING_ON_DATA;
                }
                else
                {
                    asc.LastActive = DateTime.Now;
                    AssociationMessenger.SendReject(asc);
                    asc.State = NetworkState.CLOSING_ASSOCIATION;
                }
            };

            AssociationAcceptanceReceivedAction = (acc, asc) =>
            {
                asc.Logger.Log("<-- " + acc);
                RaiseAssociationAcceptanceReceived(acc, asc);
                asc.SetFinalContexts(acc);
                if (asc.PresentationContexts.Any())
                {
                    asc.UserInfo = acc.UserInfo;
                    asc.State    = NetworkState.TRANSPORT_CONNECTION_OPEN;
                }
                else
                {
                    asc.Release();
                }
            };

            AssociationRejectAction = (rej, asc) =>
            {
                asc.Logger.Log("<-- " + rej);
                RaiseAssociationRejectionReceived(rej, asc);
                asc.Release();
            };

            ReleaseRequestReceivedAction = (rel, asc) =>
            {
                asc.Logger.Log("<-- " + rel);
                RaiseReleaseRequestReceived(rel, asc);
                AssociationMessenger.SendReleaseResponse(asc);
                asc.Release();
            };

            ReleaseResponseAction = (rel, asc) =>
            {
                asc.Logger.Log("<-- " + rel);
                RaiseReleaseResponseReceived(rel, asc);
                asc.Release();
            };
        }
Beispiel #5
0
        private void SetDefaultActions()
        {
            CEchoRequestReceivedAction = (cEchoReq, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cEchoReq.GetLogString());
                if (!asc.ServiceClass.SupportedAbstractSyntaxes.Contains(AbstractSyntax.VERIFICATION))
                {
                    return;
                }
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                var response = new CEchoResponse(cEchoReq, Status.SUCCESS);
                PDataMessenger.Send(response, asc);
                RaiseDIMSERequestReceived(cEchoReq, asc);
            };

            CEchoResponseReceivedAction = (cEchoRp, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cEchoRp.GetLogString());
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived(cEchoRp, asc);
                AssociationMessenger.SendReleaseRequest(asc);
            };

            CGetRequestReceivedAction = (cGetReq, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cGetReq.GetLogString());
                cGetReq.LogData(asc);
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                RaiseDIMSERequestReceived(cGetReq, asc);
                throw new NotImplementedException();
            };

            CGetResponseReceivedAction = (cGetRes, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cGetRes.GetLogString());
                cGetRes.LogData(asc);
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived(cGetRes, asc);
                if (cGetRes.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            };

            CMoveRequestReceivedAction = (cMoveReq, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cMoveReq.GetLogString());
                cMoveReq.LogData(asc);
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                RaiseDIMSERequestReceived(cMoveReq, asc);
                throw new NotImplementedException();
            };

            CMoveResponseReceivedAction = (cMoveRes, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cMoveRes.GetLogString());
                cMoveRes.LogData(asc);
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived(cMoveRes, asc);
                if (cMoveRes.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            };
        }
        private void SetDefaultActions()
        {
            CEchoRequestReceivedAction = (cEchoReq, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cEchoReq.GetLogString());
                if (!asc.ServiceClass.SupportedAbstractSyntaxes.Contains(AbstractSyntax.VERIFICATION))
                {
                    return;
                }
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                var response = new CEchoResponse(cEchoReq, Status.SUCCESS);
                PDataMessenger.Send(response, asc);
                RaiseDIMSERequestReceived <CEchoRequest>(cEchoReq, asc);
            };

            CEchoResponseReceivedAction = (cEchoRp, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cEchoRp.GetLogString());
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived <CEchoResponse>(cEchoRp, asc);
                AssociationMessenger.SendReleaseRequest(asc);
            };

            CFindResponseReceivedAction = (cFindResp, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cFindResp.GetLogString());
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived <CFindResponse>(cFindResp, asc);
                cFindResp.LogData(asc);
                if (cFindResp.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            };

            CMoveRequestReceivedAction = (cMoveReq, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cMoveReq.GetLogString());
                cMoveReq.LogData(asc);
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                RaiseDIMSERequestReceived <CMoveRequest>(cMoveReq, asc);
                throw new NotImplementedException();
            };

            CMoveResponseReceivedAction = (cMoveRes, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cMoveRes.GetLogString());
                cMoveRes.LogData(asc);
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived <CMoveResponse>(cMoveRes, asc);
                if (cMoveRes.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            };

            CStoreRequestReceivedAction = async(req, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + req.GetLogString());
                req.LogData(asc);
                asc.LastActive = DateTime.Now;
                asc.State      = NetworkState.TRANSPORT_CONNECTION_OPEN;
                var           resp   = new CStoreResponse(req, Status.SUCCESS);
                IDICOMElement syntax = req.Data.FindFirst(TagHelper.SOPCLASS_UID);
                RaiseDIMSERequestReceived <CStoreRequest>(req, asc);

                if (syntax != null)
                {
                    //If can store (supported Abstract Syntax) - Try
                    if (asc.PresentationContexts.Any(p => p.Id == req.DataPresentationContextId))
                    {
                        try
                        {
                            bool success = CStorePayloadAction(req.Data, asc);
                            resp.Status = success ? resp.Status : (ushort)Status.FAILURE;
                            PDataMessenger.Send(resp, asc, asc.PresentationContexts.First(p => p.Id == req.DataPresentationContextId));
                        }
                        catch (Exception e)
                        {
                            resp.Status = (ushort)Status.FAILURE;
                            PDataMessenger.Send(resp, asc);
                        }
                    }
                    else
                    {
                        //Abstract syntax not supported
                        resp.Status = (ushort)Status.FAILURE;
                        PDataMessenger.Send(resp, asc);
                    }
                }
            };

            CStoreResponseReceivedAction = (cStoreResp, asc) =>
            {
                asc.Logger.Log("<-- DIMSE" + cStoreResp.GetLogString());
                cStoreResp.LogData(asc);
                asc.LastActive = DateTime.Now;
                RaiseDIMSEResponseReceived <CStoreResponse>(cStoreResp, asc);
                if (cStoreResp.Status != (ushort)Status.PENDING)
                {
                    AssociationMessenger.SendReleaseRequest(asc);
                }
            };

            CStorePayloadAction = (dcm, asc) => { return(true); };
        }