Hi, I am using episever 8 and I am new to this episerver CMS.
I have created a new media type using the code below:
namespace Test.Website.Models.Media
{
[ContentType(DisplayName = "Excel File", GUID = "d9edcdcf-16b8-4033-8ed5-fb7293f49da34f4a33d", Description = "")]
[MediaDescriptor(ExtensionString = "xls,xlsx")]
public class ExcelFile : MediaData
{
}
}
and we are using it for a contentRefrence in one of the block:
[Display(
GroupName = SystemTabNames.Content,
Order = 10,
Name = "Data File",
Description = "Select the formatted Excel file used as the data source for the tool"
)]
[Required]
[AllowedTypes(new[] { typeof(ExcelFile) })]
public virtual ContentReference DataFile { get; set; }
everything is running fine on my local and I took the export of the page with the block where I have used this excel file, problem is with import because the contentReference is blank while importing.
And to check that I have tried with EventsPublishedContent for this block and put a dubug point on GetDataFile(block.DataFile) but everytime the parameter shows blank.
Any help is much appreciated!
public static bool IsDataFileDifferent(int blockId)
{
var repo = ServiceLocator.Current.GetInstance<IContentRepository>();
var content = repo.Get<IContent>(new ContentReference(blockId));
if(content is FinderBlock){
var block = content as FinderBlock;
var DataFile = GetDataFile(block.DataFile);
}
return DataFile;
}
public static string GetDataFile(ContentReference file)
{
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
MediaData media;
if (contentLoader.TryGet(file, out media))
{
return media.Name + media.Changed;
}
else
throw new ArgumentOutOfRangeException("file", "No media found with this ContentReference " + file.ToString());
}