public async Task <bool> Handle(AnalysisJsProvinceCommand command, CancellationToken cancellationToken)
        {
            var dicProvince = JsonConvert.DeserializeObject <Dictionary <string, JArray> >(_areaContextService.ProvinceString);
            var jaArea      = JsonConvert.DeserializeObject <JArray>(_areaContextService.AreaString);

            foreach (var key in dicProvince.Keys)
            {
                var rows = new List <object>();
                foreach (var obj in dicProvince[key])
                {
                    var code  = obj[0].Value <string>();
                    var props = new List <object> {
                        code.ToInt(), obj[1][0].Value <string>(), AreaContextService.FirstItemKey.ToInt()
                    };
                    if (code == "110000")
                    {
                        rows.Insert(0, props);//确保北京在第一个
                    }
                    else
                    {
                        rows.Add(props);
                    }

                    RecursiveAdd(jaArea, code);
                }
                _areaContextService.GetFirstDicItem().TryAdd(key, rows);
            }
            return(true);
        }
        public async Task <bool> Handle(AnalysisJsGangAoCommand command, CancellationToken cancellationToken)
        {
            //将澳追加到A-G
            var array  = JsonConvert.DeserializeObject <JArray>(_areaContextService.GangAoString);
            var aoCode = "820000";
            var ao     = array.First(i => i[0].Value <string>() == aoCode);
            var pao    = new List <object> {
                aoCode.ToInt(), ao[1][0].Value <string>(), AreaContextService.FirstItemKey.ToInt()
            };

            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyAg] as List <object>)?.Add(pao);
            RecursiveAdd(array, aoCode);

            //将香港追加到T-Z
            var gangCode = "810000";
            var gang     = array.First(i => i[0].Value <string>() == gangCode);
            var pgang    = new List <object> {
                gangCode.ToInt(), gang[1][0].Value <string>(), AreaContextService.FirstItemKey.ToInt()
            };

            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyTz] as List <object>)?.Add(pgang);
            RecursiveAdd(array, gangCode);
            return(true);
        }
Exemple #3
0
        public async Task <bool> Handle(AnalysisJsTaiwanCommand command, CancellationToken cancellationToken)
        {
            //将台湾追加到T-Z
            var array  = JsonConvert.DeserializeObject <JArray>(_areaContextService.TaiwanString);
            var twCode = "710000";
            var tw     = array.First(i => i[0].Value <string>() == twCode);
            var ptw    = new List <object> {
                twCode.ToInt(), tw[1][0].Value <string>(), AreaContextService.FirstItemKey.ToInt()
            };

            (_areaContextService.GetFirstDicItem()[AreaContextService.KeyTz] as List <object>)?.Add(ptw);
            RecursiveAdd(array, twCode);

            return(true);
        }