58 lines
2.4 KiB
C#
58 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
|
|
namespace EstrazioneAnagrafica
|
|
{
|
|
class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
static void Main(string[] args)
|
|
{
|
|
Log.ScriviLog("Starting at " + DateTime.Now.ToLongTimeString());
|
|
|
|
if (args.Count() == 0) //no arguments, starting default for the batch job
|
|
{
|
|
ConsoleVersion.StartSilient(); //start without console output
|
|
}
|
|
else //cool, someone need some special treatment
|
|
{
|
|
Log.ScriviLog("Flag: " + args[0].ToString()); //lets save what she needs
|
|
switch (args[0])
|
|
{
|
|
case "--debug":
|
|
ConsoleVersion.Start(); //she wants to see output while processing so we will start with standard console messages
|
|
break;
|
|
case "--forms":
|
|
RunForm(); //running legacy system, Luca should be happy
|
|
break;
|
|
case "--silent":
|
|
ConsoleVersion.StartSilient(); //start without console output... boring. the same as with running with no parameters
|
|
break;
|
|
default: //someone used a random string, let's show her available options
|
|
Console.WriteLine("Please run the tool with no parameters to start 'windows' mode");
|
|
Console.WriteLine("--debug will ignite batch run");
|
|
Console.WriteLine("--silent will ignite batch run with no notifications");
|
|
Console.WriteLine("--forms will start windows forms application");
|
|
Log.ScriviLog("Whooops"); //that's the most detailed log message, isn't it?
|
|
throw new Exception("incorect flag");//throw an error on the request so in task scheduler there will be an error / failure
|
|
}
|
|
}
|
|
|
|
Log.ScriviLog("Ending at " + DateTime.Now.ToLongTimeString());
|
|
}
|
|
|
|
//run the window version
|
|
private static void RunForm()
|
|
{
|
|
Application.EnableVisualStyles(); //moved from the original application to this place
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new Form1());
|
|
}
|
|
|
|
}
|
|
}
|