Esempio n. 1
0
        public static void Main(string[] args)
        {
            string inputFile = null;
            string outputFile = null;
            var shouldClip = false;
            var shouldRotate = false;
            var index = 0;
            while (index < args.Length)
            {
                switch (args[index].ToLower())
                {
                    case "-i":
                    {
                        if (index + 1 < args.Length)
                        {
                            inputFile = args[index + 1];
                            index++;
                        }

                        break;
                    }

                    case "-o":
                    {
                        if (index + 1 < args.Length)
                        {
                            outputFile = args[index + 1];
                            index++;
                        }

                        break;
                    }

                    case "-r":
                    {
                        shouldRotate = true;
                        break;
                    }

                    case "-c":
                    {
                        shouldClip = true;
                        break;
                    }
                }

                index++;
            }

            if (!IsValidPath(inputFile, true))
            {
                return;
            }

            if (!IsValidPath(outputFile, false))
            {
                return;
            }

            var port = int.Parse(ConfigurationManager.AppSettings["tcpPort"]);
            var channel = new TcpChannel(port);
            ChannelServices.RegisterChannel(channel, false);

            WriteInformationMessage("Processing...");
            try
            {
                RemotingConfiguration.RegisterWellKnownServiceType(
              typeof(DocumentProcessor),
              "ImageRecognizer",
              WellKnownObjectMode.Singleton);

                var processor = new DocumentProcessor();
                processor.ProcessDocument(inputFile, outputFile, shouldRotate, shouldClip);
            }
            finally
            {
                WriteInformationMessage("Done\n");
                ChannelServices.UnregisterChannel(channel);
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            string inputFile    = null;
            string outputFile   = null;
            var    shouldClip   = false;
            var    shouldRotate = false;
            var    index        = 0;

            while (index < args.Length)
            {
                switch (args[index].ToLower())
                {
                case "-i":
                {
                    if (index + 1 < args.Length)
                    {
                        inputFile = args[index + 1];
                        index++;
                    }

                    break;
                }

                case "-o":
                {
                    if (index + 1 < args.Length)
                    {
                        outputFile = args[index + 1];
                        index++;
                    }

                    break;
                }

                case "-r":
                {
                    shouldRotate = true;
                    break;
                }

                case "-c":
                {
                    shouldClip = true;
                    break;
                }
                }

                index++;
            }

            if (!IsValidPath(inputFile, true))
            {
                return;
            }

            if (!IsValidPath(outputFile, false))
            {
                return;
            }

            var port    = int.Parse(ConfigurationManager.AppSettings["tcpPort"]);
            var channel = new TcpChannel(port);

            ChannelServices.RegisterChannel(channel, false);

            WriteInformationMessage("Processing...");
            try
            {
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(DocumentProcessor),
                    "ImageRecognizer",
                    WellKnownObjectMode.Singleton);

                var processor = new DocumentProcessor();
                processor.ProcessDocument(inputFile, outputFile, shouldRotate, shouldClip);
            }
            finally
            {
                WriteInformationMessage("Done\n");
                ChannelServices.UnregisterChannel(channel);
            }
        }