public void CaricaDati(ref Label lb, Liste l) { if (this._b == false) { lb.Text = l.dati; } }
public void Aggiorna(ref Label lbItalia, ref Label lbInfo2) { Directory.CreateDirectory("dati-raw-json"); Directory.CreateDirectory("dati-ordinati"); this.DN = new DatiProxy(url_n, path_n); this.DR = new DatiProxy(url_r, path_r); this.regione = new Liste("denominazione_regione"); this.attributi = new List <Liste>(); this.attributi.Add(new Liste("Italia")); this.attributi.Add(new Liste("variazione_totale_positivi")); this.attributi.Add(new Liste("totale_casi")); this.attributi.Add(new Liste("totale_positivi")); this.attributi.Add(new Liste("dimessi_guariti")); this.attributi.Add(new Liste("deceduti")); var director = new Director(); var builder = new ConcreteBuilder(); director.Builder = builder; try { foreach (JObject jobj in this.DN.DownloadDati()) { director.AndamentoNazionale(jobj); Product p = builder.GetProduct(); data = p.GetData(); attributi[0].dictionary = p.GetParts(); } foreach (JObject jobj in this.DR.DownloadDati()) { director.Regione(jobj); Product p = builder.GetProduct(); string reg = regione.GetPart(p); for (int i = 1; i < attributi.Count; i++) { attributi[i].dictionary.Add(reg, attributi[i].GetPart(p)); } } foreach (Liste l in attributi) { l.Order(); } File.WriteAllText("dati-raw-json/data.txt", data); lbInfo2.Text = "\n_Dati aggiornati\n con successo!!\n"; } catch (Exception) { lbInfo2.Text = "\nAggiornamento non riuscito,\ncontrolla la connessione!!\n"; } finally { this.StampaDati(ref lbItalia, 0); } }
public LoadProxy(ref Label lb, Liste l) { this.b = true; if (File.Exists($"dati-ordinati/{l._name}.txt")) { StreamReader sr1 = File.OpenText($"dati-ordinati/{l._name}.txt"); l.dati = ""; while (!sr1.EndOfStream) { l.dati += $"{sr1.ReadLine()}\n"; } this.b = (lb.Text == l.dati) ? true : false; } else { lb.Text = ("Dati non presenti\naggiorna"); } }
public void CaricaDati(ref Label lb, Liste l) { this.GetLoad(this.b).CaricaDati(ref lb, l); }