using System;
using System.Xml;
using System.Xml.XPath;
//
using IShopSimpleQuery;
class Driver
{
/*
public struct CommandLineParameters
{
//
public string midbUsername;
public string midbPassword;
public string midbUri;
public string midbPort;
//
public string tedUsername;
public string tedPassword;
public string tedUri;
public string tedPort;
//
public string countryCode;
public string categoryCode;
//
public bool verbose;
public bool debug;
//
public string logFilename;
public string countryFilename;
public string equipmentFilename;
}
*/
[STAThread]
static void Main(string[] args)
{
Arguments CommandLine = new Arguments(args);
CommandLineParameters parameters = new CommandLineParameters ();
string configFilenamePath = string.Empty;
string debugFlag = bool.FalseString;
string helpFlag = bool.FalseString;
//
// Look for specific arguments values and display
// them if they exist (return null if they don't)
//
//*************************************************************************
//** Config Argument
//*************************************************************************
if (CommandLine["config"] != null)
{
configFilenamePath = CommandLine["config"];
if(configFilenamePath.Equals (bool.TrueString))
{
configFilenamePath = string.Empty;
}
}
else
{
helpFlag = bool.TrueString;
}
//*************************************************************************
//** Help Argument
//*************************************************************************
if (CommandLine["help"] != null)
{
helpFlag = CommandLine["help"];
}
else
{
//helpFlag = bool.TrueString;
}
//*************************************************************************
//** Debug Argument
//*************************************************************************
if (CommandLine["debug"] != null)
{
debugFlag = CommandLine["debug"];
}
else
{
//helpFlag = bool.TrueString;
}
//*************************************************************************
//########################################################################
//## Process Command Arguments
//########################################################################
if (helpFlag.Equals (bool.TrueString))
{
Usage (string.Empty);
}
else
{
//This string.Empty means the arg is invalid.
if (configFilenamePath.Equals (string.Empty))
{
Usage ("config");
}
//This string equal to "format" means print out the xml format of the
//config file.
else if (configFilenamePath.Equals ("format"))
{
PrintConfigFileFormat ();
}
//if configFilename is filled with some string.
else
{
parameters = ParseConfigFile (configFilenamePath);
if (debugFlag.Equals (bool.TrueString))
{
Console.WriteLine ("Config Filename: {0}", configFilenamePath);
}
}
}
//########################################################################
//QueryDriver driver = new QueryDriver ();
}
///
///
///
///
///
static CommandLineParameters ParseConfigFile(string path)
{
CommandLineParameters parameters = new CommandLineParameters ();
return parameters;
}
///
///
///
///
static void Usage(string command)
{
if (command.Equals (string.Empty))
{
PrintUsage ();
}
else
{
Console.WriteLine ("Argument: {0} is invalid.\n", command);
PrintUsage ();
}
}
///
///
///
///
///
static void PrintArgument(string arg, string description)
{
string usageMessage = arg.PadRight (30, ' ').PadLeft (32, ' ')
+ description.PadLeft (description.Length + 2, ' ');
Console.WriteLine (usageMessage);
}
///
///
///
///
///
static void PrintArgument(string arg, string description, bool newline)
{
string usageMessage = arg.PadRight (30, ' ').PadLeft (32, ' ')
+ description.PadLeft (description.Length + 2, ' ');
if (newline)
{
usageMessage = usageMessage + "\n";
}
Console.WriteLine (usageMessage);
}
///
///
///
static void PrintUsage()
{
Console.WriteLine ("usage: test.exe --config [|format] | --help | --debug\n");
// 123456789012345678901234567890
PrintArgument ("-u | --midbUsername ",
"The username for login to the IShop/MIDB");
PrintArgument (string.Empty , "webservice.", true);
PrintArgument ("-p | --midbPassword ",
"The password for login to the IShop/MIDB");
PrintArgument (string.Empty , "webservice.", true);
PrintArgument ("-o | --midbPortNumber ",
"The port number for connection to the");
PrintArgument (string.Empty , "IShop/MIDB webservice.", true);
PrintArgument ("-i | --midbURI ",
"The uri/url that is used to connect to the");
PrintArgument (string.Empty , "IShop/MIDB webservice.", true);
PrintArgument ("-U | --tedUsername ",
"The username for login to the TED webservice.", true);
PrintArgument ("-P | --tedPassword ",
"The password for login to the TED webservice.", true);
PrintArgument ("-O | --tedPortNumber ",
"The port number for connection to the TED");
PrintArgument (string.Empty , "webservice.", true);
PrintArgument ("-I | --tedURI ",
"The uri/url that is used to connect to the");
PrintArgument (string.Empty , "TED webservice.", true);
PrintArgument ("-cc | --countryCode ",
"The two character country code.", true);
PrintArgument ("-CC | --categoryCode ",
"The 5 digit category code.", true);
PrintArgument ("--config | format", "Filename of configuration file.");
PrintArgument (string.Empty , "NOTE: To do more than one country/category");
PrintArgument (string.Empty , "code use this argument.", true);
PrintArgument ("--help", "Prints this usage message.", true);
PrintArgument ("--debug", "Turns on debugging information.", true);
}
static void PrintConfigFileFormat()
{
string xml = "";
Console.WriteLine (xml);
}
}