Esempio n. 1
0
        public List <Photo> GetListFor(string albumId)
        {
            var service = new PicasaService("GPhotoSync");

            service.SetAuthenticationToken(_credentials.AccessToken);

            var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_credentials.User, albumId));

            query.ExtraParameters = "imgmax=d";
            var feed = service.Query(query);

            if (feed != null)
            {
                var list = feed.Entries
                           .OfType <PicasaEntry>()
                           .Select(x =>
                {
                    var accessor = new PhotoAccessor(x);

                    return(new Photo
                    {
                        Id = accessor.Id,
                        Title = accessor.PhotoTitle,
                        Path = x.Media.Content.Url
                    });
                });

                return(list.OfType <Photo>().ToList());
            }
            else
            {
                return(new List <Photo>());
            }
        }
Esempio n. 2
0
    public string uploadImageToGoogle(string path, string username, string password, string blogId)
    {
        if (!System.IO.File.Exists(path))
        {
            return("Error! Image file not found");
        }
        ///////////////////////token session and shits...///////////
        PicasaService service = new PicasaService("HowToFixPRO");

        service.setUserCredentials(username, password);
        /////////////////cdefault album is dropBox or something////
        Uri postUri = new Uri(PicasaQuery.CreatePicasaUri(username));

        System.IO.FileInfo   fileInfo   = new System.IO.FileInfo(path);
        System.IO.FileStream fileStream = fileInfo.OpenRead();

        PicasaEntry entry = (PicasaEntry)service.Insert(postUri, fileStream, "image/png", "nameOfYourFile");

        fileStream.Close();

        PhotoAccessor ac         = new PhotoAccessor(entry);
        string        contentUrl = entry.Media.Content.Attributes["url"] as string;

        return(contentUrl);
    }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Session["user"] != null && Request.QueryString["album"] != null)
                {
                    PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(((User)Session["user"]).Username, Request.QueryString["album"] as string));

                    PicasaService tmp  = Session["service"] as PicasaService;
                    PicasaFeed    feed = tmp.Query(query);

                    List <object> data = new List <object>(feed.Entries.Count);
                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        data.Add(new
                        {
                            name = entry.Title.Text,
                            url  = entry.Content.AbsoluteUri,
                        });
                    }
                    //this.Store1.T
                    this.Store1.DataSource = data;
                    this.Store1.DataBind();
                }
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    string[] filePaths = Directory.GetFiles(@"C:\WeddApp\upload");
                    DateTime current   = new DateTime();
                    for (int i = 0; i < filePaths.Length; i++)
                    {
                        PicasaService myPicasa = new PicasaService("Vikash-Test-Picasa");
                        //Passing GMail credentials(EmailID and Password)
                        myPicasa.setUserCredentials("*****@*****.**", "0542686874");

                        //User ID and AlbumID has been used to create new URL
                        Uri newURI = new Uri(PicasaQuery.CreatePicasaUri("hagit.oded", "5780002529047522017"));

                        //Image path which we are uploading
                        current = DateTime.Now;
                        System.IO.FileInfo   newFile   = new System.IO.FileInfo(filePaths[i]);
                        System.IO.FileStream neFStream = newFile.OpenRead();
                        PicasaEntry          newEntry  = (PicasaEntry)myPicasa.Insert(newURI, neFStream, "Image/jpeg", Convert.ToString(current));
                        Console.Out.WriteLine("Image " + newFile.Name + " uploaded");
                        neFStream.Close();
                        File.Delete(filePaths[i]);
                    }
                    Thread.Sleep(ts);
                }
                catch (Exception ex)
                {
                    Console.Out.WriteLine(ex.Message);
                    System.Diagnostics.EventLog.WriteEntry("WeddApp", ex.Message, System.Diagnostics.EventLogEntryType.Error, 626);
                }
            }
        }
Esempio n. 5
0
        public static IEnumerable <PicasaAlbum> GetAlbums()
        {
            var           albums  = new List <PicasaAlbum>();
            PicasaService service = new PicasaService("PicasaUnlistedAlbums");

            service.setUserCredentials(WebConfigurationManager.AppSettings["Username"], WebConfigurationManager.AppSettings["Password"]);
            AlbumQuery query           = new AlbumQuery(PicasaQuery.CreatePicasaUri("default"));
            PicasaFeed feed            = service.Query(query);
            var        albumsToExclude = WebConfigurationManager.AppSettings["AlbumsToExclude"].Split(',').ToList();

            foreach (var atomEntry in feed.Entries)
            {
                var entry = (PicasaEntry)atomEntry;
                if (albumsToExclude.Contains(entry.Title.Text) || entry.Title.Text.Contains("Hangout"))
                {
                    continue;
                }
                var album = new PicasaAlbum
                {
                    Title     = entry.Title.Text,
                    Thumbnail = entry.Media.Thumbnails[0].Url,
                    Link      = entry.AlternateUri.Content
                };
                albums.Add(album);
            }
            return(albums);
        }
Esempio n. 6
0
        public Picture AddPictureToAlbum(string albumID, Stream image, string imageName, string title, string description, DateTime?positionDateTime, Position position)
        {
            var service = new PicasaService(PicasaConfiguration.Settings.Application.Name);

            service.setUserCredentials(PicasaConfiguration.Settings.Authentication.Username, PicasaConfiguration.Settings.Authentication.Password);

            var postUri = new Uri(PicasaQuery.CreatePicasaUri(PicasaConfiguration.Settings.Authentication.Username, albumID));

            var entry = (PicasaEntry)service.Insert(postUri, image, "image/jpeg", imageName);

            entry.Title.Text   = title;
            entry.Summary.Text = description;

            if (positionDateTime != null)
            {
                entry.SetPhotoExtensionValue("timestamp", Convert.ToTimestamp(positionDateTime.Value));
            }

            if (position != null)
            {
                entry.Location           = new GeoRssWhere();
                entry.Location.Latitude  = position.Latitude;
                entry.Location.Longitude = position.Longitude;
            }

            entry = (PicasaEntry)entry.Update();

            return(PicasaDataMapper.MapPicasaImage(entry));
        }
Esempio n. 7
0
        public void on_Click(object sender, DirectEventArgs e)
        {
            if (Session["service"] != null && Session["user"] != null)
            {
                //String name = ComboBox1.SelectedItem.Value;

                string path = this.FileUploadField1.FileName;
                path = Server.MapPath(path);

                User u       = Session["user"] as User;
                Uri  postUri = new Uri(PicasaQuery.CreatePicasaUri("diegoturciostc", "5680246730142935889"));

                System.IO.Stream fileInfo = this.FileUploadField1.PostedFile.InputStream;
                int buffer = 1024 * 1024;
                System.IO.FileStream filestream = null;//new System.IO.FileStream(path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                filestream = System.IO.File.Create(path);

                filestream.SetLength(fileInfo.Length);
                int    bytesRead = -1;
                byte[] bytes     = new byte[buffer];
                while ((bytesRead = fileInfo.Read(bytes, 0, buffer)) > 0)
                {
                    filestream.Write(bytes, 0, bytesRead);
                }
                PicasaService tmp = Session["service"] as PicasaService;

                PicasaEntry entry = (PicasaEntry)tmp.Insert(postUri, filestream, "image/jpeg", path);
                filestream.Close();

                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void PhotosAuthenticationTest()
        {
            Tracing.TraceMsg("Entering PhotosAuthenticationTest");

            PicasaQuery   query   = new PicasaQuery();
            PicasaService service = new PicasaService("unittests");

            query.KindParameter = "album,tag";

            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                query.Uri = new Uri(this.defaultPhotosUri);
                AtomFeed feed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("PhotoAuthTest"));

                if (feed != null && feed.Entries.Count > 0)
                {
                    Tracing.TraceMsg("Found a Feed " + feed.ToString());
                    DisplayExtensions(feed);

                    foreach (AtomEntry entry in feed.Entries)
                    {
                        Tracing.TraceMsg("Found an entry " + entry.ToString());
                        DisplayExtensions(entry);
                    }
                }
            }
        }
Esempio n. 9
0
        private void GetPhotosFromAlbum(Album album)
        {
            int  pageSize    = 500;
            long pageCount   = album.NumPhotos / pageSize;
            int  currentPage = 0;
            int  num         = 0;

            Console.WriteLine("Album: {0} ({1})", album.Title, album.NumPhotos);

            while (currentPage <= pageCount)
            {
                PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.Service.Credentials.Username, album.Id));
                query.NumberToRetrieve = pageSize;
                query.StartIndex       = currentPage * pageSize;
                query.ExtraParameters += "imgmax=d";

                PicasaFeed feed = this.Service.Query(query);

                string destinationFolder = Path.Combine(this.DestinationRootPath, Utils.ScrubStringForFileSystem(album.Title));

                foreach (PicasaEntry entry in feed.Entries)
                {
                    Console.Write("\t [{0}/{1}]", num++.ToString("D4"), album.NumPhotos.ToString("D4"));
                    DownloadPhotoDetails(entry, this.Service, destinationFolder);
                }

                currentPage++;
            }
        }
        public ActionResult About()
        {
            string user = "******";

            PicasaService service = new PicasaService("PhotoBrowser");

            service.setUserCredentials(user, "**********");

            AlbumQuery query = new AlbumQuery();

            query.Uri = new Uri(PicasaQuery.CreatePicasaUri(user));

            PicasaFeed picasaFeed = service.Query(query);

            List <PicasaEntry> result = new List <PicasaEntry>();

            if (picasaFeed != null && picasaFeed.Entries.Count > 0)
            {
                foreach (PicasaEntry entry in picasaFeed.Entries)
                {
                    result.Add(entry);
                }
            }

            return(View(result));
        }
        public void PicasaQueryConstructorTest()
        {
            string queryUri = "http://www.google.com/test";
            string expected = "http://www.google.com/test?kind=tag";

            PicasaQuery target = new PicasaQuery(queryUri);

            Assert.AreEqual(new Uri(expected), target.Uri);
        }
        public void ThumbsizeTest()
        {
            PicasaQuery target   = new PicasaQuery(); // TODO: Initialize to an appropriate value
            string      expected = "TestValue";
            string      actual;

            target.Thumbsize = expected;
            actual           = target.Thumbsize;
            Assert.AreEqual(expected, actual);
        }
        public void AccessTest()
        {
            PicasaQuery target = new PicasaQuery(); // TODO: Initialize to an appropriate value

            PicasaQuery.AccessLevel expected = PicasaQuery.AccessLevel.AccessPrivate;
            PicasaQuery.AccessLevel actual;
            target.Access = expected;
            actual        = target.Access;
            Assert.AreEqual(expected, actual);
        }
        public void KindParameterTest()
        {
            PicasaQuery target   = new PicasaQuery(); // TODO: Initialize to an appropriate value
            string      expected = "TestValue";
            string      actual;

            target.KindParameter = expected;
            actual = target.KindParameter;
            Assert.AreEqual(expected, actual);
        }
        public List <PicasaWebAlbum> QueryAlbums(BackgroundWorker worker, int overallJobPercent)
        {
            // Create an authentication factory to deal with logging in.
            GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName);

            authFactory.AccountType = "GOOGLE_OR_HOSTED";


            this.m_albumQuery                  = new AlbumQuery(PicasaQuery.CreatePicasaUri("default"));
            this.m_albumQuery.Access           = PicasaQuery.AccessLevel.AccessAll;
            this.m_albumService                = new PicasaService(authFactory.ApplicationName);
            this.m_albumService.RequestFactory = authFactory;
            // this.m_albumService.setUserCredentials(this.m_userName, this.m_password);
            //string token = this.m_albumService.QueryAuthenticationToken();
            this.m_albumService.SetAuthenticationToken(this.mUserToken);
            List <PicasaWebAlbum> retval = new List <PicasaWebAlbum>();
            decimal count      = ((decimal)overallJobPercent / 100) * 10;
            int     smallCount = (int)count;

            try
            {
                worker.ReportProgress(0, (object)"Creating proxy");
                CreateAlbumProxy();
                worker.ReportProgress(smallCount, (object)"Proxy created");
                worker.ReportProgress(0, (object)"Querying google");
                this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery);
                worker.ReportProgress(smallCount, (object)"Done");
            }
            catch (Exception e)
            {
                this.m_albumQuery = null;
                this.m_albumService.RequestFactory = null;
                this.m_albumService = null;
                this.m_albumFeed    = null;
                retval = null;
                throw new Exception("PicasaReader failed when downloading album feed for " + this.m_userName, e);
            }
            if (this.m_albumFeed.Entries.Count > 0)
            {
                int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_albumFeed.Entries.Count), 0);
                worker.ReportProgress(0, (object)"Processing album data");
                foreach (PicasaEntry entry in this.m_albumFeed.Entries)
                {
                    AlbumAccessor ac = new AlbumAccessor(entry);

                    retval.Add(new PicasaWebAlbum(entry.Title.Text, entry.Updated, ac.NumPhotos, Convert.ToUInt64(ac.Id)));
                    worker.ReportProgress(percent, null);
                }
            }
            this.m_albumQuery = null;
            this.m_albumService.RequestFactory = null;
            this.m_albumService = null;
            this.m_albumFeed    = null;
            return(retval);
        }
Esempio n. 16
0
        public AlbumsQuery(GooglePhotosService service)
        {
            this.service = service;

            AlbumQuery albumsQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default"));

            albumsQuery.ExtraParameters = "imgmax=d";
            PicasaFeed albumsFeed = service.PicasaService.Query(albumsQuery);

            picasaAlbums = albumsFeed.Entries.OfType <PicasaEntry> ().ToArray();
        }
Esempio n. 17
0
        private void buttonGetAlbumList_Click(object sender, EventArgs e)
        {
            authenticate();

            string userName = comboLogin.Text;

            disableItemsForRun();

            Thread thr = new Thread(new ThreadStart(delegate
            {
                try
                {
                    AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(userName));

                    PicasaFeed feed = service.Query(query);

                    Invoke(new MethodInvoker(delegate
                    {
                        listAlbums.Items.Clear();
                        albumMap.Clear();

                        foreach (PicasaEntry entry in feed.Entries)
                        {
                            AlbumAccessor ac = new AlbumAccessor(entry);
                            listAlbums.Items.Add(ac.AlbumTitle);
                            albumMap[ac.AlbumTitle] = ac;
                        }

                        if (feed.Entries.Count > 0)
                        {
                            listAlbums.SelectedIndex = 0;
                        }

                        buttonGetAlbumList.Enabled = true;

                        updateItems();
                    }));
                }
                catch (Exception ex)
                {
                    Invoke(new MethodInvoker(delegate
                    {
                        uploadLog.Text = "Album list upload failed: " + ex.Message + "\r\n";

                        listAlbums.Items.Clear();
                        albumMap.Clear();

                        updateItems();
                    }));
                }
            }));

            thr.Start();
        }
Esempio n. 18
0
        /// <summary>
        /// Gets the album list.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>Dictionary of albums.</returns>
        public Dictionary <string, string> GetAlbumList(string user)
        {
            Dictionary <string, string> albums = new Dictionary <string, string>();
            PicasaFeed picasaFeed = this.picasaService.Query(new AlbumQuery(PicasaQuery.CreatePicasaUri(user)));

            foreach (AtomEntry x in picasaFeed.Entries)
            {
                albums[x.FeedUri] = x.Title.Text;
            }

            return(albums);
        }
        public string CreateAlbum(string name, bool isBackup = false)
        {
            AlbumEntry newEntry = new AlbumEntry();

            newEntry.Title.Text   = name + (isBackup ? "B" : "");
            newEntry.Summary.Text = newEntry.Title.Text;

            Uri feedUri = new Uri(PicasaQuery.CreatePicasaUri(AppSetting.GoogleUsername).ToHttpsUri());

            PicasaEntry createdEntry = (PicasaEntry)PicasaService.Insert(feedUri, newEntry);

            //5507469898148065681
            return(createdEntry.EditUri.Content);
        }
Esempio n. 20
0
        public ContentQuery(GooglePhotosService service, DiscretePicasaAlbum album)
        {
            this.service = service;
            this.album   = album;

            Picasa.Album picasaAlbum = new Picasa.Album();
            picasaAlbum.AtomEntry = album.Entry;

            PhotoQuery picturesQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("default", picasaAlbum.Id));

            picturesQuery.ExtraParameters = "imgmax=d";
            PicasaFeed picturesFeed = service.PicasaService.Query(picturesQuery);

            picasaPictures = picturesFeed.Entries.OfType <PicasaEntry> ().ToArray();
        }
        /// <summary>
        /// Do the actual upload to Picasa
        /// For more details on the available parameters, see: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_dotnet.html
        /// </summary>
        /// <param name="imageData">byte[] with image data</param>
        /// <returns>PicasaResponse</returns>
        public static PicasaInfo UploadToPicasa(byte[] imageData, string title, string filename, string contentType)
        {
            PicasaService service = new PicasaService(Picasa_APPLICATION_NAME);

            service.setUserCredentials(config.Username, config.Password);

            Uri postUri = new Uri(PicasaQuery.CreatePicasaUri(config.Username));

            // build the data stream
            Stream data = new MemoryStream(imageData);

            PicasaEntry entry = (PicasaEntry)service.Insert(postUri, data, contentType, filename);

            return(RetrievePicasaInfo(entry));
        }
        public void CreatePicasaUriTest2()
        {
            string userID = "*****@*****.**";
            Uri    test   = null;

            try
            {
                test = new Uri(PicasaQuery.CreatePicasaUri(userID));
            }
            catch (Exception)
            {
            }

            Assert.IsNotNull(test);
        }
Esempio n. 23
0
        public PagedList <AlbumSummary> ListAlbums(int page, int pageSize)
        {
            var query = new AlbumQuery(PicasaQuery.CreatePicasaUri(PicasaConfiguration.Settings.Gallery.User))
            {
                Thumbsize        = PicasaConfiguration.Settings.Pictures.ThumbnailSize.ToString(),
                StartIndex       = (page - 1) * pageSize + 1,
                NumberToRetrieve = pageSize
            };

            var feed  = GetPicasaFeed(query);
            var items = from PicasaEntry pictureEntry in feed.Entries select PicasaDataMapper.MapPicasaAlbum(pictureEntry);

            items = items.Where(item => item.Title != "Profile Photos" && item.Title != "Scrapbook Photos");

            return(new PagedList <AlbumSummary>(items, Utils.CalculatePageNumber(feed.StartIndex, feed.ItemsPerPage), feed.ItemsPerPage, Utils.CalculatePageNumber(feed.TotalResults, feed.ItemsPerPage)));
        }
Esempio n. 24
0
        public void DownloadMetadata()
        {
            AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(Username));

            query.ExtraParameters += "imgmax=d"; // passing this param allows us to get the original image size.

            PicasaFeed feed = Service.Query(query);

            foreach (PicasaEntry entry in feed.Entries)
            {
                Album album = GetAlbum(entry);
                this.Albums.Add(album);

                this.TotalImageCount += album.NumPhotos;
            }
        }
        /// <summary>
        /// Syncs a local folder to an online Picasa Web Album location
        /// </summary>
        /// <param name="folderPath">The source folder to sync.</param>
        public void SyncFolder(string folderPath)
        {
            ResetCounters();
            PicasaService session = new PicasaService("PicasaWebSync");

            session.setUserCredentials(this.PicasaUsername, this.PicasaPassword);
            AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername));

            try
            {
                WriteOutput("[Connecting to Picasa web service]");
                //fetch all albums
                PicasaFeed albumFeed = session.Query(query);

                WriteOutput("[Starting sync]");

                folderPath = folderPath.TrimEnd(new char[] { '\\' });
                DirectoryInfo sourceFolder = new DirectoryInfo(folderPath);
                m_baseDirectoryName = sourceFolder.Name;

                SyncFolder(sourceFolder, null, this.AlbumAccess, this.IncludeSubFolders, session, albumFeed);
            }
            catch (GDataRequestException gdrex)
            {
                if (gdrex.ResponseString.Contains(GDATA_RESPONSE_BADAUTH))
                {
                    throw new AuthenticationException("Picasa error - username and/or password is incorrect!  Check the config file values.");
                }
                else
                {
                    throw new Exception(string.Format("Picasa error - {0}", gdrex.ResponseString));
                }
            }

            WriteOutput("[Done]");
            WriteOutput(string.Empty);
            WriteOutput("Summary:");
            WriteOutput(string.Format("  Folders skipped: {0}", m_folderSkipCount.ToString()));
            WriteOutput(string.Format("   Albums created: {0}", m_albumCreateCount.ToString()));
            WriteOutput(string.Format("   Albums updated: {0}", m_albumUpdateCount.ToString()));
            WriteOutput(string.Format("   Albums deleted: {0}", m_albumDeleteCount.ToString()));
            WriteOutput(string.Format("   Files uploaded: {0}", m_fileCreateCount.ToString()));
            WriteOutput(string.Format("    Files removed: {0}", m_fileDeleteCount.ToString()));
            WriteOutput(string.Format("    Files skipped: {0}", m_fileSkipCount.ToString()));
            WriteOutput(string.Format("   Errors occured: {0}", m_errorsCount.ToString()));
            WriteOutput(string.Format("     Elapsed time: {0}", (DateTime.Now - m_startTime).ToString()));
        }
Esempio n. 26
0
        private static string GetAlbum(string album)
        {
            string retVal;

            try
            {
                var service = new PicasaService("exampleCo-exampleApp-1");

                string usr = Settings.GetSingleValue("Account") + "@gmail.com";
                string pwd = Settings.GetSingleValue("Password");

                service.setUserCredentials(usr, pwd);

                var        query = new PhotoQuery(PicasaQuery.CreatePicasaUri(usr, album));
                PicasaFeed feed  = service.Query(query);

                retVal = "<ul id=\"AlbumList\">";
                foreach (PicasaEntry entry in feed.Entries)
                {
                    var    firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string;
                    string thumGrp       = "/s" + Settings.GetSingleValue("PicWidth") + "/";

                    if (firstThumbUrl != null)
                    {
                        firstThumbUrl = firstThumbUrl.Replace("/s72/", thumGrp);
                    }

                    var contentUrl = entry.Media.Content.Attributes["url"] as string;

                    if (contentUrl != null)
                    {
                        contentUrl = contentUrl.Substring(0, contentUrl.LastIndexOf("/"));
                    }

                    contentUrl += "/s640/" + entry.Title.Text;

                    retVal += string.Format(Img, firstThumbUrl, contentUrl);
                }
                retVal += "</ul>";
            }
            catch (Exception qex)
            {
                retVal = qex.Message;
            }
            return(retVal);
        }
        public List <PicasaWebPhoto> QueryPhoto(BackgroundWorker worker, int overallJobPercent)
        {
            List <PicasaWebPhoto> retval = new List <PicasaWebPhoto>();

            this.m_photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.m_userName, this.m_albumName));

            this.m_photoService = new PicasaService(this.m_serviceName);
            //this.m_photoService.setUserCredentials(this.m_userName, this.m_password);
            this.m_photoService.SetAuthenticationToken(this.mUserToken);
            decimal count      = ((decimal)overallJobPercent / 100) * 10;
            int     smallCount = (int)count;

            worker.ReportProgress(0, (object)"Creating proxy");
            CreatePhotoProxy();
            try
            {
                worker.ReportProgress(smallCount, (object)"Proxy created");
                worker.ReportProgress(0, (object)"Querying google");
                this.m_photoFeed = this.m_photoService.Query(this.m_photoQuery);
                worker.ReportProgress(smallCount, (object)"Done");
                if (this.m_photoFeed.Entries.Count > 0)
                {
                    int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_photoFeed.Entries.Count), 0);
                    worker.ReportProgress(0, (object)"Processing photo data");
                    foreach (PicasaEntry photo in this.m_photoFeed.Entries)
                    {
                        retval.Add(new PicasaWebPhoto(photo, this.m_albumName));
                        worker.ReportProgress(percent, null);
                    }
                }
            }
            catch (Exception e)
            {
                this.m_photoQuery = null;
                this.m_photoService.RequestFactory = null;
                this.m_photoService = null;
                this.m_photoFeed    = null;
                throw new Exception("Query Photo Exception", e);
            }

            this.m_photoQuery = null;
            this.m_photoService.RequestFactory = null;
            this.m_photoService = null;
            this.m_photoFeed    = null;
            return(retval);
        }
Esempio n. 28
0
        public List <Album> GetList()
        {
            var service = new PicasaService("GPhotoSync");

            service.SetAuthenticationToken(_credentials.AccessToken);

            var query = new AlbumQuery();

            query.Thumbsize = "180";
            query.Uri       = new Uri(PicasaQuery.CreatePicasaUri(_credentials.User));

            var feed = service.Query(query);

            if (feed != null)
            {
                var list = feed.Entries
                           .OfType <PicasaEntry>()
                           .Where(x => !IsPostEntry(x))
                           .OrderBy(x => x.Title.Text)
                           .Select(x =>
                {
                    var accessor = new AlbumAccessor(x);

                    var thumb = x.Media.Thumbnails[0];
                    using (var stream = service.Query(new Uri(thumb.Attributes["url"] as string)))
                    {
                        var ms = new MemoryStream();
                        stream.CopyTo(ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        return(new Album
                        {
                            Id = accessor.Id,
                            Title = accessor.AlbumTitle,
                            ImageStream = ms,
                            PhotoCount = (int)accessor.NumPhotos
                        });
                    }
                })
                           .ToList();
                return(list);
            }
            else
            {
                return(new List <Album>());
            }
        }
        public void CreatePicasaUriTest1()
        {
            string userID    = "*****@*****.**";
            string albumName = "album";
            string photoID   = "photoid";
            Uri    test      = null;

            try
            {
                test = new Uri(PicasaQuery.CreatePicasaUri(userID, albumName, photoID));
            }
            catch (Exception)
            {
            }

            Assert.IsNotNull(test);
        }
Esempio n. 30
0
        public Album GetAlbum(string albumID)
        {
            var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(PicasaConfiguration.Settings.Gallery.User, albumID))
            {
                Thumbsize       = PicasaConfiguration.Settings.Pictures.ThumbnailSize.ToString(),
                ExtraParameters = PicasaConfiguration.Settings.Pictures.MaximumImageSize.HasValue ?
                                  ("imgmax=" + PicasaConfiguration.Settings.Pictures.MaximumImageSize.Value.ToString()) : ""
            };

            var feed = GetPicasaFeed(query);

            return(new Album
            {
                Summary = PicasaDataMapper.MapPicasaAlbum(feed, albumID),
                Pictures = from PicasaEntry pictureEntry in feed.Entries select PicasaDataMapper.MapPicasaImage(pictureEntry)
            });
        }