本文整理汇总了C#中Photo.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Photo.Save方法的具体用法?C# Photo.Save怎么用?C# Photo.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Photo
的用法示例。
在下文中一共展示了Photo.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
//.........这里部分代码省略.........
User = user,
PhotoAlbumID = PhotoAlbumID,
Name = String.Empty,
Description = String.Empty
};
if (Config.Photos.AutoApprovePhotos
|| billingPlanOptions.AutoApprovePhotos.Value
|| user.Level != null && user.Level.Restrictions.AutoApprovePhotos)
{
photo.Approved = true;
}
else
{
photo.Approved = false;
}
lock (threadLock)
{
int allPhotos = Photo.Search(-1, Username, -1, null, null, null, null).Length;
int maxPhotos = billingPlanOptions.MaxPhotos.Value;
if (user.Level != null && maxPhotos < user.Level.Restrictions.MaxPhotos)
maxPhotos = user.Level.Restrictions.MaxPhotos;
if (allPhotos >= maxPhotos)
{
context.Cache.Insert("silverlightPhotoUploadError_" + Username,
String.Format(
Lang.Trans("You cannot have more than {0} photos!"),
maxPhotos), null, DateTime.Now.AddMinutes(30),
Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
return;
}
photo.Save(true);
}
photo.Image.Dispose();
if (photo.Approved && !photo.PrivatePhoto)
{
#region Add NewFriendPhoto Event
var newEvent = new Event(photo.Username) { Type = Event.eType.NewFriendPhoto };
var newFriendPhoto = new NewFriendPhoto();
newFriendPhoto.PhotoID = photo.Id;
newEvent.DetailsXML = Misc.ToXml(newFriendPhoto);
newEvent.Save();
string[] usernames = User.FetchMutuallyFriends(photo.Username);
foreach (string friendUsername in usernames)
{
if (Config.Users.NewEventNotification)
{
string text =
String.Format("Your friend {0} has uploaded a new photo".Translate(),
"<b>" + photo.Username + "</b>");
string thumbnailUrl = ImageHandler.CreateImageUrl(photo.Id, 50, 50, false, true,
true);
User.SendOnlineEventNotification(photo.Username, friendUsername,
text, thumbnailUrl,
UrlRewrite.CreateShowUserPhotosUrl(
photo.Username));
}
示例2: ProcessRequest
//.........这里部分代码省略.........
if (Config.Photos.DoWatermark
&& bmp.Width >= Config.Photos.MinWidthToWatermark
&& bmp.Height >= Config.Photos.MinHeightToWatermark)
{
Image watermark;
if (context.Cache["Watermark_Image"] == null)
{
string filename = context.Server.MapPath("~/Images") + "/Watermark.png";
watermark = Image.FromFile(filename);
context.Cache.Add("Watermark_Image", watermark, new CacheDependency(filename),
Cache.NoAbsoluteExpiration, TimeSpan.FromHours(24),
CacheItemPriority.NotRemovable, null);
}
else
{
watermark = (Image)context.Cache["Watermark_Image"];
}
try
{
lock (watermark)
{
Photo.ApplyWatermark(bmp, watermark, Config.Photos.WatermarkTransparency,
Config.Photos.WatermarkPosition);
}
}
catch (Exception err)
{
Global.Logger.LogWarning("Unable to apply watermark", err);
}
}
BillingPlanOptions billingPlanOptions = null;
Subscription subscription = Subscription.FetchActiveSubscription(Username);
if (subscription == null)
billingPlanOptions = new BillingPlanOptions();
else
{
BillingPlan plan = BillingPlan.Fetch(subscription.PlanID);
billingPlanOptions = plan.Options;
}
Photo photo = new Photo();
photo.Image = bmp;
photo.ExplicitPhoto = false;
photo.User = user;
photo.PhotoAlbumID = PhotoAlbumID;
photo.Name = String.Empty;
photo.Description = String.Empty;
if (Config.Photos.AutoApprovePhotos
|| billingPlanOptions.AutoApprovePhotos.Value
|| user.Level != null && user.Level.Restrictions.AutoApprovePhotos)
{
photo.Approved = true;
}
else
{
photo.Approved = false;
}
photo.Save(true);
photo.Image.Dispose();
if (photo.Approved && !photo.PrivatePhoto)
{
#region Add NewFriendPhoto Event
Event newEvent = new Event(photo.Username);
newEvent.Type = Event.eType.NewFriendPhoto;
NewFriendPhoto newFriendPhoto = new NewFriendPhoto();
newFriendPhoto.PhotoID = photo.Id;
newEvent.DetailsXML = Misc.ToXml(newFriendPhoto);
newEvent.Save();
string[] usernames = Classes.User.FetchMutuallyFriends(photo.Username);
foreach (string friendUsername in usernames)
{
if (Config.Users.NewEventNotification)
{
string text = String.Format("Your friend {0} has uploaded a new photo".Translate(),
"<b>" + photo.Username + "</b>");
string thumbnailUrl = ImageHandler.CreateImageUrl(photo.Id, 50, 50, false, true, true);
Classes.User.SendOnlineEventNotification(photo.Username, friendUsername,
text, thumbnailUrl,
UrlRewrite.CreateShowUserPhotosUrl(
photo.Username));
}
}
#endregion
}
}
}
示例3: StoreUserPhoto
private void StoreUserPhoto(User user, string photoPath, bool isPrimary)
{
if (photoPath.IsNotNullOrEmpty() && File.Exists(photoPath))
{
try
{
using (var image = System.Drawing.Image.FromFile(photoPath))
{
var photo = new Photo();
photo.Image = image;
photo.Primary = isPrimary;
photo.Approved = true;
photo.Name = String.Empty;
photo.Description = String.Empty;
photo.User = user;
photo.Save(true);
if (isPrimary)
Photo.SetPrimary(user.Username, photo);
photo.ApprovePhoto(CurrentAdminSession.Username);
}
var destination = photoPath.Replace(".jpg", "v.jpg");
File.Copy(photoPath, destination);
File.Delete(photoPath);
}
catch (Exception ex)
{
Log(ex);
}
}
}
示例4: ProcessRequest
//.........这里部分代码省略.........
photo.ExplicitPhoto = false;
photo.User = user;
photo.PhotoAlbumID = PhotoAlbumID;
photo.Name = String.Empty;
photo.Description = String.Empty;
if (Config.Photos.AutoApprovePhotos
|| billingPlanOptions.AutoApprovePhotos.Value
|| user.Level != null && user.Level.Restrictions.AutoApprovePhotos)
{
photo.Approved = true;
}
else
{
photo.Approved = false;
}
lock(threadLock)
{
int allPhotos = Photo.Search(-1, Username, -1, null, null, null, null).Length;
int maxPhotos = billingPlanOptions.MaxPhotos.Value;
if (user.Level != null && maxPhotos < user.Level.Restrictions.MaxPhotos)
maxPhotos = user.Level.Restrictions.MaxPhotos;
if (allPhotos >= maxPhotos)
{
context.Cache.Insert("flashPhotoUploadError_" + Username,
String.Format(
Lang.Trans("You cannot have more than {0} photos!"),
maxPhotos), null, DateTime.Now.AddMinutes(30),
Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
return;
}
photo.Save(true);
}
photo.Image.Dispose();
if (photo.Approved && !photo.PrivatePhoto)
{
#region Add NewFriendPhoto Event
Event newEvent = new Event(photo.Username);
newEvent.Type = Event.eType.NewFriendPhoto;
NewFriendPhoto newFriendPhoto = new NewFriendPhoto();
newFriendPhoto.PhotoID = photo.Id;
newEvent.DetailsXML = Misc.ToXml(newFriendPhoto);
newEvent.Save();
string[] usernames = Classes.User.FetchMutuallyFriends(photo.Username);
foreach (string friendUsername in usernames)
{
if (Config.Users.NewEventNotification)
{
string text = String.Format("Your friend {0} has uploaded a new photo".Translate(),
"<b>" + photo.Username + "</b>");
string thumbnailUrl = ImageHandler.CreateImageUrl(photo.Id, 50, 50, false, true, true);
Classes.User.SendOnlineEventNotification(photo.Username, friendUsername,
text, thumbnailUrl,
UrlRewrite.CreateShowUserPhotosUrl(
photo.Username));
}