Пример #1
0
        public static void addPhotos(int brafId, string entry, string extract)
        {
            //AdferoVideoOutputsClient xc = new AdferoVideoClient(baseUrl, publicKey, secretKey).VideoOutputs();

            string publicKey = MyGlobals.VideoPublicKey;
            string secretKey = MyGlobals.VideoSecretKey;
            string baseUrl   = "http://" + MyGlobals.VideoBaseURL + "/v2/";

            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "************Just checking the BAseURL**********************<br>";
            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + baseUrl;
            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>***********************************************<br>";

            //in case there are no photos
            MyGlobals.CompleteContent = entry;
            MyGlobals.CompleteExtract = extract;



            AdferoClient client = new AdferoClient(baseUrl, publicKey, secretKey);

            AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotosClient photos = client.ArticlePhotos();

            foreach (AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotoListItem phot in photos.ListForArticle(brafId, 0, 20).Items)
            {
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "////////////////////////Display entry Preimage///////////////////////////////<br>";
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Here is a photo" + phot.Id;
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>/////////////////////////////////////////////////////////////////////////<br>";
                //string test = photos.Get(brafId).SourcePhotoId.ToString();
                int    imageID = phot.Id;
                int    photoID = photos.Get(imageID).SourcePhotoId;
                string alttext = photos.Get(imageID).Fields["altText"];
                string caption = photos.Get(imageID).Fields["caption"];

                MyGlobals.imageID = photoID.ToString();

                string photoURL = "http://" + MyGlobals.VideoPhotoURL + "/v2/photo/" + photoID + ".jpg";
                //TODO still need to add global value here

                //string entry = "TEST CONTENT";
                //string description = "TEST EXTRACT";
                string appPath = HttpRuntime.AppDomainAppVirtualPath == "/" ? appPath = "" : appPath = HttpRuntime.AppDomainAppVirtualPath;



                GetImages retrieveImage2 = new GetImages(photoURL, entry, extract, appPath, caption);
                retrieveImage2.DownloadImageDebug();



                MyGlobals.CompleteContent = retrieveImage2._entry;
                MyGlobals.CompleteExtract = retrieveImage2._description;
            }
        }
        private PhotoInstance?GetPhotoInstance(AdferoVideoDotNet.AdferoArticles.Articles.AdferoArticle article, AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotosClient photos, AdferoVideoDotNet.AdferoPhotos.AdferoPhotoClient photoClient, string scaleAxis, int scale)
        {
            PhotoInstance?inst = null;

            AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotoList photoList = photos.ListForArticle(article.Id, 0, 100);
            if (photoList.TotalCount > 0)
            {
                AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhoto apho = photos.Get(photoList.Items[0].Id);
                int photoId = apho.SourcePhotoId;
                AdferoVideoDotNet.AdferoPhotos.Photos.AdferoPhoto pho = photoClient.Photos().GetScaleLocationUrl(photoId, scaleAxis, scale);
                string photoUrl     = pho.LocationUri;
                string photoCaption = photos.Get(photoList.Items[0].Id).Fields["caption"];

                enumeratedTypes.enumPhotoOrientation ori = enumeratedTypes.enumPhotoOrientation.Landscape;
                if (scaleAxis == AdferoVideoDotNet.AdferoPhotos.Photos.AdferoScaleAxis.Y)
                {
                    ori = enumeratedTypes.enumPhotoOrientation.Portrait;
                }

                string cleanedUrl = photoUrl;
                if (cleanedUrl.IndexOf('?') >= 0)
                {
                    cleanedUrl = cleanedUrl.Substring(0, cleanedUrl.IndexOf('?'));
                }

                inst = new PhotoInstance()
                {
                    AltText             = photoCaption,
                    Caption             = photoCaption,
                    DestinationFileName = Slugify(article.Fields["title"]) + "-" + scale + Path.GetExtension(cleanedUrl),
                    Height      = 0,
                    Id          = apho.Id,
                    Orientation = ori,
                    Type        = enumeratedTypes.enumPhotoInstanceType.Custom,
                    Url         = photoUrl,
                    Width       = 0
                };
            }

            return(inst);
        }