private void InputServerName()
        {
            bool                  isSelectedServerOptionValid = false;
            MFilesSettings        selectedMFilesSettings      = null;
            List <MFilesSettings> adminServerConnPropsList    = GetAdminServerNames(new MFilesServerApplication());
            int numLabel = 1;

            while (!isSelectedServerOptionValid)
            {
                Console.WriteLine("Select M-Files server:");
                adminServerConnPropsList.ForEach(serverConnProps => Console.WriteLine($"({numLabel++}) {serverConnProps.Alias}"));
                string selectedServerOption = Console.ReadLine();

                bool isSelectedServerOptionInt = int.TryParse(selectedServerOption, out int selectedServerOptionInInt);
                isSelectedServerOptionValid = isSelectedServerOptionInt && selectedServerOptionInInt <= adminServerConnPropsList.Count;

                if (isSelectedServerOptionValid)
                {
                    selectedMFilesSettings = adminServerConnPropsList[selectedServerOptionInInt - 1];
                    MFilesSettings.Server  = selectedMFilesSettings.Server;
                    MFilesSettings.Alias   = selectedMFilesSettings.Alias;
                    Console.WriteLine($"[INFO] Selected M-Files Server:  {MFilesSettings.Alias} ({MFilesSettings.Server})\n");
                }
                else
                {
                    Console.WriteLine($"[ERROR] Selected server <{selectedServerOption}> is invalid. Please try again...\n");
                    numLabel = 1;
                }
            }
        }
        public MFilesSettings GetMFilesSettings()
        {
            MFilesSettings mfSettings = new MFilesSettings()
            {
                MFDevToolCommand = MFDevelopmentKitCommand.Deploy
            };

            if (!IsEmpty())
            {
                mfSettings = new MFilesSettings()
                {
                    ProjectName        = _ProjectName
                    , Server           = _ServerName
                    , Port             = _Port
                    , VaultName        = _VaultName
                    , VaultGUID        = _VaultGUID
                    , AuthType         = (MFAuthType)Int32.Parse(_AuthType)
                    , Domain           = _Domain
                    , Username         = _UserName
                    , Password         = _Password
                    , MFDevToolCommand = MFDevelopmentKitCommand.Deploy
                    , SilentExit       = _SilentExit
                };
            }

            return(mfSettings);
        }
        public override void Run(string[] args)
        {
            Console.WriteLine("\n+-----------------------------------------+");
            Console.WriteLine("| Application Development Kit for M-Files |");
            Console.WriteLine("+-----------------------------------------+\n");
            MFilesSettings = new MFilesSettings();
            MFilesSettings.ReadSettingsFile();
            MFilesSettings.Display();

            InputCommand();

            switch (MFilesSettings.MFDevToolCommand)
            {
            case MFDevelopmentKitCommand.Update:
            case MFDevelopmentKitCommand.Deploy:
                if (!MFilesSettings.HasSettingsXmlFile)
                {
                    Console.WriteLine("[INFO] No existing M-Files settings file...\n");
                    PromptUserForMFilesettings();
                    MFilesSettings.SaveToXmlFile();
                }
                else
                {
                    Console.WriteLine("[INFO] M-Files settings file exists...\n");
                    ConnectUsingCurrentSettings();
                }
                break;

            case MFDevelopmentKitCommand.New:             // New command
                PromptUserForMFilesettings();
                MFilesSettings.SaveToXmlFile();
                break;
            }
        }
        public MFilesSettings GetMFilesSettings()
        {
            MFilesSettings mfSettings = new MFilesSettings()
            {
                MFDevToolCommand = MFDevelopmentKitCommand.New
            };

            if (!IsEmpty())
            {
                mfSettings = new MFilesSettings()
                {
                    ProjectName        = _ProjectName
                    , Server           = _ServerName
                    , Port             = _Port
                    , VaultName        = _VaultName
                    , VaultGUID        = _VaultGUID
                    , AuthType         = (MFAuthType)Int32.Parse(_AuthType)
                    , Domain           = _Domain
                    , Username         = _UserName
                    , Password         = _Password
                    , MFDevToolCommand = MFDevelopmentKitCommand.New
                };
            }

            return(mfSettings);

            //AbstractMFDeveloperTool devTool = new CLIDeveloperTool();
            //devTool.MFilesSettings = mfilesSettings;
            //Api api = new Api(devTool);
            //AbstractionLayerGenerator alGenerator = new AbstractionLayerGenerator() { Api = api };
            //alGenerator.Generate();
        }
        public override void Run(string[] args)
        {
            CommandLineOptions commandLineOpts = CommandLineOptions.Parse(args);

            if (commandLineOpts?.Command == null)
            {
                return;
            }

            // Getting current m-files settings from xml file
            MFilesSettings = new MFilesSettings();
            MFilesSettings.ReadSettingsFile();

            // Set m-files settings from command
            MFilesSettings cliMfSettings = commandLineOpts.Command.GetMFilesSettings();

            cliMfSettings.Validate();

            if (cliMfSettings.IsValidSettings)
            {
                switch (cliMfSettings.MFDevToolCommand)
                {
                case MFDevelopmentKitCommand.Update:
                case MFDevelopmentKitCommand.Deploy:
                    if (!MFilesSettings.HasSettingsXmlFile)
                    {
                        Console.WriteLine("[INFO] No existing M-Files settings file...\n");
                        MFilesSettings = cliMfSettings;
                        MFilesSettings.SaveToXmlFile();
                    }
                    else
                    {
                        Console.WriteLine("[INFO] M-Files settings file exists...\n");
                        ConnectUsingCurrentSettings();
                    }
                    break;

                default:                 // New command
                    MFilesSettings = cliMfSettings;
                    MFilesSettings.SaveToXmlFile();
                    ConnectUsingCurrentSettings();
                    break;
                }
            }
            else
            {
                MFilesSettings.MFDevToolCommand = cliMfSettings.MFDevToolCommand;
                switch (cliMfSettings.MFDevToolCommand)
                {
                case MFDevelopmentKitCommand.Update:
                case MFDevelopmentKitCommand.Deploy:
                    Console.WriteLine("[WARN] M-Files settings from cli is lacking...");
                    Console.WriteLine("[INFO] M-Files settings file exists...\n");
                    ConnectUsingCurrentSettings();
                    break;

                default:                 // New command
                    PromptUserForMFilesettings();
                    MFilesSettings.SaveToXmlFile();
                    break;
                }
            }
        }
 public MFVaultApplicationInstaller(MFilesSettings mfilesSettings)
 {
     // Go through command prompt if M-Files settings option is empty
     //Initialize();
     MFilesSettings = mfilesSettings;
 }
예제 #7
0
 public Api(AbstractMFDevelopmentKit developmentTool)
 {
     DevelopertTool = developmentTool;
     MFilesSettings = DevelopertTool.MFilesSettings;
     Vaults         = DevelopertTool.Vaults;
 }