Beispiel #1
0
        public ExistingScreenshotList Screenshots(BucketLocationsRequest m)
        {
            var link              = Link(m.id);
            var url               = ScreenshotUrl + "?url=" + link.Url;
            var client            = ScreenshotClient();
            var screenshotRequest = client.GetAsync(new Uri(url)).Result;
            var screenshotData    = screenshotRequest.Content.ReadAsStringAsync().Result;

            Console.WriteLine(url);
            Console.WriteLine(screenshotData);

            var screenshotExists = JsonConvert.DeserializeObject <ExistingScreenshotList>(screenshotData);
            var screenshotRet    = new ExistingScreenshotList
            {
                urls = new List <ExistingScreenshot>(),
                last = screenshotExists.last
            };

            var first = screenshotExists.urls.FirstOrDefault(x => x.key.EndsWith("/1"));

            if (first != null)
            {
                screenshotRet.urls.Add(first);
            }

            var last = screenshotExists.urls.FirstOrDefault(x => x.key == screenshotExists.last && !x.key.EndsWith("/1"));

            if (last != null)
            {
                screenshotRet.urls.Add(last);
            }

            return(screenshotRet);
        }
Beispiel #2
0
        public List <BucketLocationsModel> BucketLocations(BucketLocationsRequest m)
        {
            using (var client = new LLCContext())
            {
                var buckets  = Buckets();
                var response = new List <BucketLocationsModel>();
                var links    = client.ObjectLinks.Where(x => x.Link == m.id);
                var dist     = new List <string>();
                if (links != null)
                {
                    foreach (var link in links)
                    {
                        var obj = client.Objects.FirstOrDefault(x => x.Id == link.Object);
                        var url = string.Format("https://{0}.s3.amazonaws.com/{1}", buckets.FirstOrDefault(x => x.Id == obj.Bucket).Name, obj.Key);
                        if (!dist.Contains(url))
                        {
                            dist.Add(url);
                        }
                    }

                    foreach (var d in dist)
                    {
                        response.Add(new BucketLocationsModel
                        {
                            data = d
                        });
                    }
                }

                return(response);
            }
        }
        public JsonResult Post([FromBody] BucketLocationsRequest m)
        {
            var model = _service.Screenshots(m);

            return(Json(model));
        }
 public JsonResult Post([FromBody] BucketLocationsRequest m)
 {
     var model = _service.BucketLocations(m);
     return Json(model);
 }