コード例 #1
0
		public NewAlbumDialog(PicasaService service, PicasaFeed feed)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            this.service = service;
            this.feed = feed;
		}
コード例 #2
0
 public void CreateFeedEntryTest()
 {
     Uri uriBase = new Uri("http://www.google.com"); 
     IService iService = null; // TODO: Initialize to an appropriate value
     PicasaFeed target = new PicasaFeed(uriBase, iService); // TODO: Initialize to an appropriate value
     PicasaEntry expected = null;
     expected = target.CreateFeedEntry() as PicasaEntry;
     Assert.IsNotNull(expected);
 }
コード例 #3
0
ファイル: PhotoBrowser.cs プロジェクト: mintwans/cpsc483
		public PictureBrowser(PicasaService service, PicasaFeed feed, string albumTitle)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

            this.photoFeed = feed;
            this.picasaService = service;
            this.Text += albumTitle;

            if (this.photoFeed != null && this.photoFeed.Entries.Count > 0) 
            {
                foreach (PicasaEntry entry in this.photoFeed.Entries)
                {
                    ListViewItem item = new ListViewItem(entry.Title.Text);
                    item.Tag = entry;
                    this.PhotoList.Items.Add(item);
                }
            }
            
		}
コード例 #4
0
ファイル: reLiveMain.cs プロジェクト: mintwans/cpsc483
        private void UpdateAlbumFeed()
        {
            AlbumQuery query = new AlbumQuery();

            this.albumList.Clear();
            albumCalendar.BoldedDates = null;
            this.AlbumPicture.Image = null;
            this.mapLinkLabel.Hide();
            this.albumLabel.Hide();

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

            try
            {
                this.picasaFeed = this.picasaService.Query(query);
            }
            catch (Google.GData.Client.GDataRequestException)
            {
                MessageBox.Show("You need to add the Picasaweb Service:\nLogin through your web browser and accept the terms of service."
                    + "\nIn addition, please check your internet connection and try again!");
                System.Diagnostics.Process.Start("www.picasaweb.google.com");
                this.googleAuthToken = null;
                login();
                return;
            }
            
            if (this.picasaFeed != null && this.picasaFeed.Entries.Count > 0)
            {
            foreach (PicasaEntry entry in this.picasaFeed.Entries)
            {
                albumList.Add(entry);
                albumCalendar.AddBoldedDate(entry.Published); //adds album dates to calendar as bold entries
            }
            }
            this.albumCalendar.UpdateBoldedDates();
            calendarUpdate();
        }
コード例 #5
0
ファイル: PhotoBrowser.cs プロジェクト: Zelxin/RPiKeg
        private void OnDone(object sender, AsyncOperationCompletedEventArgs e)
        {
            UserState ut = e.UserState as UserState;

            if (this.states.Contains(ut) == false)
                return;

            this.states.Remove(ut);
        
            if (e.Error == null && e.Cancelled == false)
            {

                if (ut.opType == UserState.OperationType.query ||
                    ut.opType == UserState.OperationType.queryForBackup)
                {
                    if (e.Feed != null)
                    {
                        this.photoFeed = e.Feed as PicasaFeed;
                        this.InitializeList(ut.filename);
                    }
                }

                if (ut.opType == UserState.OperationType.upload)
                {
                    if (e.Entry != null)
                    {
                        ListViewItem item = new ListViewItem(e.Entry.Title.Text);
                        item.Tag = e.Entry;
                        this.PhotoList.Items.Add(item);
                        this.FileInfo.Text = "Upload succeeded";
                    }
                }
                if (ut.opType == UserState.OperationType.download ||
                    ut.opType == UserState.OperationType.downloadList)
                {
                    if (e.ResponseStream != null)
                    {
                        WriteFile(ut.filename, e.ResponseStream);
                        this.FileInfo.Text = "Saved file: " + ut.filename;
                    }
                }
                if (ut.opType == UserState.OperationType.downloadList)
                {
                    // we need to create a new object for uniqueness

                    UserState u = new UserState();
                    u.counter = ut.counter + 1;
                    u.feed = ut.feed;
                    u.foldername = ut.foldername;
                    u.opType = UserState.OperationType.downloadList;
                    
                    if (u.feed.Entries.Count > 0)
                    {
                        u.feed.Entries.RemoveAt(0);
                        this.PhotoList.Items.RemoveAt(0);

                    }
                    this.states.Add(u);
                    SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile);

                    this.BeginInvoke(d, u);

                }
                if (ut.opType == UserState.OperationType.queryForBackup)
                {
                    UserState u = new UserState();
                    u.opType = UserState.OperationType.downloadList;
                    u.feed = this.photoFeed;
                    u.counter = 1;
                    u.foldername = ut.foldername;
                    u.filename = ut.foldername + "\\image1.jpg";
                    this.states.Add(u);
                    SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile);
                    this.BeginInvoke(d, u);
                }
            }
            this.progressBar.Value = 0;

            if (this.states.Count == 0)
            {
                this.CancelAsync.Enabled = false;
                this.CancelAsync.Visible = false;
            }

        }
コード例 #6
0
        private void UpdateAlbumFeed()
        {
            AlbumQuery query = new AlbumQuery();

            this.AlbumList.Clear();

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

            this.picasaFeed = this.picasaService.Query(query);

            if (this.picasaFeed != null && this.picasaFeed.Entries.Count > 0) 
            {
                foreach (PicasaEntry entry in this.picasaFeed.Entries)
                {
                    ListViewItem item = new ListViewItem(entry.Title.Text + 
                                    " (" + entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos) + " )");
                    item.Tag = entry;
                    this.AlbumList.Items.Add(item);
                }
            }
            this.AlbumList.Update();
        }
コード例 #7
0
        /// <summary>
        /// Syncs a local folder to an online Picasa Web Album location
        /// </summary>
        /// <param name="sourceFolder">The source folder to sync.</param>
        /// <param name="albumNamePrefix">A prefix to prepend to the album name.</param>
        /// <param name="includeSubFolders">Indicated whether to sync all subfolders recursively.</param>
        /// <param name="session">The current authenticated Picasa session.</param>
        /// <param name="albumFeed">A feed listing all existing Picass Web Albums in the Picasa account.</param>
        private void SyncFolder(DirectoryInfo sourceFolder, string albumNamePrefix, AlbumAccessEnum targetAlbumAccess, bool includeSubFolders, PicasaService session, PicasaFeed albumFeed)
        {
            if (!sourceFolder.Exists)
            {
                throw new DirectoryNotFoundException(string.Format("Folder '{0}' cannot be located.", sourceFolder.FullName));
            }

            string targetAlbumName = GetTargetAlbumName(sourceFolder, albumNamePrefix);
            Dictionary<string, FileInfo> sourceFiles = GetSourceFiles(sourceFolder);
            bool excludeFolder = ShouldExcludeFolder(sourceFolder, sourceFiles);
            PicasaEntry existingAlbumEntry = albumFeed.Entries.FirstOrDefault(a => a.Title.Text == targetAlbumName) as PicasaEntry;

            if (excludeFolder)
            {
                if (existingAlbumEntry != null && !this.AddOnly)
                {
                    //album needs to be removed
                    WriteOutput(string.Format("Removing Album: {0} (excluded but already exists)", targetAlbumName));
                    existingAlbumEntry.Delete();
                    existingAlbumEntry.Summary.Text = ENTRY_DELETED_SUMMARY;
                    m_albumDeleteCount++;
                }
                else
                {
                    m_folderSkipCount++;
                }
            }
            else
            {
                WriteOutput(string.Format("Syncing Folder: {0} to Album: {1}", sourceFolder.FullName, targetAlbumName), true);

                try
                {
                    targetAlbumAccess = DetermineAlbumAccess(sourceFolder, targetAlbumAccess);

                    if (sourceFiles.Count > 0)
                    {
                        Album targetAlbum = new Album();
                        if (existingAlbumEntry != null)
                        {
                            targetAlbum.AtomEntry = existingAlbumEntry;
                            if (targetAlbum.Access != targetAlbumAccess.ToString().ToLower())
                            {
                                UpdateAlbumAccess(session, targetAlbum, targetAlbumAccess);
                            }
                        }
                        else
                        {
                            targetAlbum = CreateAlbum(session, albumFeed, targetAlbumName, targetAlbumAccess);
                        }

                        PhotoQuery existingAlbumPhotosQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername, targetAlbum.Id));
                        PicasaFeed existingAlbumPhotosFeed = session.Query(existingAlbumPhotosQuery);

                        //sync folder files
                        DeleteFilesFromAlbum(sourceFiles, existingAlbumPhotosFeed);

                        foreach (KeyValuePair<string, FileInfo> file in sourceFiles.OrderBy(f => f.Value.LastWriteTime))
                        {
                            AddFileToAlbum(file.Value, targetAlbum, existingAlbumPhotosFeed, session);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteOutput(string.Format("Skipping Folder: {0} (Error - {1})", sourceFolder.Name, ex.Message), true);
                }

                if (includeSubFolders)
                {
                    DirectoryInfo[] subfolders = sourceFolder.GetDirectories().OrderBy(d => d.CreationTime).ToArray();
                    if (subfolders.Length > 0)
                    {
                        foreach (DirectoryInfo folder in subfolders)
                        {
                            SyncFolder(folder, targetAlbumName, targetAlbumAccess, includeSubFolders, session, albumFeed);
                        }
                    }
                }
            }
        }
コード例 #8
0
        private Album CreateAlbum(PicasaService session, PicasaFeed albumFeed, string targetAlbumName, AlbumAccessEnum albumAccess)
        {
            //create album (doesn't exist)
            WriteOutput(string.Concat("Creating Album: ", targetAlbumName), true);
            AlbumEntry newAlbumEntry = new AlbumEntry();
            newAlbumEntry.Title.Text = targetAlbumName;
            newAlbumEntry.Summary.Text = targetAlbumName;
            newAlbumEntry.Published = DateTime.Now;

            Album newAlbum = new Album();
            newAlbum.AtomEntry = newAlbumEntry;
            newAlbum.Access = albumAccess.ToString().ToLower();

            Uri insertAlbumFeedUri = new Uri(PicasaQuery.CreatePicasaUri(this.PicasaUsername));
            newAlbum.AtomEntry = (PicasaEntry)session.Insert(insertAlbumFeedUri, newAlbumEntry);
            m_albumCreateCount++;

            return newAlbum;
        }
コード例 #9
0
        private void DeleteFilesFromAlbum(Dictionary<string, FileInfo> sourceFiles, PicasaFeed existingAlbumPhotosFeed)
        {
            foreach (PicasaEntry albumPhotoEntry in existingAlbumPhotosFeed.Entries)
            {
                bool deleteAlbumPhoto = false;

                if (!this.AddOnly && this.ClearAlbumPhotosFirst)
                {
                    WriteOutput(string.Format("Deleting Album File: {0} (-emptyAlbumFirst option specified)", albumPhotoEntry.Title.Text), true);
                    deleteAlbumPhoto = true;
                }
                else if (!this.AddOnly && !sourceFiles.ContainsKey(albumPhotoEntry.Title.Text))
                {
                    WriteOutput(string.Format("Deleting Album File: {0} (does not exist in source folder)", albumPhotoEntry.Title.Text), true);
                    deleteAlbumPhoto = true;
                }
                else if (!this.AddOnly && sourceFiles[albumPhotoEntry.Title.Text].LastWriteTime > albumPhotoEntry.Published)
                {
                    WriteOutput(string.Format("Deleting Album File: {0} (updated since last upload)", albumPhotoEntry.Title.Text), true);
                    deleteAlbumPhoto = true;
                }

                if (deleteAlbumPhoto)
                {
                    albumPhotoEntry.Delete();
                    albumPhotoEntry.Summary.Text = ENTRY_DELETED_SUMMARY;
                    m_fileDeleteCount++;
                }
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Danh Sách Album";

            service.setUserCredentials("*****@*****.**", "doantruong");
            feed = service.Query(query);
            foreach (PicasaEntry entry in feed.Entries)
            {
                AlbumAccessor ac = new AlbumAccessor(entry);
                listAlbum.Add(ac);
            }
            if (!IsPostBack)
            {
                int soDong = LoadAlbum();
                FilterSTT(soDong, 0, 10);
            }
            this.GridViewPicasa.HeaderStyle.CssClass = "headerstyle";

            //photos

            string maAlbum = null;
            List<SPHOTO> listPhotos = new List<SPHOTO>();
            if(Request.QueryString["id"] != null)
            {
                maAlbum = Request.QueryString["id"].ToString();
            }
            if(maAlbum != null)
            {
                PhotoQuery Pquery = new PhotoQuery(PicasaQuery.CreatePicasaUri("*****@*****.**",maAlbum));
                feed = service.Query(Pquery);
                foreach (PicasaEntry entry in feed.Entries)
                {
                    SPHOTO temp = new SPHOTO();

                    temp.title = entry.Title.Text;
                    temp.thumbURL = entry.Media.Thumbnails[1].Attributes["url"] as string;
                    listPhotos.Add(temp);

                }
                ListViewPhotos.DataSource = listPhotos;
                ListViewPhotos.DataBind();
            }
            if (maAlbum != null)
            {
                //lay ma

                //lay thong tin va load len cac textbox
                for (int i = 0; i < listAlbum.Count; i++)
                {
                    if (listAlbum[i].Id == maAlbum)
                    {
                        currentAlbum = listAlbum[i];
                        break;
                    }
                }
                switch (currentAlbum.Access)
                {
                    case "public":
                        DropDownListAccess.SelectedIndex = 0;
                        break;

                    case "private":
                        DropDownListAccess.SelectedIndex = 1;
                        break;
                    case "protected":
                        DropDownListAccess.SelectedIndex = 2;
                        break;

                }
                txtalbumtitle.Text = currentAlbum.AlbumTitle;
                txtmieuta.Text = currentAlbum.AlbumSummary;
            }
        }
コード例 #11
0
        /// <summary>
        /// Syncs a local file to an online Picasa Web Album location
        /// </summary>
        /// <param name="sourceFile">The image to sync.</param>
        /// <param name="targetAlbum">The target Picasa Web Album.</param>
        /// <param name="targetAlbumPhotoFeed">The target Picasa Web Album photo feed listing existing photos.</param>
        /// <param name="session">The current authenticated Picasa session.</param>
        private void AddFileToAlbum(FileInfo sourceFile, Album targetAlbum, PicasaFeed targetAlbumPhotoFeed, PicasaService session)
        {
            try
            {
                PicasaEntry existingPhotoEntry = (PicasaEntry)targetAlbumPhotoFeed.Entries.FirstOrDefault(
                    p => p.Title.Text == sourceFile.Name && p.Summary.Text != ENTRY_DELETED_SUMMARY);

                if (existingPhotoEntry != null)
                {
                    WriteOutput(string.Format("Skipping File: {0} (already exists)", sourceFile.Name), true);
                    m_fileSkipCount++;
                }
                else
                {
                    ImageFormat imageFormat;
                    string contentType;
                    bool isImage;
                    bool isVideo;
                    GetFileInfo(sourceFile, out isImage, out isVideo, out imageFormat, out contentType);

                    Stream postResponseStream = null;
                    Stream postFileStream = null;
                    string souceFilePath = sourceFile.FullName;

                    try
                    {
                        if (isVideo && this.ResizeVideos)
                        {
                            WriteOutput(string.Concat("Resizing Video: ", sourceFile.FullName), true);
                            string resizedVideoPath = VideoResizer.ResizeVideo(sourceFile, this.ResizeVideosCommand);
                            //change souceFilePath to resized video file location
                            souceFilePath = resizedVideoPath;
                        }

                        using (Stream sourceFileStream = new FileStream(souceFilePath, FileMode.Open, FileAccess.Read))
                        {
                            postFileStream = sourceFileStream;

                            if (isImage && this.ResizePhotos)
                            {
                                WriteOutput(string.Concat("Resizing Photo: ", sourceFile.FullName), true);
                                postFileStream = ImageResizer.ResizeImage(postFileStream, imageFormat, this.ResizePhotosMaxSize);
                            }

                            WriteOutput(string.Format("Uploading File: {0}", sourceFile.FullName), true);
                            Uri insertPhotoFeedUri = new Uri(PicasaQuery.CreatePicasaUri(this.PicasaUsername, targetAlbum.Id));

                            PhotoEntry newFileEntry = new PhotoEntry();
                            newFileEntry.Title.Text = sourceFile.Name;
                            newFileEntry.Summary.Text = string.Empty;
                            newFileEntry.MediaSource = new MediaFileSource(postFileStream, sourceFile.Name, contentType);

                            //upload file using multipart request
                            postResponseStream = session.EntrySend(insertPhotoFeedUri, newFileEntry, GDataRequestType.Insert);
                            newFileEntry.MediaSource.GetDataStream().Dispose();
                        }

                        m_fileCreateCount++;

                    }
                    finally
                    {
                        if (postResponseStream != null)
                        {
                            postResponseStream.Dispose();
                        }

                        if (postFileStream != null)
                        {
                            postFileStream.Dispose();
                        }
                    }

                    if (isVideo && this.ResizeVideos)
                    {
                        //video was resized and souceFilePath should be temp/resized video path
                        try
                        {
                            File.Delete(souceFilePath);
                        }
                        catch (Exception ex)
                        {
                            WriteOutput(string.Format("Error Deleting Resized Video: {0} (Error - {1})", sourceFile.FullName, ex.Message), true);
                        }
                    }
                }
            }
            catch (GDataRequestException gdex)
            {
                WriteOutput(string.Format("Skipping File: {0} (Error - {1})", sourceFile.Name, gdex.ResponseString), true);
                m_errorsCount++;
            }
            catch (Exception ex)
            {
                WriteOutput(string.Format("Skipping File: {0} (Error - {1})", sourceFile.Name, ex), true);
                m_errorsCount++;
            }
        }
コード例 #12
0
        protected virtual void Dispose(bool disposing)
        {
            if (!is_disposed) // only dispose once!
            {
                if (disposing)
                {
                    
                    m_albumService = null;
                    m_albumFeed = null;
                    m_albumQuery = null;
                    m_photoService = null;
                    m_photoQuery = null;
                    m_photoFeed = null;
                    m_userName = null;
                    m_serviceName = null;
                    m_albumName = null;
                }

            }
            this.is_disposed = true;
        }
コード例 #13
0
      /*  public string LoginToGoogle(out string token)
        {
            GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName);
            authFactory.AccountType = "GOOGLE_OR_HOSTED";

            this.m_albumService = new PicasaService(authFactory.ApplicationName);
            try
            {
                this.m_albumService.setUserCredentials(this.m_userName, this.m_password);
                this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately
            }
            catch (CaptchaRequiredException e)
            {
                token = e.Token;
                return e.Url;
            }
        }

        public string LoginToGoogle(out string token, string CAPTCHAAnswer, string CAPTCHAToken)
        {
            GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName);
            authFactory.AccountType = "GOOGLE_OR_HOSTED";
            string token = string.Empty;
            this.m_albumService = new PicasaService(authFactory.ApplicationName);
            authFactory.CaptchaAnswer = CAPTCHAAnswer;
            authFactory.CaptchaToken = CAPTCHAToken;
            this.m_albumService.setUserCredentials(this.m_userName, this.m_password);

            token = this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately
            return token;


        }
        */
        public List<PicasaWebAlbum> QueryAlbums()
        {
            // Create an authentication factory to deal with logging in.
            GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName);
            authFactory.AccountType = "GOOGLE_OR_HOSTED";
                       
            this.m_albumService = new PicasaService(authFactory.ApplicationName);
            this.m_albumService.RequestFactory = authFactory;
            this.m_albumService.SetAuthenticationToken(this.mUserToken);
           
         
            this.m_albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default"));
            this.m_albumQuery.Access = PicasaQuery.AccessLevel.AccessAll;
           

            List<PicasaWebAlbum> retval = new List<PicasaWebAlbum>();
           
            try
            {
                CreateAlbumProxy();
                this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery);
                
            }
            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);

            }
            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)));
            }
            this.m_albumQuery = null;
            this.m_albumService.RequestFactory = null;
            this.m_albumService = null;
            this.m_albumFeed = null;
            return retval;
        }
コード例 #14
0
        public List<string> QueryTag(PicasaWebPhoto photo, BackgroundWorker worker, int overallJobPercent)
        {
            List<string> retval = new List<string>();
            this.m_tagQuery = new TagQuery(TagQuery.CreatePicasaUri(this.m_userName, this.m_albumName, photo.AccessId));
            this.m_tagService = new PicasaService("Tags");
            //this.m_tagService.setUserCredentials(this.m_userName, this.m_password);
            this.m_tagService.SetAuthenticationToken(this.mUserToken);
            decimal count = ((decimal)overallJobPercent / 100) * 10;
            int smallCount = (int)count;
            worker.ReportProgress(0, (object)"Creating proxy");
            CreateTagProxy();
            try
            {
                worker.ReportProgress(smallCount, (object)"Proxy created");
                worker.ReportProgress(0, (object)"Querying google");
                this.m_tagFeed = this.m_tagService.Query(this.m_tagQuery);
                worker.ReportProgress(smallCount, (object)"Done");
                if (this.m_tagFeed.Entries.Count > 0)
                {
                    int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_tagFeed.Entries.Count), 0);
                    worker.ReportProgress(0, (object)"Processing tag data");
                    foreach (PicasaEntry entry in m_tagFeed.Entries)
                    {
                        retval.Add(entry.Title.Text);
                        worker.ReportProgress(percent, null);
                    }
                }
            }
            catch (Exception e)
            {
                this.m_tagQuery = null;
                this.m_tagService.RequestFactory = null;
                this.m_tagService = null;
                this.m_tagFeed = null;
                throw new Exception("Query Tag Exception", e);

            }


            this.m_tagQuery = null;
            this.m_tagService.RequestFactory = null;
            this.m_tagService = null;
            this.m_tagFeed = null;
            return retval;
        }
コード例 #15
0
        public List<string> QueryTag(PicasaWebPhoto photo)
        {
            List<string> retval = new List<string>();
            this.m_tagQuery = new TagQuery(TagQuery.CreatePicasaUri(this.m_userName, this.m_albumName, photo.AccessId));
            this.m_tagService = new PicasaService("Tags");
            //this.m_tagService.setUserCredentials(this.m_userName, this.m_password);
            this.m_tagService.SetAuthenticationToken(this.mUserToken);
            CreateTagProxy();
            try
            {
                this.m_tagFeed = this.m_tagService.Query(this.m_tagQuery);

                foreach (PicasaEntry entry in m_tagFeed.Entries)
                {
                    retval.Add(entry.Title.Text);
                }
            }
            catch (Exception e)
            {
                this.m_tagQuery = null;
                this.m_tagService.RequestFactory = null;
                this.m_tagService = null;
                this.m_tagFeed = null;
                throw new Exception("Query Tag Exception", e);

            }


            this.m_tagQuery = null;
            this.m_tagService.RequestFactory = null;
            this.m_tagService = null;
            this.m_tagFeed = null;
            return retval;

        }
コード例 #16
0
        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;
        }
コード例 #17
0
        public List<PicasaWebPhoto> QueryPhoto(string tags)
        {
            List<PicasaWebPhoto> retval = new List<PicasaWebPhoto>();
            GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName);
            authFactory.AccountType = "GOOGLE_OR_HOSTED";
            this.m_photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.m_userName, this.m_albumName));
            this.m_photoQuery.Tags = tags;
           
            this.m_photoService = new PicasaService(authFactory.ApplicationName);
            this.m_photoService.RequestFactory = authFactory;
            //this.m_photoService.setUserCredentials(this.m_userName, this.m_password);
            this.m_photoService.SetAuthenticationToken(this.mUserToken);


          
          
            CreatePhotoProxy();
            try
            {
                this.m_photoFeed = this.m_photoService.Query(this.m_photoQuery);

                foreach (PicasaEntry photo in this.m_photoFeed.Entries)
                {
                    retval.Add(new PicasaWebPhoto(photo, this.m_albumName));
                }
            }
            catch (Exception e)
            {
                
                throw new Exception("Query Photo Exception", e);
            }
            finally
            {
                this.m_photoQuery = null;
                this.m_photoService.RequestFactory = null;
                this.m_photoService = null;
                this.m_photoFeed = null;
            }

          
            return retval;
        }
コード例 #18
0
        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;
        }