Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron533 committed Aug 4, 2024
1 parent 531632a commit 4be2ea3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DicomGrep/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public MainViewModel()

this.searchService.OnCompletDicomFile += SearchService_OnCompletDicomFile;

this.searchService.OnSearchComplete += SearchService_OnSearchComplete;
this.searchService.OnAllSearchComplete += SearchService_OnSearchComplete;

}

Expand Down Expand Up @@ -388,7 +388,7 @@ private void SearchService_OnCompletDicomFile(object sender, DicomGrepCore.Servi
}
}

private void SearchService_OnSearchComplete(object sender, DicomGrepCore.Services.EventArgs.OnSearchCompleteEventArgs e)
private void SearchService_OnSearchComplete(object sender, DicomGrepCore.Services.EventArgs.OnAllSearchCompleteEventArgs e)
{
this.MainStatus = MainStatusEnum.Complete;
InvalidateRequerySuggested();
Expand Down
2 changes: 1 addition & 1 deletion DicomGrepCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static void DoSearch(SearchCriteria criteria)
Console.WriteLine(e.Filename);
}
};
searchService.OnSearchComplete += (sender, e) =>
searchService.OnAllSearchComplete += (sender, e) =>
{
Console.WriteLine($"> Search completed.");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DicomGrepCore.Services.EventArgs
{
public class OnSearchCompleteEventArgs : System.EventArgs
public class OnAllSearchCompleteEventArgs : System.EventArgs
{
public CompleteReasonEnum Reason { get; set; }
}
Expand Down
19 changes: 17 additions & 2 deletions DicomGrepCore/Services/Interfaces/ISearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ namespace DicomGrepCore.Services.Interfaces
{
public interface ISearchService
{
/// <summary>
/// Generate the file list to be searched based on the search criteria.
/// </summary>
event SearchService.ListFileCompletedDelegate FileListCompleted;
event SearchService.OnCompletDicomFileDelegate OnCompletDicomFile;

/// <summary>
/// Load a DICOM file and search for the search criteria.
/// </summary>
event SearchService.OnLoadDicomFileDelegate OnLoadDicomFile;
event SearchService.OnSearchCompleteDelegate OnSearchComplete;

/// <summary>
/// Finish searching a DICOM file.
/// </summary>
event SearchService.OnCompletDicomFileDelegate OnCompletDicomFile;

/// <summary>
/// Finish searching all DICOM files.
/// </summary>
event SearchService.OnAllSearchCompleteDelegate OnAllSearchComplete;

void Search(SearchCriteria criteria, CancellationTokenSource tokenSource);
}
Expand Down
12 changes: 6 additions & 6 deletions DicomGrepCore/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ public class SearchService : ISearchService
public delegate void OnCompletDicomFileDelegate(object sender, OnCompleteDicomFileEventArgs e);
public event OnCompletDicomFileDelegate OnCompletDicomFile;

public delegate void OnSearchCompleteDelegate(object sender, OnSearchCompleteEventArgs e);
public event OnSearchCompleteDelegate OnSearchComplete;
public delegate void OnAllSearchCompleteDelegate(object sender, OnAllSearchCompleteEventArgs e);
public event OnAllSearchCompleteDelegate OnAllSearchComplete;

private SearchCriteria criteria;
private List<string> filenameList = new List<string>();
private List<string> matchFilenameList = new List<string>();
private CancellationToken token;

// the search service itself maintains a simple search result
private int searchedFileCount = 0;
private int matchFileCount = 0;

Expand Down Expand Up @@ -83,11 +84,11 @@ public void Search(SearchCriteria criteria, CancellationTokenSource tokenSource)
options.CancellationToken.ThrowIfCancellationRequested();
SearchInDicomFile(filename);
});
OnSearchComplete?.Invoke(this, new OnSearchCompleteEventArgs { Reason = Enums.CompleteReasonEnum.Normal });
OnAllSearchComplete?.Invoke(this, new OnAllSearchCompleteEventArgs { Reason = Enums.CompleteReasonEnum.Normal });
}
catch (OperationCanceledException)
{
OnSearchComplete?.Invoke(this, new OnSearchCompleteEventArgs { Reason = Enums.CompleteReasonEnum.UserCancelled });
OnAllSearchComplete?.Invoke(this, new OnAllSearchCompleteEventArgs { Reason = Enums.CompleteReasonEnum.UserCancelled });
logger.Info("User cancelled the search.");
}
finally
Expand Down Expand Up @@ -157,10 +158,9 @@ private void SearchInDicomFile(string filePath)

string patientName = string.Empty;
string sopClassName = string.Empty;
DicomUID sopClassUID = null;


if (dicomFile.Dataset.TryGetSingleValue<DicomUID>(DicomTag.SOPClassUID, out sopClassUID))
if (dicomFile.Dataset.TryGetSingleValue<DicomUID>(DicomTag.SOPClassUID, out DicomUID sopClassUID))
{
// compare the sop class uid
if (!string.IsNullOrWhiteSpace(criteria.SearchSopClassUid) && sopClassUID.UID != criteria.SearchSopClassUid)
Expand Down

0 comments on commit 4be2ea3

Please sign in to comment.