本文整理汇总了C#中umbraco.cms.businesslogic.media.Media.getProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Media.getProperty方法的具体用法?C# Media.getProperty怎么用?C# Media.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.media.Media
的用法示例。
在下文中一共展示了Media.getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoHandleMedia
public override void DoHandleMedia(Media media, PostedMediaFile postedFile, BusinessLogic.User user)
{
// Get Image object, width and height
var image = System.Drawing.Image.FromStream(postedFile.InputStream);
var fileWidth = image.Width;
var fileHeight = image.Height;
// Get umbracoFile property
var propertyId = media.getProperty("umbracoFile").Id;
// Get paths
var destFileName = ConstructDestFileName(propertyId, postedFile.FileName);
var destPath = ConstructDestPath(propertyId);
var destFilePath = VirtualPathUtility.Combine(destPath, destFileName);
var ext = VirtualPathUtility.GetExtension(destFileName).Substring(1);
var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);
// Set media properties
media.getProperty("umbracoFile").Value = destFilePath;
media.getProperty("umbracoWidth").Value = fileWidth;
media.getProperty("umbracoHeight").Value = fileHeight;
media.getProperty("umbracoBytes").Value = postedFile.ContentLength;
if (media.getProperty("umbracoExtension") != null)
media.getProperty("umbracoExtension").Value = ext;
if (media.getProperty("umbracoExtensio") != null)
media.getProperty("umbracoExtensio").Value = ext;
// Create directory
if (UmbracoSettings.UploadAllowDirectories)
Directory.CreateDirectory(absoluteDestPath);
// Generate thumbnail
var thumbDestFilePath = Path.Combine(absoluteDestPath, Path.GetFileNameWithoutExtension(destFileName) + "_thumb");
GenerateThumbnail(image, 100, fileWidth, fileHeight, thumbDestFilePath + ".jpg");
// Generate additional thumbnails based on PreValues set in DataTypeDefinition uploadField
GenerateAdditionalThumbnails(image, fileWidth, fileHeight, thumbDestFilePath);
image.Dispose();
// Save file
postedFile.SaveAs(absoluteDestFilePath);
// Close stream
postedFile.InputStream.Close();
// Save media
media.Save();
}
示例2: update
public void update(mediaCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier == null) throw new Exception("No carrier specified");
Media m = new Media(carrier.Id);
if (carrier.MediaProperties != null)
{
foreach (mediaProperty updatedproperty in carrier.MediaProperties)
{
if (!(updatedproperty.Key.ToLower().Equals("umbracofile")))
{
Property property = m.getProperty(updatedproperty.Key);
if (property == null)
throw new Exception("property " + updatedproperty.Key + " was not found");
property.Value = updatedproperty.PropertyValue;
}
}
}
m.Save();
}
示例3: DoHandleMedia
public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
{
// Get umbracoFile property
var propertyId = media.getProperty(Constants.Conventions.Media.File).Id;
// Get paths
var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
var ext = Path.GetExtension(destFilePath).Substring(1);
//var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
//var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);
// Set media properties
media.getProperty(Constants.Conventions.Media.File).Value = FileSystem.GetUrl(destFilePath);
media.getProperty(Constants.Conventions.Media.Bytes).Value = uploadedFile.ContentLength;
if (media.getProperty(Constants.Conventions.Media.Extension) != null)
media.getProperty(Constants.Conventions.Media.Extension).Value = ext;
// Legacy: The 'extensio' typo applied to MySQL (bug in install script, prior to v4.6.x)
if (media.getProperty("umbracoExtensio") != null)
media.getProperty("umbracoExtensio").Value = ext;
FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);
// Save media
media.Save();
}
示例4: DoHandleMedia
public override void DoHandleMedia(Media media, PostedMediaFile uploadedFile, User user)
{
// Get umbracoFile property
var propertyId = media.getProperty("umbracoFile").Id;
// Get paths
var destFilePath = FileSystem.GetRelativePath(propertyId, uploadedFile.FileName);
var ext = Path.GetExtension(destFilePath).Substring(1);
//var absoluteDestPath = HttpContext.Current.Server.MapPath(destPath);
//var absoluteDestFilePath = HttpContext.Current.Server.MapPath(destFilePath);
// Set media properties
media.getProperty("umbracoFile").Value = FileSystem.GetUrl(destFilePath);
media.getProperty("umbracoBytes").Value = uploadedFile.ContentLength;
if (media.getProperty("umbracoExtension") != null)
media.getProperty("umbracoExtension").Value = ext;
if (media.getProperty("umbracoExtensio") != null)
media.getProperty("umbracoExtensio").Value = ext;
FileSystem.AddFile(destFilePath, uploadedFile.InputStream, uploadedFile.ReplaceExisting);
// Save media
media.Save();
}
示例5: GetRelations
public DataTable GetRelations(object id)
{
var usages = new List<Document>();
// Media Picker
using (var reader = Application.SqlHelper.ExecuteReader("SELECT DISTINCT contentNodeId FROM cmsPropertyData WHERE [email protected]", new SqlServerParameter("0", id)))
{
while (reader.Read())
{
usages.Add(new Document(reader.GetInt("contentNodeId")));
}
}
// RTE
var media = new Media((int) id);
if (media != null)
{
var file = media.getProperty("umbracoFile");
if (file != null)
{
var filePath = file.Value;
using (var reader = Application.SqlHelper.ExecuteReader("SELECT DISTINCT contentNodeId FROM cmsPropertyData WHERE (dataNtext LIKE '%' + @0 + '%' or dataNvarchar LIKE '%' + @0 + '%') AND contentNodeId <> @1", new SqlServerParameter("0", filePath), new SqlServerParameter("1", id)))
{
while (reader.Read())
{
usages.Add(new Document(reader.GetInt("contentNodeId")));
}
}
}
}
// TODO: MNTP
// TODO: DAMP
return UmbracoObject.Content.ToDataTable(usages);
}
示例6: Compress
internal static Kraken Compress(Media umbracoMedia, bool? wait = null)
{
if (umbracoMedia == null || umbracoMedia.Id == 0)
throw new ArgumentException("Invalid Umbraco Media node", "umbracoMedia");
var p = umbracoMedia.getProperty(Constants.UmbracoPropertyAliasFile);
if (p != null && p.Value != null)
{
string img = p.Value.ToString();
Kraken result = null;
try
{
result = Compress(img, wait); // UPLOAD
}
catch (KrakenException)
{
try
{
string imageUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + img;
Uri uri;
if (Uri.TryCreate(imageUrl, UriKind.Absolute, out uri))
result = Compress(uri, wait); // URI
}
catch (KrakenException)
{
}
}
if (result != null)
result.MediaId = umbracoMedia.Id;
return result;
}
else
throw new Exception("Target Umbraco media item has no file");
}
示例7: formatMedia
private string formatMedia(string html)
{
// Local media path
string localMediaPath = getLocalMediaPath();
// Find all media images
string pattern = "<img [^>]*src=\"(?<mediaString>/media[^\"]*)\" [^>]*>";
MatchCollection tags =
Regex.Matches(html, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match tag in tags)
if (tag.Groups.Count > 0)
{
// Replace /> to ensure we're in old-school html mode
string tempTag = "<img";
string orgSrc = tag.Groups["mediaString"].Value;
// gather all attributes
// TODO: This should be replaced with a general helper method - but for now we'll wanna leave Umbraco.dll alone for this patch
Hashtable ht = new Hashtable();
MatchCollection m =
Regex.Matches(tag.Value.Replace(">", " >"),
"(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"|(?<attributeName>\\S*)=(?<attributeValue>[^\"|\\s]*)\\s",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match attributeSet in m)
{
if (attributeSet.Groups["attributeName"].Value.ToString().ToLower() != "src")
ht.Add(attributeSet.Groups["attributeName"].Value.ToString(),
attributeSet.Groups["attributeValue"].Value.ToString());
}
// build the element
// Build image tag
IDictionaryEnumerator ide = ht.GetEnumerator();
while(ide.MoveNext())
tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\"";
// Find the original filename, by removing the might added width and height
orgSrc =
orgSrc.Replace(
"_" + helper.FindAttribute(ht, "width") + "x" + helper.FindAttribute(ht, "height"), "").
Replace("%20", " ");
// Check for either id or guid from media
string mediaId = getIdFromSource(orgSrc, localMediaPath);
Media imageMedia = null;
try
{
int mId = int.Parse(mediaId);
Property p = new Property(mId);
imageMedia = new Media(Content.GetContentFromVersion(p.VersionId).Id);
}
catch
{
try
{
imageMedia = new Media(Content.GetContentFromVersion(new Guid(mediaId)).Id);
}
catch
{
}
}
// Check with the database if any media matches this url
if (imageMedia != null)
{
try
{
// Check extention
if (imageMedia.getProperty("umbracoExtension").Value.ToString() != orgSrc.Substring(orgSrc.LastIndexOf(".") + 1, orgSrc.Length - orgSrc.LastIndexOf(".") - 1))
orgSrc = orgSrc.Substring(0, orgSrc.LastIndexOf(".")+1) +
imageMedia.getProperty("umbracoExtension").Value.ToString();
// Format the tag
tempTag = tempTag + " rel=\"" +
imageMedia.getProperty("umbracoWidth").Value.ToString() + "," +
imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + orgSrc +
"\"";
tempTag += "/>";
// Replace the tag
html = html.Replace(tag.Value, tempTag);
}
catch (Exception ee)
{
Log.Add(LogTypes.Error, User.GetUser(0), -1,
"Error reading size data from media: " + imageMedia.Id.ToString() + ", " +
ee.ToString());
}
}
else
Log.Add(LogTypes.Error, User.GetUser(0), -1,
"Error reading size data from media (not found): " + orgSrc);
}
return html;
}
示例8: SetImageMediaProperties
// -------------------------------------------------------------------------
// Private members
// -------------------------------------------------------------------------
private static void SetImageMediaProperties(Media media, string file, int fileWidth, int fileHeight, int bytes, string ext)
{
media.getProperty("umbracoFile").Value = file;
media.getProperty("umbracoWidth").Value = fileWidth;
media.getProperty("umbracoHeight").Value = fileHeight;
media.getProperty("umbracoBytes").Value = bytes;
media.getProperty("umbracoExtension").Value = ext;
}
示例9: LookupData
private void LookupData()
{
if (MediaId > 0 && Media.IsNode(MediaId))
{
Media m = new Media(MediaId);
// TODO: Remove "Magic strings" from code.
var pFile = m.getProperty("fileName");
if (pFile == null) pFile = m.getProperty("umbracoFile");
if (pFile == null) pFile = m.getProperty("file");
if (pFile == null)
{
//the media requested does not correspond with the standard umbraco properties
return;
}
MediaItemPath = pFile.Value != null && !string.IsNullOrEmpty(pFile.Value.ToString())
? IOHelper.ResolveUrl(pFile.Value.ToString())
: "#";
AltText = MediaItemPath != "#" ? m.Text : ui.GetText("no") + " " + ui.GetText("media");
var pWidth = m.getProperty("umbracoWidth");
var pHeight = m.getProperty("umbracoHeight");
if (pWidth != null && pWidth.Value != null && pHeight != null && pHeight.Value != null)
{
int.TryParse(pWidth.Value.ToString(), out m_FileWidth);
int.TryParse(pHeight.Value.ToString(), out m_FileHeight);
}
string ext = MediaItemPath.Substring(MediaItemPath.LastIndexOf(".") + 1, MediaItemPath.Length - MediaItemPath.LastIndexOf(".") - 1);
MediaItemThumbnailPath = MediaItemPath.Replace("." + ext, "_thumb.jpg");
ImageFound = true;
}
else
{
ImageFound = false;
}
}
示例10: delete
public void delete(int id, string username, string password)
{
Authenticate(username, password);
Media m = new Media(id);
if (m.HasChildren)
throw new Exception("Cannot delete Media " + id + " as it has child nodes");
Property p = m.getProperty("umbracoFile");
if (p != null)
{
if (!(p.Value == System.DBNull.Value))
{
var path = _fs.GetRelativePath(p.Value.ToString());
if(_fs.FileExists(path))
_fs.DeleteFile(path, true);
}
}
m.delete();
}
示例11: formatMedia
private string formatMedia(string html)
{
// root media url
var rootMediaUrl = _fs.GetUrl("");
// Find all media images
var pattern = String.Format("<img [^>]*src=\"(?<mediaString>{0}[^\"]*)\" [^>]*>", rootMediaUrl);
MatchCollection tags =
Regex.Matches(html, pattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match tag in tags)
if (tag.Groups.Count > 0)
{
// Replace /> to ensure we're in old-school html mode
string tempTag = "<img";
string orgSrc = tag.Groups["mediaString"].Value;
// gather all attributes
// TODO: This should be replaced with a general helper method - but for now we'll wanna leave umbraco.dll alone for this patch
Hashtable ht = new Hashtable();
MatchCollection m =
Regex.Matches(tag.Value.Replace(">", " >"),
"(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"|(?<attributeName>\\S*)=(?<attributeValue>[^\"|\\s]*)\\s",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
//GE: Add ContainsKey check and expand the ifs for readability
foreach (Match attributeSet in m)
{
if (attributeSet.Groups["attributeName"].Value.ToString().ToLower() != "src")
{
if (!ht.ContainsKey(attributeSet.Groups["attributeName"].Value.ToString()))
{
ht.Add(attributeSet.Groups["attributeName"].Value.ToString(), attributeSet.Groups["attributeValue"].Value.ToString());
}
}
}
// build the element
// Build image tag
IDictionaryEnumerator ide = ht.GetEnumerator();
while (ide.MoveNext())
tempTag += " " + ide.Key.ToString() + "=\"" + ide.Value.ToString() + "\"";
// Find the original filename, by removing the might added width and height
// NH, 4.8.1 - above replaced by loading the right media file from the db later!
orgSrc =
global::Umbraco.Core.IO.IOHelper.ResolveUrl(orgSrc.Replace("%20", " "));
// Check for either id or guid from media
string mediaId = getIdFromSource(orgSrc, rootMediaUrl);
Media imageMedia = null;
try
{
int mId = int.Parse(mediaId);
Property p = new Property(mId);
imageMedia = new Media(Content.GetContentFromVersion(p.VersionId).Id);
}
catch
{
try
{
imageMedia = new Media(Content.GetContentFromVersion(new Guid(mediaId)).Id);
}
catch
{
}
}
// Check with the database if any media matches this url
if (imageMedia != null)
{
try
{
// Format the tag
tempTag = tempTag + " rel=\"" +
imageMedia.getProperty("umbracoWidth").Value.ToString() + "," +
imageMedia.getProperty("umbracoHeight").Value.ToString() + "\" src=\"" + global::Umbraco.Core.IO.IOHelper.ResolveUrl(imageMedia.getProperty("umbracoFile").Value.ToString()) +
"\"";
tempTag += "/>";
// Replace the tag
html = html.Replace(tag.Value, tempTag);
}
catch (Exception ee)
{
Log.Add(LogTypes.Error, User.GetUser(0), -1,
"Error reading size data from media: " + imageMedia.Id.ToString() + ", " +
ee.ToString());
}
}
else
Log.Add(LogTypes.Error, User.GetUser(0), -1,
"Error reading size data from media (not found): " + orgSrc);
}
return html;
}
示例12: GetKrakStatus
internal static EnmIsKrakable GetKrakStatus(Media im)
{
// Je mag een Umbraco Media node krakken onder de volgende voorwaarden:
var s = global::Kraken.Configuration.Settings;
if (String.IsNullOrEmpty(s.ApiKey) || String.IsNullOrEmpty(s.ApiSecret))
return EnmIsKrakable.MissingCredentials;
// 1: Er zit wat in :)
if (im == null || im.Id == 0)
return EnmIsKrakable.Unkrakable;
var p = im.getProperty(Constants.UmbracoPropertyAliasStatus);
// 2: Het status veld dient aanwezig te zijn
if (p == null)
return EnmIsKrakable.Unkrakable;
// 3: Als hij geen afbeelding bevat, dan mag het niet
p = im.getProperty(Constants.UmbracoPropertyAliasFile);
if (p == null || p.Value == null || String.IsNullOrEmpty(p.Value.ToString()))
return EnmIsKrakable.Unkrakable;
// 4: Als het geen jpeg, gif of png is dan kan het bestand niet gekrakt worden
string img = p.Value.ToString();
if (img == null ||
(!img.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) &&
!img.EndsWith("jpeg", StringComparison.OrdinalIgnoreCase) &&
!img.EndsWith("png", StringComparison.OrdinalIgnoreCase) &&
!img.EndsWith("gif", StringComparison.OrdinalIgnoreCase)))
return EnmIsKrakable.Unkrakable;
// W 18-9-2015: Vanaf nu mag je afbeeldingen re-kraken
// 3: En dit status veld dient ook nog eens LEEG te zijn (want als je al een status hebt dan is er dus al iets gebeurd)
// Status betekend dus echt EINDSTATUS
p = im.getProperty(Constants.UmbracoPropertyAliasStatus);
if (p != null && p.Value != null && !String.IsNullOrEmpty(p.Value as String))
{
if (p.Value as String == EnmKrakStatus.Original.ToString())
return EnmIsKrakable.Original;
else if (p.Value as String == EnmKrakStatus.Compressed.ToString())
return EnmIsKrakable.Kraked;
else
// Weet niet wat het is dus niet kraken!
return EnmIsKrakable.Unkrakable;
}
else
// Yaay, deze media item mag gekrakt worden
return EnmIsKrakable.Krakable;
}
示例13: writeContents
public void writeContents(int id, string filename, Byte[] contents, string username, string password)
{
Authenticate(username, password);
filename = filename.Replace("/", global::Umbraco.Core.IO.IOHelper.DirSepChar.ToString());
filename = filename.Replace(@"\", global::Umbraco.Core.IO.IOHelper.DirSepChar.ToString());
filename = filename.Substring(filename.LastIndexOf(global::Umbraco.Core.IO.IOHelper.DirSepChar) + 1, filename.Length - filename.LastIndexOf(global::Umbraco.Core.IO.IOHelper.DirSepChar) - 1).ToLower();
var m = new Media(id);
var numberedFolder = MediaSubfolderCounter.Current.Increment();
var path = _fs.GetRelativePath(numberedFolder.ToString(CultureInfo.InvariantCulture), filename);
var stream = new MemoryStream();
stream.Write(contents, 0, contents.Length);
stream.Seek(0, 0);
_fs.AddFile(path, stream);
m.getProperty("umbracoFile").Value = _fs.GetUrl(path);
m.getProperty("umbracoExtension").Value = Path.GetExtension(filename).Substring(1);
m.getProperty("umbracoBytes").Value = _fs.GetSize(path);
m.Save();
}
示例14: Save
/// <summary>
/// Save the kraked image to a specific Umbraco Media node
/// </summary>
/// <param name="imKrakTarget">Target media node</param>
/// <param name="keepOriginal">Save the original image in Umbraco? Pass NULL to use global settings</param>
/// <param name="hasChanged">Has a new image been selected for the media node just now?</param>
/// <returns>Success status</returns>
internal bool Save(Media mKrakTarget, bool? keepOriginal = null, bool hasChanged = false)
{
umbraco.cms.businesslogic.property.Property p;
// Validate parameters
var status = GetKrakStatus(mKrakTarget);
if (status == EnmIsKrakable.Unkrakable || status == EnmIsKrakable.Original || String.IsNullOrEmpty(kraked_url))
// This image is unkrakable, do not proceed
return false;
// Determine the path and the name of the image
var relativeFilepath = mKrakTarget.getProperty(Constants.UmbracoPropertyAliasFile).Value.ToString();
var relativeDirectory = System.IO.Path.GetDirectoryName(relativeFilepath);
var absoluteDirectory = System.Web.Hosting.HostingEnvironment.MapPath("~" + relativeDirectory);
string filename = Path.GetFileName(relativeFilepath);
if (keepOriginal == null)
keepOriginal = Configuration.Settings.KeepOriginal;
// Has this media node already been Kraked before?
int originalSize = 0;
if (status == EnmIsKrakable.Kraked)
{
p = mKrakTarget.getProperty(Constants.UmbracoPropertyAliasOriginalSize);
if (p != null && p.Value != null)
int.TryParse(p.Value.ToString(), out originalSize);
}
if (originalSize == 0)
originalSize = original_size;
var compressionRate = (((decimal)(originalSize - kraked_size)) / originalSize).ToString("p2");
// The following might seem redundant, but Umbraco's "SetValue" extension method used below actually does a lot of magic for us.
// However, Umbraco will also create a new media folder for us to contain the new image which we do NOT want (the url to the image has to remain unchanged).
// So some extra efforts are required to make sure the compressed image will be switched in the place of the original image.
var originalUmbracoFilePropertyData = mKrakTarget.getProperty(Constants.UmbracoPropertyAliasFile).Value.ToString(); // Get the original property data
if (!mKrakTarget.AddFile(kraked_url, filename))
return false; // Krak failed
// Extract the absolute directory path
var newRelativeFilepath = mKrakTarget.getProperty(Constants.UmbracoPropertyAliasFile).Value.ToString(); // Retrieve the relative filepath to the new image location
var newRelativeDirectory = System.IO.Path.GetDirectoryName(newRelativeFilepath); // Extract the relative directoryname
var newAbsoluteDirectory = System.Web.Hosting.HostingEnvironment.MapPath("~" + newRelativeDirectory); // Convert to it's absolute variant
mKrakTarget.getProperty(Constants.UmbracoPropertyAliasFile).Value = originalUmbracoFilePropertyData; // Put the original property data back in place
// If an "original" media node is already present under the current node, then save our original data to that node.
// Else we will keep creating new nodes under the current node each time we save, and we never want more then 1 original node!
var mOriginal = mKrakTarget.Children.FirstOrDefault(x => x.Text == EnmKrakStatus.Original.ToString() && x.getProperty(Constants.UmbracoPropertyAliasStatus) != null && x.getProperty(Constants.UmbracoPropertyAliasStatus).Value as String == "Original");
// Does the original media node already exist?
bool originalExists = mOriginal != null;
// Do we need to keep a backup of the originally kraked image?
if (keepOriginal.Value)
{
if (!originalExists)
// No. Simply create a new "Original" media node under the current node, which will be used to store our "backup"
mOriginal = Media.MakeNew(EnmKrakStatus.Original.ToString(), MediaType.GetByAlias(mKrakTarget.ContentType.Alias), mKrakTarget.User, mKrakTarget.Id);
// We are only allowed to MODIFY the ORIGINAL media node if the FILE has CHANGED! If the original file has not been modified, then we are ONLY allowed to create a NEW media node (aka it didn't exist before)
if (hasChanged || !originalExists)
{
// Copy all properties of the current media node to the original (aka: BACKUP)
foreach (var p2 in mOriginal.GenericProperties)
p2.Value = mKrakTarget.getProperty(p2.PropertyType.Alias).Value;
// The image has been modified during the saving proces before, so correct that by specifying the correct original imag
p = mOriginal.getProperty(Constants.UmbracoPropertyAliasFile);
if (p != null)
// Save the original data, but replace the old relative filepath with the new one
p.Value = originalUmbracoFilePropertyData.Replace(relativeFilepath, newRelativeFilepath);
// The same for filesize
p = mOriginal.getProperty(Constants.UmbracoPropertyAliasSize);
if (p != null)
p.Value = originalSize;
// Set the "status" of the original image to "Original", so we know in the future this is the original image
p = mOriginal.getProperty(Constants.UmbracoPropertyAliasStatus);
if (p != null)
p.Value = EnmKrakStatus.Original.ToString();
// Save the original node. It will be placed directly underneath the current media node
mOriginal.Save();
// Now swap the folders so everything is correct again
string tmpFolder = absoluteDirectory + "_tmp";
System.IO.Directory.Move(absoluteDirectory, tmpFolder);
System.IO.Directory.Move(newAbsoluteDirectory, absoluteDirectory);
System.IO.Directory.Move(tmpFolder, newAbsoluteDirectory);
}
else
{
// Leave the original alone! So just replace the target folder with the compressed version
if (System.IO.Directory.Exists(absoluteDirectory))
//.........这里部分代码省略.........
示例15: Media_BeforeSave
// <summary>umbraco Media BeforeSav event: Media fiel prüfen
/// </summary>
void Media_BeforeSave(Media sender, umbraco.cms.businesslogic.SaveEventArgs e)
{
try
{
Config config = Config.GetConfig();
foreach (ConfigDatatype author in config.Datatypes)
{
foreach (Property pr in sender.GenericProperties)
{
if (author.Guid == pr.PropertyType.DataTypeDefinition.DataType.Id)
{
Property fileprop = sender.getProperty(pr.PropertyType.Alias);
e.Cancel = File_Scanner(fileprop);
}
}
}
}
catch (Exception ex)
{
}
if (html_msg.Length > 0)
{
HtmlContent(html_msg);
html_msg.Clear();
}
}