예제 #1
0
        public void UploadPhoto(Site e, IEnumerable <HttpPostedFileBase> files, string[] noteList)
        {
            var l = PicasaRepository.I.UploadPhoto2(files, noteList);

            if (l == null)
            {
                return;
            }

            for (int i = 0; i < l.Count; i++)
            {
                var entry = l[i];
                if (entry != null)
                {
                    SitePhoto photo = new SitePhoto();

                    Helper.UpdateIPhoto(files.ElementAt(i), noteList[i], entry, photo);

                    e.SitePhotoes.Add(photo);

                    Save();

                    string title = string.Format("SP_{0}_S_{1}", photo.ID.ToString(), e.ID.ToString());
                    PicasaRepository.I.UpdateTitle(photo.AtomUrl, title);
                }
            }
        }
예제 #2
0
        public void MovePhoto(SitePhoto photo, SiteDetail sd)
        {
            //PicasaRepository picasaRepository = new PicasaRepository();

            //if (string.IsNullOrEmpty(sd.AlbumUrl))
            //{
            //    sd.AlbumUrl = picasaRepository.CreateAlbum("SD_" + sd.ID.ToString());
            //}

            //var createdEntry = picasaRepository.MovingPhoto(photo.Url, photo.AtomUrl, sd.AlbumUrl, photo.Note);

            //if (createdEntry != null)
            //{
            //    var p = new SiteDetailPhoto();

            //    p.Url = createdEntry.Media.Content.Url;
            //    p.AtomUrl = createdEntry.EditUri.Content;
            //    p.TakenDate = photo.TakenDate;
            //    p.Lng = photo.Lng;
            //    p.Lat = photo.Lat;
            //    p.Note = photo.Note;
            //    sd.SiteDetailPhotoes.Add(p);

            //    DB.DeleteObject(photo);
            //}

            //Save();
        }
예제 #3
0
        public void UploadPhoto(Site e, IEnumerable <HttpPostedFileBase> files, string[] noteList)
        {
            if (files == null ||
                files.Count() == 0 ||
                files.Where(r => r != null).Count() == 0)
            {
                return;
            }

            PicasaService service = InitPicasaService();


            if (string.IsNullOrEmpty(e.AlbumUrl))
            {
                e.AlbumUrl = CreateAlbum(e.ID.ToString());
            }

            Uri postUri = new Uri(e.AlbumUrl.Replace("entry", "feed"));

            for (int i = 0; i < files.Count(); i++)
            {
                var item = files.ElementAt(i);

                if (item != null)
                {
                    DateTime?takenDate = GetMetadata_TakenDate(item);

                    MemoryStream mStream = new MemoryStream();

                    item.InputStream.Position = 0;
                    item.InputStream.CopyTo(mStream);
                    mStream.Position = 0;

                    //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, mStream, "image/jpeg", "");
                    //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, item.InputStream, "image/jpeg", "");
                    //photoUriList.Add(entry.Media.Content.Url);


                    PicasaEntry entry = new PhotoEntry();
                    entry.MediaSource = new Google.GData.Client.MediaFileSource(mStream, Path.GetFileName(item.FileName), "image/jpeg");
                    entry.Title       = new AtomTextConstruct(AtomTextConstructElementType.Title, noteList[i]);
                    entry.Summary     = new AtomTextConstruct(AtomTextConstructElementType.Summary, noteList[i]);

                    //service.InsertAsync(postUri, entry, new { SiteID = e.ID, AM = asyncManager });
                    PicasaEntry createdEntry = service.Insert(postUri, entry);

                    if (createdEntry != null)
                    {
                        SitePhoto photo = new SitePhoto();

                        photo.Url       = createdEntry.Media.Content.Url;
                        photo.AtomUrl   = createdEntry.EditUri.Content;
                        photo.TakenDate = takenDate;
                        photo.Note      = noteList[i];
                        e.SitePhotoes.Add(photo);
                    }
                }
            }
        }
예제 #4
0
        public void DeletePhoto(SitePhoto item)
        {
            PicasaService service = InitPicasaService();
            PicasaEntry a = (PicasaEntry)service.Get(item.AtomUrl);

            byte[] b;
            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(item.Url);
            WebResponse myResp = myReq.GetResponse();
            Stream stream = myResp.GetResponseStream();

            using (BinaryReader br = new BinaryReader(stream))
            {
                b = br.ReadBytes(500000);
                br.Close();
            }
            myResp.Close();

            MemoryStream mem = new MemoryStream(b);

            UploadPhotoToBackupAlbum(item.Site, mem);

            a.Delete();
        }
예제 #5
0
        public void DeletePhoto(SitePhoto item)
        {
            PicasaService service = InitPicasaService();
            PicasaEntry   a       = (PicasaEntry)service.Get(item.AtomUrl);

            byte[]         b;
            HttpWebRequest myReq  = (HttpWebRequest)WebRequest.Create(item.Url);
            WebResponse    myResp = myReq.GetResponse();
            Stream         stream = myResp.GetResponseStream();

            using (BinaryReader br = new BinaryReader(stream))
            {
                b = br.ReadBytes(500000);
                br.Close();
            }
            myResp.Close();

            MemoryStream mem = new MemoryStream(b);

            UploadPhotoToBackupAlbum(item.Site, mem);

            a.Delete();
        }
예제 #6
0
 /// <summary>
 /// Create a new SitePhoto object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static SitePhoto CreateSitePhoto(global::System.Int32 id)
 {
     SitePhoto sitePhoto = new SitePhoto();
     sitePhoto.ID = id;
     return sitePhoto;
 }
예제 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SitePhotoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSitePhotoes(SitePhoto sitePhoto)
 {
     base.AddObject("SitePhotoes", sitePhoto);
 }
예제 #8
0
        public void UploadPhoto(Site e, IEnumerable<HttpPostedFileBase> files, string[] noteList)
        {
            if (files == null
                || files.Count() == 0
                || files.Where(r => r != null).Count() == 0)
            {
                return;
            }

            PicasaService service = InitPicasaService();

            if (string.IsNullOrEmpty(e.AlbumUrl))
            {
                e.AlbumUrl = CreateAlbum(e.ID.ToString());
            }

            Uri postUri = new Uri(e.AlbumUrl.Replace("entry", "feed"));

            for (int i = 0; i < files.Count(); i++)
            {
                var item = files.ElementAt(i);

                if (item != null)
                {
                    DateTime? takenDate = GetMetadata_TakenDate(item);

                    MemoryStream mStream = new MemoryStream();

                    item.InputStream.Position = 0;
                    item.InputStream.CopyTo(mStream);
                    mStream.Position = 0;

                    //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, mStream, "image/jpeg", "");
                    //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, item.InputStream, "image/jpeg", "");
                    //photoUriList.Add(entry.Media.Content.Url);

                    PicasaEntry entry = new PhotoEntry();
                    entry.MediaSource = new Google.GData.Client.MediaFileSource(mStream, Path.GetFileName(item.FileName), "image/jpeg");
                    entry.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, noteList[i]);
                    entry.Summary = new AtomTextConstruct(AtomTextConstructElementType.Summary, noteList[i]);

                    //service.InsertAsync(postUri, entry, new { SiteID = e.ID, AM = asyncManager });
                    PicasaEntry createdEntry = service.Insert(postUri, entry);

                    if (createdEntry != null)
                    {
                        SitePhoto photo = new SitePhoto();

                        photo.Url = createdEntry.Media.Content.Url;
                        photo.AtomUrl = createdEntry.EditUri.Content;
                        photo.TakenDate = takenDate;
                        photo.Note = noteList[i];
                        e.SitePhotoes.Add(photo);
                    }
                }
            }
        }