public string AttachCSSFile(string fileName, string cdnPath = "")
{
if (!string.IsNullOrEmpty(cdnPath) && !Repository.Configuration.IsLocal) return string.Format("<link type='text/css' href='{0}' rel='stylesheet'/>", ConvertCDNPath(cdnPath));
if (GenerateHTMLDisplay)
{
if (ExecutionContext == ReportExecutionContext.WebReport || ExecutionContext == ReportExecutionContext.WebOutput)
{
return string.Format("<link type='text/css' href='{0}Content/{1}' rel='stylesheet'/>", WebUrl, fileName);
}
else
{
//reference local file
string fileReference = "file:///" + HttpUtility.HtmlEncode(Path.Combine(Repository.ViewContentFolder, fileName));
return string.Format("<link type='text/css' href='{0}' rel='stylesheet'/>", fileReference);
}
}
//generating result file, set the CSS directly in the result
string result = "<style type='text/css'>\r\n";
string sourceFilePath = Path.Combine(Repository.ViewContentFolder, fileName);
result += File.ReadAllText(sourceFilePath);
result += "\r\n</style>\r\n";
return result;
}