public void Move(MoveInfo info) { try { DicomServer dicomServer = ServiceLocator.Retrieve <DicomServer>(); string lastStatus = string.Empty; _Scp.Timeout = dicomServer.ClientTimeout; foreach (string aetitle in _AeTitles) { if (!Move(_Scp, info, aetitle, dicomServer.TemporaryDirectory, ref lastStatus) && EnableRetry && NumberOfRetries > 0) { MoveServer server = new MoveServer(_Scp); Job <MoveServer> retryJob = new Job <MoveServer>() { Loops = 1, Data = server }; server.DestinationAE = aetitle; server.Info = info; server.RetryCount = NumberOfRetries; server.LastStatus = lastStatus; server.IPAddress = _Scp.PeerAddress.ToString(); retryJob.StartTime = Timeout.Milliseconds().FromNow(); Module.Scheduler.SubmitJob <MoveServer>(retryJob, Retry); } } } catch (Exception e) { Logger.Global.SystemException(string.Empty, e); } }
public void Store() { StoreFailure storeFailures = new StoreFailure(); DicomServer dcmServer = ServiceLocator.Retrieve <DicomServer>(); try { foreach (DicomScp scp in _Scps) { string lastStatus = string.Empty; string clientAE = Module._Options.AETitle.Length > 0 ? Module._Options.AETitle : dcmServer.AETitle; // // If the store operation failed and we have enabled retry we need to schedule this action to be retried again // if (!Store(clientAE, scp, _DataSet, ref lastStatus)) { ResendServer server = new ResendServer(scp); server.AETitle = clientAE; server.RetryCount = NumberOfRetries; server.LastStatus = lastStatus; server.IPAddress = scp.PeerAddress.ToString(); storeFailures.Scps.Add(server); } } } catch (Exception ex) { Logger.Global.SystemException(string.Empty, ex); } if (storeFailures.Scps.Count > 0) { storeFailures.Dataset = _DataSet; if (EnableRetry && NumberOfRetries > 0) { Job <StoreFailure> retryJob = new Job <StoreFailure>() { Loops = 1, Data = storeFailures }; retryJob.StartTime = Timeout.Milliseconds().FromNow(); Module.Scheduler.SubmitJob <StoreFailure>(retryJob, Retry); } else { // // Since we have no retries we will send this to manual resend // storeFailures.Save(); } } }
private void Retry(Job <MoveServer> job, MoveServer server) { string lastStatus = string.Empty; DicomServer dicomServer = ServiceLocator.Retrieve <DicomServer>(); bool success; server.Scp.AETitle = dicomServer.AETitle; server.Scp.PeerAddress = IPAddress.Parse(dicomServer.HostAddress); server.Scp.Timeout = dicomServer.ClientTimeout; success = Move(server.Scp, server.Info, server.DestinationAE, dicomServer.TemporaryDirectory, ref lastStatus); server.RetryCount--; // // If the store operation failed and we do not have not exhausted our retry count we // will try to send this dataset again later // if (!success && server.RetryCount > 0) { Job <MoveServer> retryJob = new Job <MoveServer>() { Loops = 1, Data = server }; string retryMessage = server.RetryCount > 0 ? string.Format("are {0} retries", server.RetryCount) : "is only 1 retry"; string message = string.Format("[Rules] Failed to successfully move dataset to {0}. There {0} left.", server.Scp.AETitle, retryMessage); Logger.Global.SystemMessage(LogType.Error, message, string.Empty); retryJob.StartTime = Timeout.Milliseconds().FromNow(); Module.Scheduler.SubmitJob <MoveServer>(retryJob, Retry); } else { // // If the dataset is not successfully store we need to save the info so that it can be manually sent to // its destination. // if (!success) { try { string message = string.Format("[Rules] Failed to successfully move dataset to {0} after {1} retries. Dataset will be added to manual resend queue", server.Scp.AETitle, NumberOfRetries); Logger.Global.SystemMessage(LogType.Error, message, string.Empty); server.Save(); } catch (Exception e) { Logger.Global.SystemException(string.Empty, e); } } } }
private void Retry(Job <StoreFailure> job, StoreFailure storeFailure) { int count = storeFailure.Scps.Count; DicomServer dcmServer = ServiceLocator.Retrieve <DicomServer>(); foreach (ResendServer server in storeFailure.Scps.ToList()) { string lastStatus = string.Empty; bool success; string aetitle = !string.IsNullOrEmpty(server.AETitle) ? server.AETitle : dcmServer.AETitle; server.Scp.PeerAddress = IPAddress.Parse(server.IPAddress); success = Store(aetitle, server.Scp, storeFailure.Dataset, ref lastStatus); server.RetryCount--; // // If the store operation failed and we do not have not exhausted our retry count we // will try to send this dataset again later // if (!success && server.RetryCount > 0) { string retryMessage = server.RetryCount > 0 ? string.Format("are {0} retries", server.RetryCount) : "is only 1 retry"; string message = string.Format("[Rules] Failed to successfully store dataset to {0}. There {1} left.", server.Scp.AETitle, retryMessage); Logger.Global.SystemMessage(LogType.Error, message, string.Empty); } else { // // If the dataset is not successfully store we need to save the info so that it can be manually sent to // its destination. // if (!success) { try { string message = string.Format("[Rules] Failed to successfully store dataset to {0} after {1} retries. Dataset will be added to manual resend queue", server.Scp.AETitle, NumberOfRetries); Logger.Global.SystemMessage(LogType.Error, message, string.Empty); } catch (Exception e) { Logger.Global.SystemException(string.Empty, e); } } else { storeFailure.Scps.Remove(server); } } } // // Some items still failed so we need to resubmit // if (storeFailure.Scps.Count > 0) { int itemsToRetry = (from scp in storeFailure.Scps where scp.RetryCount > 0 select scp).Count(); if (itemsToRetry > 0) { Job <StoreFailure> retryJob = new Job <StoreFailure>() { Loops = 1, Data = storeFailure }; retryJob.StartTime = Timeout.Milliseconds().FromNow(); Module.Scheduler.SubmitJob <StoreFailure>(retryJob, Retry); } else { storeFailure.Save(); } } }