public static AppConfigurationModes DoStartUp()
        {
            var appModes = new AppConfigurationModes();
            appModes.StartupMode = AppStartUpMode.UserInterfaceMode;

            Console.Clear();
            Console.WriteLine(" ");
            Console.WriteLine(_gDisplay.BannerEqualChar);
            Console.WriteLine(_gDisplay.BannerEqualChar);
            var headr = _gDisplay.AppName;
            var lSpacer = _gDisplay.GetLeftSpacer(headr);
            Console.WriteLine(lSpacer + headr);
            Console.WriteLine(_gDisplay.BannerEqualChar);
            Console.WriteLine(_gDisplay.BannerEqualChar);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(" This Application will copy files and directories to a specific");
            Console.WriteLine(" directory tree, using parameters from an XML file in the");
            Console.WriteLine(" application directory.");
            Console.WriteLine(_gDisplay.BannerDashChar);
            Console.WriteLine(" Do you wish to continue? (Press Y to execute): ");
            Console.ForegroundColor = ConsoleColor.White;

            var key = Console.ReadKey(true);
            if(!(key.KeyChar=='Y') && !(key.KeyChar=='y') )
            {
                appModes.ExecutionMode = AppExecutionMode.AbortAndExit;

                return appModes;
            }

            Console.WriteLine(_gDisplay.BannerDashChar);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(" Do you wish to create a log file in the application directory for");
            Console.WriteLine(" for this copy operation? (Press L to create a Log file): ");
            Console.ForegroundColor = ConsoleColor.White;
            var key2 = Console.ReadKey(true);
            if(!(key2.KeyChar=='L') &&  !(key2.KeyChar=='l'))
            {
                appModes.ExecutionMode = AppExecutionMode.ExecuteWithoutLog;

                return appModes;
            }

            Console.Clear();
            Console.WriteLine("Initiating Copy Operation.....");

            appModes.ExecutionMode = AppExecutionMode.ExecuteWithLog;

            return appModes;
        }
        public LogAndDisplayController(AppConfigurationModes appModes)
        {
            CurrentApplicationMode = appModes;

            InitializeLogingOperations();
        }
Exemplo n.º 3
0
        private static AppConfigurationModes ProcessCommandLineArguments(string[] args)
        {
            var appModes = new AppConfigurationModes();

            if(args==null ||  args.Length < 1)
            {
                appModes.StartupMode = AppStartUpMode.UserInterfaceMode;

                return appModes;
            }

            appModes.StartupMode = AppStartUpMode.CommandLineBatchMode;

            if(args[0].Contains("?"))
            {
                appModes.ExecutionMode = AppExecutionMode.DisplayHelp;

                return appModes;
            }

            appModes.ExecutionMode = AppExecutionMode.AbortAndExit;
            appModes.ExecutionMode = AppExecutionMode.ExecuteWithoutLog;
            appModes.XmlFileMode = AppXmlMode.DefaultXmlFile;

            foreach (var s in args)
            {
                if(s.ToLower().Contains(@"/y"))
                {
                    appModes.ExecutionMode = AppExecutionMode.ExecuteWithoutLog;
                }

                if(s.ToLower().Contains(@"/l"))
                {
                    appModes.ExecutionMode = AppExecutionMode.ExecuteWithLog;
                }

                if (!s.ToLower().Contains(@"/f="))
                {
                    continue;
                }

                var xmlF = s.Remove(0, 3).Trim();

                if (string.IsNullOrEmpty(xmlF) || !File.Exists(xmlF))
                {
                    continue;
                }

                appModes.XmlFileMode = AppXmlMode.UserEnteredXmlFile;

                appModes.ExternalXmlFile = xmlF;
            }

            return appModes;
        }