예제 #1
0
        public static IEnumerable <SentinelProduct> ReadJson(string json) //e:\Data\S1\Tiles_S1A_UA-EXT_2044434443542054.json
        {
            var items   = JsonConvert.DeserializeObject <Rootobject>(json);
            var imports = new List <SentinelProduct>();

            items.products.ToList().ForEach(p =>
            {
                var import = new SentinelProduct();

                var child = p.indexes.FirstOrDefault(i => i.name == IndexesDictionary[IndexesEnum.product])?.children;

                import.Uuid       = p.uuid;
                import.Id         = p.id;
                import.Identifier = p.identifier;
                import.Instrument = p.instrument;


                if (child != null)
                {
                    import.DateTime      = Helper.Convert <DateTime>(child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Sensing_start])?.value);
                    import.Footprint     = child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Footprint])?.value;
                    import.JTSfootprint  = child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.JTS_footprint])?.value;
                    import.RelativeOrbit = Helper.Convert <int>(child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Relative_orbit_9start0])?.value);
                    import.PassDirection = child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Pass_direction])?.value;
                    import.SliceNumber   = Helper.Convert <int>(child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Slice_number])?.value);
                    import.OrbitNumber   = Helper.Convert <int>(child.FirstOrDefault(c => c.name == productItemsDictionary[ValuebaleProductEnum.Relative_orbit_9start0])?.value);
                }

                imports.Add(import);
            });

            return(imports);
        }
예제 #2
0
        private static void DownloadProbuct(SentinelProduct product, string tileFolderName)
        {
            using (WebClient client = new WebClient())
            {
                client.Credentials = new NetworkCredential(MilSpaceConfiguration.DemStorages.ScihubUserName, MilSpaceConfiguration.DemStorages.ScihubPassword);
                client.QueryString.Add("Id", product.Identifier);
                SentinelProductrequestBuildercs builder = new SentinelProductrequestBuildercs(product.Uuid);

                string tileFolder = Path.Combine(MilSpaceConfiguration.DemStorages.SentinelDownloadStorage, tileFolderName);
                if (!Directory.Exists(tileFolder))
                {
                    try
                    {
                        Directory.CreateDirectory(tileFolder);
                    }
                    catch (Exception ex)
                    {
                        logger.ErrorEx($"Cannot create the folder {tileFolder}");
                        logger.ErrorEx(ex.Message);
                        Client_DownloadFileCompleted(client, new AsyncCompletedEventArgs(ex, true, null));
                        return;
                    }
                }

                string fileName = Path.Combine(MilSpaceConfiguration.DemStorages.SentinelDownloadStorage, tileFolderName, product.Identifier + ".zip");
                client.DownloadFileCompleted += Client_DownloadFileCompleted;
                client.DownloadFileAsync(builder.Url, fileName);
            }
        }