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..."); }
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 static void UninstallVAE(MFilesServerApplication server, VaultOnServer vaultOnServer, RetryingVaultConnection vaultConnection, string applicationGuid) { if (!vaultConnection.DoWithReconnect(vault => TryUninstallCustomApplication(vault, applicationGuid))) { return; } Console.WriteLine("[INFO] Completed uninstallation..."); }
private void btn_Extract_Click(object sender, EventArgs e) { if (list_Vaults.SelectedIndex != -1) { var itemName = list_Vaults.SelectedItem.ToString(); VaultOnServer selectedVault = null; foreach (VaultOnServer item in _vaults) { if (item.Name == itemName) { selectedVault = item; break; } } try { ExtractResult exResult = null; LoggedInVaultHolder.LoggedInVault = selectedVault.LogIn(); DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string folderName = folderBrowserDialog1.SelectedPath; Cursor.Current = Cursors.WaitCursor; exResult = ApplicationHelper.ExtractVault(folderName, LoggedInVaultHolder.LoggedInVault); Cursor.Current = Cursors.Default; var sb = new StringBuilder(); sb.AppendLine("Succesfully Extracted!"); sb.AppendLine("Event Handlers: " + exResult.EventHandlersCount.ToString()); sb.AppendLine("State Actions: " + exResult.StateActionCount.ToString()); sb.AppendLine("State Triggers: " + exResult.TriggerCount.ToString()); sb.AppendLine("Conditions: " + exResult.ConditionCount.ToString()); sb.AppendLine("Automatic Numbering: " + exResult.NumberingCount.ToString()); sb.AppendLine("Calculated Values: " + exResult.CalculatedValuesCount.ToString()); sb.AppendLine("Validations: " + exResult.ValidationsCount.ToString()); sb.AppendLine("Applications: " + exResult.ApplicationsCount.ToString()); MessageBox.Show(sb.ToString(), "M-Files Code Extractor", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception Ex) { MessageBox.Show("Seçilen kütüphaneye bağlanılamadı;\n" + Ex.Message.Substring(0, Ex.Message.IndexOf("\r\n\r\n")), "M-Files Code Extractor", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Lütfen bir kütüphane seçiniz.", "M-Files Code Extractor", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Retrieves the vaults from the server. /// </summary> /// <param name="vaults">The vaults on the server.</param> /// <returns>true if the connection happened without exceptions, false otherwise.</returns> public bool TryGetOnlineVaults(out IEnumerable <VaultOnServer> vaults) { try { vaults = this.GetOnlineVaults().ToArray(); return(true); } catch { // HACK: Exception handling. vaults = new VaultOnServer[0]; return(false); } }
private static void ReinstallApplication(FileInfo appFile, MFilesServerApplication server, VaultOnServer vaultOnServer, RetryingVaultConnection vaultConnection, string applicationGuid) { Console.WriteLine("[INFO] Checking for previous installation of the application..."); if (vaultConnection.DoWithReconnect(vault => IsApplicationInstalled(vault, applicationGuid))) { Console.WriteLine("[INFO] Found previous installation of the application..."); Console.WriteLine("[INFO] Uninstalling the previous installation of the application..."); UninstallVAE(server, vaultOnServer, vaultConnection, applicationGuid); } Console.WriteLine("[INFO] Installing the application..."); vaultConnection.DoWithReconnect(vault => vault.CustomApplicationManagementOperations.InstallCustomApplication(appFile.FullName)); Console.WriteLine("[INFO] Completed installation of the application..."); Console.WriteLine($"[INFO] Restarting the vault <{vaultOnServer.Name}>..."); server.VaultManagementOperations.TakeVaultOffline(vaultOnServer.GUID, true); server.VaultManagementOperations.BringVaultOnline(vaultOnServer.GUID); Console.WriteLine($"[INFO] Completed restarting the vault <{vaultOnServer.Name}>..."); }
public RetryingVaultConnection(VaultOnServer vaultOnServer, Func <VaultOnServer, Vault> connectFunction) { this.vaultOnServer = vaultOnServer; this.connectFunction = connectFunction; }