|
@ -54,10 +54,10 @@ namespace fileFinder |
|
|
{ |
|
|
{ |
|
|
TaskController controller = this; |
|
|
TaskController controller = this; |
|
|
TreeNode itemsNode = new TreeNode(); |
|
|
TreeNode itemsNode = new TreeNode(); |
|
|
ProgressReportModel _report = new ProgressReportModel(); |
|
|
|
|
|
List<string> foundFiles = getFileList(query.fileUrl, query.fileNameQuery); |
|
|
List<string> foundFiles = getFileList(query.fileUrl, query.fileNameQuery); |
|
|
|
|
|
report.Report(createReport(null, null, 0, 0, foundFiles.Count)); |
|
|
|
|
|
|
|
|
int counter = 0; |
|
|
int matchingFiles = 0, processedFiles = 0; |
|
|
foreach (string item in foundFiles) |
|
|
foreach (string item in foundFiles) |
|
|
{ |
|
|
{ |
|
|
switch (state) |
|
|
switch (state) |
|
@ -65,31 +65,39 @@ namespace fileFinder |
|
|
case TaskState.Finished: |
|
|
case TaskState.Finished: |
|
|
return null; |
|
|
return null; |
|
|
case TaskState.Pause: |
|
|
case TaskState.Pause: |
|
|
_report.progress = counter; |
|
|
report.Report(createReport((TreeNode)itemsNode.Clone(), |
|
|
_report.currentFileUrl = item; |
|
|
item, matchingFiles, processedFiles, foundFiles.Count)); |
|
|
_report.currentTreeNode = (TreeNode)itemsNode.Clone(); |
|
|
|
|
|
report.Report(_report); |
|
|
|
|
|
while (state == TaskState.Pause) |
|
|
while (state == TaskState.Pause) |
|
|
Thread.Sleep(100); |
|
|
Thread.Sleep(100); |
|
|
goto case TaskState.Work; |
|
|
goto case TaskState.Work; |
|
|
case TaskState.Work: |
|
|
case TaskState.Work: |
|
|
string[] fileLines = getFileContents(item); |
|
|
string[] fileLines = getFileContents(item); |
|
|
_report.progress = counter; |
|
|
report.Report(createReport(null, item, matchingFiles, processedFiles, foundFiles.Count)); |
|
|
_report.currentFileUrl = item; |
|
|
|
|
|
report.Report(_report); |
|
|
|
|
|
|
|
|
|
|
|
if ((fileLines.Length > 0) && (isFileContainQuery(fileLines, query.fileInnerQuery))) |
|
|
if ((fileLines.Length > 0) && (isFileContainQuery(fileLines, query.fileInnerQuery))) |
|
|
{ |
|
|
{ |
|
|
counter++; |
|
|
|
|
|
await fillChildNode(itemsNode, item.Replace(query.fileUrl, "")); |
|
|
await fillChildNode(itemsNode, item.Replace(query.fileUrl, "")); |
|
|
|
|
|
matchingFiles++; |
|
|
} |
|
|
} |
|
|
|
|
|
processedFiles++; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
report.Report(createReport(null, "none", matchingFiles, processedFiles, foundFiles.Count)); |
|
|
controller.stopTask(); |
|
|
controller.stopTask(); |
|
|
return itemsNode; |
|
|
return itemsNode; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ProgressReportModel createReport(TreeNode treeNode, string fileUrl, int matchingFiles, int processedFiles, int totalNumOfFiles) |
|
|
|
|
|
{ |
|
|
|
|
|
ProgressReportModel prm = new ProgressReportModel(); |
|
|
|
|
|
prm.currentTreeNode = treeNode; |
|
|
|
|
|
prm.currentFileUrl = fileUrl; |
|
|
|
|
|
prm.matchingFiles = matchingFiles; |
|
|
|
|
|
prm.processedFiles = processedFiles; |
|
|
|
|
|
prm.totalNumOfFiles = totalNumOfFiles; |
|
|
|
|
|
return prm; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<string> getFileList(string directory, string nameQuery) |
|
|
private List<string> getFileList(string directory, string nameQuery) |
|
|
{ |
|
|
{ |
|
|