Exemplo n.º 1
0
    private static CommandLineOptions GetCommandlineOptions(string[] args)
    {
        if (args.Length == 0)
        {
            Usage();
        }

        CommandLineOptions commandLineOptions = new CommandLineOptions();

        CommandLine.Utility.Arguments arguments = new CommandLine.Utility.Arguments(args);

        if (string.IsNullOrEmpty(arguments["n"]))
        {
            Usage();
        }
        bool boolVal = false;

        if (Boolean.TryParse(arguments["n"], out boolVal))
        {
            Usage();
        }
        commandLineOptions.printerName = arguments["n"];

        if (!string.IsNullOrEmpty(arguments["j"]))
        {
            commandLineOptions.jobStatus = true;
        }

        return(commandLineOptions);
    }
Exemplo n.º 2
0
        public void ExecMain(string[] args)
        {
            sThisEXEPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            sThisEXEPath = sThisEXEPath.Substring(0, sThisEXEPath.LastIndexOf("\\") + 1);
            sThisAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
            sThisAssemblyName = sThisAssemblyName.Substring(0, sThisAssemblyName.IndexOf(","));
            if (sAppName.Length == 0)
            {
                sAppName = sThisAssemblyName;
            }

            Log.FileName = sThisEXEPath + sAppName + ".log";
            CommandLine = new CommandLine.Utility.Arguments(args);
            ProcessCmdArgs(CommandLine);
            Log.LogKill();
            Console_WriteLine("Starting " + sAppName + " on " + DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString());
            ProcessCommandLineEvent();
            if (args.Length == 0)
            {
                bShowHelp = true;
            }
            if (bShowHelp)
            {
                ShowUsage();
            }
            else
            {
                if (CommandLine["parm"] != null)
                {
                    sParmFileName = CommandLine["parm"];
                    String sParmFilePath = sParmFileName.Substring(0, sParmFileName.LastIndexOf("\\") + 1);
                    if (sParmFilePath.Length == 0)
                    {
                        sParmFileName = sThisEXEPath + sParmFileName;
                    }
                    if (!System.IO.File.Exists(sParmFileName))
                    {
                        throw new ArgumentException("Parm File " + sParmFileName + " that is specified on -p on the commandl line does not exist.");
                    }
                    ProcessParmFile(sParmFileName);
                }

                if (ValidateAndShowRunParameters())
                {

                }
            }
            Console_WriteLine("Ending " + sAppName + " on " + DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString());
        }