コード例 #1
0
        static void Main(string[] args)
        {
            // Hide the console window
            NativeMethods.ShowWindow(NativeMethods.GetConsoleWindow(), NativeMethods.SW_HIDE);

            ServiceLogger.CreateLogFileDirectory();
            ServiceLogger.WriteLine();
            OutputDirectory = GetOutputDirectory();
            FileUtils.ValidFileExtensions.Add(".txt");
            try
            {
                //if no arguments where passed set the default source directory from the appconfig
                if (args.Length == 0)
                {
                    if (!ConfigurationManager.AppSettings.AllKeys.Contains("DefaultSourceDirectory"))
                    {
                        throw new Exception("App.config, Key: DefaultSourceDirectory, missing. Please pass source directory as argument.");
                    }
                    if (ConfigurationManager.AppSettings["DefaultSourceDirectory"].Equals(""))
                    {
                        throw new Exception("App.config, Key: DefaultSourceDirectory, value is empty. Please pass source directory as argument.");
                    }
                    args = new string[] { ConfigurationManager.AppSettings["DefaultSourceDirectory"] };
                }

                //Gather the filePaths into the serviceFilePath collection
                FilePathImporter.ParseArgs(args);

                if (FlexibleMessageBox.Show("The following files have been loaded for conversion:\n" + FileConfirmationMessage + "\n\nWould you like to start the conversion?", "AAI Log Converter - Continue?", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                {
                    Thread t = new Thread(new ThreadStart(() => { MessageBox.Show("The Conversion will continue in the background.\nFeel free to continue working while you wait.", "AAI Log Converter - Info", MessageBoxButtons.OK); }));
                    t.Start();

                    //start the conversion process
                    StartProc();

                    if (MessageBox.Show("The log file conversion has Sucessfully Completed.\nWould you like to open the output directory now?", "AAI Log Converter - Success!", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                    {
                        Process.Start(OutputDirectory);
                    }
                }
                else
                {
                    ServiceLogger.WriteLine("End user did not accept prompt to continue.");
                }
            }
            catch (Exception ex)
            {
                ServiceLogger.WriteLine("ERROR:: " + ex.Message, new StackTrace(ex).GetFrame(0).GetMethod().Name, ex.Source, new StackTrace(ex).GetFrame(0).GetFileLineNumber());
                MessageBox.Show(ex.Message, "AAI Log Converter - ERROR", MessageBoxButtons.OK);
            }
        }