private void ConnectAndReinstall(string applicationGuid, FileInfo applicationPackageFile) { MFilesServerApplication server = new MFilesServerApplication(); Console.WriteLine($"[INFO] Connecting to <{MFilesSettings.Server}>..."); server.Connect(MFilesSettings.AuthType, MFilesSettings.Username, MFilesSettings.Password, MFilesSettings.Domain, null, MFilesSettings.Server, null, "", true); Console.WriteLine($"[INFO] Successully connected to <{MFilesSettings.Server}>..."); Vaults = server.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 <{VaultOnServer.Name}>..."); RetryingVaultConnection vaultConnection = new RetryingVaultConnection(VaultOnServer, vos => vos.LogIn()); ReinstallApplication(applicationPackageFile, server, VaultOnServer, vaultConnection, applicationGuid); }
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 static VaultOnServer GetVaultOnServer(MFilesServerApplication server, string vaultName = null) { try { return(server.GetOnlineVaults().GetVaultByName(vaultName)); } catch (Exception ex) { Console.WriteLine("[ERROR] Problem connecting to the vault: " + vaultName + "\n" + ex.Message); } return(null); }
/// <summary> /// /// </summary> /// <param name="host"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="port"></param> /// <param name="authType"></param> /// <returns>[GUID, NAME]</returns> public static Dictionary <string, string> GetVaults(string host, string username, string password, string port = "2266", MFAuthType authType = MFAuthType.MFAuthTypeSpecificWindowsUser) { var serverApp = new MFilesServerApplication(); var connectRes = serverApp.Connect(authType, username, password, "", "ncacn_ip_tcp", host, port); if (connectRes == MFServerConnection.MFServerConnectionAnonymous) { return(null); } return(serverApp.GetOnlineVaults().Cast <VaultOnServer>().ToDictionary(c => c.GUID, c => c.Name)); }
public Form1() { InitializeComponent(); app = new MFilesServerApplication(); var conn = app.Connect(MFAuthType.MFAuthTypeSpecificMFilesUser, "admin", "111111"); var vaults = app.GetOnlineVaults(); foreach (VaultOnServer vaultOnServer in vaults) { comboBox1.Items.Add(vaultOnServer.GUID + vaultOnServer.Name); } }
/// <summary> /// Retrieves the vaults from the server. /// </summary> /// <remarks>Exceptions during connection will be thrown.</remarks> public IEnumerable <VaultOnServer> GetOnlineVaults() { // Attempt to connect to the vault using the extension method. var serverApplication = new MFilesServerApplication(); if (serverApplication.Connect(this) == MFServerConnection.MFServerConnectionAuthenticated) { foreach (var vault in serverApplication.GetOnlineVaults().Cast <VaultOnServer>()) { yield return(vault); } } }
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); }
public static string[] GetOnlineVaults() { //Connect With M-Files Account serverApp.Connect(MFAuthType.MFAuthTypeSpecificMFilesUser, TestConstants.Username, TestConstants.Password, "", "ncacn_ip_tcp", "localhost", "2266"); //Get Online Vaults var onlineVaults = serverApp.GetOnlineVaults(); //Create Array var vaults = new string[onlineVaults.Count]; //M-Files API Does Not USE 0 Indexes for (int i = 1; i <= onlineVaults.Count; i++) { vaults[i - 1] = onlineVaults[i].Name; } return(vaults); }
private void btn_Connect_Click(object sender, EventArgs e) { if (txt_Password.Text.Trim() == "" || txt_ServerAddress.Text.Trim() == "" || txt_Password.Text.Trim() == "" && userTypeList.SelectedIndex != -1) { MessageBox.Show("Lütfen tüm alanları doldurunuz.", "M-Files Code Extractor", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var userType = userTypeList.SelectedItem as UserType; try { if (userType.Id == 1) { Cursor.Current = Cursors.WaitCursor; serverApp.Connect(MFAuthType.MFAuthTypeSpecificWindowsUser, txt_Username.Text, txt_Password.Text, "", "ncacn_ip_tcp", txt_ServerAddress.Text); } else { Cursor.Current = Cursors.WaitCursor; serverApp.Connect(MFAuthType.MFAuthTypeSpecificMFilesUser, txt_Username.Text, txt_Password.Text, "", "ncacn_ip_tcp", txt_ServerAddress.Text); } } catch (Exception) { MessageBox.Show("Sunucuya bağlanılamadı.", "M-Files Code Extractor", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; return; } //Get Online Vaults var onlineVaults = serverApp.GetOnlineVaults(); //Pop The Vaults Form var oForm = new OnlineVaultsForm(onlineVaults); oForm.ShowDialog(); }