/// <summary>
        /// <para>Main Program call for GarminTo application</para>
        /// </summary>
        /// <param name="args">Args for the GarminTo application</param>
        public static void Main(string[] args)
        {
            // read FIT file test
            fitSource = new FileStream(@"D:\temp\fit-files\20150919-092010-1-1328-ANTFS-4-0.FIT", FileMode.Open);
            var fitDecode = new FickleFrostbite.FIT.Decode();
            var mesgBroadcaster = new FickleFrostbite.FIT.MesgBroadcaster();
            fitDecode.MesgEvent += mesgBroadcaster.OnMesg;
            fitDecode.MesgDefinitionEvent += mesgBroadcaster.OnMesgDefinition;
            mesgBroadcaster.MesgEvent += new MesgEventHandler(OnMesg);
            mesgBroadcaster.MesgDefinitionEvent += new MesgDefinitionEventHandler(OnMesgDefn);
            mesgBroadcaster.FileIdMesgEvent += new MesgEventHandler(OnFileIDMesg);
            mesgBroadcaster.UserProfileMesgEvent += new MesgEventHandler(OnUserProfileMesg);
            bool status = fitDecode.IsFIT(fitSource);
            status &= fitDecode.CheckIntegrity(fitSource);
            // Process the file
            if (status == true)
            {
                Console.WriteLine("Decoding...");
                fitDecode.Read(fitSource);
                Console.WriteLine("Decoded FIT file.");
            }
            else
            {
                try
                {
                    Console.WriteLine("Integrity Check Failed {0}", args[0]);
                    Console.WriteLine("Attempting to decode...");
                    fitDecode.Read(fitSource);
                }
                catch (FitException ex)
                {
                    Console.WriteLine("DecodeDemo caught FitException: " + ex.Message);
                }
            }
            fitSource.Close();
            Console.WriteLine("");
            Console.WriteLine("Summary:");
            int totalMesgs = 0;
            foreach (KeyValuePair<ushort, int> pair in mesgCounts)
            {
                Console.WriteLine("MesgID {0,3} Count {1}", pair.Key, pair.Value);
                totalMesgs += pair.Value;
            }

            if (args.Length < 2)
            {
                Program.ShowUsageMessage();
            }
            else
            {
                /* process input file (either single file or directory) into list of FileInfo */
                var inputFiles = Program.GetInputFiles(args[0]);

                /* process export options */
                var exportOptions = args.ToList();
                exportOptions.RemoveAt(0);

                /* for each export option determine what type of option
                 *              and then run the process over that option */
                foreach (var exportOption in exportOptions)
                {
                    var googleMapsMatch = googleMapsRegex.Match(exportOption);
                    var sqlMatch = sqlRegex.Match(exportOption);
                    var excel2013Match = excel2013Regex.Match(exportOption);

                    if (googleMapsMatch.Success) { Processor.ToGoogleMaps(inputFiles, googleMapsMatch); }

                    if (sqlMatch.Success) { Processor.ToSql(inputFiles, sqlMatch); }

                    if (excel2013Match.Success) { Processor.ToExcel2013(inputFiles, excel2013Match); }
                }
            }

            System.Console.WriteLine("Press any key to close ... ");
            System.Console.ReadKey();
        }
        /// <summary>
        /// <para>Main Program call for GarminTo application</para>
        /// </summary>
        /// <param name="args">Args for the GarminTo application</param>
        public static void Main(string[] args)
        {
            // read FIT file test
            fitSource = new FileStream(@"D:\temp\fit-files\20160101-090645-1-1328-ANTFS-4-0.FIT", FileMode.Open);
            var fitDecode       = new FickleFrostbite.FIT.Decode();
            var mesgBroadcaster = new FickleFrostbite.FIT.MesgBroadcaster();

            fitDecode.MesgEvent                  += mesgBroadcaster.OnMesg;
            fitDecode.MesgDefinitionEvent        += mesgBroadcaster.OnMesgDefinition;
            mesgBroadcaster.MesgEvent            += new MesgEventHandler(OnMesg);
            mesgBroadcaster.MesgDefinitionEvent  += new MesgDefinitionEventHandler(OnMesgDefn);
            mesgBroadcaster.FileIdMesgEvent      += new MesgEventHandler(OnFileIDMesg);
            mesgBroadcaster.UserProfileMesgEvent += new MesgEventHandler(OnUserProfileMesg);
            bool status = fitDecode.IsFIT(fitSource);

            status &= fitDecode.CheckIntegrity(fitSource);
            // Process the file
            if (status == true)
            {
                Console.WriteLine("Decoding...");
                fitDecode.Read(fitSource);
                Console.WriteLine("Decoded FIT file.");
            }
            else
            {
                try
                {
                    Console.WriteLine("Integrity Check Failed {0}", args[0]);
                    Console.WriteLine("Attempting to decode...");
                    fitDecode.Read(fitSource);
                }
                catch (FitException ex)
                {
                    Console.WriteLine("DecodeDemo caught FitException: " + ex.Message);
                }
            }
            fitSource.Close();
            Console.WriteLine("");
            Console.WriteLine("Summary:");
            int totalMesgs = 0;

            foreach (KeyValuePair <ushort, int> pair in mesgCounts)
            {
                Console.WriteLine("MesgID {0,3} Count {1}", pair.Key, pair.Value);
                totalMesgs += pair.Value;
            }


            if (args.Length < 2)
            {
                Program.ShowUsageMessage();
            }
            else
            {
                /* process input file (either single file or directory) into list of FileInfo */
                var inputFiles = Program.GetInputFiles(args[0]);

                /* process export options */
                var exportOptions = args.ToList();
                exportOptions.RemoveAt(0);

                /* for each export option determine what type of option
                 *              and then run the process over that option */
                foreach (var exportOption in exportOptions)
                {
                    var googleMapsMatch = googleMapsRegex.Match(exportOption);
                    var sqlMatch        = sqlRegex.Match(exportOption);
                    var excel2013Match  = excel2013Regex.Match(exportOption);

                    if (googleMapsMatch.Success)
                    {
                        Processor.ToGoogleMaps(inputFiles, googleMapsMatch);
                    }

                    if (sqlMatch.Success)
                    {
                        Processor.ToSql(inputFiles, sqlMatch);
                    }

                    if (excel2013Match.Success)
                    {
                        Processor.ToExcel2013(inputFiles, excel2013Match);
                    }
                }
            }

            System.Console.WriteLine("Press any key to close ... ");
            System.Console.ReadKey();
        }