Ejemplo n.º 1
0
        /// <summary>
        /// Entry point for embedding the library
        /// Does some in-before checks against the given data
        /// </summary>
        public static IActionResult DoAction(string[] args)
        {
            var message = AppConfig.Setup();

            if (message != null)
            {
                CC.Resolve <IInputOutput>().Write(message);
            }

            var commandLineHelper = CC.Resolve <ICommandLineHelper>();

            commandLineHelper.CheckAmountOfParameters(args);

            var extractedArguments = commandLineHelper.ExtractArguments(args);

            commandLineHelper.CheckForPinOrResume(extractedArguments.Arguments);

            if (extractedArguments.Action == ActionPersist.ActionName)
            {
                var transactionService = CC.Resolve <ITransactionService>();
                return(transactionService.DoPersistence(extractedArguments.Arguments));
            }

            // 'old' FinCMD code without any special workflow
            var finTsService = CC.Resolve <IFinTsService>();

            return(finTsService.DoAction(extractedArguments.Action, extractedArguments.Arguments));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main entry point for the command-line application.
        /// </summary>
        /// <return>Return Code: -1 for an exception, otherwise the internal status code</return>
        public static int Main(string[] args)
        {
            var message = AppConfig.Setup();

            if (message != null)
            {
                CC.Resolve <IInputOutput>().Write(message);
            }

            int returnCode        = -1;
            var commandLineHelper = CC.Resolve <ICommandLineHelper>();

            try
            {
                IActionResult result = DoAction(args);
                returnCode = result.OrderStatusCode;
            }
            catch (ArgumentException ex)
            {
                commandLineHelper.DisplayShortException(ex);
                commandLineHelper.ShowUsage();
            }
            catch (ActionException ex)
            {
                commandLineHelper.DisplayActionException(ex);
            }
            catch (Exception ex)
            {
                commandLineHelper.DisplayException(ex);
            }

            return(returnCode);
        }