本文整理汇总了C#中DotNetNuke.Services.FileSystem.FolderInfo类的典型用法代码示例。如果您正苦于以下问题:C# FolderInfo类的具体用法?C# FolderInfo怎么用?C# FolderInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FolderInfo类属于DotNetNuke.Services.FileSystem命名空间,在下文中一共展示了FolderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFolder
public int AddFolder(FolderInfo folder)
{
var tmpFolder = FolderManager.Instance.GetFolder(folder.PortalID, folder.FolderPath);
if (tmpFolder != null && folder.FolderID == Null.NullInteger)
{
folder.FolderID = tmpFolder.FolderID;
}
if (folder.FolderID == Null.NullInteger)
{
folder = (FolderInfo)FolderManager.Instance.AddFolder(FolderMappingController.Instance.GetFolderMapping(folder.PortalID, folder.FolderMappingID), folder.FolderPath);
}
else
{
FolderManager.Instance.UpdateFolder(folder);
}
return folder.FolderID;
}
示例2: RemoveOrphanedFiles
private static void RemoveOrphanedFiles( FolderInfo folder, int PortalId )
{
FileController objFileController = new FileController();
if( folder.StorageLocation != (int)FolderController.StorageLocationTypes.DatabaseSecure )
{
foreach( Services.FileSystem.FileInfo objFile in GetFilesByFolder( PortalId, folder.FolderID ) )
{
RemoveOrphanedFile( objFile, PortalId );
}
}
}
示例3: CollectData
public void CollectData(FolderInfo folderInfo, int startIndex, int portalId)
{
ArrayList filesWorking = FileSystemUtils.GetFilesByFolder(portalId, folderInfo.FolderID);
if (filesWorking != null)
{
foreach (DotNetNuke.Services.FileSystem.FileInfo fileInfo in filesWorking)
{
ParseCSV(fileInfo, startIndex);
}
}
ImportData(this.portalId);
}
示例4: UpdateFolder
public void UpdateFolder(FolderInfo objFolderInfo)
{
FolderManager.Instance.UpdateFolder(objFolderInfo);
}
示例5: AddAllUserReadPermission
public static void AddAllUserReadPermission(FolderInfo folder, PermissionInfo permission)
{
FolderManager.Instance.AddAllUserReadPermission(folder, permission);
}
示例6: RenderFolder
/// <summary>
/// Render all Directories and sub directories recursive
/// </summary>
/// <param name="folderInfo">The folder Info.</param>
/// <returns>
/// TreeNode List
/// </returns>
private RadTreeNode RenderFolder(FolderInfo folderInfo)
{
if (!FolderPermissionController.CanViewFolder(folderInfo))
{
return null;
}
RadTreeNode tnFolder = new RadTreeNode
{
Text = folderInfo.FolderName,
Value = folderInfo.PhysicalPath,
ImageUrl = "Images/folder.gif",
ExpandedImageUrl = "Images/folderOpen.gif",
ToolTip = folderInfo.FolderID.ToString()
};
if (folderInfo.StorageLocation.Equals((int)FolderController.StorageLocationTypes.SecureFileSystem))
{
tnFolder.ImageUrl = "Images/folderLocked.gif";
tnFolder.ExpandedImageUrl = "Images/folderOpenLocked.gif";
}
else if (folderInfo.StorageLocation.Equals((int)FolderController.StorageLocationTypes.DatabaseSecure))
{
tnFolder.ImageUrl = "Images/folderdb.gif";
tnFolder.ExpandedImageUrl = "Images/folderdb.gif";
}
/*ArrayList folders = FileSystemUtils.GetFoldersByParentFolder(
this._portalSettings.PortalId, folderInfo.FolderPath);*/
var folders = FolderManager.Instance.GetFolders(folderInfo).ToList();
if (folders.Any())
{
foreach (RadTreeNode node in
folders.Cast<FolderInfo>().Select(this.RenderFolder).Where(node => node != null))
{
switch (this.GetStorageLocationType(Convert.ToInt32(node.ToolTip)))
{
case FolderController.StorageLocationTypes.SecureFileSystem:
{
node.ImageUrl = "Images/folderLocked.gif";
node.ExpandedImageUrl = "Images/folderOpenLocked.gif";
}
break;
case FolderController.StorageLocationTypes.DatabaseSecure:
{
node.ImageUrl = "Images/folderdb.gif";
node.ExpandedImageUrl = "Images/folderdb.gif";
}
break;
}
tnFolder.Nodes.Add(node);
}
}
return tnFolder;
}
示例7: CanViewFolder
/// <summary>
/// Returns a flag indicating whether the current user can view a folder or file
/// </summary>
/// <param name="folder">The page</param>
/// <returns>A flag indicating whether the user has permission</returns>
public virtual bool CanViewFolder(FolderInfo folder)
{
return HasFolderPermission(folder, ViewFolderPermissionKey);
}
示例8: OverwriteFolder_Adds_Folder_To_FoldersToDelete_If_FolderMapping_Is_Editable
public void OverwriteFolder_Adds_Folder_To_FoldersToDelete_If_FolderMapping_Is_Editable()
{
var fileManager = new Mock<IFileManager>();
FileManager.RegisterInstance(fileManager.Object);
_folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId);
_folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
var files = new List<IFileInfo>();
_mockFolderManager.Setup(mfm => mfm.GetFiles(_folderInfo.Object, It.IsAny<bool>(), It.IsAny<bool>())).Returns(files);
var destinationFolder = new FolderInfo();
_mockFolderManager.Setup(mfm => mfm.DeleteFolder(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath));
var folderMapping = new FolderMappingInfo();
_mockFolderManager.Setup(mfm => mfm.GetFolderMapping(It.IsAny<Dictionary<int, FolderMappingInfo>>(), Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFolderManager.Setup(mfm => mfm.IsFolderMappingEditable(folderMapping)).Returns(true);
var foldersToDelete = new SortedList<string, IFolderInfo>();
_mockFolderManager.Object.OverwriteFolder(_folderInfo.Object, destinationFolder, new Dictionary<int, FolderMappingInfo>(), foldersToDelete);
Assert.AreEqual(1, foldersToDelete.Count);
}
示例9: OverwriteFolder_Deletes_Source_Folder_In_Database
public void OverwriteFolder_Deletes_Source_Folder_In_Database()
{
var fileManager = new Mock<IFileManager>();
FileManager.RegisterInstance(fileManager.Object);
_folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId);
_folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
var files = new List<IFileInfo>();
_mockFolderManager.Setup(mfm => mfm.GetFiles(_folderInfo.Object, It.IsAny<bool>(), It.IsAny<bool>())).Returns(files);
var destinationFolder = new FolderInfo();
_mockFolderManager.Setup(mfm => mfm.DeleteFolder(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath)).Verifiable();
var folderMapping = new FolderMappingInfo();
_mockFolderManager.Setup(mfm => mfm.GetFolderMapping(It.IsAny<Dictionary<int, FolderMappingInfo>>(), Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFolderManager.Setup(mfm => mfm.IsFolderMappingEditable(folderMapping)).Returns(false);
_mockFolderManager.Object.OverwriteFolder(_folderInfo.Object, destinationFolder, new Dictionary<int, FolderMappingInfo>(), new SortedList<string, IFolderInfo>());
_mockFolderManager.Verify();
}
示例10: OverwriteFolder_Calls_MoveFile_For_Each_File_In_Source_Folder
public void OverwriteFolder_Calls_MoveFile_For_Each_File_In_Source_Folder()
{
_folderInfo.Setup(fi => fi.PortalID).Returns(Constants.CONTENT_ValidPortalId);
_folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
var destinationFolder = new FolderInfo();
var file1 = new FileInfo();
var file2 = new FileInfo();
var file3 = new FileInfo();
var files = new List<IFileInfo> { file1, file2, file3 };
_mockFolderManager.Setup(mfm => mfm.GetFiles(_folderInfo.Object, It.IsAny<bool>(), It.IsAny<bool>())).Returns(files);
var fileManager = new Mock<IFileManager>();
FileManager.RegisterInstance(fileManager.Object);
fileManager.Setup(fm => fm.MoveFile(It.IsAny<IFileInfo>(), destinationFolder));
_mockFolderManager.Setup(mfm => mfm.DeleteFolder(Constants.CONTENT_ValidPortalId, Constants.FOLDER_ValidFolderRelativePath));
var folderMapping = new FolderMappingInfo();
_mockFolderManager.Setup(mfm => mfm.GetFolderMapping(It.IsAny<Dictionary<int, FolderMappingInfo>>(), Constants.FOLDER_ValidFolderMappingID)).Returns(folderMapping);
_mockFolderManager.Setup(mfm => mfm.IsFolderMappingEditable(folderMapping)).Returns(false);
_mockFolderManager.Object.OverwriteFolder(_folderInfo.Object, destinationFolder, new Dictionary<int, FolderMappingInfo>(), new SortedList<string, IFolderInfo>());
fileManager.Verify(fm => fm.MoveFile(It.IsAny<IFileInfo>(), destinationFolder), Times.Exactly(3));
}
示例11: MoveFolder_Throws_When_Move_Operation_Is_Not_Valid
public void MoveFolder_Throws_When_Move_Operation_Is_Not_Valid()
{
_folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath);
_folderInfo.Setup(fi => fi.FolderMappingID).Returns(Constants.FOLDER_ValidFolderMappingID);
IFolderInfo destinationFolder = new FolderInfo();
destinationFolder.FolderPath = Constants.FOLDER_OtherValidFolderRelativePath;
destinationFolder.FolderMappingID = Constants.FOLDER_ValidFolderMappingID;
_pathUtils.Setup(pu => pu.FormatFolderPath(Constants.FOLDER_OtherValidFolderRelativePath)).Returns(Constants.FOLDER_OtherValidFolderRelativePath);
_mockFolderManager.Setup(mfm => mfm.FolderExists(It.IsAny<int>(), It.IsAny<string>())).Returns(false);
_mockFolderManager.Setup(mfm => mfm.CanMoveBetweenFolderMappings(It.IsAny<FolderMappingInfo>(), It.IsAny<FolderMappingInfo>())).Returns(true);
_mockFolderManager.Setup(mfm => mfm.IsMoveOperationValid(_folderInfo.Object, destinationFolder, It.IsAny<string>())).Returns(false);
_mockFolderManager.Object.MoveFolder(_folderInfo.Object, destinationFolder);
}
示例12: MoveFolder_Returns_The_Same_Folder_If_The_Paths_Are_The_Same
public void MoveFolder_Returns_The_Same_Folder_If_The_Paths_Are_The_Same()
{
_folderInfo.Setup(fi => fi.FolderPath).Returns(Constants.FOLDER_ValidFolderRelativePath);
IFolderInfo destinationFolder = new FolderInfo();
destinationFolder.FolderPath = Constants.FOLDER_ValidFolderRelativePath;
_pathUtils.Setup(pu => pu.FormatFolderPath(Constants.FOLDER_ValidFolderRelativePath)).Returns(Constants.FOLDER_ValidFolderRelativePath);
var movedFolder = _folderManager.MoveFolder(_folderInfo.Object, destinationFolder);
Assert.AreEqual(_folderInfo.Object, movedFolder);
}
示例13: ParseFiles
/// <summary>
/// Processes all Files from the template
/// </summary>
/// <param name="nodeFiles">Template file node for the Files</param>
/// <param name="PortalId">PortalId of the new portal</param>
/// <history>
/// [cnurse] 11/09/2004 Created
/// </history>
private void ParseFiles( XmlNodeList nodeFiles, int PortalId, FolderInfo objFolder )
{
int FileId = 0;
FileController objController = new FileController();
FileInfo objInfo = null;
string fileName = null;
foreach( XmlNode node in nodeFiles )
{
fileName = XmlUtils.GetNodeValue( node, "filename", "" );
//First check if the file exists
objInfo = objController.GetFile( fileName, PortalId, objFolder.FolderID );
if( objInfo == null )
{
objInfo = new FileInfo();
objInfo.PortalId = PortalId;
objInfo.FileName = fileName;
objInfo.Extension = XmlUtils.GetNodeValue( node, "extension", "" );
objInfo.Size = XmlUtils.GetNodeValueInt( node, "size", 0 );
objInfo.Width = XmlUtils.GetNodeValueInt( node, "width", 0 );
objInfo.Height = XmlUtils.GetNodeValueInt( node, "height", 0 );
objInfo.ContentType = XmlUtils.GetNodeValue( node, "contenttype", "" );
objInfo.FolderId = objFolder.FolderID;
objInfo.Folder = objFolder.FolderPath;
//Save new File
FileId = objController.AddFile( objInfo );
}
else
{
//Get Id from File
FileId = objInfo.FileId;
}
}
}
示例14: GetFiles
/// <summary>
/// Get all Files and Put them in a DataTable for the GridView
/// </summary>
/// <param name="currentFolderInfo">The current folder info.</param>
/// <returns>
/// The File Table
/// </returns>
public DataTable GetFiles(FolderInfo currentFolderInfo)
{
DataTable filesTable = new DataTable();
filesTable.Columns.Add(new DataColumn("FileName", typeof(string)));
filesTable.Columns.Add(new DataColumn("PictureURL", typeof(string)));
filesTable.Columns.Add(new DataColumn("Info", typeof(string)));
filesTable.Columns.Add(new DataColumn("FileId", typeof(int)));
HttpRequest httpRequest = HttpContext.Current.Request;
var type = "Link";
if (!string.IsNullOrEmpty(httpRequest.QueryString["Type"]))
{
type = httpRequest.QueryString["Type"];
}
// Get Folder Info Secure?
var isSecure =
this.GetStorageLocationType(currentFolderInfo.FolderID).Equals(
FolderController.StorageLocationTypes.SecureFileSystem);
var isDatabaseSecure =
this.GetStorageLocationType(currentFolderInfo.FolderID).Equals(
FolderController.StorageLocationTypes.DatabaseSecure);
var filesArrayList = FileSystemUtils.GetFilesByFolder(
this._portalSettings.PortalId, currentFolderInfo.FolderID);
var files = filesArrayList.OfType<DotNetNuke.Services.FileSystem.FileInfo>().ToList();
if (this.SortFilesDescending)
{
Utility.SortDescending(files, item => item.FileName);
}
foreach (DotNetNuke.Services.FileSystem.FileInfo fileItem in files)
{
// Check if File Exists
/*if (!File.Exists(string.Format("{0}{1}", fileItem.PhysicalPath, isSecure ? ".resources" : string.Empty)))
{
continue;
}*/
var item = fileItem;
var name = fileItem.FileName;
var extension = fileItem.Extension;
if (isSecure)
{
name = GetFileNameCleaned(name);
extension = Path.GetExtension(name);
}
switch (type)
{
case "Image":
{
// Show Images only
foreach (DataRow dr in
from sAllowExt in this.allowedImageExt
where name.ToLower().EndsWith(sAllowExt)
select filesTable.NewRow())
{
if (isSecure || isDatabaseSecure)
{
var link = string.Format("fileID={0}", fileItem.FileId);
dr["PictureURL"] = Globals.LinkClick(link, int.Parse(this.request.QueryString["tabid"]), Null.NullInteger);
}
else
{
dr["PictureURL"] = MapUrl(fileItem.PhysicalPath);
}
dr["FileName"] = name;
dr["FileId"] = item.FileId;
dr["Info"] =
string.Format(
"<span class=\"FileName\">{0}</span><br /><span class=\"FileInfo\">Size: {1}</span>",
name,
fileItem.Size);
filesTable.Rows.Add(dr);
}
}
break;
case "Flash":
{
//.........这里部分代码省略.........
示例15: CanDeleteFolder
/// <summary>
/// Returns a flag indicating whether the current user can delete a folder or file
/// </summary>
/// <param name="folder">The page</param>
/// <returns>A flag indicating whether the user has permission</returns>
public virtual bool CanDeleteFolder(FolderInfo folder)
{
return HasFolderPermission(folder, DeleteFolderPermissionKey);
}