protected void ConnectUsingCurrentSettings()
        {
            Console.WriteLine($"\n[INFO] Connecting to <{MFilesSettings.Server}> server...");
            bool isValidCredentials = TryConnect();

            if (!isValidCredentials)
            {
                Console.WriteLine($"[ERROR] Something wrong connecting to <{MFilesSettings.Server}> server...\n");
                return;
            }
            Console.WriteLine($"[INFO] Successfully connected to <{MFilesSettings.Server}> server...");

            Vaults = MFilesServerApp.GetOnlineVaults();
            VaultOnServer vaultOnServer    = null;
            bool          isUsingVaultGuid = !string.IsNullOrWhiteSpace(MFilesSettings.VaultGUID);
            string        vaultGuidName    = isUsingVaultGuid ? MFilesSettings.VaultGUID : MFilesSettings.VaultName;

            if (isUsingVaultGuid)
            {
                vaultOnServer            = Vaults.GetVaultByGUID(vaultGuidName);
                MFilesSettings.VaultName = vaultOnServer.Name;
            }
            else
            {
                vaultOnServer = Vaults.GetVaultByName(vaultGuidName);
            }

            Console.WriteLine($"[INFO] Connecting to <{MFilesSettings.VaultName}> vault...");
            Vault = vaultOnServer.LogIn();
            Console.WriteLine($"[INFO] Successfully connected to <{MFilesSettings.VaultName}> vault...");
        }
Exemple #2
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            // Using the Server mode to connect to the M-Files Server.
            app = new MFilesServerApplication();

            string host = hostTextBox.Text;

            // Using the default values for connecting to server (HTTP, 2266, current Windows user, etc.),
            // for details and options see:
            // https://www.m-files.com/api/documentation/latest/index.html#MFilesAPI~MFilesServerApplication.html
            conn = app.Connect(NetworkAddress: host);

            // Populate the combo box so that the user can choose which vault to use.
            VaultsOnServer vaults = app.GetOnlineVaults();

            foreach (VaultOnServer v in vaults)
            {
                vaultComboBox.Items.Add(new VaultComboBoxItem(v.Name, v.GUID));
            }
            vaultComboBox.Enabled = true;
            //       EnableButtons(true);

            // Must re-start the tool if need to connect to another server.
            hostTextBox.Enabled   = false;
            connectButton.Enabled = false;
        }
        private string GetVaultNames()
        {
            StringBuilder sb = new StringBuilder();

            Vaults = MFilesServerApp.GetOnlineVaults();
            for (int i = 1; i < Vaults.Count + 1; i++)
            {
                sb.AppendLine($"({i}) {Vaults[i].Name}");
            }

            return(sb?.Remove(sb.Length - 2, 1).ToString());
        }
Exemple #4
0
        private void populateVaults()
        {
            // Populate the combo box so that the user can choose which vault to use.
            VaultsOnServer vaults = app.GetOnlineVaults();

            foreach (VaultOnServer v in vaults)
            {
                vaultComboBox.Items.Add(new VaultComboBoxItem(v.Name, v.GUID));
            }
            vaultComboBox.Enabled = true;

            // Must re-start the tool if need to connect to another server.
            hostTextBox.Enabled   = false;
            connectButton.Enabled = false;
            EnableTopButtons(true);
        }
Exemple #5
0
 public OnlineVaultsForm(VaultsOnServer VaultsOnServer)
 {
     InitializeComponent();
     _vaults = VaultsOnServer;
 }