Beispiel #1
0
        public override string CopyFile(string path, string newPath)
        {
            try
            {
                string virtualPathAndFile    = FileSystemValidation.ToVirtualPath(path);
                string virtualNewPathAndFile = FileSystemValidation.ToVirtualPath(newPath);

                string returnValue = DNNValidator.OnCopyFile(virtualPathAndFile, virtualNewPathAndFile);
                if (!(string.IsNullOrEmpty(returnValue)))
                {
                    return(returnValue);
                }

                //Returns errors or empty string when successful (ie: NewFileAlreadyExists)
                returnValue = TelerikContent.CopyFile(virtualPathAndFile, virtualNewPathAndFile);

                if (string.IsNullOrEmpty(returnValue))
                {
                    string     virtualNewPath = FileSystemValidation.RemoveFileName(virtualNewPathAndFile);
                    FolderInfo dnnFolder      = DNNValidator.GetUserFolder(virtualNewPath);
                    var        dnnFileInfo    = new Services.FileSystem.FileInfo();
                    FillFileInfo(virtualNewPathAndFile, ref dnnFileInfo);

                    DNNFileCtrl.AddFile(PortalSettings.PortalId, dnnFileInfo.FileName, dnnFileInfo.Extension, dnnFileInfo.Size, dnnFileInfo.Width, dnnFileInfo.Height, dnnFileInfo.ContentType, dnnFolder.FolderPath, dnnFolder.FolderID, true);
                }

                return(returnValue);
            }
            catch (Exception ex)
            {
                return(DNNValidator.LogUnknownError(ex, path, newPath));
            }
        }
Beispiel #2
0
        public override string StoreBitmap(System.Drawing.Bitmap bitmap, string url, System.Drawing.Imaging.ImageFormat format)
        {
            try
            {
                //base calls CheckWritePermissions method
                string virtualPathAndFile = FileSystemValidation.ToVirtualPath(url);
                string virtualPath        = FileSystemValidation.RemoveFileName(virtualPathAndFile);
                string returnValue        = DNNValidator.OnCreateFile(virtualPathAndFile, 0);
                if (!(string.IsNullOrEmpty(returnValue)))
                {
                    return(returnValue);
                }

                returnValue = TelerikContent.StoreBitmap(bitmap, virtualPathAndFile, format);

                var dnnFileInfo = new Services.FileSystem.FileInfo();
                FillFileInfo(virtualPathAndFile, ref dnnFileInfo);

                //check again with real contentLength
                string errMsg = DNNValidator.OnCreateFile(virtualPathAndFile, dnnFileInfo.Size);
                if (!(string.IsNullOrEmpty(errMsg)))
                {
                    TelerikContent.DeleteFile(virtualPathAndFile);
                    return(errMsg);
                }

                FolderInfo dnnFolder = DNNValidator.GetUserFolder(virtualPath);
                Services.FileSystem.FileInfo dnnFile = DNNFileCtrl.GetFile(dnnFileInfo.FileName, PortalSettings.PortalId, dnnFolder.FolderID);

                if (dnnFile != null)
                {
                    DNNFileCtrl.UpdateFile(dnnFile.FileId, dnnFileInfo.FileName, dnnFileInfo.Extension, dnnFileInfo.Size, bitmap.Width, bitmap.Height, dnnFileInfo.ContentType, dnnFolder.FolderPath, dnnFolder.FolderID);
                }
                else
                {
                    DNNFileCtrl.AddFile(PortalSettings.PortalId, dnnFileInfo.FileName, dnnFileInfo.Extension, dnnFileInfo.Size, bitmap.Width, bitmap.Height, dnnFileInfo.ContentType, dnnFolder.FolderPath, dnnFolder.FolderID, true);
                }

                return(returnValue);
            }
            catch (Exception ex)
            {
                return(DNNValidator.LogUnknownError(ex, url));
            }
        }