예제 #1
0
        public async Task<Judet[]> InitJudete()
        {

            var dd = new DownloadData();
            var dataBytes =await dd.Data(new Uri("http://data.gov.ro/storage/f/2013-11-01T11%3A53%3A13.359Z/siruta-judete.csv"));
            string data = Encoding.UTF8.GetString(dataBytes);
            var list = new List<Judet>();
            var lines = data.Split(new string[] {Environment.NewLine},StringSplitOptions.RemoveEmptyEntries);
            foreach (var line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                    continue;

                var arr=line.Split(new string[] { ";"}, StringSplitOptions.RemoveEmptyEntries);

                if(arr[0]=="JUD")//header
                    continue;

                var j = new Judet();
                j.Cod = arr[3];
                j.Nume = arr[1];
                j.ID = arr[2];//FSJ
                list.Add(j);
            }
            return list.ToArray();

        }
예제 #2
0
        public async Task<UAT[]> InitUat(Judet[] judete)
        {
            var dd = new DownloadData();
            var dataBytes = await dd.Data(new Uri("http://data.gov.ro/storage/f/2013-11-01T11%3A49%3A59.808Z/siruta.csv"));
            string data = Encoding.UTF8.GetString(dataBytes);
            var list = new List<UAT>();
            var lines = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            Judet lastJudet = null;
            foreach (var line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                    continue;

                var arr = line.Split(new string[] { ";" }, StringSplitOptions.None);

                if (arr[0] == "\"SIRUTA\"")//header
                    continue;

                if (arr[12].Contains("00000000000"))//rang => judet
                {
                    var idJudet = int.Parse(arr[12].Replace("00000000000", "").Replace("\"",""));
                    lastJudet = judete.First(it => it.ID == idJudet.ToString());
                    continue;
                }
                if (lastJudet == null)
                {
                    throw new ArgumentException("not found judet for " + line);
                }
                var uat = new UAT();
                uat.UatTip= (arr[5]);
                uat.Nume = arr[1].Replace("\"", "");
                uat.ID = arr[9];
                
                uat.Judet = lastJudet;
                list.Add(uat);
            }
            return list.ToArray();
            
        }
예제 #3
0
        static AlternateNamesJudet[] GetAlternate(Judet[] jud)
        {
            var alternateNames = new List<AlternateNamesJudet>();
            Func<string, string, AlternateNamesJudet> a = (altNume, Nume) =>
            {
                altNume = altNume.ToLower();
                Nume = Nume.ToLower();
                var alt = new AlternateNamesJudet();
                alt.IDJudet = jud.First(it => it.Nume.ToLower() == Nume).ID;
                alt.AlternateName = altNume;
                return alt;
            };

            alternateNames.Add(a("argeş", "arges"));

            alternateNames.Add(a("bacău", "bacau"));
            alternateNames.Add(a("Bistriţa-N.", "BISTRITA-NASAUD"));
            alternateNames.Add(a("bistriţa-năsăud", "BISTRITA-NASAUD"));
            alternateNames.Add(a("bistrita nasaud", "BISTRITA-NASAUD"));
            alternateNames.Add(a("Botoşani", "Botosani"));
            alternateNames.Add(a("botoșani", "Botosani"));
            alternateNames.Add(a("braşov", "Brasov"));
            alternateNames.Add(a("brașov", "Brasov"));
            alternateNames.Add(a("brăila", "braila"));
            alternateNames.Add(a("buzău", "buzau"));
            alternateNames.Add(a("caraş-s.", "CARAS-SEVERIN"));
            alternateNames.Add(a("caras severin", "CARAS-SEVERIN"));
            alternateNames.Add(a("caraş-severin", "CARAS-SEVERIN"));
            alternateNames.Add(a("călăraşi", "calarasi"));
            alternateNames.Add(a("călărași", "calarasi"));
            alternateNames.Add(a("constanţa", "Constanta"));
            alternateNames.Add(a("constanța", "Constanta"));
            alternateNames.Add(a("dîmboviţa", "dimbovita"));
            alternateNames.Add(a("dâmboviţa", "dimbovita"));
            alternateNames.Add(a("dâmbovita", "dimbovita"));
            alternateNames.Add(a("dambovita", "dimbovita"));
            alternateNames.Add(a("galaţi", "galati"));
            alternateNames.Add(a("ialomiţa", "ialomita"));
            alternateNames.Add(a("ialomița", "ialomita"));
            alternateNames.Add(a("iaşi", "iasi"));
            
            alternateNames.Add(a("maramureş", "maramures"));
            alternateNames.Add(a("mehedinţi", "mehedinti"));
            alternateNames.Add(a("mureş", "mures"));
            alternateNames.Add(a("mureș", "mures"));
            alternateNames.Add(a("neamţ", "neamt"));
            alternateNames.Add(a("satu-mare", "satu_mare"));
            alternateNames.Add(a("satu mare", "satu_mare"));
            alternateNames.Add(a("sălaj", "salaj"));
            alternateNames.Add(a("timiş", "timis"));
            alternateNames.Add(a("vâlcea", "vilcea"));
            alternateNames.Add(a("valcea", "vilcea"));
            alternateNames.Add(a("m.bucureşti", "bucuresti"));
            alternateNames.Add(a("MUNICIPIUL BUCURESTI", "bucuresti"));
            alternateNames.Add(a("bucureşti", "bucuresti"));
            alternateNames.Add(a("sector 1", "bucuresti"));
            alternateNames.Add(a("sector 2", "bucuresti"));
            alternateNames.Add(a("sector 3", "bucuresti"));
            alternateNames.Add(a("sector 4", "bucuresti"));
            alternateNames.Add(a("sector 5", "bucuresti"));
            alternateNames.Add(a("sector 6", "bucuresti"));






            //using (var rep = new Repository<AlternateNamesJudet>())
            //{
            //    await rep.StoreDataAsNew(alternateNames);
            //}
            return alternateNames.ToArray();
        }