本文整理汇总了C#中Photo.VersionUri方法的典型用法代码示例。如果您正苦于以下问题:C# Photo.VersionUri方法的具体用法?C# Photo.VersionUri怎么用?C# Photo.VersionUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo.VersionUri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
private PhotoChanges Update (Photo photo) {
PhotoChanges changes = photo.Changes;
// Update photo.
if (changes.DescriptionChanged || changes.DefaultVersionIdChanged || changes.TimeChanged || changes.UriChanged || changes.RatingChanged || changes.MD5SumChanged )
Database.ExecuteNonQuery (
new DbCommand (
"UPDATE photos " +
"SET description = :description, " +
" default_version_id = :default_version_id, " +
" time = :time, " +
" uri = :uri, " +
" rating = :rating, " +
" md5_sum = :md5_sum " +
"WHERE id = :id ",
"description", photo.Description,
"default_version_id", photo.DefaultVersionId,
"time", DbUtils.UnixTimeFromDateTime (photo.Time),
"uri", photo.VersionUri (Photo.OriginalVersionId).OriginalString,
"rating", String.Format ("{0}", photo.Rating),
"md5_sum", photo.MD5Sum,
"id", photo.Id
)
);
// Update tags.
if (changes.TagsRemoved != null)
foreach (Tag tag in changes.TagsRemoved)
Database.ExecuteNonQuery (new DbCommand (
"DELETE FROM photo_tags WHERE photo_id = :photo_id AND tag_id = :tag_id",
"photo_id", photo.Id,
"tag_id", tag.Id));
if (changes.TagsAdded != null)
foreach (Tag tag in changes.TagsAdded)
Database.ExecuteNonQuery (new DbCommand (
"INSERT OR IGNORE INTO photo_tags (photo_id, tag_id) " +
"VALUES (:photo_id, :tag_id)",
"photo_id", photo.Id,
"tag_id", tag.Id));
// Update versions.
if (changes.VersionsRemoved != null)
foreach (uint version_id in changes.VersionsRemoved)
Database.ExecuteNonQuery (new DbCommand (
"DELETE FROM photo_versions WHERE photo_id = :photo_id AND version_id = :version_id",
"photo_id", photo.Id,
"version_id", version_id));
if (changes.VersionsAdded != null)
foreach (uint version_id in changes.VersionsAdded) {
PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
Database.ExecuteNonQuery (new DbCommand (
"INSERT OR IGNORE INTO photo_versions (photo_id, version_id, name, uri, protected, md5_sum) " +
"VALUES (:photo_id, :version_id, :name, :uri, :is_protected, :md5_sum)",
"photo_id", photo.Id,
"version_id", version_id,
"name", version.Name,
"uri", version.Uri.ToString (),
"is_protected", version.IsProtected,
"md5_sum", version.MD5Sum));
}
if (changes.VersionsModified != null)
foreach (uint version_id in changes.VersionsModified) {
PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
Database.ExecuteNonQuery (new DbCommand (
"UPDATE photo_versions SET name = :name, " +
"uri = :uri, protected = :protected, md5_sum = :md5_sum " +
"WHERE photo_id = :photo_id AND version_id = :version_id",
"name", version.Name,
"uri", version.Uri.ToString (),
"protected", version.IsProtected,
"photo_id", photo.Id,
"md5_sum", version.MD5Sum,
"version_id", version_id));
}
photo.Changes = null;
return changes;
}
示例2: UpdateMD5Sum
public void UpdateMD5Sum (Photo photo) {
string md5_sum = Photo.GenerateMD5 (photo.VersionUri (Photo.OriginalVersionId));
photo.MD5Sum = md5_sum;
Database.ExecuteNonQuery (
new DbCommand (
"UPDATE photos " +
"SET md5_sum = :md5_sum " +
"WHERE ID = :id",
"md5_sum", md5_sum,
"id", photo.Id
)
);
foreach (uint version_id in photo.VersionIds) {
if (version_id == Photo.OriginalVersionId)
continue;
PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion;
string version_md5_sum = Photo.GenerateMD5 (version.Uri);
if (version.MD5Sum == version_md5_sum)
continue;
version.MD5Sum = version_md5_sum;
photo.Changes.ChangeVersion (version_id);
}
Commit (photo);
}
示例3: DirectoryPath
protected static string DirectoryPath(Photo p)
{
return Path.GetDirectoryName(p.VersionUri(Photo.OriginalVersionId));
}