-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (38 loc) · 1.95 KB
/
Program.cs
File metadata and controls
46 lines (38 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Dotcore.FileSystem;
using Dotcore.FileSystem.Directory;
using ESCLScan;
using ESCLScan.Scanner;
using ESCLScan.Upload;
using Sharprompt;
var workingDirectory = Prompt.Input<string>("Enter working directory", defaultValue: "./").ToDirectoryInfo();
var printerIp = Prompt.Input<string>("Enter printer IP address", defaultValue: "192.168.1.100");
var quality = Prompt.Input<int>("Enter scan quality (0: lowest, x: highest)", defaultValue: 3);
var shouldUpload = Prompt.Confirm("Upload to FTP Server?", defaultValue: true);
Uploader.Config? uploadConfig = null;
if (shouldUpload){
var ftpServerIp = Prompt.Input<string>("Enter FTP Server IP address", defaultValue: "192.168.1.200");
var ftpServerUserName = Prompt.Input<string>("Enter FTP Server FTP user name", defaultValue: "ftpuser");
var ftpServerPassword = Prompt.Password("Enter FTP Server FTP password");
uploadConfig = new Uploader.Config(ftpServerIp, new Credential(ftpServerUserName, ftpServerPassword));
}
var scannerConfig = new Scanner.Config(printerIp, quality);
while (true)
{
Console.WriteLine("ESCLScan - Main menu");
var mainMenuAction = Prompt.Select("Select action", new[] { "Scan document", "Quit" });
if(mainMenuAction == "Quit") break;
var documentName = Prompt.Input<string>("Enter document name");
var documentWorkingDirectory = workingDirectory.CombineDirectory(documentName);
documentWorkingDirectory.EnsureExists();
var pages = await Scanner.ScanMultiplePages(
scannerConfig,
documentWorkingDirectory,
() => Prompt.Confirm("Scan another page?", defaultValue: true))
.ToListAsync();
var mergedFile = documentWorkingDirectory.CombineFile($"{documentName}.pdf");
PDFMerge.Merge(pages, mergedFile);
if (!shouldUpload || uploadConfig == null) continue;
await Uploader.UploadDocument(uploadConfig, mergedFile);
//documentWorkingDirectory.Delete();
Console.WriteLine($"document {documentName} uploaded successfully");
}