예제 #1
0
        public static void ProcessProfilePhotoWithCrop(Member member, Image Original, Image Cropped)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName    = GlobalWebID + @".jpg";

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();

            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType      = (int)ResourceFileType.PhotoLarge;
            PhotoResourceFile.Path     = member.NickName + "/" + "pmed" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            Photo.SaveToDisk(Original, PhotoResourceFile.SavePath);

            //create the thumbnail
            ResourceFile ThumbnailResourceFile = new ResourceFile();

            ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
            ThumbnailResourceFile.ResourceType      = (int)ResourceFileType.PhotoThumbnail;
            ThumbnailResourceFile.Path     = member.NickName + "/" + "pthmb" + "/";
            ThumbnailResourceFile.FileName = FileName;
            ThumbnailResourceFile.Save();
            Photo.SaveToDisk(Cropped, ThumbnailResourceFile.SavePath);

            member.DefaultPhoto = ThumbnailResourceFile;
            member.ProfilePhotoResourceFileID = ThumbnailResourceFile.ResourceFileID;

            member.Save();
        }
예제 #2
0
        /// <summary>
        /// </summary>
        /// <param name="member"></param>
        /// <param name="image"></param>
        public static void ProcessProfilePhoto(Member member, Image image)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName    = GlobalWebID + @".jpg";

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();

            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType      = (int)ResourceFileType.PhotoLarge;
            PhotoResourceFile.Path     = member.NickName + "/" + "pmed" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

            //create the thumbnail
            ResourceFile ThumbnailResourceFile = new ResourceFile();

            ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
            ThumbnailResourceFile.ResourceType      = (int)ResourceFileType.PhotoThumbnail;
            ThumbnailResourceFile.Path     = member.NickName + "/" + "pthmb" + "/";
            ThumbnailResourceFile.FileName = FileName;
            ThumbnailResourceFile.Save();
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo102x102(MediumImage);
            Photo.SaveToDisk(ThumbnailImage, ThumbnailResourceFile.SavePath);

            member.DefaultPhoto = ThumbnailResourceFile;
            member.ProfilePhotoResourceFileID = ThumbnailResourceFile.ResourceFileID;

            member.Save();
        }
예제 #3
0
        public static void ProcessProfilePhoto(Int32 memberId, String nickname, Image image)
        {
            if (String.IsNullOrEmpty(nickname))
            {
                throw new ArgumentNullException("nickname");
            }

            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            var webId    = UniqueID.NewWebID();
            var fileName = String.Concat(webId, @".jpg");

            /* Create medium image. */
            var photoResourceFile = new ResourceFile()
            {
                WebResourceFileID = webId,
                ResourceType      = (int)ResourceFileType.PhotoLarge,
                Path     = String.Concat(nickname, "/pmed/"),
                FileName = fileName
            };

            photoResourceFile.Save();

            var mediumImage = Photo.Resize480x480(image);

            Photo.SaveToDisk(mediumImage, photoResourceFile.SavePath);

            /* Create thumbnail. */
            var thumbnailResourceFile = new ResourceFile()
            {
                WebResourceFileID = webId,
                ResourceType      = (int)ResourceFileType.PhotoThumbnail,
                Path     = String.Concat(nickname, "/pthmb/"),
                FileName = fileName
            };

            thumbnailResourceFile.Save();

            var thumbnailImage = Photo.ResizeTo102x102(mediumImage);

            Photo.SaveToDisk(thumbnailImage, thumbnailResourceFile.SavePath);

            Member.UpdateProfilePhotoResourceFileId(memberId, thumbnailResourceFile.ResourceFileID);

            mediumImage.Dispose();
            thumbnailImage.Dispose();
        }
예제 #4
0
        public static void ProcessAAFPhoto(Member member, AskAFriend AAF, Image image, int IndexOrder)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName    = GlobalWebID + @".jpg";

            AskAFriendPhoto photo = new AskAFriendPhoto();

            photo.AskAFriendID = AAF.AskAFriendID;
            photo.IndexOrder   = IndexOrder;

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();

            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType      = (int)ResourceFileType.AAFLarge;
            PhotoResourceFile.Path     = member.NickName + "/" + "aaflrge" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

            photo.PhotoResourceFileID = PhotoResourceFile.ResourceFileID;

            //create the thumbnail
            ResourceFile ThumbnailPhoto = new ResourceFile();

            ThumbnailPhoto.WebResourceFileID = GlobalWebID;
            ThumbnailPhoto.ResourceType      = (int)ResourceFileType.AAFThumbnail;
            ThumbnailPhoto.Path     = member.NickName + "/" + "aafthmb" + "/";
            ThumbnailPhoto.FileName = FileName;
            ThumbnailPhoto.Save();
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
            Photo.SaveToDisk(ThumbnailImage, ThumbnailPhoto.SavePath);

            photo.Save();

            if (IndexOrder == 1)
            {
                AAF.DefaultPhotoResourceFileID = ThumbnailPhoto.ResourceFileID;
            }

            AAF.Save();
        }
예제 #5
0
        /// <summary>
        /// Sets the thumbnail for a Video
        /// </summary>
        /// <param name="Thumbnail"></param>
        public void SetLiveThumbnail(Image Thumbnail)
        {
            Image  Resized = Photo.ResizeTo124x91(Thumbnail);
            Member member  = new Member(this.MemberID);

            ResourceFile thumbnailRes = new ResourceFile();

            thumbnailRes.WebResourceFileID = Misc.UniqueID.NewWebID();
            thumbnailRes.ResourceType      = (int)ResourceFileType.VideoThumbnail;
            thumbnailRes.FileName          = member.NickName + "/" + thumbnailRes.WebResourceFileID + ".jpg";

            string ThumbnailSaveLocation = member.NickName + @"\vthmb\" + thumbnailRes.WebResourceFileID + ".jpg";

            Photo.SaveToDisk(Resized, ThumbnailSaveLocation);

            thumbnailRes.Save();

            //need to add this to the LiveBroadcast table
            this.ThumbnailResourceFileID = thumbnailRes.ResourceFileID;
            this.Save();
        }
예제 #6
0
        public static NSpot ProcessNSpotPhoto(Member member, NSpot nSpot, Image image)
        {
            Database      db          = DatabaseFactory.CreateDatabase();
            DbConnection  conn        = db.CreateConnection();
            DbTransaction Transaction = null;

            try
            {
                conn.Open();
                Transaction = conn.BeginTransaction();

                string GlobalWebID = UniqueID.NewWebID();
                string FileName    = GlobalWebID + @".jpg";

                // create the large photo
                // just store the large image.. dont make a resource record
                System.Drawing.Image MainImage = Photo.Resize480x480(image);
                string Savepath = member.NickName + @"\" + "nslrge" + @"\" + FileName;
                Photo.SaveToDisk(MainImage, Savepath);

                //create the medium
                ResourceFile PhotoResourceFile = new ResourceFile();
                PhotoResourceFile.CreatedDT         = DateTime.Now;
                PhotoResourceFile.WebResourceFileID = GlobalWebID;
                PhotoResourceFile.ResourceType      = (int)ResourceFileType.NspotPhoto;
                PhotoResourceFile.Path     = member.NickName + "/" + "nsmed" + "/";
                PhotoResourceFile.FileName = FileName;
                PhotoResourceFile.Save(db);
                System.Drawing.Image MediumImage = Photo.Resize190x130(MainImage);
                Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

                //create the thumbnail
                ResourceFile ThumbnailResourceFile = new ResourceFile();
                ThumbnailResourceFile.CreatedDT         = DateTime.Now;
                ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
                ThumbnailResourceFile.ResourceType      = (int)ResourceFileType.NspotThumbnail;
                ThumbnailResourceFile.Path     = member.NickName + "/" + "nsthmb" + "/";
                ThumbnailResourceFile.FileName = FileName;
                ThumbnailResourceFile.Save(db);
                System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
                Photo.SaveToDisk(ThumbnailImage, ThumbnailResourceFile.SavePath);

                // attached the resource ids to the photos
                nSpot.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
                nSpot.PhotoResourceFileID     = PhotoResourceFile.ResourceFileID;

                nSpot.Save(db);

                Transaction.Commit();
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(nSpot);
        }
예제 #7
0
        // <summary>
        /// Lawrence: This method appears to be obselete and was used as an interim solution for video encoder...
        /// </summary>
        /// <returns></returns>
        public static void ProxyProcessVideo(Stream FLVStream, Member member, string UNCPathToUserDirectory, string VideoTitle)
        {
            if (VideoTitle.Length > 35)
            {
                VideoTitle = VideoTitle.Substring(0, 35);
            }

            string VideoFileName = UniqueID.NewWebID() + ".flv";

            string SavePath = UNCPathToUserDirectory + member.NickName + @"\video\" + VideoFileName;

            int Length = 256;

            Byte[] buffer    = new Byte[256];
            int    bytesRead = FLVStream.Read(buffer, 0, Length);

            FileStream fs = new FileStream(SavePath, FileMode.Create);

            // write the required bytes
            while (bytesRead > 0)
            {
                fs.Write(buffer, 0, bytesRead);
                bytesRead = FLVStream.Read(buffer, 0, Length);
            }

            FLVStream.Close();

            fs.Flush();
            fs.Close();

            ResourceFile VideoResourceFile = new ResourceFile();

            VideoResourceFile.WebResourceFileID = UniqueID.NewWebID();
            VideoResourceFile.FileName          = VideoFileName;
            VideoResourceFile.Path         = @"/" + member.NickName + @"/video/";
            VideoResourceFile.ResourceType = (int)ResourceFileType.Video;
            VideoResourceFile.Save();


            Process FFMpegProcess;

            FFMpegProcess = new System.Diagnostics.Process();

            string ThumbnailName     = UniqueID.NewWebID();
            string ThumbnailSavePath = OSRegistry.GetDiskUserDirectory() + member.NickName + @"\vthmb\";

            if (ThumbnailName.Length > 21)
            {
                ThumbnailName = ThumbnailName.Substring(0, 20);
            }

            string FullSavePath = ThumbnailSavePath + ThumbnailName;
            string arg          = "-i " + SavePath + " -an -ss 00:00:07 -t 00:00:01 -r 1 -y -s 160x120 " + FullSavePath + "%d.jpg";
            string cmd          = @"c:\ffmpeg.exe";

            FFMpegProcess = System.Diagnostics.Process.Start(cmd, arg);
            FFMpegProcess.WaitForExit();
            FFMpegProcess.Close();


            //ffmpeg must add a 1 to the end of the file
            ThumbnailName += "1.jpg";

            ResourceFile ThumbnailResourceFile = new ResourceFile();

            ThumbnailResourceFile.WebResourceFileID = UniqueID.NewWebID();
            ThumbnailResourceFile.FileName          = ThumbnailName;
            ThumbnailResourceFile.Path         = member.NickName + @"/vthmb/";
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.VideoThumbnail;
            ThumbnailResourceFile.Save();

            Video video = new Video();

            video.MemberID                = member.MemberID;
            video.WebVideoID              = UniqueID.NewWebID();
            video.Title                   = VideoTitle;
            video.Description             = "No Description";
            video.DTCreated               = DateTime.Now;
            video.VideoResourceFileID     = VideoResourceFile.ResourceFileID;
            video.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
            video.Save();

            // update the number of photos
            MemberProfile memberProfile = member.MemberProfile[0];

            memberProfile.NumberOfVideos++;
            memberProfile.Save();
        }
예제 #8
0
        /// <summary>
        /// Saves the video file to disk
        /// </summary>
        /// <returns></returns>
        public static void QueueVideoForEncoding(Video video, Stream FLVStream, string Extension, Member member, string VideoTitle)
        {
            if (VideoTitle.Length > 35)
            {
                VideoTitle = VideoTitle.Substring(0, 35);
            }

            string VideoFileName = UniqueID.NewWebID();
            string VideoPreprocessedInputFile = OSRegistry.GetDiskUserDirectory() + member.NickName + @"\video\" + VideoFileName + "." + Extension;

            string VideoInputFile  = member.NickName + @"\video\" + VideoFileName + "." + Extension;
            string VideoOutputFile = member.NickName + @"\video\" + VideoFileName + ".flv";

            int Length = 256;

            Byte[] buffer    = new Byte[256];
            int    bytesRead = FLVStream.Read(buffer, 0, Length);

            FileStream fs = new FileStream(VideoPreprocessedInputFile, FileMode.Create);

            // write the required bytes
            while (bytesRead > 0)
            {
                fs.Write(buffer, 0, bytesRead);
                bytesRead = FLVStream.Read(buffer, 0, Length);
            }

            FLVStream.Close();

            fs.Flush();
            fs.Close();

            ResourceFile VideoResourceFile = new ResourceFile();

            VideoResourceFile.WebResourceFileID = UniqueID.NewWebID();
            VideoResourceFile.FileName          = VideoFileName + ".flv";
            VideoResourceFile.Path         = @"/" + member.NickName + @"/video/";
            VideoResourceFile.ResourceType = (int)ResourceFileType.Video;
            VideoResourceFile.Save();

            string ThumbnailName     = UniqueID.NewWebID() + ".jpg";
            string ThumbnailSavePath = member.NickName + @"\vthmb\" + ThumbnailName;

            ResourceFile ThumbnailResourceFile = new ResourceFile();

            ThumbnailResourceFile.WebResourceFileID = UniqueID.NewWebID();
            ThumbnailResourceFile.FileName          = ThumbnailName;
            ThumbnailResourceFile.Path         = member.NickName + @"/vthmb/";
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.VideoThumbnail;
            ThumbnailResourceFile.Save();


            video.MemberID                = member.MemberID;
            video.WebVideoID              = UniqueID.NewWebID();
            video.Category                = 1;
            video.DTCreated               = DateTime.Now;
            video.VideoResourceFileID     = VideoResourceFile.ResourceFileID;
            video.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
            video.Status = (int)VideoStatus.EncoderQueue;
            video.Save();

            // update the number of photos
            MemberProfile memberProfile = member.MemberProfile[0];

            memberProfile.NumberOfVideos++;
            memberProfile.Save();

            VideoEncoderQueue VideoEncode = new VideoEncoderQueue();

            VideoEncode.VideoID             = video.VideoID;
            VideoEncode.VideoInputFile      = VideoInputFile;
            VideoEncode.VideoOutputFile     = VideoOutputFile;
            VideoEncode.ThumbnailOutputFile = ThumbnailSavePath;
            VideoEncode.Status = (int)VideoEncoderStatus.Ready;
            VideoEncode.Save();
        }
예제 #9
0
        // <summary>
        /// Lawrence: This method appears to be obselete and was used as an interim solution for video encoder... 
        /// </summary>
        /// <returns></returns>
        public static void ProxyProcessVideo(Stream FLVStream, Member member, string UNCPathToUserDirectory, string VideoTitle)
        {
            if (VideoTitle.Length > 35)
            {
                VideoTitle = VideoTitle.Substring(0, 35);
            }

            string VideoFileName = UniqueID.NewWebID() + ".flv";

            string SavePath = UNCPathToUserDirectory + member.NickName + @"\video\" + VideoFileName;

            int Length = 256;
            Byte[] buffer = new Byte[256];
            int bytesRead = FLVStream.Read(buffer, 0, Length);

            FileStream fs = new FileStream(SavePath, FileMode.Create);

            // write the required bytes
            while (bytesRead > 0)
            {
                fs.Write(buffer, 0, bytesRead);
                bytesRead = FLVStream.Read(buffer, 0, Length);
            }

            FLVStream.Close();

            fs.Flush();
            fs.Close();

            ResourceFile VideoResourceFile = new ResourceFile();
            VideoResourceFile.WebResourceFileID = UniqueID.NewWebID();
            VideoResourceFile.FileName = VideoFileName;
            VideoResourceFile.Path = @"/" + member.NickName + @"/video/";
            VideoResourceFile.ResourceType = (int)ResourceFileType.Video;
            VideoResourceFile.Save();


            Process FFMpegProcess;
            FFMpegProcess = new System.Diagnostics.Process();

            string ThumbnailName = UniqueID.NewWebID();
            string ThumbnailSavePath = OSRegistry.GetDiskUserDirectory() + member.NickName + @"\vthmb\";

            if (ThumbnailName.Length > 21)
            {
                ThumbnailName = ThumbnailName.Substring(0, 20);
            }

            string FullSavePath = ThumbnailSavePath + ThumbnailName;
            string arg = "-i " + SavePath + " -an -ss 00:00:07 -t 00:00:01 -r 1 -y -s 160x120 " + FullSavePath + "%d.jpg";
            string cmd = @"c:\ffmpeg.exe";

            FFMpegProcess = System.Diagnostics.Process.Start(cmd, arg);
            FFMpegProcess.WaitForExit();
            FFMpegProcess.Close();


            //ffmpeg must add a 1 to the end of the file
            ThumbnailName += "1.jpg";

            ResourceFile ThumbnailResourceFile = new ResourceFile();
            ThumbnailResourceFile.WebResourceFileID = UniqueID.NewWebID();
            ThumbnailResourceFile.FileName = ThumbnailName;
            ThumbnailResourceFile.Path = member.NickName + @"/vthmb/";
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.VideoThumbnail;
            ThumbnailResourceFile.Save();

            Video video = new Video();
            video.MemberID = member.MemberID;
            video.WebVideoID = UniqueID.NewWebID();
            video.Title = VideoTitle;
            video.Description = "No Description";
            video.DTCreated = DateTime.Now;
            video.VideoResourceFileID = VideoResourceFile.ResourceFileID;
            video.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
            video.Save();

            // update the number of photos
            MemberProfile memberProfile = member.MemberProfile[0];
            memberProfile.NumberOfVideos++;
            memberProfile.Save();

        }
예제 #10
0
        /// <summary>
        /// Sets the thumbnail for a Video
        /// </summary>
        /// <param name="Thumbnail"></param>
        public void SetLiveThumbnail(Image Thumbnail)
        {
            Image Resized = Photo.ResizeTo124x91(Thumbnail);
            Member member = new Member(this.MemberID);

            ResourceFile thumbnailRes = new ResourceFile();
            thumbnailRes.WebResourceFileID = Misc.UniqueID.NewWebID();
            thumbnailRes.ResourceType = (int)ResourceFileType.VideoThumbnail;
            thumbnailRes.FileName = member.NickName + "/" + thumbnailRes.WebResourceFileID + ".jpg";

            string ThumbnailSaveLocation = member.NickName + @"\vthmb\" + thumbnailRes.WebResourceFileID + ".jpg";

            Photo.SaveToDisk(Resized, ThumbnailSaveLocation);

            thumbnailRes.Save();

            //need to add this to the LiveBroadcast table
            this.ThumbnailResourceFileID = thumbnailRes.ResourceFileID;
            this.Save();

        }
예제 #11
0
        /// <summary>
        /// Saves the video file to disk
        /// </summary>
        /// <returns></returns>
        public static void QueueVideoForEncoding(Video video, Stream FLVStream,string Extension, Member member, string VideoTitle)
        {
            if (VideoTitle.Length > 35)
            {
                VideoTitle = VideoTitle.Substring(0, 35);
            }

            string VideoFileName = UniqueID.NewWebID();
            string VideoPreprocessedInputFile = OSRegistry.GetDiskUserDirectory() + member.NickName + @"\video\" + VideoFileName + "." + Extension;

            string VideoInputFile = member.NickName + @"\video\" + VideoFileName + "." + Extension;
            string VideoOutputFile = member.NickName + @"\video\" + VideoFileName + ".flv";

            int Length = 256;
            Byte[] buffer = new Byte[256];
            int bytesRead = FLVStream.Read(buffer, 0, Length);

            FileStream fs = new FileStream(VideoPreprocessedInputFile, FileMode.Create);

            // write the required bytes
            while (bytesRead > 0)
            {
                fs.Write(buffer, 0, bytesRead);
                bytesRead = FLVStream.Read(buffer, 0, Length);
            }

            FLVStream.Close();

            fs.Flush();
            fs.Close();

            ResourceFile VideoResourceFile = new ResourceFile();
            VideoResourceFile.WebResourceFileID = UniqueID.NewWebID();
            VideoResourceFile.FileName = VideoFileName + ".flv";
            VideoResourceFile.Path = @"/" + member.NickName + @"/video/";
            VideoResourceFile.ResourceType = (int)ResourceFileType.Video;
            VideoResourceFile.Save();

            string ThumbnailName = UniqueID.NewWebID() + ".jpg";
            string ThumbnailSavePath = member.NickName + @"\vthmb\" + ThumbnailName;

            ResourceFile ThumbnailResourceFile = new ResourceFile();
            ThumbnailResourceFile.WebResourceFileID = UniqueID.NewWebID();
            ThumbnailResourceFile.FileName = ThumbnailName;
            ThumbnailResourceFile.Path = member.NickName + @"/vthmb/";
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.VideoThumbnail;
            ThumbnailResourceFile.Save();

            
            video.MemberID = member.MemberID;
            video.WebVideoID = UniqueID.NewWebID();
            video.Category = 1;
            video.DTCreated = DateTime.Now;
            video.VideoResourceFileID = VideoResourceFile.ResourceFileID;
            video.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
            video.Status = (int)VideoStatus.EncoderQueue;
            video.Save();

            // update the number of photos
            MemberProfile memberProfile = member.MemberProfile[0];
            memberProfile.NumberOfVideos++;
            memberProfile.Save();

            VideoEncoderQueue VideoEncode = new VideoEncoderQueue();

            VideoEncode.VideoID = video.VideoID;
            VideoEncode.VideoInputFile = VideoInputFile;
            VideoEncode.VideoOutputFile = VideoOutputFile;
            VideoEncode.ThumbnailOutputFile = ThumbnailSavePath;
            VideoEncode.Status = (int)VideoEncoderStatus.Ready;
            VideoEncode.Save();

        }
예제 #12
0
        public static void ProcessProfilePhotoWithCrop(Member member, Image Original, Image Cropped)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName = GlobalWebID + @".jpg";

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();
            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType = (int)ResourceFileType.PhotoLarge;
            PhotoResourceFile.Path = member.NickName + "/" + "pmed" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            Photo.SaveToDisk(Original, PhotoResourceFile.SavePath);

            //create the thumbnail
            ResourceFile ThumbnailResourceFile = new ResourceFile();
            ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.PhotoThumbnail;
            ThumbnailResourceFile.Path = member.NickName + "/" + "pthmb" + "/";
            ThumbnailResourceFile.FileName = FileName;
            ThumbnailResourceFile.Save();
            Photo.SaveToDisk(Cropped, ThumbnailResourceFile.SavePath);

            member.DefaultPhoto = ThumbnailResourceFile;
            member.ProfilePhotoResourceFileID = ThumbnailResourceFile.ResourceFileID;

            member.Save();
        }
예제 #13
0
        /// <summary>
        /// </summary>
        /// <param name="member"></param>
        /// <param name="image"></param>
        public static void ProcessProfilePhoto(Member member, Image image)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName = GlobalWebID + @".jpg";

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();
            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType = (int)ResourceFileType.PhotoLarge;
            PhotoResourceFile.Path = member.NickName + "/" + "pmed" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

            //create the thumbnail
            ResourceFile ThumbnailResourceFile = new ResourceFile();
            ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
            ThumbnailResourceFile.ResourceType = (int)ResourceFileType.PhotoThumbnail;
            ThumbnailResourceFile.Path = member.NickName + "/" + "pthmb" + "/";
            ThumbnailResourceFile.FileName = FileName;
            ThumbnailResourceFile.Save();
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo102x102(MediumImage);
            Photo.SaveToDisk(ThumbnailImage, ThumbnailResourceFile.SavePath);

            member.DefaultPhoto = ThumbnailResourceFile;
            member.ProfilePhotoResourceFileID = ThumbnailResourceFile.ResourceFileID;

            member.Save();
        }
예제 #14
0
        public static void ProcessProfilePhoto(Int32 memberId, String nickname, Image image)
        {
            if (String.IsNullOrEmpty(nickname))
                throw new ArgumentNullException("nickname");
            
            if (image == null)
                throw new ArgumentNullException("image");

            var webId = UniqueID.NewWebID();
            var fileName = String.Concat(webId, @".jpg");

            /* Create medium image. */
            var photoResourceFile = new ResourceFile()
            {
                WebResourceFileID = webId,
                ResourceType = (int)ResourceFileType.PhotoLarge,
                Path = String.Concat(nickname, "/pmed/"),
                FileName = fileName
            };

            photoResourceFile.Save();

            var mediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(mediumImage, photoResourceFile.SavePath);

            /* Create thumbnail. */
            var thumbnailResourceFile = new ResourceFile()
            {
                WebResourceFileID = webId,
                ResourceType = (int)ResourceFileType.PhotoThumbnail,
                Path = String.Concat(nickname, "/pthmb/"),
                FileName = fileName
            };
            thumbnailResourceFile.Save();

            var thumbnailImage = Photo.ResizeTo102x102(mediumImage);
            Photo.SaveToDisk(thumbnailImage, thumbnailResourceFile.SavePath);

            Member.UpdateProfilePhotoResourceFileId(memberId, thumbnailResourceFile.ResourceFileID);

            mediumImage.Dispose();
            thumbnailImage.Dispose();
        }
예제 #15
0
        public static void ProcessAAFPhoto(Member member, AskAFriend AAF, Image image, int IndexOrder)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName = GlobalWebID + @".jpg";

            AskAFriendPhoto photo = new AskAFriendPhoto();
            photo.AskAFriendID = AAF.AskAFriendID;
            photo.IndexOrder = IndexOrder;

            //create the medium
            ResourceFile PhotoResourceFile = new ResourceFile();
            PhotoResourceFile.WebResourceFileID = GlobalWebID;
            PhotoResourceFile.ResourceType = (int)ResourceFileType.AAFLarge;
            PhotoResourceFile.Path = member.NickName + "/" + "aaflrge" + "/";
            PhotoResourceFile.FileName = FileName;
            PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(image);
            Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

            photo.PhotoResourceFileID = PhotoResourceFile.ResourceFileID;

            //create the thumbnail
            ResourceFile ThumbnailPhoto = new ResourceFile();
            ThumbnailPhoto.WebResourceFileID = GlobalWebID;
            ThumbnailPhoto.ResourceType = (int)ResourceFileType.AAFThumbnail;
            ThumbnailPhoto.Path = member.NickName + "/" + "aafthmb" + "/";
            ThumbnailPhoto.FileName = FileName;
            ThumbnailPhoto.Save();
            System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
            Photo.SaveToDisk(ThumbnailImage, ThumbnailPhoto.SavePath);

            photo.Save();

            if (IndexOrder == 1)
            {
                AAF.DefaultPhotoResourceFileID = ThumbnailPhoto.ResourceFileID;
            }

            AAF.Save();
        }
예제 #16
0
        public static NSpot ProcessNSpotPhoto(Member member, NSpot nSpot, Image image)
        {
            Database db = DatabaseFactory.CreateDatabase();
            DbConnection conn = db.CreateConnection();
            DbTransaction Transaction = null;

            try
            {
                conn.Open();
                Transaction = conn.BeginTransaction();

                string GlobalWebID = UniqueID.NewWebID();
                string FileName = GlobalWebID + @".jpg";

                // create the large photo
                // just store the large image.. dont make a resource record
                System.Drawing.Image MainImage = Photo.Resize480x480(image);
                string Savepath = member.NickName + @"\" + "nslrge" + @"\" + FileName;
                Photo.SaveToDisk(MainImage, Savepath);

                //create the medium
                ResourceFile PhotoResourceFile = new ResourceFile();
                PhotoResourceFile.CreatedDT = DateTime.Now;
                PhotoResourceFile.WebResourceFileID = GlobalWebID;
                PhotoResourceFile.ResourceType = (int)ResourceFileType.NspotPhoto;
                PhotoResourceFile.Path = member.NickName + "/" + "nsmed" + "/";
                PhotoResourceFile.FileName = FileName;
                PhotoResourceFile.Save(db);
                System.Drawing.Image MediumImage = Photo.Resize190x130(MainImage);
                Photo.SaveToDisk(MediumImage, PhotoResourceFile.SavePath);

                //create the thumbnail
                ResourceFile ThumbnailResourceFile = new ResourceFile();
                ThumbnailResourceFile.CreatedDT = DateTime.Now;
                ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
                ThumbnailResourceFile.ResourceType = (int)ResourceFileType.NspotThumbnail;
                ThumbnailResourceFile.Path = member.NickName + "/" + "nsthmb" + "/";
                ThumbnailResourceFile.FileName = FileName;
                ThumbnailResourceFile.Save(db);
                System.Drawing.Image ThumbnailImage = Photo.ResizeTo124x91(MediumImage);
                Photo.SaveToDisk(ThumbnailImage, ThumbnailResourceFile.SavePath);

                // attached the resource ids to the photos
                nSpot.ThumbnailResourceFileID = ThumbnailResourceFile.ResourceFileID;
                nSpot.PhotoResourceFileID = PhotoResourceFile.ResourceFileID;

                nSpot.Save(db);

                Transaction.Commit();

            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return nSpot;
        }