当前位置: 首页>>代码示例>>C#>>正文


C# Photo.Save方法代码示例

本文整理汇总了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));
                                }
开发者ID:haimon74,项目名称:Easy-Fixup,代码行数:67,代码来源:SilverlightUpload.ashx.cs

示例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
                }
            }
        }
开发者ID:varlo,项目名称:Unona9,代码行数:101,代码来源:WebcamUpload.ashx.cs

示例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);
         }
     }
 }
开发者ID:haimon74,项目名称:Easy-Fixup,代码行数:31,代码来源:ImportDummyProfiles.aspx.cs

示例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));
                                        }
开发者ID:haimon74,项目名称:Easy-Fixup,代码行数:67,代码来源:FlashUpload.ashx.cs


注:本文中的Photo.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。