Exemple #1
0
        private static string GetFindPackageResult(string url, List <Package> packages, bool latestVersion)
        {
            string apiUri = url.Replace("&", "&amp;");
            Uri    uri    = new Uri(apiUri);

            DateTime updated = packages.Any()
                                   ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                                   : DateTime.UtcNow;

            entry[] entries = latestVersion
                ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) }
                : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray();

            feed feed = new feed
            {
                @base   = InvokeUrl + "/",
                id      = WebUtility.HtmlDecode(uri.ToString()),
                title   = new feedTitle("FindPackagesById"),
                updated = updated,
                link    = new feedLink("FindPackagesById", "FindPackagesById"),
                entry   = entries
            };

            XmlSerializer serializer = new XmlSerializer(typeof(feed));
            MemoryStream  ms         = new MemoryStream();

            serializer.Serialize(ms, feed);
            ms.Position = 0;
            return(new StreamReader(ms).ReadToEnd());
        }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        feed script = (feed)target;

        if (GUILayout.Button("Refresh feed"))
        {
            script.refresh_feed();
        }
    }
Exemple #3
0
    protected void ExecFQLBtn_Click(object sender, EventArgs e)
    {
        facebook.fql  q = new facebook.fql(Master.API);
        facebook.feed f = new feed(Master.API);
        q.UseJson = UseJson.Checked;
        string result = q.query(TextBox1.Text);

        result       = result.Replace("<", "&lt;");
        result       = result.Replace(">", "&gt;");
        qresult.Text = result;
    }
Exemple #4
0
    void Start()
    {
        if (feed.instance != null)
        {
            DestroyImmediate(this.gameObject);
        }

        feed.instance = this;

        this.refresh_feed();
    }
Exemple #5
0
        public async Task <SearchResultModel> GetId(double latitude, double longitude, DateTime date)
        {
            // logger.LogInformation("Checking directories...");
            CheckBaseDirectories();

            // logger.LogInformation("Searching file...");
            string endOfDay   = $"{date:yyyy-MM-dd}T23:59:59.999Z";
            string startOfDay = $"{date:yyyy-MM-dd}T00:00:00.000Z";

            string requestUri = "https://scihub.copernicus.eu/dhus/search?q=" +
                                $"( footprint:\"Intersects({latitude}, {longitude})\" ) AND " +
                                $"( ingestionDate:[{startOfDay} TO {endOfDay} ] ) AND " +
                                "( (platformname:Sentinel-3 AND filename:S3A_* AND producttype:OL_2_LFR___ AND " +
                                "instrumentshortname:OLCI AND productlevel:L2))";

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(
                                                                                           System.Text.Encoding.ASCII.GetBytes(
                                                                                               $"{username}:{password}")));
            var result = await client.GetAsync(requestUri);

            result.EnsureSuccessStatusCode();
            var response = await result.Content.ReadAsStringAsync();

            XmlSerializer serializer   = new XmlSerializer(typeof(feed));
            StringReader  reader       = new StringReader(response);
            feed          finalMessage = (feed)serializer.Deserialize(reader);

            if (finalMessage.entry == null)
            {
                return(new SearchResultModel {
                    latitude = latitude.ToString(), longitude = longitude.ToString(), date = date, searchResult = SearchResultEnum.noDatasetFound
                });
            }

            /*if (Directory.Exists($"/app/Copernicus/Processed/{date:dd-MM-yyy}/{finalMessage.entry[0].id}"))
             *  return new SearchResultModel { searchResult = SearchResultEnum.dataAlreadyProcessed };*/

            var   metaData = finalMessage.entry[0].str[1].Value;
            Regex pattern  = new Regex(@"(?:<gml:coordinates>)(.*.)(?:<)");

            metaData = pattern.Match(metaData).Groups[1].ToString() /*.Replace(" ", ";\n")*/;
            metaData = $"{finalMessage.entry[0].id}:{finalMessage.entry[0].date[3].Value.ToString().Replace(":", "|")}:{metaData}";
            Directory.CreateDirectory($"/app/Copernicus/Processed/{date:dd-MM-yyyy}");
            File.AppendAllText($"/app/Copernicus/Processed/{date:dd-MM-yyyy}/metadata.txt", metaData + "\n");

            await DownloadMapData($"'{finalMessage.entry[0].id}'", finalMessage.entry[0].title, finalMessage.entry[0].date[3].Value);

            return(new SearchResultModel {
                latitude = latitude.ToString(), longitude = longitude.ToString(), date = date, id = finalMessage.entry[0].id, searchResult = SearchResultEnum.success
            });
        }
Exemple #6
0
    public posts(dynamic json)
    {
        jsonObj = json;

        if (jsonObj != null)
        {
            id   = jsonObj.id;
            name = jsonObj.name;
            if (jsonObj.feed != null)
            {
                feed = new feed(jsonObj.feed);
            }
        }
    }
Exemple #7
0
        public static HttpResponseMessage Find(HttpRequestMessage request, string filter, string orderby, bool desc,
                                               string top, string id)
        {
            Uri uri = request.RequestUri;

            string         title    = id.ToLowerInvariant();
            List <Package> packages = PackageDAO.Read(p => p.Title.ToLowerInvariant() == title).Result;

            entry[] entries = filter == "IsLatestVersion"
                ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) }
                : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray();
            DateTime updated = packages.Any()
                ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated
                : DateTime.UtcNow;

            string baseUri = uri.Scheme + "://" + uri.Host + ":" + uri.Port;
            string apiUri  = baseUri + "/api/v2/";

            feed feed = new feed
            {
                @base   = apiUri,
                id      = WebUtility.HtmlDecode(uri.ToString()),
                title   = new feedTitle("FindPackagesById"),
                updated = updated,
                link    = new feedLink("FindPackagesById", "FindPackagesById"),
                entry   = entries
            };

            XmlSerializer serializer = new XmlSerializer(typeof(feed));
            MemoryStream  ms         = new MemoryStream();

            serializer.Serialize(ms, feed);
            ms.Position = 0;
            string result = new StreamReader(ms).ReadToEnd();

            HttpResponseMessage res = request.CreateResponse(HttpStatusCode.OK);

            res.Content = new StringContent(result);

            res.Content.Headers.Remove("Content-Type");
            res.Content.Headers.Add("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
            res.Headers.Add("DataServiceVersion", "2.0;");

            return(res);
        }
Exemple #8
0
        public override Task <List <ArticleModel> > EvaluateFeed(FeedModel feedModel)
        {
            return(ExecuteSafe(async() =>
            {
                var feed = await DownloadAsync(feedModel);

                var articlelist = new List <ArticleModel>();
                if (feed == null)
                {
                    return articlelist;
                }

                var f = JsonConvert.DeserializeObject <feed[]>(feed);
                feed articlefeed = f.FirstOrDefault(i => i.type == "teaser");
                if (articlefeed != null)
                {
                    articlelist.AddRange(articlefeed.items.Where(i => i.type == "teaser")
                                         .Select(i => FeedModelToArticleModel(i, feedModel))
                                         .Where(am => am != null));
                }

                return articlelist;
            }));
        }