|
@@ -21,6 +21,8 @@ class KMBatchManager: NSObject {
|
|
|
public static let manager = KMBatchManager()
|
|
|
fileprivate(set) var state: KMBatchManagerSate = .unknow
|
|
|
|
|
|
+ var outputFolderPath: String = ""
|
|
|
+
|
|
|
var filesData: [KMBatchProcessingTableViewModel] = []
|
|
|
var batchFilesData: [KMBatchProcessingTableViewModel] {
|
|
|
get {
|
|
@@ -45,8 +47,10 @@ class KMBatchManager: NSObject {
|
|
|
}
|
|
|
|
|
|
let outputFolderPath = (panel.url?.path)!
|
|
|
+ self.outputFolderPath = outputFolderPath
|
|
|
//
|
|
|
self.batchUnkown()
|
|
|
+ self.batchProgress()
|
|
|
switch type {
|
|
|
case .convertPDF:
|
|
|
self.convertPDFExport(data: data, outputFolderPath: outputFolderPath)
|
|
@@ -131,9 +135,6 @@ extension KMBatchManager {
|
|
|
self.itemProgress(item: item, processValue: progress)
|
|
|
}, completion: { [unowned self] finished, error in
|
|
|
if finished {
|
|
|
- if FileManager.default.fileExists(atPath: outputFolderPath) {
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
|
|
|
- }
|
|
|
self.itemSuccess(item: item)
|
|
|
} else {
|
|
|
self.itemFailure(item: item, error: error! as NSError)
|
|
@@ -387,7 +388,6 @@ extension KMBatchManager {
|
|
|
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -438,7 +438,6 @@ extension KMBatchManager {
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
}
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -490,7 +489,6 @@ extension KMBatchManager {
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
}
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -539,7 +537,6 @@ extension KMBatchManager {
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
}
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -588,7 +585,6 @@ extension KMBatchManager {
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
}
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -652,7 +648,6 @@ extension KMBatchManager {
|
|
|
if i == filesData.count - 1 {
|
|
|
self.batchSuccess()
|
|
|
}
|
|
|
- NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: outputFolderPath)])
|
|
|
}
|
|
|
// }
|
|
|
}
|
|
@@ -934,11 +929,19 @@ extension KMBatchManager {
|
|
|
}
|
|
|
|
|
|
func batchSuccess() {
|
|
|
+ if FileManager.default.fileExists(atPath: self.outputFolderPath) {
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: self.outputFolderPath)])
|
|
|
+ }
|
|
|
+
|
|
|
self.state = .complete
|
|
|
NotificationCenter.default.post(name: NSNotification.Name(kBacthProcessNotification), object: nil)
|
|
|
}
|
|
|
|
|
|
func batchFailure() {
|
|
|
+ if FileManager.default.fileExists(atPath: self.outputFolderPath) {
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: self.outputFolderPath)])
|
|
|
+ }
|
|
|
+
|
|
|
self.state = .error
|
|
|
NotificationCenter.default.post(name: NSNotification.Name(kBacthProcessNotification), object: nil)
|
|
|
}
|