Пример #1
0
        /// <summary>
        /// Undo checkout on the specified file.
        /// </summary>
        /// <exception>Exception</exception>
        private void UndoCheckout(string fileName)
        {
            string normalizedPath = RepositoryPath.NormalizeFolder(fileName);

            if (IsVaultFolder(normalizedPath))
            {
                VaultClientFolder vaultClientFolder = ClientInstance.TreeCache.Repository.Root.FindFolderRecursive(normalizedPath);

                if (!String.IsNullOrEmpty(WorkingFolder))
                {
                    ClientInstance.TreeCache.SetWorkingFolder(vaultClientFolder.FullPath, WorkingFolder);
                }

                ClientInstance.UndoCheckOut(vaultClientFolder, true, LocalCopyType.Replace);
                Log.LogMessage(MessageImportance.Normal, string.Format(Properties.Resources.VaultUndoCheckoutSuccessful, vaultClientFolder.Name));
            }

            if (IsVaultFile(normalizedPath))
            {
                VaultClientFile vaultClientFile = ClientInstance.TreeCache.Repository.Root.FindFileRecursive(normalizedPath);

                if (!String.IsNullOrEmpty(WorkingFolder))
                {
                    ClientInstance.TreeCache.SetWorkingFolder(vaultClientFile.Parent.FullPath, WorkingFolder);
                }

                ClientInstance.UndoCheckOut(vaultClientFile, LocalCopyType.Replace);
                Log.LogMessage(MessageImportance.Normal, string.Format(Properties.Resources.VaultUndoCheckoutSuccessful, vaultClientFile.Name));
            }

            if (IsVaultFolder(normalizedPath) == false && IsVaultFile(normalizedPath) == false)
            {
                throw new Exception(string.Format(Properties.Resources.VaultResourceNotFound, normalizedPath));
            }
        }