Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
Scheduled job
Use UnifiedFile and UnifiedDirectory.GetFiles / GetDirectories
http://world.episerver.com/documentation/class-library/?documentId=cms/7/25a9113a-09bc-b669-f00b-976d8a0abe16
UrlRewriteProvider.ConvertToExternal to get paths
see
http://world.episerver.com/Forum/Developer-forum/EPiServer-CMS-6-R2/Thread-Container/2012/9/Absolute-external-URL-property/
Output using EPiServer logging...(log4net)?
Use a scheduled job instead of a user pressed button to avoid timeouts.
Set scheduled job to run as an admin kind of user to avoid any access rights problem. E.g.
if (HttpContext.Current == null)
{
PrincipalInfo.CurrentPrincipal = new GenericPrincipal(
new GenericIdentity("Scheduled DummyTask"),
new[] { "Administrators" });
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("Doc Report");
var files = new List<UnifiedFile>();
UnifiedDirectory docsDirectory = null;
UnifiedDirectory globalDirectory = null;
UnifiedDirectory pageFilesDirectory = null;
docsDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory("~/Documents/") as UnifiedDirectory;
this.GetAllFiles(docsDirectory, files);
globalDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory("~/Global/") as UnifiedDirectory;
this.GetAllFiles(globalDirectory, files);
pageFilesDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory("~/PageFiles/") as UnifiedDirectory;
this.GetAllFiles(pageFilesDirectory, files);
Int32 iCount = 0;
foreach (var file in files)
{
try
{
sb.AppendLine("<a href='https://" + Request.Url.Host + file.VirtualPath + "'>https://" + Request.Url.Host + file.VirtualPath + "</a><br/>");
iCount += 1;
}
catch (Exception exception)
{
//logger.ErrorFormat("Error exporting file {0}. Error was: {1}", file.VirtualPath, exception.ToString());
}
}
sb.AppendLine("Total Count: " + iCount.ToString());
StartIndexOnItemLit.Text = sb.ToString();
}
void GetAllFiles(UnifiedDirectory start, List<UnifiedFile> files)
{
foreach (UnifiedFile file in start.GetFiles())
{
if (file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".jpeg" || file.Extension.ToLower() == ".png" || file.Extension.ToLower() == ".gif")
{
files.Add(file);
}
}
foreach (UnifiedDirectory dir in start.GetDirectories())
{
GetAllFiles(dir, files);
}
}
Hi,
Our client would like a Asset library report and would like the report to have a friendly URL generated for each Image and file in the Asset Library in CMS Episerver 6 R2.
Is this at all possible? If so do you know what code is best to use?
Many thanks
JOn