本文整理汇总了C#中DotNetNuke.Entities.Portals.PortalController.HasSpaceAvailable方法的典型用法代码示例。如果您正苦于以下问题:C# PortalController.HasSpaceAvailable方法的具体用法?C# PortalController.HasSpaceAvailable怎么用?C# PortalController.HasSpaceAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Portals.PortalController
的用法示例。
在下文中一共展示了PortalController.HasSpaceAvailable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportModule
private string ExportModule(int moduleID, string fileName, IFolderInfo folder)
{
var strMessage = "";
if (Module != null)
{
if (!String.IsNullOrEmpty(Module.DesktopModule.BusinessControllerClass) && Module.DesktopModule.IsPortable)
{
try
{
var objObject = Reflection.CreateObject(Module.DesktopModule.BusinessControllerClass, Module.DesktopModule.BusinessControllerClass);
//Double-check
if (objObject is IPortable)
{
var content = Convert.ToString(((IPortable)objObject).ExportModule(moduleID));
if (!String.IsNullOrEmpty(content))
{
//remove invalid chars in content
content = Regex.Replace(content, _invalidCharsRegex, string.Empty);
//add attributes to XML document
content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<content type=\"" + CleanName(Module.DesktopModule.ModuleName) + "\" version=\"" +
Module.DesktopModule.Version + "\">" + content + "</content>";
//First check the Portal limits will not be exceeded (this is approximate)
var objPortalController = new PortalController();
var strFile = PortalSettings.HomeDirectoryMapPath + folder.FolderPath + fileName;
if (objPortalController.HasSpaceAvailable(PortalId, content.Length))
{
//add file to Files table
using (var fileContent = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
FileManager.Instance.AddFile(folder, fileName, fileContent, true, true, "application/octet-stream");
}
}
else
{
strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFile);
}
}
else
{
strMessage = Localization.GetString("NoContent", LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
}
}
catch
{
strMessage = Localization.GetString("Error", LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
}
}
return strMessage;
}
示例2: ExportModule
private string ExportModule(int moduleID, string fileName, string folder)
{
var strMessage = "";
if (Module != null)
{
if (!String.IsNullOrEmpty(Module.DesktopModule.BusinessControllerClass) && Module.DesktopModule.IsPortable)
{
try
{
var objObject = Reflection.CreateObject(Module.DesktopModule.BusinessControllerClass, Module.DesktopModule.BusinessControllerClass);
//Double-check
if (objObject is IPortable)
{
var content = Convert.ToString(((IPortable)objObject).ExportModule(moduleID));
if (!String.IsNullOrEmpty(content))
{
//add attributes to XML document
content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<content type=\"" + CleanName(Module.DesktopModule.ModuleName) + "\" version=\"" +
Module.DesktopModule.Version + "\">" + content + "</content>";
//First check the Portal limits will not be exceeded (this is approximate)
var objPortalController = new PortalController();
var strFile = PortalSettings.HomeDirectoryMapPath + folder + fileName;
if (objPortalController.HasSpaceAvailable(PortalId, content.Length))
{
//save the file
var objStream = File.CreateText(strFile);
objStream.WriteLine(content);
objStream.Close();
//add file to Files table
#pragma warning disable 612,618
FileSystemUtils.AddFile(fileName, PortalId, folder, PortalSettings.HomeDirectoryMapPath, "application/octet-stream");
#pragma warning restore 612,618
}
else
{
strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFile);
}
}
else
{
strMessage = Localization.GetString("NoContent", LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
}
}
catch
{
strMessage = Localization.GetString("Error", LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
}
}
return strMessage;
}
示例3: CheckDestFolderAccess
/// -----------------------------------------------------------------------------
/// <summary>
/// The CheckDestFolderAccess helper method Checks to make sure file copy/move
/// operation will not exceed portal available space
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [DYNST] 2/1/2004 Created
/// [Jon Henning] 11/1/2004 Updated to use ClientAPI/DNNTree
/// [cnurse] 12/2/2004 Updated to use Localization
/// </history>
/// -----------------------------------------------------------------------------
public string CheckDestFolderAccess(long intSize)
{
if (Request.IsAuthenticated)
{
string strDestFolder = PathUtils.Instance.AddTrailingSlash(UnMaskPath(DestPath));
var objPortalController = new PortalController();
if (objPortalController.HasSpaceAvailable(FolderPortalID, intSize) || Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
{
return "";
}
else
{
return Localization.GetString("NotEnoughSpace", LocalResourceFile);
}
}
else
{
return Localization.GetString("PleaseLogin", LocalResourceFile);
}
}
示例4: ExportModule
private string ExportModule( int ModuleID, string FileName )
{
string strMessage = "";
ModuleController objModules = new ModuleController();
ModuleInfo objModule = objModules.GetModule( ModuleID, TabId, false );
if (objModule != null)
{
if (objModule.BusinessControllerClass != "" & objModule.IsPortable)
{
try
{
object objObject = Reflection.CreateObject(objModule.BusinessControllerClass, objModule.BusinessControllerClass);
//Double-check
if (objObject is IPortable)
{
string Content = Convert.ToString(((IPortable)objObject).ExportModule(ModuleID));
if (Content != "")
{
// add attributes to XML document
Content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<content type=\"" + CleanName(objModule.FriendlyName) + "\" version=\"" + objModule.Version + "\">" + Content + "</content>";
//First check the Portal limits will not be exceeded (this is approximate)
PortalController objPortalController = new PortalController();
string strFile = PortalSettings.HomeDirectoryMapPath + FileName;
if (objPortalController.HasSpaceAvailable(PortalId, Content.Length))
{
// save the file
StreamWriter objStream = File.CreateText(strFile);
objStream.WriteLine(Content);
objStream.Close();
// add file to Files table
FileController objFiles = new FileController();
FileInfo finfo = new FileInfo(strFile);
FolderController objFolders = new FolderController();
FolderInfo objFolder = objFolders.GetFolder(PortalId, "");
Services.FileSystem.FileInfo objFile = objFiles.GetFile(lblFile.Text, PortalId, objFolder.FolderID);
if (objFile == null)
{
objFiles.AddFile(PortalId, lblFile.Text, "xml", finfo.Length, 0, 0, "application/octet-stream", "", objFolder.FolderID, true);
}
else
{
objFiles.UpdateFile(objFile.FileId, objFile.FileName, "xml", finfo.Length, 0, 0, "application/octet-stream", "", objFolder.FolderID);
}
}
else
{
strMessage += "<br>" + string.Format(Localization.GetString("DiskSpaceExceeded"), strFile);
}
}
else
{
strMessage = Localization.GetString("NoContent", this.LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", this.LocalResourceFile);
}
}
catch
{
strMessage = Localization.GetString("Error", this.LocalResourceFile);
}
}
else
{
strMessage = Localization.GetString("ExportNotSupported", this.LocalResourceFile);
}
}
return strMessage;
}
示例5: UnzipFile
//.........这里部分代码省略.........
{
try
{
sortedFolders.Add( objZipEntry.Name.ToString() );
}
catch( Exception ex )
{
objZipInputStream.Close();
return ex.Message;
}
}
objZipEntry = objZipInputStream.GetNextEntry();
}
sortedFolders.Sort();
foreach( string s in sortedFolders )
{
try
{
AddFolder( settings, DestFolder, s.ToString(), storageLocation );
}
catch( Exception ex )
{
return ex.Message;
}
}
objZipEntry = objZipInputStream.GetNextEntry();
while( objZipEntry != null )
{
if( objZipEntry.IsDirectory )
{
try
{
AddFolder( settings, DestFolder, objZipEntry.Name, storageLocation );
}
catch( Exception ex )
{
objZipInputStream.Close();
return ex.Message;
}
}
objZipEntry = objZipInputStream.GetNextEntry();
}
//Recreate the Zip Input Stream and parse it for the files
objZipInputStream = new ZipInputStream( GetFileStream( file ) );
objZipEntry = objZipInputStream.GetNextEntry();
while( objZipEntry != null )
{
if( !objZipEntry.IsDirectory )
{
if( objPortalController.HasSpaceAvailable( FolderPortalId, objZipEntry.Size ) )
{
strFileName = Path.GetFileName( objZipEntry.Name );
if( !String.IsNullOrEmpty( strFileName ) )
{
string strExtension = Path.GetExtension( strFileName ).Replace( ".", "" );
string a = "," + settings.HostSettings["FileExtensions"].ToString().ToLower();
if( ( a.IndexOf( "," + strExtension.ToLower(), 0 ) + 1 ) != 0 || isHost )
{
try
{
string folderPath = Path.GetDirectoryName( DestFolder + objZipEntry.Name.Replace( "/", "\\" ) );
DirectoryInfo Dinfo = new DirectoryInfo( folderPath );
if( !Dinfo.Exists )
{
AddFolder( settings, DestFolder, objZipEntry.Name.Substring( 0, objZipEntry.Name.Replace( "/", "\\" ).LastIndexOf( "\\" ) ) );
}
string zipEntryFileName = DestFolder + objZipEntry.Name.Replace( "/", "\\" );
strMessage += AddFile( FolderPortalId, objZipInputStream, zipEntryFileName, "", objZipEntry.Size, Globals.GetSubFolderPath( zipEntryFileName ), false, false );
}
catch( Exception ex )
{
objZipInputStream.Close();
return ex.Message;
}
}
else
{
// restricted file type
strMessage += "<br>" + string.Format( Localization.GetString( "RestrictedFileType" ), strFileName, settings.HostSettings["FileExtensions"].ToString().Replace( ",", ", *." ) );
}
}
}
else // file too large
{
strMessage += "<br>" + string.Format( Localization.GetString( "DiskSpaceExceeded" ), strFileName );
}
}
objZipEntry = objZipInputStream.GetNextEntry();
}
objZipInputStream.Close();
return strMessage;
}
示例6: UploadFile
public static string UploadFile( string RootPath, HttpPostedFile objHtmlInputFile, bool Unzip )
{
// Obtain PortalSettings from Current Context
PortalSettings settings = PortalController.GetCurrentPortalSettings();
int PortalId = GetFolderPortalId( settings );
bool isHost = Convert.ToBoolean( ( ( settings.ActiveTab.ParentId == settings.SuperTabId ) ? true : false ) );
PortalController objPortalController = new PortalController();
string strMessage = "";
string strFileName = RootPath + Path.GetFileName( objHtmlInputFile.FileName );
string strExtension = Path.GetExtension( strFileName ).Replace( ".", "" );
string strFolderpath = Globals.GetSubFolderPath( strFileName );
if( objPortalController.HasSpaceAvailable( PortalId, objHtmlInputFile.ContentLength ) )
{
string a = "," + settings.HostSettings["FileExtensions"].ToString().ToUpper();
if( ( a.IndexOf( "," + strExtension.ToUpper(), 0 ) + 1 ) != 0 || isHost )
{
//Save Uploaded file to server
try
{
strMessage += AddFile( PortalId, objHtmlInputFile.InputStream, strFileName, objHtmlInputFile.ContentType, objHtmlInputFile.ContentLength, strFolderpath, true, true );
//Optionally Unzip File?
if( Path.GetExtension( strFileName ).ToLower() == ".zip" & Unzip )
{
strMessage += UnzipFile( strFileName, RootPath, settings );
}
}
catch( Exception )
{
// save error - can happen if the security settings are incorrect
strMessage += "<br>" + string.Format( Localization.GetString( "SaveFileError" ), strFileName );
}
}
else
{
// restricted file type
strMessage += "<br>" + string.Format( Localization.GetString( "RestrictedFileType" ), strFileName, settings.HostSettings["FileExtensions"].ToString().Replace( ",", ", *." ) );
}
}
else // file too large
{
strMessage += "<br>" + string.Format( Localization.GetString( "DiskSpaceExceeded" ), strFileName );
}
return strMessage;
}
示例7: Check_DiskSpace
/// <summary>
/// Validates disk space available
/// </summary>
/// <param name="virtualPathAndName">The system path. ie: C:\WebSites\DotNetNuke_Community\Portals\0\sample.gif</param>
/// <param name="contentLength">Content Length</param>
/// <returns>The error message or empty string</returns>
/// <remarks></remarks>
private object Check_DiskSpace(string virtualPathAndName, long contentLength)
{
try
{
string fileName = Path.GetFileName(virtualPathAndName);
PortalController portalCtrl = new PortalController();
if (! (portalCtrl.HasSpaceAvailable(PortalController.GetCurrentPortalSettings().PortalId, contentLength)))
{
return string.Format(Localization.GetString("DiskSpaceExceeded"), ToEndUserPath(virtualPathAndName));
}
}
catch (Exception ex)
{
return LogUnknownError(ex, virtualPathAndName, contentLength.ToString());
}
return string.Empty;
}
示例8: CheckDestFolderAccess
/// <summary>
/// The CheckDestFolderAccess helper method Checks to make sure file copy/move
/// operation will not exceed portal available space
/// </summary>
/// <history>
/// [DYNST] 2/1/2004 Created
/// [Jon Henning] 11/1/2004 Updated to use ClientAPI/DNNTree
/// [cnurse] 12/2/2004 Updated to use Localization
/// </history>
public string CheckDestFolderAccess( long intSize )
{
if( Request.IsAuthenticated )
{
FileSystemUtils.AddTrailingSlash( UnMaskPath( DestPath ) );
PortalController objPortalController = new PortalController();
if( objPortalController.HasSpaceAvailable( FolderPortalID, intSize ) || ( PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId ) )
{
return "";
}
else
{
return Localization.GetString( "NotEnoughSpace", this.LocalResourceFile );
}
}
else
{
return Localization.GetString( "PleaseLogin", this.LocalResourceFile );
}
}