Exemplo n.º 1
0
        public void Rename(IFile file, string newName)
        {
            var callLog = Log.Call();

            try
            {
                var path = Path.Combine(_oqtServerPaths.FullContentPath(AdamContext.Site.ContentPath), file.Path);

                var currentFilePath = Path.Combine(path, file.FullName);
                if (TryToRenameFile(newName, currentFilePath, path))
                {
                    return;
                }

                var dnnFile = FileRepository.GetFile(file.AsOqt().SysId);
                dnnFile.Name = newName;
                FileRepository.UpdateFile(dnnFile);
                Log.Add($"VirtualFile {dnnFile.FileId} renamed to {dnnFile.Name}");

                callLog("ok");
            }
            catch (Exception e)
            {
                callLog($"Error:{e.Message}; {e.InnerException}");
            }
        }
Exemplo n.º 2
0
        public void Delete(IFile file)
        {
            var callLog = Log.Call();
            var dnnFile = FileRepository.GetFile(file.AsOqt().SysId);

            FileRepository.DeleteFile(dnnFile.FileId);
            callLog("ok");
        }
Exemplo n.º 3
0
        public void Rename(IFile file, string newName)
        {
            var callLog = Log.Call();

            try
            {
                var path = Path.Combine(_oqtServerPaths.FullContentPath(AdamContext.Site.ContentPath), file.Path);

                var currentFilePath = Path.Combine(path, file.FullName);
                if (!System.IO.File.Exists(currentFilePath))
                {
                    callLog($"Can't rename because source file do not exists {currentFilePath}");
                    return;
                }

                var newFilePath = Path.Combine(path, newName);
                if (!System.IO.File.Exists(newFilePath))
                {
                    callLog($"Can't rename because file with new name already exists {newFilePath}");
                    return;
                }

                System.IO.File.Move(currentFilePath, newFilePath);
                Log.Add($"File renamed {currentFilePath} to {newFilePath}");

                var dnnFile = FileRepository.GetFile(file.AsOqt().SysId);
                dnnFile.Name = newName;
                FileRepository.UpdateFile(dnnFile);
                Log.Add($"VirtualFile {dnnFile.FileId} renamed to {dnnFile.Name}");

                callLog("ok");
            }
            catch (Exception e)
            {
                callLog($"Error:{e.Message}; {e.InnerException}");
            }
        }