static void Main(string[] arguments) { var args = new Devmasters.Args(arguments, new string[] { "/apikey" }); //create dataset if (!args.MandatoryPresent()) { Console.WriteLine("MostyRSD /apikey=...."); return; } try { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Most> .OpenDataset(args["/apikey"], "stav-mostu"); } catch (HlidacStatu.Api.V2.CoreApi.Client.ApiException e) { //ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset<Most>.CreateDataset(apiKey, reg); } catch (Exception e) { throw; } //download, parse and save data into dataset var mosty = DownloadData(ds); GenerateAllKML(mosty); }
static void Main(string[] arguments) { var conf = new HlidacStatu.Api.V2.CoreApi.Client.Configuration(); conf.AddDefaultHeader("Authorization", System.Configuration.ConfigurationManager.AppSettings["apikey"]); conf.Timeout = 180 * 1000; api2 = HlidacStatu.Api.V2.Dataset.Typed.Dataset <record> .OpenDataset(System.Configuration.ConfigurationManager.AppSettings["apikey"], DataSetId); args = new Devmasters.Args(arguments, new string[] { "/mp3path" }); logger.Info("Starting with params" + string.Join(" ", args.Arguments)); //create dataset if (!args.MandatoryPresent()) { Help(); return; } string osobaId = args["/osobaid"]; string playlist = args["/playlist"]; int threads = args.GetNumber("/t") ?? 5; int max = args.GetNumber("/max") ?? 300; string[] vids = args.GetArray("/ids"); string mp3path = args["/mp3path"]; HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", System.Configuration.ConfigurationManager.AppSettings["apikey"]); var jsonResult = httpClient.GetStringAsync("https://www.hlidacstatu.cz/api/v2/osoby/social?typ=Youtube") .Result; var osoby = Newtonsoft.Json.JsonConvert.DeserializeObject <osoba[]>(jsonResult); foreach (var o in osoby) { foreach (var url in o.SocialniSite) { if (string.IsNullOrEmpty(osobaId)) { Process(o, url.Url, threads, max, vids, mp3path); } else if (o.NameId == osobaId) { Process(o, url.Url, threads, max, vids, mp3path); } } } }
public Dataset(string token) { try { Connector = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Trest> .OpenDataset(token, "rejstrik-trestu-pravnickych-osob"); } catch (Exception e) { throw; } }
static DateTime startDt = DateTime.Now.Date.AddDays(-10); //new DateTime(2020,09,04); public static void ProcessExcelObsazenost(string fn, HlidacStatu.Api.V2.Dataset.Typed.Dataset <NemocniceData> ds) { Devmasters.Logging.Logger.Root.Info($"ProcessExcelObsazenost {fn} "); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (var p = new ExcelPackage(new System.IO.FileInfo(fn))) { foreach (var ws in p.Workbook.Worksheets) { //first date 2020-09-04 for (int row = 11; row < 100000; row++) { var dt = ws.Cells[row, 1].GetValue <DateTime?>(); if (dt.HasValue && dt.Value >= startDt) { string id = "id_" + dt.Value.ToString("yyyy-MM-dd"); Console.Write(dt.Value.ToString("yyyy-MM-dd ")); NemocniceData data = null; try { data = ds.GetItem(id); } catch (Exception) { } if (data == null) { continue; } var region = data.regions.FirstOrDefault(m => m.region == NemocniceData.ExcelWorkBookToRegion(ws.Name)); if (region != null) { var idx = data.regions.IndexOf(region); data.regions[idx].Pacienti_bezpriznaku = ws.Cells[row, 7].GetValue <int>(); data.regions[idx].Pacienti_lehky = ws.Cells[row, 8].GetValue <int>(); data.regions[idx].Pacienti_stredni = ws.Cells[row, 9].GetValue <int>(); data.regions[idx].Pacienti_tezky = ws.Cells[row, 10].GetValue <int>(); data.regions[idx].Pacienti_zemreli = ws.Cells[row, 22].GetValue <int>() - ws.Cells[row - 1, 22].GetValue <int>(); Devmasters.Logging.Logger.Root.Info($"ProcessExcelObsazenost save {ws.Name} - {dt.Value.ToString("yyyy-MM-dd ")} - {region.region} "); ds.AddOrUpdateItem(data, HlidacStatu.Api.V2.Dataset.Typed.ItemInsertMode.rewrite); } else { Console.WriteLine("not found region " + ws.Name); } } } } } }
public static void Imap(string password, HlidacStatu.Api.V2.Dataset.Typed.Dataset <NemocniceData> ds) { string obsazenostFile = null; Devmasters.Logging.Logger.Root.Info("connection to uzisbackupmbx@"); using (ImapClient Client = new ImapClient("imap.gmail.com", 993, "*****@*****.**", password, AuthMethod.Login, true)) { // This returns all messages sent since August 23rd 2012. IEnumerable <uint> uids = Client.Search( SearchCondition.Unseen() ); Devmasters.Logging.Logger.Root.Info($"found {uids.Count()} email"); // The expression will be evaluated for every MIME part // of every mail message in the uids collection. IEnumerable <MailMessage> messages = Client.GetMessages(uids, true); foreach (var msg in messages) { string reportDir = uzisRoot + msg.Date()?.ToString("yyyy-MM-dd") + "\\"; if (System.IO.Directory.Exists(reportDir) == false) { System.IO.Directory.CreateDirectory(reportDir); } Devmasters.Logging.Logger.Root.Info($"saving {msg.Attachments?.Count()} files"); foreach (var att in msg.Attachments) { if (att.ContentDisposition.Inline == false) { var attfn = MakeValidFileName(att.Name); using (var fs = System.IO.File.Create(reportDir + attfn)) { att.ContentStream.Seek(0, System.IO.SeekOrigin.Begin); att.ContentStream.CopyTo(fs); } if (attfn.Contains("hosp04_KRAJE")) { obsazenostFile = reportDir + attfn; Obsazenost.ProcessExcelObsazenost(obsazenostFile, ds); } } } } } }
public static void LastObsazenost(HlidacStatu.Api.V2.Dataset.Typed.Dataset <NemocniceData> ds) { for (int i = 0; i < 10; i++) { DateTime dt = DateTime.Now.Date.AddDays(-1 * i); string reportDir = uzisRoot + dt.ToString("yyyy-MM-dd") + "\\"; if (System.IO.Directory.Exists(reportDir)) { foreach (var fn in System.IO.Directory.EnumerateFiles(reportDir, "*.xlsx")) { if (fn.Contains("hosp04_KRAJE")) { Devmasters.Logging.Logger.Root.Info($"Process lastObsazenost {fn}"); Obsazenost.ProcessExcelObsazenost(fn, ds); return; } } } } }
static List <Most> DownloadData(HlidacStatu.Api.V2.Dataset.Typed.Dataset <Most> ds) { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/plain")); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*")); //httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json;charset=UTF-8"); Console.Write($"Reading data from source ...."); var content = new System.Net.Http.StringContent( "{\"bounds\":{\"epsg\":\"5514\",\"esri\":\"10267\",\"xmin\":-991863.6,\"xmax\":-77136.4,\"ymin\":-1255189.7,\"ymax\":-896165},\"layers\":\" Most\",\"zoomIndex\":17}" //cela cr //"{\"bounds\":{\"epsg\":\"5514\",\"esri\":\"10267\",\"xmin\":-727484.2,\"xmax\":-720530.9,\"ymin\":-1065980.9,\"ymax\":-1063864.3},\"layers\":\"Most Podjezd\",\"zoomIndex\":14}" //test mirosovice , System.Text.Encoding.UTF8, "application/json"); var jsonResult = httpClient.PostAsync("http://bms.clevera.cz/api/assetregistermap/GetMapAllObjects?t=1&d=0", content) .Result.Content .ReadAsStringAsync().Result; Console.WriteLine($"Done."); var data = Newtonsoft.Json.Linq.JObject.Parse(jsonResult); //JArray mosty = data["MapObjects"]; List <Most> mosty = new List <Most>(); int count = 0; int total = data["MapObjects"].Count(); ParallelOptions po = new ParallelOptions() { MaxDegreeOfParallelism = 5 }; Parallel.ForEach <JToken>(data["MapObjects"], po, jo => { var c = System.Threading.Interlocked.Increment(ref count); if (c % 20 == 0) { Console.WriteLine($"{count} z {total}"); } Most m = new Most(); m.Id = jo["g"].Value <string>(); var gps = Geo.JTSK.ToWgs( Math.Abs(jo["y"].Value <double>()), Math.Abs(jo["x"].Value <double>()) ); m.GPS_Lat = gps.getLatitude(); m.GPS_Lng = gps.getLongitude(); var dataMost = httpClient.GetStringAsync("http://bms.clevera.cz/api/assetregistermap/GetMapObjekt?g=" + m.Id).Result; var jsonMost = Newtonsoft.Json.Linq.JObject.Parse(dataMost); if (jsonMost["o"] != null) { m.Jmeno = jsonMost["o"]["n"].Value <string>(); m.MistniNazev = jsonMost["o"]["m"].Value <string>(); m.Oznaceni = jsonMost["o"]["c"].Value <string>(); string[] spravce = jsonMost["o"]["sl"].Value <string>().Split('|'); m.SpravaOrganizace = spravce[0]; if (spravce.Length > 1) { m.SpravaStredisko = spravce[1]; if (spravce.Length > 2) { m.SpravaProvozniUsek = spravce[2]; } } m.PopisStavu = jsonMost["o"]["s"].Value <string>()?.Trim() ?? ""; if (m.PopisStavu.StartsWith("I ")) { m.Stav = 1; } else if (m.PopisStavu.StartsWith("II ")) { m.Stav = 2; } else if (m.PopisStavu.StartsWith("III ")) { m.Stav = 3; } else if (m.PopisStavu.StartsWith("IV ")) { m.Stav = 4; } else if (m.PopisStavu.StartsWith("V ")) { m.Stav = 5; } else if (m.PopisStavu.StartsWith("VI ")) { m.Stav = 6; } else if (m.PopisStavu.StartsWith("VII ")) { m.Stav = 7; } else if (m.PopisStavu.StartsWith("VIII ")) { m.Stav = 8; } m.ProhlidkaPopis = jsonMost["o"]["p"].Value <string>()?.Trim() ?? ""; var dat = GetRegexGroupValue(m.ProhlidkaPopis, @"(?<dat>\d{2}\.\d{2}\.\d{4})", "dat"); if (!string.IsNullOrEmpty(dat)) { if (DateTime.TryParseExact(dat, "dd.MM.yyyy", System.Globalization.CultureInfo.GetCultureInfo("cs"), System.Globalization.DateTimeStyles.AssumeLocal, out var datum)) { m.PosledniProhlidka = datum; } } mosty.Add(m); var id = ds.AddOrUpdateItem(m, HlidacStatu.Api.V2.Dataset.Typed.ItemInsertMode.rewrite); } }); return(mosty); }
static void Main(string[] arguments) { Console.WriteLine($"Jednání-Rady-ČT - {System.Reflection.Assembly.GetEntryAssembly().GetName().Version}"); Devmasters.Logging.Logger.Root.Info($"Jednání-Rady-ČT - {System.Reflection.Assembly.GetEntryAssembly().GetName().Version}"); Devmasters.Logging.Logger.Root.Debug("Jednání Rady ČT starting with " + string.Join(',', arguments)); var args = new Devmasters.Args(arguments, new string[] { "/mp3path", "/apikey" }); if (args.MandatoryPresent() == false) { Help(); } mp3path = args.Get("/mp3path", null); if (args.Exists("/utdl")) { YTDL = args["/utdl"]; } else { YTDL = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe"; } startPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); apiKey = args["/apikey"]; rewrite = args.Exists("/rewrite"); afterDay = DateTime.Now.Date.AddDays(-1 * args.GetNumber("/daysback", 10000).Value); if (args.Exists("/ids")) { ids = args.GetArray("/ids"); } skips2t = args.Exists("/skips2t"); int threads = args.GetNumber("/t") ?? 5; try { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Jednani> .OpenDataset(apiKey, DataSetId); } catch (ApiException e) { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Jednani> .CreateDataset(apiKey, Registration()); } catch (Exception e) { throw; } string nextPages = "https://www.ceskatelevize.cz/ivysilani/10000000064-jednani-rady-ceske-televize/dalsi-casti/{0}"; int page = 0; bool stop = false; List <Jednani> jednani = new List <Jednani>(); do { page++; using (Devmasters.Net.HttpClient.URLContent net = new Devmasters.Net.HttpClient.URLContent(string.Format(nextPages, page))) { Console.WriteLine($"Page {page}"); net.IgnoreHttpErrors = true; net.Tries = 5; net.TimeInMsBetweenTries = 2000; string html = ""; try { Devmasters.Logging.Logger.Root.Debug($"downloading {net.Url} "); html = net.GetContent().Text; } catch (Exception e) { Devmasters.Logging.Logger.Root.Error($"{net.Url} failed", e); } Devmasters.XPath xp = new Devmasters.XPath(html); var links = xp.GetNodes("//li[contains(@class,'itemBlock')]"); if (links == null || links.Count == 0) { break; } foreach (var link in links) { Jednani j = new Jednani(); j.Odkaz = urlPrefix + Devmasters.XPath.Tools.GetNodeAttributeValue(link, "div/h3/a[@class='itemSetPaging']", "href"); j.Titulek = Devmasters.XPath.Tools.GetNodeText(link, "div/h3/a[@class='itemSetPaging']").Trim(); j.DatumJednani = Devmasters.DT.Util.ToDate(Devmasters.XPath.Tools.GetNodeText(link, "div/p").Trim()) ?? DateTime.MinValue; j.Id = Devmasters.RegexUtil.GetRegexGroupValue(j.Odkaz, "/ivysilani/10000000064-jednani-rady-ceske-televize/(?<id>\\d{2,})", "id"); if (j.DatumJednani > afterDay && (ids == null || ids.Contains(j.Id)) ) { jednani.Add(j); } } } } while (stop == false); // Devmasters.Logging.Logger.Root.Debug($"Starting {jednani.Count} items "); Devmasters.Batch.Manager.DoActionForAll <string>(jednani.Select(m => m.Id).Reverse(), id => { bool exists = ds.ItemExists(id); if (!string.IsNullOrEmpty(id) && (!exists || rewrite) ) { Devmasters.Logging.Logger.Root.Debug($"Start parsing {id} "); var fullJ = ParseJednani(jednani.First(m => m.Id == id)); Devmasters.Logging.Logger.Root.Debug($"Saving {id} "); ds.AddOrUpdateItem(fullJ, HlidacStatu.Api.V2.Dataset.Typed.ItemInsertMode.rewrite); } else if (exists) { //check voice2text var fullJ = ds.GetItemSafe(id); if (!(fullJ.PrepisAudia?.Count() > 0)) { Devmasters.Logging.Logger.Root.Debug($"Checking AUDIO text {id} "); var aud = Audio(fullJ); if (aud?.Count() > 0) { fullJ.PrepisAudia = aud; ds.AddOrUpdateItem(fullJ, HlidacStatu.Api.V2.Dataset.Typed.ItemInsertMode.rewrite); } } } return(new Devmasters.Batch.ActionOutputData() { Log = id }); }, true, maxDegreeOfParallelism: threads); }
static void Main(string[] parameters) { var args = new Devmasters.Args(parameters); logger.Info($"Starting with args {string.Join(' ',parameters)}"); apiKey = args["/apikey"]; force = args.Exists("/force"); var jsonGen = new JSchemaGenerator { DefaultRequired = Required.Default }; var genJsonSchema = jsonGen.Generate(typeof(majitele)).ToString(); HlidacStatu.Api.V2.CoreApi.Model.Registration reg = new HlidacStatu.Api.V2.CoreApi.Model.Registration( "Skuteční majitelé firem", DatasetNameId, "https://esm.justice.cz/", "https://github.com/HlidacStatu/Datasety/tree/master/SkutecniMajitele", "Evidence skutečných majitelů firem podle zákona č. 37/2021 Sb.", genJsonSchema, betaversion: true, allowWriteAccess: false, orderList: new string[, ] { { "Podle datumu zápisu", "datum_zapis" }, { "Podle IČ subjektu", "ico" }, }, defaultOrderBy: "datum_zapis desc", searchResultTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template() { Body = @" <!-- scriban {{ date.now }} --> <table class=""table table-hover""> <thead> <tr> <th>Detail</th> <th>Subjekt</th> <th>Skutečný majitel</th> </tr> </thead> <tbody> {{ for item in model.Result }} <tr> <td ><a href=""{{ fn_DatasetItemUrl item.id }}"">{{item.id}}</a></td> <td >{{fn_RenderCompanyWithLink item.ico}}</td> <td > {{ for sk in item.skutecni_majitele }} {{ if !(fn_IsNullOrEmpty sk.osobaId) }} {{fn_RenderPersonWithLink2 sk.osobaId}}, {{else }} {{sk.osoba_jmeno}} {{sk.osoba_prijmeni}}, {{ end }} {{end }} </td> </tr> {{ end }} </tbody></table> " }, detailTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template() { Body = @" <!-- scriban {{ date.now }} --> {{this.item = model}} <table class=""table table-hover""><tbody> <tr><td>IČ</td><td ><a href=""{{ fn_DatasetItemUrl item.id }}"">{{item.id}}</a></td></tr> <tr><td>Subjekt</td><td >{{fn_RenderCompanyWithLink item.ico}}<br/> {{fn_RenderCompanyInformations item.ico 3}}</td></tr> <tr><td>Skutečný majitel</td><td > {{ for sk in item.skutecni_majitele }} <dl> <dt> {{ if !(fn_IsNullOrEmpty sk.osobaId) }} {{fn_RenderPersonWithLink2 sk.osobaId}} {{else }} {{sk.osoba_jmeno}} {{sk.osoba_prijmeni}} {{end}} ({{sk.udaj_typ_nazev}}) </dt> <dd> {{if !(fn_IsNullOrEmpty sk.podil_na_prospechu_hodnota) }} Podíl na prospěchu ze společnosti: {{sk.podil_na_prospechu_hodnota}} {{if sk.podil_na_prospechu_typ==""PROCENTA""}}%{{else}}({{sk.podil_na_prospechu_typ}}){{end}} <br/> {{end}} {{if !(fn_IsNullOrEmpty sk.podil_na_hlasovani_hodnota) }} Podíl na hlasovacích právech: {{sk.podil_na_hlasovani_hodnota}} {{if sk.podil_na_hlasovani_typ==""PROCENTA""}}%{{else}}({{sk.podil_na_hlasovani_typ}}){{end}} <br/> {{end}} </dd> </dl> {{end }} </td></tr> </table> " } ); try { if (args.Exists("/new")) { Configuration configuration = new Configuration(); configuration.AddDefaultHeader("Authorization", apiKey); HlidacStatu.Api.V2.CoreApi.DatasetyApi datasetyApi = new HlidacStatu.Api.V2.CoreApi.DatasetyApi(configuration); datasetyApi.ApiV2DatasetyDelete(reg.DatasetId); } ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <majitele> .OpenDataset(apiKey, DatasetNameId); } catch (HlidacStatu.Api.V2.CoreApi.Client.ApiException e) { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <majitele> .CreateDataset(apiKey, reg); } catch (Exception e) { throw; } var wc = new System.Net.WebClient(); var package_list = Newtonsoft.Json.Linq.JObject.Parse( wc.DownloadString("https://dataor.justice.cz/api/3/action/package_list") ); var onlyCurrYears = package_list["result"] .ToArray() .Select(m => m.Value <string>()) .Where(m => m.EndsWith($"-{DateTime.Now.Year}") && m.Contains("-full-")) //.Where(m => m == "as-full-ostrava-2021") //DEBUG ; Devmasters.Batch.Manager.DoActionForAll <string>(onlyCurrYears, name => { ProcessXML(args, name); return(new Devmasters.Batch.ActionOutputData()); }, Devmasters.Batch.Manager.DefaultOutputWriter, Devmasters.Batch.Manager.DefaultProgressWriter, !System.Diagnostics.Debugger.IsAttached, maxDegreeOfParallelism: 2, prefix: "Get XMLS "); }
static void InitDS(bool recreate, string apiKey) { var jsonGen = new JSchemaGenerator { DefaultRequired = Required.Default }; var genJsonSchema = jsonGen.Generate(typeof(UOHSData)).ToString(); HlidacStatu.Api.V2.CoreApi.Model.Registration reg = new HlidacStatu.Api.V2.CoreApi.Model.Registration( "Rozhodnutí UOHS", datasetId, "http://www.uohs.cz/cs/verejne-zakazky/sbirky-rozhodnuti/", "https://github.com/HlidacStatu/Datasety/tree/master/Rozhodnuti-UOHS", "Sbírka rozhodnutí Úřadu pro ochranu hospodářské soutěže od roku 1999 v oblastech hospodářská soutěž, veřejné zakázky, veřejná podpora a významná tržní síla.", genJsonSchema, betaversion: false, allowWriteAccess: false, orderList: new string[, ] { { "Podle datumu právní moci", "PravniMoc" }, { "Podle roku", "Rok" }, { "Podle IČ subjektu", "ico" }, }, defaultOrderBy: "PravniMoc desc", searchResultTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template() { Body = @" <!-- scriban {{ date.now }} --> <table class=""table table-hover""> <thead> <tr> <th>ČJ </th> <th>Instance </th> <th>Nabytí právní moci </th> <th>Účastníci řízení </th> <th>Věc </th> <th>Typ správního řízení </th> </tr> </thead> <tbody> {{ for item in model.Result }} <tr> <td style=""white-space: nowrap;""> <a href=""{{fn_DatasetItemUrl item.Id}}"">{{ fn_ShortenText item.Cj 20 }} </a> </td> <td style=""white-space: nowrap;""> {{item.Instance}} </td> <td> {{fn_FormatDate item.PravniMoc ""dd.MM.yyyy""}} </td> <td> {{ for u in item.Ucastnici}} {{ if (fn_IsNullOrEmpty u.ICO)}} {{ fn_NormalizeText u.Jmeno }} {{else}} <a href=""https://www.hlidacstatu.cz/subjekt/{{u.ICO}}"">{{fn_NormalizeText u.Jmeno}} </a> <br /> {{end #if }} {{ end #for }} </td> <td> {{fn_ShortenText item.Vec 200}} </td> <td>{{item.Typ_spravniho_rizeni}} </td> </tr> {{end }} </tbody> </table> " }, detailTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template() { Body = @" <!-- scriban {{ date.now }} --> {{this.item = model}} <table class=""table table-hover""> <tbody> <tr> <td>Číslo jednací </td> <td>{{item.Cj}} </td> </tr> <tr> <td>Instance </td> <td>{{item.Instance}} </td> </tr> <tr> <td>Věc </td> <td>{{ fn_HighlightText highlightingData item.Vec ""Vec"" }} </td> </tr> <tr> <td>Účastníci </td> <td> {{for u in item.Ucastnici}} {{ if (fn_IsNullOrEmpty u.ICO) }} {{fn_NormalizeText u.Jmeno}} {{else}} <a href=""https://www.hlidacstatu.cz/subjekt/{{u.ICO}}"">{{fn_NormalizeText u.Jmeno}} </a> <br /> {{end}} {{end}} </td> </tr> <tr> <td>Typ řízení </td> <td>{{item.Typ_spravniho_rizeni}} </td> </tr> <tr> <td>Typ rozhodnutí </td> <td>{{item.Typ_spravniho_rizeni}} </td> </tr> <tr> <td>Nabytí právní moci </td> <td>{{fn_FormatDate item.PravniMoc ""dd.MM.yyyy""}} </td> </tr> <tr> <td>Související řízení </td> <td> {{for u in item.SouvisejiciUrl}} <a href=""{{u}}"">{{u}} </a> <br /> {{end}} </td> </tr> <tr> <td>Zdroj na UOHS </td> <td> <a href=""{{item.Url}}"" target=""_blank"">{{item.Url}} </a> </td> </tr> {{ if item.Rozhodnuti}} <tr> <td>Rozhodnutí </td> <td> <pre> {{ fn_HighlightText highlightingData item.Rozhodnuti.PlainText ""Rozhodnuti.PlainText"" }} </pre> </td> </tr> {{end}} </tbody> </table> " } ); try { if (recreate) { Configuration configuration = new Configuration(); configuration.AddDefaultHeader("Authorization", apiKey); if (debug) { System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true; configuration.BasePath = "https://local.hlidacstatu.cz"; } HlidacStatu.Api.V2.CoreApi.DatasetyApi datasetyApi = new HlidacStatu.Api.V2.CoreApi.DatasetyApi(configuration); datasetyApi.ApiV2DatasetyDelete(reg.DatasetId); } if (debug) { System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true; ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <UOHSData> .OpenDataset(apiKey, datasetId, "https://local.hlidacstatu.cz"); } else { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <UOHSData> .OpenDataset(apiKey, datasetId); } } catch (HlidacStatu.Api.V2.CoreApi.Client.ApiException e) { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <UOHSData> .CreateDataset(apiKey, reg); } catch (Exception e) { throw; } }
static void CreateDataset(Dictionary <string, string> args) { var jsonGen = new JSchemaGenerator { DefaultRequired = Required.Default }; var genJsonSchema = jsonGen.Generate(typeof(Nemocnice)).ToString(); HlidacStatu.Api.V2.CoreApi.Model.Registration reg = new HlidacStatu.Api.V2.CoreApi.Model.Registration( "Online dispečink intenzivní péče – volné kapacity nemocnic", "kapacity-jedn-nemocnic", "https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19", "", "Všechna data jsou přehledně zobrazena na https://www.hlidacstatu.cz/kapacitanemocnic", genJsonSchema, betaversion: false, allowWriteAccess: false, searchResultTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template("", @"<br/> <br/> <br/> <br/> <p style=""font-size:160%;font-weight:bold;""> Všechna data jsou přehledně zobrazena na <a href=""https://www.hlidacstatu.cz/kapacitanemocnic?utm_source=dataset&utm_medium=link&utm_campaign=kapacitanemocnic"">https://www.hlidacstatu.cz/kapacitanemocnic</a> </p> <br/> <br/> Zde jsou uložena v databázi a jsou tak snadno dostupná pro veřejnost přes <a href=""https://www.hlidacstatu.cz/api/v2/swagger/index#/Datasety"">API, aktuální a ve strojově čitelné podobě</a>. <br/> <br/> Originální data v Excelu jsou ke stažení na <a href=""https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19"">https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19</a>, část ""<i>COVID‑19: Online dispečink intenzivní péče – volné kapacity </i>"" <br/> "), detailTemplate: new HlidacStatu.Api.V2.CoreApi.Model.Template("", @"<br/> <br/> <br/> <br/> <p style=""font-size:160%;font-weight:bold;""> Všechna data jsou přehledně zobrazena na <a href=""https://www.hlidacstatu.cz/kapacitanemocnic?utm_source=dataset&utm_medium=link&utm_campaign=kapacitanemocnic"">https://www.hlidacstatu.cz/kapacitanemocnic</a> </p> <br/> <br/> Zde jsou uložena v databázi a jsou tak snadno dostupná pro veřejnost přes <a href=""https://www.hlidacstatu.cz/api/v2/swagger/index#/Datasety"">API, aktuální a ve strojově čitelné podobě</a>. <br/> <br/> Originální data v Excelu jsou ke stažení na <a href=""https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19"">https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19</a>, část ""<i>COVID‑19: Online dispečink intenzivní péče – volné kapacity </i>"" <br/> ") ); try { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Nemocnice> .OpenDataset(args["/apikey"], "kapacity-jedn-nemocnic"); if (ds == null) { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Nemocnice> .CreateDataset(args["/apikey"], reg); } } catch (ApiException e) { ds = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Nemocnice> .CreateDataset(args["/apikey"], reg); } catch (Exception e) { throw; } }
static void Main(string[] args) { string argValue = string.Empty; if (args.Count() == 0) { Help(); return; } Dictionary <string, string> arguments = new Dictionary <string, string>(); arguments = args .Select(m => m.Split('=')) .ToDictionary(m => m[0].ToLower(), v => v.Length == 1 ? "" : v[1]); if (!arguments.TryGetValue("/apikey", out apikey)) { Help(); return; } int daysBack = 3; if (arguments.TryGetValue("/daysback", out argValue)) { daysBack = Convert.ToInt32(argValue); } int rok = 0; if (arguments.TryGetValue("/rok", out argValue)) { rok = Convert.ToInt32(argValue); } else { Help(); return; } bool rewrite = false; if (arguments.TryGetValue("/rewrite", out argValue)) { rewrite = true; } int?schuze = null; if (arguments.TryGetValue("/schuze", out argValue)) { schuze = Convert.ToInt32(argValue); } dsc = HlidacStatu.Api.V2.Dataset.Typed.Dataset <Steno> .OpenDataset(apikey, "stenozaznamy-psp"); //create dataset string datasetid = "stenozaznamy-psp"; //var data = ParsePSPWeb.ParseSchuze(2010, 5).ToArray(); //System.Diagnostics.Debugger.Break(); StreamWriter reader = null; CsvWriter csv = null; HashSet <string> jmena2Check = new HashSet <string>(); var vsechnSchuze = ParsePSPWeb.VsechnySchuze(rok); //find latest item already in DB var lastSchuzeInDb = 1; List <int> schuzeToParse = new List <int>(); if (schuze.HasValue) { schuzeToParse.Add(schuze.Value); } else if (rewrite) { schuzeToParse.AddRange(vsechnSchuze.Select(m => m.schuze)); } else { //za posledni 3 dny DateTime after = DateTime.Now.Date.AddDays(-1 * daysBack); schuzeToParse.AddRange(vsechnSchuze.Where(m => m.last >= after).Select(m => m.schuze)); } Console.WriteLine("Zpracuji schuze " + string.Join(",", schuzeToParse)); Devmasters.Batch.Manager.DoActionForAll <int>(schuzeToParse, s => { foreach (var item in ParsePSPWeb.ParseSchuze(rok, s)) { try { if (rewrite == false) { var exists = dsc.ItemExists(item.Id); if (exists) { continue; //exists, skip } } } catch (Exception) //doesnt exists { } if (item.celeJmeno?.Split(' ')?.Count() > 2) { if (!jmena2Check.Contains(item.celeJmeno)) { jmena2Check.Add(item.celeJmeno); } } using (var net = new Devmasters.Net.HttpClient.URLContent($"https://www.hlidacstatu.cz/api/v1/PoliticiFromText?Authorization={apikey}")) { net.Method = Devmasters.Net.HttpClient.MethodEnum.POST; net.RequestParams.Form.Add("text", item.text); net.Timeout = 60 * 1000; var sosoby = net.GetContent().Text; var osoby = Newtonsoft.Json.Linq.JArray.Parse(sosoby); if (osoby != null && osoby.Count > 0) { item.politiciZminky = osoby .Select(ja => ja.Value <string>("osobaid")) .Where(o => !string.IsNullOrWhiteSpace(o)) .ToArray(); } } if (apikey == "csv") { csv.WriteRecord <Steno>(item); csv.NextRecord(); if (item.poradi % 10 == 0) { csv.Flush(); } } else { SaveItem(item, true); } } return(new Devmasters.Batch.ActionOutputData()); }, !System.Diagnostics.Debugger.IsAttached); if (apikey == "csv") { csv.Flush(); csv.Dispose(); reader.Close(); } Console.WriteLine(); Console.WriteLine("Podezrela jmena:"); foreach (var k in jmena2Check) { Console.WriteLine(k); } return; //download, parse and save data into dataset //GetData(dsDef, datasetid, fn); }