Ejemplo n.º 1
0
        public void ItShouldParseAllBundeslands()
        {
            var all = Bundesland.All;

            foreach (var bundesland in all)
            {
                Bundesland.Parse(bundesland.Value).ShouldBeSome().Should().Be(bundesland);
            }
        }
Ejemplo n.º 2
0
        public static async Task <List <Vacation> > LoadForYearAsync(Bundesland bundesland, string year)
        {
            var client   = new HttpClient();
            var response = await client.GetAsync(string.Format("http://api.smartnoob.de/ferien/v1/ferien/?bundesland={0}&jahr={1}", BundeslandShorts[bundesland], year));

            var json = await response.Content.ReadAsStringAsync();

            JObject vacations = JObject.Parse(json);
            var     data      = vacations["daten"].Children().ToList();

            var output = new List <Vacation>();

            foreach (var vacation in data)
            {
                output.Add(JsonConvert.DeserializeObject <Vacation>(vacation.ToString()));
            }
            output.Sort();

            return(output);
        }
Ejemplo n.º 3
0
        List <Bundesland> getBundeslaender()
        {
            List <Bundesland> bundeslaender = new List <Bundesland>();

            con.Open();
            cmd.CommandText = "Select * from Bundesland;";
            reader          = cmd.ExecuteReader();

            while (reader.Read())
            {
                Bundesland bundesland = new Bundesland();

                bundesland.id = reader.GetInt32(0);
                bundesland.kurzbezeichnung = reader.GetString(1);
                bundesland.bezeichnung     = reader.GetString(2);



                bundeslaender.Add(bundesland);
            }
            con.Close();
            return(bundeslaender);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbBundeslaender_SelectedIndexChanged(object sender, EventArgs e)
        {
            Bundesland bundesland   = (Bundesland)lbBundeslaender.SelectedItem;
            int        idBundesland = bundesland.id;

            chartF1.Series.Clear();
            dgvOrders.Rows.Clear();
            clCust objCust = new clCust();

            dt_last_order = new DateTime();

            db_access_connection con = new db_access_connection();

            List <Landkreis> landkreise = con.Landkreis(idBundesland);

            foreach (Landkreis landkreis in landkreise)
            {
                lbLandkreis.Items.Add(landkreis.name.ToString());
                //lbBundeslaender.Items.Add(bundesland.bezeichnung);
            }

            /*
             * //Resten der Check-Boxen
             * cbWood.Enabled = false;
             * cbWood.Checked = false;
             * cbAzV.Checked = false;
             * cbAzV.Enabled = false;
             * cbRestmuell.Enabled = false;
             * cbRestmuell.Checked = false;
             * cbSperrmuell.Enabled = false;
             * cbSperrmuell.Checked = false;
             * cbPaper.Checked = false;
             * cbPaper.Enabled = false;
             *
             * //Variablendeklaration
             * //Diese Nummern bekommen die Serien des Charts
             * series_count = 0;
             * //series_count_azv = 0;
             * //series_count_sperrmuell = 0;
             * //series_count_wood = 0;
             * amoAmount_sperr = 0;
             * amoAmount_azv = 0;
             * amoAmount_wood = 0;
             * amoAmount_paper = 0;
             * middle_weight = 0;
             * int_last_12m_orders = 0;
             *
             *
             * string customer_name = Convert.ToString(lbClients.SelectedItem);
             *
             * objCust.getCust(globalConnectionString, customer_name);
             *
             *
             *
             * lblCustID.Text = "Kundennumer: " +  Convert.ToString(objCust.kundennummer);
             * lblCustName.Text = "Name: " + objCust.name;
             * lblCustContact.Text = "Ansprechpartner: " + objCust.strasse + " " + Convert.ToString(objCust.Hausnummer) + ", " + Convert.ToString(objCust.PLZ) + " " + objCust.ort;
             *
             * clAmount_get f1_clAmountGet = new clAmount_get();
             *
             * List < clAmount > f1_list_clAmountt = new List<clAmount>();
             * f1_list_clAmountt = f1_clAmountGet.getAmount(customer_name, globalConnectionString);
             *
             * //Abfrage für die letzte Bestellung
             * try
             * {
             *  dt_last_order = f1_list_clAmountt[0].amoDate;
             * }
             *
             * catch
             * {
             *  dt_last_order = DateTime.MinValue;
             * }
             *
             *
             *
             *
             * //Auffüllen der DGV mit den jeweiligen Aufträgen
             * for (int i = 0; i < f1_list_clAmountt.Count; i++)
             * {
             *  dgvOrders.Rows.Add(f1_list_clAmountt[i].amoArt, f1_list_clAmountt[i].amoAmount, f1_list_clAmountt[i].amoDate.ToShortDateString());
             *
             *  middle_weight += f1_list_clAmountt[i].amoAmount;
             *
             *  //Abfrage nach der letzten Bestellung
             *  if (f1_list_clAmountt[i].amoDate > dt_last_order)
             *      dt_last_order = f1_list_clAmountt[i].amoDate;
             *
             *  //Abfrage nach der Anzahl der Bestellungen in den letzten 12 Monaten
             *  if (f1_list_clAmountt[i].amoDate < DateTime.Now)
             *      int_last_12m_orders += 1;
             * }
             *
             * draw_Chart(f1_list_clAmountt);
             *
             */
        }
Ejemplo n.º 5
0
 public void ItShouldParseBW()
 {
     Bundesland.Parse("BW").ShouldBeSome().Should().Be(Bundesland.BadenWuerttemberg);
 }
Ejemplo n.º 6
0
        public void ItCreatesTaxNumbers(string bundesland, string input, string expected)
        {
            var model = Bundesland.Parse(bundesland).AssertSome();

            TaxNumber.FromLocalTaxNumber(model, input).should_be_valid().Value.Should().Be(expected);
        }
Ejemplo n.º 7
0
 public void ItShouldReturnNoneInCaseOfInvalidCode()
 {
     Bundesland.Parse("DDT").ShouldBeNone();
 }
Ejemplo n.º 8
0
        public int CompareTo(UeberhangmandatEntryViewModel other)
        {
            var blandcomp = Bundesland.CompareTo(other.Bundesland);

            return(blandcomp != 0 ? blandcomp : Party.CompareTo(other.Party));
        }
 public int CompareTo(BundeslandWithWahlkreiseViewModel <T> other)
 {
     return(Bundesland.CompareTo(other.Bundesland));
 }
Ejemplo n.º 10
0
 public static WahlkreisOverviewViewModel GetWahlkreisOverviewViewModel(int electionId, Bundesland bundesland,
                                                                        BasicWahlkreisOverview overview, IEnumerable <ErststimmeWahlkreisOverview> firstVotes,
                                                                        IEnumerable <ZweitstimmeWahlkreisOverview> secondVotes)
 {
     return(new WahlkreisOverviewViewModel
     {
         ElectionId = electionId,
         Bundesland = new BundeslandViewModel
         {
             Id = bundesland.Id,
             Name = bundesland.Name
         },
         Wahlkreis = new WahlkreisViewModel
         {
             Id = overview.Wahlkreis_Id,
             Name = overview.Wahlkreis_Name
         },
         Participation = overview.Participation ?? -1,
         Candidate = new PersonWithPartyViewModel
         {
             Person = new PersonViewModel
             {
                 Id = overview.Person_Id ?? -1,
                 Title = overview.Title,
                 Firstname = overview.Firstname,
                 Lastname = overview.Lastname
             },
             Party = new PartyViewModel
             {
                 Id = overview.Party_Id,
                 Name = overview.Party_Name
             }
         },
         FirstVotes = GetWahlkreisFirstVotesViewModels(electionId, overview.Wahlkreis_Id, firstVotes).ToList().OrderBy(r => r),
         SecondVotes = GetWahlkreisSecondVotesViewModels(electionId, overview.Wahlkreis_Id, secondVotes).ToList().OrderBy(r => r)
     });
 }
Ejemplo n.º 11
0
 public static BundeslandWithWahlkreiseViewModel <WahlkreisViewModel> GetBundeslandListViewModel(Bundesland bundesland,
                                                                                                 IEnumerable <Wahlkrei> wahlkreise)
 {
     return(new BundeslandWithWahlkreiseViewModel <WahlkreisViewModel>
     {
         Bundesland = new BundeslandViewModel
         {
             Id = bundesland.Id,
             Name = bundesland.Name
         },
         Wahlkreise = GetWahlkreisListViewModels(wahlkreise).ToList().OrderBy(r => r)
     });
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            string resultsUrl = "http://www.bundeswahlleiter.de/de/bundestagswahlen/BTW_BUND_09/ergebnisse/wahlkreisergebnisse/";

            string bundeslandPageContent = DownloadPage(resultsUrl);
            if (bundeslandPageContent == null)
            {
                Console.WriteLine("Bundesländer konnten nicht geladen werden. Abbruch.");
                return;
            }
            SimpleListItem[] bundeslandList = ParseSimpleList(bundeslandPageContent);

            List<Bundesland> bundeslaender = new List<Bundesland>();
            foreach(var curBundesland in bundeslandList)
            {
                Bundesland newBL = new Bundesland();
                newBL.Name = curBundesland.Name;
                newBL.Wahlkreise = new List<Wahlkreis>();
                string blUri = resultsUrl + curBundesland.Link;

                Console.WriteLine("Parse Bundesland " + curBundesland.Name + " ...");

                //Parse Wahlkreise
                string blWahlkreisePageContent = DownloadPage(blUri);
                if (blWahlkreisePageContent == null)
                {
                    Console.WriteLine("Wahlkreise konnten nicht geladen werden. Abbruch.");
                    return;
                }
                SimpleListItem[] blWahlkreiseList = ParseSimpleList(blWahlkreisePageContent);
                foreach (var curWahlkreis in blWahlkreiseList)
                {
                    Wahlkreis newWK = new Wahlkreis();

                    Match wkNameMatch = WahlkreisNameRegex.Match(curWahlkreis.Name);
                    if (wkNameMatch.Success)
                    {
                        newWK.Name = wkNameMatch.Groups["name"].Value;
                        newWK.Nr = int.Parse(wkNameMatch.Groups["nr"].Value);
                    }
                    else
                        newWK.Name = curWahlkreis.Name;

                    Console.WriteLine("  Parse Wahlkreis " + newWK.Name + " ...");

                    //Parse Ergebnisse
                    string wkErgebnisPageContent = DownloadPage(blUri + curWahlkreis.Link);
                    if (wkErgebnisPageContent == null)
                    {
                        Console.WriteLine("Wahlkreise-Ergebnis konnte nicht geladen werden. Abbruch.");
                        return;
                    }

                    var wkVotes = ParseVoteList(wkErgebnisPageContent);
                    newWK.Wahlberechtigte = wkVotes["Wahlberechtigte"]; wkVotes.Remove("Wahlberechtigte");
                    newWK.Waehler = wkVotes["Wähler"]; wkVotes.Remove("Wähler");
                    newWK.Ungueltige = wkVotes["Ungültige"]; wkVotes.Remove("Ungültige");
                    newWK.Gueltige = wkVotes["Gültige"]; wkVotes.Remove("Gültige");

                    newWK.Parteien = new List<Partei>();
                    foreach (var curPartei in wkVotes)
                    {
                        Partei newPartei = new Partei() { Id=GetParteiId(curPartei.Key), Ergebnis=curPartei.Value};
                        newWK.Parteien.Add(newPartei);
                    }

                    newBL.Wahlkreise.Add(newWK);
                }

                bundeslaender.Add(newBL);
            }

            //Write to CSV

            StreamWriter csvWriter = new StreamWriter("Ergebnisse2009.csv", false, Encoding.UTF8);

            csvWriter.WriteLine("Bundestagswahl 2009");
            csvWriter.WriteLine("Endgültig");

            csvWriter.Write("Nr,Gebiet,gehört,Wahlberechtigte,,,,Wähler,,,,Ungültige,,,,Gültige,,,,");
            foreach (string curPartei in ParteienDict.Keys)
                csvWriter.Write(curPartei + ",,,,");
            csvWriter.Write(Environment.NewLine);
            csvWriter.Write(",,zu,");
            for (int a = 1; a < CurParteienDictKey + 4; a++)
                csvWriter.Write("Erststimmen,,Zweitstimmen,,");
            csvWriter.Write(Environment.NewLine);
            csvWriter.Write(",,,");
            for (int a = 1; a < CurParteienDictKey + 4; a++)
                csvWriter.Write("Endgültig,,");

            int CurBundeslandId = 1;
            foreach (var curBL in bundeslaender)
            {
                foreach(var curWK in curBL.Wahlkreise)
                {
                    csvWriter.Write(curWK.Nr + ",");
                    csvWriter.Write("\"" + curWK.Name + "\",");
                    csvWriter.Write(CurBundeslandId + ",");

                    WriteVotes(csvWriter, curWK.Wahlberechtigte);
                    WriteVotes(csvWriter, curWK.Waehler);
                    WriteVotes(csvWriter, curWK.Ungueltige);
                    WriteVotes(csvWriter, curWK.Gueltige);

                    foreach (var curPartei in ParteienDict)
                    {
                        bool foundPartei = false;
                        foreach (var curWkPartei in curWK.Parteien)
                        {
                            if (curPartei.Value == curWkPartei.Id)
                            {
                                WriteVotes(csvWriter, curWkPartei.Ergebnis);
                                foundPartei = true;
                            }
                        }
                        if (!foundPartei)
                            csvWriter.Write(",,,,");
                    }
                    csvWriter.Write(Environment.NewLine);
                }

                csvWriter.Write(CurBundeslandId + ",");
                csvWriter.Write("\"" + curBL.Name + "\",");
                csvWriter.Write("99");
                csvWriter.Write(Environment.NewLine);
                csvWriter.Write(Environment.NewLine);

                CurBundeslandId++;
            }

            csvWriter.Write("99,\"Bundesgebiet\"");
            csvWriter.Write(Environment.NewLine);

            csvWriter.Close();

            Console.ReadLine();
        }