コード例 #1
0
ファイル: PluckHelper.cs プロジェクト: dphoebus/Groundfloor
        public static Dictionary <string, string> UpdatePluckPhotoDetails(string appName, Pluck.Config.PluckConfigElement pluckConfig, string description, string title, string tags, string photoKey)
        {
            var requests = new RequestBatch();

            #region Add UpdatePhotoActionRequest to batch
            var updateRequest = new UpdatePhotoActionRequest
            {
                Description = description,
                Title       = title,
                Tags        = tags,
                PhotoKey    = new PhotoKey {
                    Key = photoKey
                }
            };

            requests.AddRequest(updateRequest);
            #endregion

            #region Add UpdateDiscoveryFilterFlagActionRequest to batch
            ////Make the photo not discoverable
            UpdateDiscoveryFilterFlagActionRequest discAction = new UpdateDiscoveryFilterFlagActionRequest();
            discAction.BaseKey = updateRequest.PhotoKey;
            discAction.ExcludeFromDiscovery = true;
            requests.AddRequest(discAction);
            #endregion

            #region Add PhotoRequest to batch
            requests.AddRequest(new PhotoRequest {
                PhotoKey = updateRequest.PhotoKey
            });
            #endregion

            var pluckService = new PluckService(pluckConfig.apiUrl);
            var authToken    = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);

            ResponseBatch responseBatch = pluckService.SendRequest(requests, authToken);

            Dictionary <string, string> resultURI = new Dictionary <string, string>();
            if (responseBatch != null)
            {
                if (responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions != null && responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions.Length > 0)
                {
                    throw new ApplicationException(responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions[0].ExceptionMessage);
                }

                IResponse     photoObject  = responseBatch.Envelopes[2].GetResponse();
                PhotoResponse photoDetails = (PhotoResponse)photoObject;

                resultURI.Add("tiny", photoDetails.Photo.Image.Tiny);
                resultURI.Add("full", photoDetails.Photo.Image.Full);
                resultURI.Add("small", photoDetails.Photo.Image.Small);   //60x60
                resultURI.Add("medium", photoDetails.Photo.Image.Medium); //h=200
            }
            return(resultURI);
        }
コード例 #2
0
ファイル: PluckHelper.cs プロジェクト: dphoebus/Groundfloor
        public static PhotoModerationStatus GetPhotoModerationStatus(PluckConfigElement pluckConfig, string photoKey)
        {
            var pluckService = new PluckService(pluckConfig.apiUrl);
            var authToken    = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);

            var requests     = new RequestBatch();
            var photorequest = new PhotoRequest {
                PhotoKey = new PhotoKey {
                    Key = photoKey
                }
            };

            requests.AddRequest(photorequest);

            ResponseBatch responseBatch = pluckService.SendRequest(requests, authToken);
            var           photo         = (PhotoResponse)responseBatch.Envelopes[0].GetResponse();

            return(DetermineModerationStatus(photo));
        }
コード例 #3
0
ファイル: PluckHelper.cs プロジェクト: dphoebus/Groundfloor
        public static void GetPhotoModerationStatus(PluckConfigElement pluckConfig, List <string> photoKeys)
        {
            if (photoKeys.Count == 0)
            {
                return;
            }

            var          pluckService = new PluckService(pluckConfig.apiUrl);
            var          authToken    = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);
            RequestBatch requests     = null;

            int numBatches = photoKeys.Count / PLUCK_BATCH_SIZE;

            if (photoKeys.Count % PLUCK_BATCH_SIZE > 0)
            {
                numBatches++;
            }

            int photoKeyIndex = 0;

            for (int batchNumber = 1; batchNumber <= numBatches; batchNumber++)
            {
                requests = new RequestBatch();
                #region build requests batch
                for (int i = 0; i < PLUCK_BATCH_SIZE; i++)
                {
                    photoKeyIndex = (batchNumber * PLUCK_BATCH_SIZE) - PLUCK_BATCH_SIZE + i;

                    if (photoKeyIndex == photoKeys.Count)
                    {
                        break;
                    }

                    var photorequest = new PhotoRequest()
                    {
                        PhotoKey = new PhotoKey {
                            Key = photoKeys[photoKeyIndex]
                        }
                    };

                    requests.AddRequest(photorequest);
                }
                #endregion

                ResponseBatch             responseBatch = pluckService.SendRequest(requests, authToken);
                Dictionary <string, bool> photoStatus   = new Dictionary <string, bool>();

                #region build responses batch
                if (responseBatch != null)
                {
                    foreach (var envelope in responseBatch.Envelopes)
                    {
                        var photo  = (PhotoResponse)envelope.GetResponse();
                        var status = DetermineModerationStatus(photo);

                        if (status == PhotoModerationStatus.Pending || status == PhotoModerationStatus.Unknown)
                        {
                            continue;
                        }

                        try
                        {
                            //var photokey = photoKeys[photoKeyIndex];
                            //UserSubmitDB.SetModerationStatus(photo.Photo.PhotoKey.Key, (status == PhotoModerationStatus.Approved));
                            if (status == PhotoModerationStatus.Approved)
                            {
                                photoStatus.Add(photo.Photo.PhotoKey.Key, true);
                            }
                            else
                            {
                                string photokey = photo.ResponseStatus.Exceptions.Where(e => e.Name == "PhotoKey").Select(e => e.Value).FirstOrDefault();
                                photoStatus.Add(photokey, false);
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
                #endregion
            }
        }
コード例 #4
0
ファイル: PluckHelper.cs プロジェクト: keith9820/Groundfloor
        public static void GetPhotoModerationStatus(PluckConfigElement pluckConfig, List<string> photoKeys)
        {
            if (photoKeys.Count == 0)
                return;

            var pluckService = new PluckService(pluckConfig.apiUrl);
            var authToken = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);
            RequestBatch requests = null;

            int numBatches = photoKeys.Count / PLUCK_BATCH_SIZE;
            if (photoKeys.Count % PLUCK_BATCH_SIZE > 0)
                numBatches++;

            int photoKeyIndex = 0;

            for (int batchNumber = 1; batchNumber <= numBatches; batchNumber++)
            {
                requests = new RequestBatch();
                #region build requests batch
                for (int i = 0; i < PLUCK_BATCH_SIZE; i++)
                {
                    photoKeyIndex = (batchNumber * PLUCK_BATCH_SIZE) - PLUCK_BATCH_SIZE + i;

                    if (photoKeyIndex == photoKeys.Count)
                        break;

                    var photorequest = new PhotoRequest()
                    {
                        PhotoKey = new PhotoKey { Key = photoKeys[photoKeyIndex] }
                    };

                    requests.AddRequest(photorequest);
                }
                #endregion

                ResponseBatch responseBatch = pluckService.SendRequest(requests, authToken);
                Dictionary<string, bool> photoStatus = new Dictionary<string, bool>();

                #region build responses batch
                if (responseBatch != null)
                {
                    foreach (var envelope in responseBatch.Envelopes)
                    {
                        var photo = (PhotoResponse)envelope.GetResponse();
                        var status = DetermineModerationStatus(photo);

                        if (status == PhotoModerationStatus.Pending || status == PhotoModerationStatus.Unknown)
                            continue;

                        try
                        {
                            //var photokey = photoKeys[photoKeyIndex];
                            //UserSubmitDB.SetModerationStatus(photo.Photo.PhotoKey.Key, (status == PhotoModerationStatus.Approved));
                            if (status == PhotoModerationStatus.Approved)
                            {
                                photoStatus.Add(photo.Photo.PhotoKey.Key, true);
                            }
                            else
                            {
                                string photokey = photo.ResponseStatus.Exceptions.Where(e => e.Name == "PhotoKey").Select(e => e.Value).FirstOrDefault();
                                photoStatus.Add(photokey, false);
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
                #endregion
            }
        }
コード例 #5
0
ファイル: PluckHelper.cs プロジェクト: keith9820/Groundfloor
        public static Dictionary<string, string> UpdatePluckPhotoDetails(string appName, Pluck.Config.PluckConfigElement pluckConfig, string description, string title, string tags, string photoKey)
        {
            var requests = new RequestBatch();

            #region Add UpdatePhotoActionRequest to batch
            var updateRequest = new UpdatePhotoActionRequest
            {
                Description = description,
                Title = title,
                Tags = tags,
                PhotoKey = new PhotoKey { Key = photoKey }
            };

            requests.AddRequest(updateRequest);
            #endregion

            #region Add UpdateDiscoveryFilterFlagActionRequest to batch
            ////Make the photo not discoverable
            UpdateDiscoveryFilterFlagActionRequest discAction = new UpdateDiscoveryFilterFlagActionRequest();
            discAction.BaseKey = updateRequest.PhotoKey;
            discAction.ExcludeFromDiscovery = true;
            requests.AddRequest(discAction);
            #endregion

            #region Add PhotoRequest to batch
            requests.AddRequest(new PhotoRequest { PhotoKey = updateRequest.PhotoKey });
            #endregion

            var pluckService = new PluckService(pluckConfig.apiUrl);
            var authToken = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);

            ResponseBatch responseBatch = pluckService.SendRequest(requests, authToken);

            Dictionary<string, string> resultURI = new Dictionary<string, string>();
            if (responseBatch != null)
            {
                if (responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions != null && responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions.Length > 0)
                {
                    throw new ApplicationException(responseBatch.Envelopes[0].Payload.ResponseStatus.Exceptions[0].ExceptionMessage);
                }

                IResponse photoObject = responseBatch.Envelopes[2].GetResponse();
                PhotoResponse photoDetails = (PhotoResponse)photoObject;

                resultURI.Add("tiny", photoDetails.Photo.Image.Tiny);
                resultURI.Add("full", photoDetails.Photo.Image.Full);
                resultURI.Add("small", photoDetails.Photo.Image.Small);//60x60
                resultURI.Add("medium", photoDetails.Photo.Image.Medium);//h=200
            }
            return resultURI;
        }
コード例 #6
0
ファイル: PluckHelper.cs プロジェクト: keith9820/Groundfloor
        public static PhotoModerationStatus GetPhotoModerationStatus(PluckConfigElement pluckConfig, string photoKey)
        {
            var pluckService = new PluckService(pluckConfig.apiUrl);
            var authToken = new UserAuthenticationToken(pluckConfig.userKey, pluckConfig.userNickname, pluckConfig.userEmail, pluckConfig.sharedSecret);

            var requests = new RequestBatch();
            var photorequest = new PhotoRequest{PhotoKey = new PhotoKey { Key = photoKey }};
            requests.AddRequest(photorequest);

            ResponseBatch responseBatch = pluckService.SendRequest(requests, authToken);
            var photo = (PhotoResponse)responseBatch.Envelopes[0].GetResponse();

            return DetermineModerationStatus(photo);
        }