using gmslLibrary;
using wpfLibrary;
using GM=gmslAPI;
namespace gmUpgrade
{
public static class Program
{
[System.STAThread] // Much faster using STA, ~1.6 vs 8.6 seconds
static void Main(string[] args)
{
// When started by gmStudio, TaskInfo is passed on the command line.
// The TaskInfo XML file is generated by gmStudio. It contains
// details about the upgrade task and the upgrade environment.
// For debugging or direct operation, load upgrade tasks here.
if (args.Length == 0)
{
args = new string[] {
@"TaskInfo=c:\Upgrades\proj\log\Upgrade-task1-exe-csh.xml",
@"TaskInfo=c:\Upgrades\proj\log\Upgrade-task2-exe-csh.xml",
@"TaskInfo=c:\Upgrades\proj\log\Upgrade-task3-exe-csh.xml",
@"TaskInfo=c:\Upgrades\proj\log\Upgrade-task4-exe-csh.xml"
};
}
RunAllTranslations(args);
System.Environment.Exit(0);
}
static void RunAllTranslations(string[] args)
{
GM.gmslAPI.LoadLicense(logInfo:true); // Must load gmStudio License
string taskInfoPath = "";
foreach (string arg in args)
{
if (arg.StartsWith("TaskInfo="))
{
taskInfoPath = arg.Split('=')[1];
if (!System.IO.File.Exists(taskInfoPath))
{
System.Console.WriteLine("ERROR: TaskInfo File Not Found:" + taskInfoPath);
System.Environment.Exit(999);
}
else
{
Run1Translation(taskInfoPath);
}
}
}
}
private static void Run1Translation(string taskInfoPath)
{
GM.gmStudioTask task = GM.gmslAPI.Load(taskInfoPath);
bool useWPF = task.UserDesc == "WPF";
// Go to Upgrade project working folder so relative file references are correct
System.IO.Directory.SetCurrentDirectory(task.WorkFolder);
// Detailed translation rules are stored in a ScriptRules.xml file.
// This format can be used by both XML-based and API-based upgrade tasks.
// The ScriptRules class makes themthe rules available to API calls.
// Rules may also be created on the fly using gmAPI calls.
GM.ScriptRules rules = new GM.ScriptRules(@"..\usr\ScriptRules.xml");
rules.AddRules(task, "SetOptions");
rules.AddRules(task, "PreEdits");
rules.AddRules(task, "msado15.dll");
rules.AddRules(task, "scrrun.dll");
rules.AddRules(task, "excel.exe");
rules.AddRules(task, "AssessmentRules");
rules.AddRules(task, "GenericCollections");
rules.logEnable = true;
if (rules.logEnable) FileSystem.LogMessage(rules.AllRulesReport());
gmBasic.StartUp(@"..\usr\gmBasic.xml", null, null);
Execute.Storage(action: "Create", identifier: task.JobId);
Execute.gmPL(commands: rules.OptionRules);
Execute.Compile(project: task.SrcPath, commands: rules.CompileRules);
if (rules.PreAnalyseRules != 0)
{
Execute.gmPL(commands: rules.PreAnalyseRules);
}
Execute.Analyse();
if (rules.PostAnalyseRules!=0)
{
Execute.gmPL(commands: rules.PostAnalyseRules);
}
int projectRoot = (useWPF ? wpfSubsystem.WPFCodeScan() : 0); // WPF
Execute.Output(status: "New", filename: task.BndPath);
if (useWPF) wpfSubsystem.WPFAuthorProject(projectRoot, rules.AuthorRules); // WPF
else Execute.Author(commands: rules.AuthorRules);
Execute.Storage(action: "Close");
gmBasic.Terminate();
}
}
}
|