Ejemplo n.º 1
0
        public async void GetFeedContent_OnSuccess_Should_ReturnContent()
        {
            var target  = new FlickrService(clientFactoryMock.Object);
            var content = await target.GetFeedContentAsync(new Uri("http://foo/"));

            Assert.NotNull(content);
        }
Ejemplo n.º 2
0
        public void BuildJsonData_NullParam()
        {
            FlickrService instance    = new FlickrService();
            var           returnValue = instance.BuildFlickrJsonData("");

            Assert.AreEqual(null, returnValue);
        }
Ejemplo n.º 3
0
        public FlickrCommands(FlickrService flickrService, SubscriptionsService subscriptionsService, FlickrEmbedGenerator flickrEmbedGenerator)
        {
            _flickrService        = flickrService;
            _subscriptionsService = subscriptionsService;
            _flickrEmbedGenerator = flickrEmbedGenerator;

            _flickrService.OnNewFlickrPhoto += FlickrServiceOnNewFlickrServicePhotoAsync;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Obtain ConsumerKey and ConsumerSecret from
        /// http://www.flickr.com/services/apps/by/me
        /// </summary>
        partial void ShareFlickr_TouchUpInside(UIButton sender)
        {
            var flickr = new FlickrService {
                ConsumerKey    = ServiceConstants.FlickrConsumerKey,
                ConsumerSecret = ServiceConstants.FlickrConsumerSecret,
            };

            Share(flickr);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Obtain ConsumerKey and ConsumerSecret from
        /// http://www.flickr.com/services/apps/by/me
        /// </summary>
        void ShareFlickr_Click(object sender, EventArgs ea)
        {
            var flickr = new FlickrService {
                ConsumerKey    = ServiceConstants.FlickrConsumerKey,
                ConsumerSecret = ServiceConstants.FlickrConsumerSecret,
            };

            Share(flickr);
        }
Ejemplo n.º 6
0
        public void BuildJsonData_ValidStringParam()
        {
            FlickrService instance    = new FlickrService();
            var           returnValue = instance.BuildFlickrJsonData(TestData.GetJsonData());

            Assert.IsNotNull(returnValue);
            Assert.AreEqual(20, returnValue.Items.Count);
            Assert.IsNotNull(returnValue.Description);
            Assert.IsNotNull(returnValue.Modified);
        }
Ejemplo n.º 7
0
        public async void GetFeedContent_OnError_Should_ThrowException()
        {
            var httpClient = new HttpClient(new DelegatingHandlerStub(HttpStatusCode.NotFound));

            clientFactoryMock = new Mock <IHttpClientFactory>(MockBehavior.Strict);
            clientFactoryMock.Setup(cf => cf.CreateClient(It.IsAny <string>())).Returns(httpClient);

            var target = new FlickrService(clientFactoryMock.Object);

            var ex = await Assert.ThrowsAsync <HttpRequestException>(() => target.GetFeedContentAsync(new Uri("http://foo/")));

            Assert.IsAssignableFrom <HttpRequestException>(ex);
        }
Ejemplo n.º 8
0
        private async Task <IActionResult> GetImagesAsync(string tags = "")
        {
            try
            {
                var imageFeeds = await FlickrService.FetchImageFeedsAsync(tags);

                return(Ok(imageFeeds));
            }
            catch (HttpRequestException httpRequestException)
            {
                return(BadRequest($"Error: {httpRequestException.Message}"));
            }
        }
Ejemplo n.º 9
0
        public async Task GetLastUploadedPhotoUrl_FunctionTest_ShouldReturnFileUrl()
        {
            //arrange
            var userId = "christianfroehlich";
            var logger = new Mock <ILoggingService>();
            var target = new FlickrService(logger.Object);

            //act
            var url = await target.GetLastUploadedPhotoUrl(_flickrApiKey, _flickrApiSecret, userId);

            //assert
            // will throw an exception if there is no user
            Assert.NotNull(url);
        }
Ejemplo n.º 10
0
 public MainViewModel()
 {
     flickrService = Singleton <FlickrService> .Instance;
     Icon          = new BitmapImage(flickrService.IconUri);
     UserName      = flickrService.UserName;
     if (syncFolder == null)
     {
         var path = ApplicationData.Current.LocalSettings.Values["syncFolder"];
         if (path != null)
         {
             StorageFolder.GetFolderFromPathAsync(path.ToString()).AsTask().ContinueWith(t => SyncFolder = t.Result);
         }
     }
 }
Ejemplo n.º 11
0
        private void UpdatePhotos()
        {
            FlickrService flickr = new FlickrService();

            flickr.SearchPhotos(_tags, 10, delegate(Photo[] photos) {
                if ((photos == null) || (photos.Length == 0))
                {
                    return;
                }

                _photos        = photos;
                _selectedIndex = 0;

                RaisePhotoChanged();
            });
        }
Ejemplo n.º 12
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();


            this.Loaded    += new RoutedEventHandler(MainPage_Loaded);
            flickrService   = FlickrService.getInstance();
            locationService = LocationService.getInstance();
            forecastService = ForecastService.getInstance();

            if ((bool)IsolatedStorageSettings.ApplicationSettings["initstart"] == true)
            {
                IsolatedStorageSettings.ApplicationSettings["initstart"] = false;
            }
            flickrService.updateBg += new FlickrService.UpdateBg(updateBackGround);
        }
Ejemplo n.º 13
0
    /// <summary>
    /// Event handler for the page load event
    /// </summary>
    /// <param name="sender">sender</param>
    /// <param name="e">eventargs</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        FlickrService    flickr = new FlickrService();
        List <RestImage> list   = flickr.FindImages(SearchFor);

        if (list == null)
        {
            labMessage.Text  = "Flickr service is unavailable";
            panError.Visible = true;
        }
        else
        {
            panError.Visible      = false;
            dlstPhotos.DataSource = list;
            dlstPhotos.DataBind();
        }
    }
        static PhotoGridPage()
        {
            jQuery.OnDocumentReady(delegate() {
                string apiKey = (string)jQuery.FromElement(Document.Body).GetDataValue("flickrKey");
                FlickrService flickrService = new FlickrService(apiKey);

                jQuery.Select("#searchButton").Click(delegate(jQueryEvent e) {
                    string tags = jQuery.Select("#tagsTextBox").GetValue();

                    flickrService.SearchPhotos(tags, 20).Done(
                        delegate(IEnumerable <Photo> photos) {
                        jQueryObject thumbnailList = jQuery.Select("#thumbsList");
                        thumbnailList.Empty();

                        if (photos == null)
                        {
                            return;
                        }

                        jQuery.Select("#thumbnailTemplate").Plugin <jQueryTemplateObject>().
                        RenderTemplate(photos).
                        AppendTo(thumbnailList);

                        thumbnailList.
                        Plugin <jQueryIsotopeObject>().Isotope(new IsotopeOptions("layoutMode", IsotopeLayout.Masonry)).
                        Find("a").
                        Plugin <jQueryLightBoxObject>().LightBox();

                        thumbnailList.Find("li").
                        MouseOver(delegate(jQueryEvent e2) {
                            jQuery.This.CSS("box-shadow", "0 0 15px #888");
                        }).
                        MouseOut(delegate(jQueryEvent e2) {
                            jQuery.This.CSS("box-shadow", "");
                        });
                    });

                    jQuery.FromElement(Document.Body).Focus();
                    e.PreventDefault();
                });
            });
        }
Ejemplo n.º 15
0
        private static void AddPhotosToPhotoset(string photosetName, string photosetId, List <string> photoIds)
        {
            Console.WriteLine();
            Logger.Info("Moving uploaded files to the photoset...");
            //todo: move to FlickrService
            var fails = FlickrService.ParallelExecute(photoIds, id => Uploader.AddPictureToPhotoSet(id, photosetId), Settings.BatchSizeForParallelProcessing);

            if (!fails.Any())
            {
                Logger.Info("Uploaded pictures were successfully moved to '{0}'.", photosetName);
            }
            else
            {
                Logger.Error("Moved with errors:");
                foreach (var fail in fails)
                {
                    Logger.Error("{0,-20}: {1}", fail.Key, fail.Value);
                }
            }
        }
 internal FlickrTestEndpoint(FlickrService service)
 {
     Service = service;
 }
 internal FlickrPhotosEndpoint(FlickrService service)
 {
     Service = service;
 }
 internal FlickrPeopleEndpoint(FlickrService service)
 {
     Service = service;
 }
 /// <summary>
 /// Initializes a new instanc based on the specified <paramref name="service"/>.
 /// </summary>
 /// <param name="service">An instance of <see cref="FlickrService"/> representing the parent service.</param>
 internal FlickrPlacesEndpoint(FlickrService service)
 {
     Service = service;
 }
Ejemplo n.º 20
0
 public PhotosController(GalleryService galleryService, FlickrService flickrService)
 {
     _galleryService = galleryService;
     _flickrService  = flickrService;
 }
Ejemplo n.º 21
0
 internal FlickrGroupsPoolsEndpoint(FlickrService service)
 {
     Service = service;
 }
 internal FlickrGalleriesEndpoint(FlickrService service)
 {
     Service = service;
 }
 public MainViewModel(FlickrService flickrService)
 {
     _flickrService = flickrService;
     LoadInitialPhotosCommand = new ExtendedCommand(LoadInitialPhotos);
 }
Ejemplo n.º 24
0
        private void Process(string path, Options options)
        {
            var files = FileService.FindPictureFiles(path);

            if (!files.Any())
            {
                Logger.Warning("Could not locate any files to upload in the directory: {0}.", path);

                return;
            }


            Logger.Debug("Processing files in the directory: {0}.", path);

            var photosetName = Path.GetFileName(path.TrimEnd('\\'));

            var    photoset        = Uploader.FindPhotosetByName(photosetName);
            var    photosetExists  = photoset != null && photoset.Title == photosetName;
            var    photosetChanged = false;
            string photosetId      = null;

            var photosetPhotos = photosetExists
              ? Uploader.GetPhotosetPictures(photoset.PhotosetId)
              : new List <Photo>();

            if (photosetExists)
            {
                photosetId = photoset.PhotosetId;

                var totalFilesInDirectory = files.Count;
                files.RemoveAll(x => photosetPhotos.Any(p => p.Title == Path.GetFileNameWithoutExtension(x)));
                Logger.Info("{0} out of {1} files are already in the existing photoset.", totalFilesInDirectory - files.Count, totalFilesInDirectory);
            }

            // Check again as the collection might have been modified
            if (!files.Any())
            {
                Logger.Warning("All photos are already in the photoset. Nothing to upload.");
            }
            else
            {
                photosetChanged = true;

                #region Upload photos

                var photoIds = new List <string>();

                Console.WriteLine();
                Logger.Info("Uploading files...");

                //todo: move to FlickrService
                var failures = FlickrService.ParallelExecute(files, fileName =>
                {
                    var title = Path.GetFileNameWithoutExtension(fileName);

                    var photo = photosetPhotos.FirstOrDefault(x => x.Title == title); //?? Uploader.FindPictureByName(title);
                    if (photo == null || photo.Title != title)
                    {
                        var photoId = Uploader.UploadPicture(fileName, title, null, null);
                        if (photoIds.Contains(photoId))
                        {
                            throw new Exception($"{title} is already in the list of uploaded files.");
                        }

                        photoIds.Add(photoId);
                    }
                }, Settings.BatchSizeForParallelUpload);

                if (failures.Any())
                {
                    Logger.Error("Uploaded with errors:");

                    foreach (var failure in failures)
                    {
                        Logger.Error("{0,-20}: {1}", failure.Key, failure.Value);
                    }
                }
                else
                {
                    Logger.Info("All files were successfully uploaded.");
                }

                #endregion

                if (!photoIds.Any())
                {
                    Logger.Warning("No files were uploaded to '{0}'.", photosetName);
                }

                else if (!photosetExists)
                {
                    Console.WriteLine();
                    Logger.Info("Creating photoset '{0}'...", photosetName);

                    var coverPhotoId = photoIds.First();
                    photoIds.Remove(coverPhotoId);

                    photoset   = Uploader.CreatePhotoSet(photosetName, coverPhotoId);
                    photosetId = photoset.PhotosetId;

                    Logger.Info("Photoset created.");

                    photosetExists = true;
                }

                AddPhotosToPhotoset(photosetName, photosetId, photoIds);
            }

            bool updatePermissions = options.ShareWithFamily || options.ShareWithFriends;

            if (photosetExists && (photosetChanged || updatePermissions))
            {
                photosetPhotos = Uploader.GetPhotosetPictures(photosetId);

                FileService.ValidateDirectory(options.Path, photosetPhotos);

                if (photosetPhotos.Count > 1)
                {
                    if (photosetChanged)
                    {
                        FlickrService.SortPhotosInSet(photosetPhotos);
                    }

                    if (updatePermissions)
                    {
                        FlickrService.SetPermissions(photosetPhotos, options.ShareWithFamily, options.ShareWithFriends);
                    }
                }
            }
        }
Ejemplo n.º 25
0
 internal FlickrGroupsEndpoint(FlickrService service)
 {
     Service = service;
     Pools   = new FlickrGroupsPoolsEndpoint(service);
 }
 /// <summary>
 /// Initializes a new instanc based on the specified <paramref name="service"/>.
 /// </summary>
 /// <param name="service">An instance of <see cref="FlickrService"/> representing the parent service.</param>
 internal FlickrUrlsEndpoint(FlickrService service)
 {
     Service = service;
 }