public void UploadPhoto(SiteMonitoring e, IEnumerable <HttpPostedFileBase> files, string[] noteList, bool?IsReview = null)
        {
            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)
                {
                    SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

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

                    photo.IsReview = IsReview;
                    e.SiteMonitoringPhotoes.Add(photo);

                    Save();

                    string title = string.Format("SMP_{0}_SM_{1}", photo.ID.ToString(), e.ID.ToString());

                    PicasaRepository.I.UpdateTitle(photo.AtomUrl, title);
                }
            }
        }
Beispiel #2
0
        public void DeletePhoto(SiteMonitoringPhoto 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.SiteMonitoring, mem);

            a.Delete();
        }
Beispiel #3
0
        public void DeletePhoto(SiteMonitoringPhoto 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.SiteMonitoring, mem);

            a.Delete();
        }
Beispiel #4
0
 /// <summary>
 /// Create a new SiteMonitoringPhoto object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static SiteMonitoringPhoto CreateSiteMonitoringPhoto(global::System.Int32 id)
 {
     SiteMonitoringPhoto siteMonitoringPhoto = new SiteMonitoringPhoto();
     siteMonitoringPhoto.ID = id;
     return siteMonitoringPhoto;
 }
Beispiel #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SiteMonitoringPhotoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSiteMonitoringPhotoes(SiteMonitoringPhoto siteMonitoringPhoto)
 {
     base.AddObject("SiteMonitoringPhotoes", siteMonitoringPhoto);
 }
Beispiel #6
0
        public void UploadPhoto(SiteMonitoring e, IEnumerable<HttpPostedFileBase> files, string[] noteList, bool isCheckDate = true, bool? IsReview = null)
        {
            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("M" + 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);

                    ContractDetailTimeline timeline = e.ContractDetail.ContractDetailTimelines.Where(r => r.Order == e.Order).FirstOrDefault();
                    if (
                        !isCheckDate ||
                        (timeline != null
                        && takenDate.HasValue
                        && timeline.Contains(takenDate))
                        )
                    {
                        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)
                        {
                            SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

                            photo.Url = createdEntry.Media.Content.Url;
                            photo.AtomUrl = createdEntry.EditUri.Content;
                            photo.TakenDate = takenDate;
                            photo.Note = noteList[i];
                            photo.IsReview = IsReview;

                            e.SiteMonitoringPhotoes.Add(photo);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public void UploadPhoto(SiteMonitoring e, IEnumerable <HttpPostedFileBase> files, string[] noteList, bool isCheckDate = true, bool?IsReview = null)
        {
            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("M" + 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);

                    ContractDetailTimeline timeline = e.ContractDetail.ContractDetailTimelines.Where(r => r.Order == e.Order).FirstOrDefault();
                    if (
                        !isCheckDate ||
                        (timeline != null &&
                         takenDate.HasValue &&
                         timeline.Contains(takenDate))
                        )
                    {
                        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)
                        {
                            SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

                            photo.Url       = createdEntry.Media.Content.Url;
                            photo.AtomUrl   = createdEntry.EditUri.Content;
                            photo.TakenDate = takenDate;
                            photo.Note      = noteList[i];
                            photo.IsReview  = IsReview;

                            e.SiteMonitoringPhotoes.Add(photo);
                        }
                    }
                }
            }
        }