Exemplo n.º 1
0
        public string UploadPhotographToFlickr(string flickrAuth, string title, string description, string path, string tag)
        {
            try
            {
                flickr.AuthToken = flickrAuth;

                bool uploadAsPublic = true;

                string photoId = flickr.UploadPicture(ConfigurationManager.AppSettings["TempFileLocalPath"].ToString(), title, description, tag, uploadAsPublic, false, false);
                if (photoId != null && photoId != "")
                {
                    bool setFlag = false;

                    // Get list of users sets
                    PhotosetCollection sets = flickr.PhotosetsGetList();

                    //add photo to appropriate skichair photoset
                    foreach (Photoset set in sets)
                    {
                        if (set.Title.Equals(tag))
                        {
                            setFlag = true;
                            //add the photo to that set
                            AddPhotoToPhotoset(set.PhotosetId, photoId);
                            break;
                        }
                    }

                    //if photoset didn't exist create it
                    if (!setFlag)
                    {
                        //create photoset and add photo to it
                        CreateFlickrPhotoSet(tag, photoId);
                        flickr.GroupsPoolsAdd(photoId, Utility.FlickrGroupID);
                    }

                    return(photoId);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                System.IO.StreamWriter sw = System.IO.File.AppendText(ConfigurationManager.AppSettings["ErrorLogPath"].ToString() + "SkiChairErrorLogFile.txt");
                try
                {
                    string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, "Error: " + ex.Message);
                    sw.WriteLine(logLine);
                }
                finally
                {
                    sw.Close();
                }
                return("");
            }
        }