示例#1
0
        public void run()
        {
            while (true)
            {
                String input = inputs.getNextInput();
                if (input == null)
                {
                    break;
                }

                if (File.Exists(input))
                {
                    try
                    {
                        if (config.Multi)
                        {
                            Result[] results = decodeMulti(new Uri(input), config.Hints);
                            if (results != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResultMulti(input, results);
                                }
                            }
                        }
                        else
                        {
                            Result result = decode(new Uri(input), config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                    }
                    catch (IOException)
                    {
                    }
                }
                else
                {
                    try
                    {
                        if (decode(new Uri(input), config.Hints) != null)
                        {
                            successful++;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
示例#2
0
 public void run()
 {
     ResultString = String.Empty;
     while (true)
     {
         String input = inputs.getNextInput();
         if (input == null)
         {
             break;
         }
         try
         {
             Result[] results = decodeMulti(new Uri(Path.GetFullPath(input)), input, config.Hints);
             if (results != null)
             {
                 successful++;
             }
         }
         catch (IOException exc)
         {
             Console.WriteLine(exc.ToString());
         }
     }
 }
示例#3
0
        public void run()
        {
            ResultString = String.Empty;
            while (true)
            {
                String input = inputs.getNextInput();
                if (input == null)
                {
                    break;
                }

                if (File.Exists(input))
                {
                    try
                    {
                        if (config.Multi)
                        {
                            Result[] results = decodeMulti(new Uri(Path.GetFullPath(input)), input, config.Hints);
                            if (results != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResultMulti(input, results);
                                }
                            }
                        }
                        else
                        {
                            Result result = decode(new Uri(Path.GetFullPath(input)), input, config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                    }
                    catch (IOException exc)
                    {
                        Console.WriteLine(exc.ToString());
                    }
                }
                else
                {
                    try
                    {
                        var tempFile = Path.GetTempFileName();
                        var uri      = new Uri(input);
                        var client   = new WebClient();
                        client.DownloadFile(uri, tempFile);
                        try
                        {
                            Result result = decode(new Uri(tempFile), input, config.Hints);
                            if (result != null)
                            {
                                successful++;
                                if (config.DumpResults)
                                {
                                    dumpResult(input, result);
                                }
                            }
                        }
                        finally
                        {
                            File.Delete(tempFile);
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.ToString());
                    }
                }
            }
        }