Example #1
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);
                }
            }
        }
        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));
        }
Example #3
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));
        }
Example #4
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);
    }
Example #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);
        }
Example #6
0
        public PicasaService initializePicasa()
        {
            PicasaService service = new PicasaService("BlueTube");

            service.setUserCredentials(username, password);
            return(service);
        }
Example #7
0
        private static PicasaFeed GetPicasaFeed(KindQuery query)
        {
            var service = new PicasaService(PicasaConfiguration.Settings.Application.Name);

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

            return(service.Query(query));
        }
Example #8
0
        public PicasaService InitPicasaService()
        {
            PicasaService service = new PicasaService("OAMS");

            service.setUserCredentials(OAMSSetting.GoogleUsername, OAMSSetting.GooglePassword);

            service.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(service_AsyncOperationCompleted);
            return(service);
        }
Example #9
0
        public Downloader(Settings settings)
        {
            this.DestinationRootPath = settings.DestinationRootPath;
            Username = settings.Username;
            string password = settings.Password;

            this.DestinationRootPath = Path.Combine(settings.DestinationRootPath, settings.Username);

            Service = new PicasaService(ApplicationName);
            Service.setUserCredentials(Username, password);

            this.Albums = new List <Album>();
        }
        /// <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));
        }
        /// <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()));
        }
Example #12
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 static PicasaEntry RetrievePicasaEntry(string id)
        {
            PicasaService service = new PicasaService(Picasa_APPLICATION_NAME);

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

            PhotoQuery photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(config.Username, string.Empty, id));

            photoQuery.NumberToRetrieve = 1;
            PicasaFeed picasaFeed = service.Query(photoQuery);

            if (picasaFeed.Entries.Count > 0)
            {
                return((PicasaEntry)picasaFeed.Entries[0]);
            }

            return(null);
        }
 private string UploadPhoto()
 {
     try
     {
         PicasaService service = new PicasaService("picasaupload");
         service.setUserCredentials(user.email, user.password);
         var         file       = "screenshot.png";
         var         fileStream = new FileStream(file, FileMode.Open);
         PicasaEntry entry      = (PicasaEntry)service.Insert(new Uri("https://picasaweb.google.com/data/feed/api/user/default/albumid/default"), fileStream, "image/jpeg", file);
         fileStream.Close();
         PhotoAccessor  ac           = new PhotoAccessor(entry);
         string         albumId      = ac.AlbumId;
         string         photoId      = ac.Id;
         string         contentUrl   = entry.Media.Content.Attributes["url"] as string;
         ThreadDelegate UploadFinish = delegate()
         {
             client.pid        = photoId;
             client.uploading  = false;
             label1.Opacity    = 0;
             button1.IsEnabled = true;
             button1.Content   = "Share";
             return("succeed");
         };
         this.Dispatcher.BeginInvoke(DispatcherPriority.Send, UploadFinish);
         return("succeed");
     }
     catch (Exception ex)
     {
         ThreadDelegate UploadFinish = delegate()
         {
             label1.Content   = "Upload failed";
             client.uploading = false;
             return("fail");
         };
         this.Dispatcher.BeginInvoke(DispatcherPriority.Send, UploadFinish);
         return("fail");
     }
 }
Example #15
0
        private static string GetSlideShow(string albumId)
        {
            string s;

            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 AlbumQuery(PicasaQuery.CreatePicasaUri(usr));
                PicasaFeed feed  = service.Query(query);

                string id  = "";
                string key = "";

                foreach (PicasaEntry entry in feed.Entries)
                {
                    var ac = new AlbumAccessor(entry);

                    if (ac.Name == albumId)
                    {
                        id = ac.Id;
                        string feedUri = entry.FeedUri;
                        if (feedUri.Contains("authkey="))
                        {
                            string authKey = feedUri.Substring(feedUri.IndexOf("authkey=")).Substring(8);
                            key = authKey;
                        }
                    }
                }

                if (key.Length > 0)
                {
                    key = "authkey%3D" + key;
                }

                string user = Settings.GetSingleValue("Account");

                string auto = "";
                if (bool.Parse(Settings.GetSingleValue("AutoPlay")) == false)
                {
                    auto = "&noautoplay=1";
                }

                string width  = Settings.GetSingleValue("ShowWidth");
                string height = "96";

                if (int.Parse(width) > 0)
                {
                    height = (int.Parse(width) * 0.74).ToString();
                }
                s = string.Format(Tag, id, key, user, auto, width, height);
            }
            catch (Exception exp)
            {
                s = exp.Message;
            }
            return(s);
        }
Example #16
0
 private void authenticate()
 {
     service.setUserCredentials(comboLogin.Text, textPassword.Text);
 }
Example #17
0
    protected string GetAlbumsTable()
    {
        if (string.IsNullOrEmpty(Settings.GetSingleValue("Account")))
        {
            return(string.Empty);
        }

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

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

        service.setUserCredentials(usr, pwd);

        var sb = new StringBuilder("<table class=\"beTable\">");

        var        query = new AlbumQuery(PicasaQuery.CreatePicasaUri(usr));
        PicasaFeed feed  = service.Query(query);

        sb.Append(GetHeader());

        var cnt = 0;

        foreach (PicasaEntry entry in feed.Entries)
        {
            var          ac   = new AlbumAccessor(entry);
            const string cell = "<td>{0}</td>";

            sb.Append(cnt % 2 == 0 ? "<tr>" : "<tr class=\"alt\">");

            // thumbnail
            string albumUri      = ((Google.GData.Client.AtomEntry)(entry)).AlternateUri.ToString();
            string firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string;
            string thumbAncr     = string.Format("<a href=\"{2}\"><img src=\"{0}\" alt=\"{1}\" width=\"40\" /></a>",
                                                 firstThumbUrl, entry.Title.Text, albumUri);
            sb.Append(string.Format(cell, thumbAncr));

            // title
            sb.Append(string.Format(cell, ac.AlbumTitle));

            // description
            sb.Append(string.Format(cell, ac.AlbumSummary + "&nbsp;"));

            // number of photos
            sb.Append(string.Format(cell, ac.NumPhotos));

            // access
            sb.Append(string.Format(cell, ac.Access));

            // extension tag
            string       feedUri = entry.FeedUri;
            const string showTag = "[PicasaShow:{0}]";
            const string albmTag = "[PicasaAlbum:{0}]";

            if (ac.Access.ToLower() == "protected")
            {
                sb.Append(string.Format(cell, "&nbsp;"));
                sb.Append(string.Format(cell, "&nbsp;"));
            }
            else
            {
                sb.Append(string.Format(cell, string.Format(showTag, ac.AlbumTitle)));
                sb.Append(string.Format(cell, string.Format(albmTag, ac.AlbumTitle)));
            }


            sb.Append("</tr>");
            cnt++;
        }

        return(sb + "</table>");
    }