Exemplo n.º 1
0
        /// <summary>
        /// Convert one source of data to another format.
        /// File.csv --> json, xml, db
        /// File.json --> csv, xml, db
        /// File.xml --> csv, json, db
        /// File.db (db info not data) --> csv, json, xml
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // default no wait for user key at the end.
            bool waitforUser = false;

            try
            {
                if (Conversion.CheckParams(args) == false)
                {
                    waitforUser = true;
                    HelpCommandLine.DisplayHelp();
                }
                else if (args.Contains("-wait"))
                {
                    //
                    // Did the user state wait for messages?
                    //
                    waitforUser = true;
                }
            }
            catch (Exception ex)
            {
                waitforUser = true;
                Console.WriteLine(ex.ToString());

                HelpCommandLine.DisplayHelp(args);
            }

            //
            // wait for the user to read the messages.
            //
            if (waitforUser)
            {
                Console.ReadKey();
            }
        }
Exemplo n.º 2
0
 public static CommandLine Get(string[] cmdParams)
 {
     if (cmdParams.Length < 1)
      throw new ArgumentException("An action must be specified.");
     string action = cmdParams[0];
     CommandLine result = null;
     switch (action)
     {
      case "help":
       result = new HelpCommandLine();
       break;
      case "querymethods":
       result = new QueryMethodsCommandLine();
       break;
      case "importtasklist":
       result = new ImportTaskListCommandLine();
       break;
      case "addtask":
       result = new AddTaskCommandLine();
       break;
     }
     if (result != null)
     {
      result.Parse(cmdParams);
      return result;
     }
     else
      throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
       "Unknown action: {0}", action));
 }