Beispiel #1
0
        /// <summary>
        /// Delete the Repository Item from file system and removing it from cache
        /// </summary>
        /// <param name="repositoryItem"></param>
        public void DeleteRepositoryItem(RepositoryItemBase repositoryItem)
        {
            RepositoryFolderBase itemFolder = GetItemRepositoryFolder(repositoryItem);

            if (itemFolder != null)
            {
                itemFolder.DeleteRepositoryItem(repositoryItem);
            }
        }
Beispiel #2
0
        public void MoveItem(RepositoryItemBase repositoryItem, string targetFolder)
        {
            RepositoryFolderBase RF       = GetItemRepositoryFolder(repositoryItem);
            RepositoryFolderBase targetRF = GetRepositoryFolderByPath(targetFolder);

            if (RF != null && targetRF != null)
            {
                RF.DeleteRepositoryItem(repositoryItem);
                targetRF.AddRepositoryItem(repositoryItem);
            }
            else
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to Move repository item because source or target folders failed to be identified for item '{0}' and target folder '{1}'.", repositoryItem.FilePath, targetFolder));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Move existing shared repository item to PrevVersion folder. And remove it from cache
        /// </summary>
        /// <param name="repositoryItem"></param>
        public void MoveSharedRepositoryItemToPrevVersion(RepositoryItemBase repositoryItem)
        {
            if (repositoryItem.FileName != null && File.Exists(repositoryItem.FileName))
            {
                RepositoryFolderBase repostitoryRootFolder = GetItemRepositoryRootFolder(repositoryItem);

                string targetPath = Path.Combine(repostitoryRootFolder.FolderFullPath, "PrevVersions");
                if (!Directory.Exists(targetPath))
                {
                    repostitoryRootFolder.PauseFileWatcher();
                    //We do not want to file watcher track PrevVersions Folder. So creating it explicity using Create directory
                    Directory.CreateDirectory(targetPath);
                    repostitoryRootFolder.ResumeFileWatcher();
                }

                string dts = DateTime.Now.ToString("yyyyMMddHHmm");

                string targetFileName = repositoryItem.ItemName + "." + dts + "." + repositoryItem.ObjFileExt + ".xml";

                targetFileName = General.RemoveInvalidCharsCombinePath(targetPath, targetFileName);

                if (targetFileName.Length > 255)
                {
                    targetFileName = targetFileName.Substring(0, 250) + new Random().Next(1000).ToString();
                }

                try
                {
                    if (File.Exists(targetFileName))
                    {
                        File.Delete(targetFileName);
                    }
                    //We want to delete the item and remove it from cache. So first we copy it to destination and then delete using Repository Folder.
                    File.Copy(repositoryItem.FileName, targetFileName);
                    RepositoryFolderBase repositoryFolder = GetItemRepositoryFolder(repositoryItem);
                    repositoryFolder.DeleteRepositoryItem(repositoryItem);
                }
                catch (IOException ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Shared Repository moving item to PrevVersion", ex);
                }
            }
        }