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);
        }
Exemplo n.º 2
0
 private static bool IsRetryableMFilesLockError(Exception ex)
 {
     if (ex is COMException)
     {
         string errors = ex.ToString();
         if (errors.Contains("(0x800403F9)") ||
             errors.Contains("(0x80040454)") ||
             (errors.Contains("update conflicts with concurrent update") || errors.Contains("IBCODE=isc_no_dup")) ||
             (errors.Contains("lock conflict on no wait transaction") || errors.Contains("attempt to store duplicate value") && errors.Contains("IX_PV_")) ||
             (errors.IndexOf("(0x80040041)") != -1 ||
              RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 3960) ||
              (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 3961) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 1205)) ||
              (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 1203) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 1204) || (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 1221) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 1222)))) ||
             ((RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 2601) && errors.Contains("IX_PV_")) ||
              (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 40197) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 40501)) ||
              (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 40549) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 40613) || (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 64) || RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 233))) ||
              (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 258) ||
               RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 10053) ||
               (RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 10054) ||
                RetryingVaultConnection.IsMSSQLServerErrorCode(errors, 10060)) ||
               errors.Contains("SMux") && errors.Contains("xFFFFFFFF") && errors.Contains("SQLSTATE: 08S02"))) ||
             (errors.Contains("Communication link failure") || errors.Contains("Physical connection is not usable")))
         {
             return(true);
         }
     }
     return(false);
 }
 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 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}>...");
 }