This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStep10.cs
68 lines (58 loc) · 2.25 KB
/
Step10.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json.Linq;
namespace M101
{
public class Step10
{
private const string _ACTIV_NAME = "Step10";
private const string _EXE_NAME = "mBgExec";
private static string _EXE_PATH = Path.Combine(Montage.BIN_PATH, _EXE_NAME);
public JObject Main(JObject args)
{
Action<string> log = (string msg) => Montage.Log(args, $"{_ACTIV_NAME} {msg}");
log("Start");
Montage.ServerURL = args.GetValue("serverURL").ToString();
Directory.CreateDirectory(Montage.PROJ_DIR);
Directory.CreateDirectory(Montage.CORR_DIR);
log("Download");
{
var projected = args.GetValue("projected") as JArray;
var files = new List<KeyValuePair<string, string>>(Montage.RAWS.Length + 2);
files.Add(KeyValuePair.Create(Montage.IMG_TBL, Montage.IMG_TBL));
files.Add(KeyValuePair.Create(Montage.CORR_TBL, Montage.CORR_TBL));
foreach (var proj in projected)
{
var trg = proj.ToString();
files.Add(KeyValuePair.Create(trg, Path.Combine(Montage.PROJ_DIR, trg)));
files.Add(KeyValuePair.Create(Montage.ToArea(trg), Path.Combine(Montage.PROJ_DIR, Montage.ToArea(trg))));
}
Montage.Download(files.ToArray()).Wait();
}
log("Run " + _EXE_NAME);
using (var proc = new Process()
{
StartInfo = new ProcessStartInfo()
{
FileName = _EXE_PATH,
Arguments = $"-p {Montage.PROJ_DIR} {Montage.IMG_TBL} {Montage.CORR_TBL} {Montage.CORR_DIR}",
RedirectStandardOutput = true
}
})
{
proc.Start();
proc.WaitForExit();
log(proc.StandardOutput.ReadToEnd());
}
log("Upload");
{
var files = Directory.GetFiles(Montage.CORR_DIR);
Montage.Upload(files).Wait();
}
log("Finish");
return args;
}
}
}