Example #1
0
        public async Task <bool> DumpOneStationENodeb()
        {
            var stat = ENodebBases.Pop();

            if (stat == null)
            {
                throw new NullReferenceException("stat is null!");
            }
            await _eNodebBaseRepository
            .UpdateOneInUse <IENodebBaseRepository, ENodebBase, ENodebBaseExcel>(stat);

            await _eNodebRepository
            .UpdateOneInUse <IENodebRepository, ENodeb, ENodebBaseExcel, Town>(stat, Towns, excel =>
            {
                if (excel.StationDistrict == "南海")
                {
                    return(excel.StationTown.Replace("金沙", "丹灶").Replace("小塘", "狮山"));
                }
                if (excel.StationDistrict != "禅城" || excel.StationTown == "南庄")
                {
                    return(excel.StationTown);
                }
                return(_stationDictionary.CalculateStationTown(excel));
            }, (info, excel) =>
            {
                var station = _stationDictionary.FirstOrDefault(x => x.StationNum == excel.StationNum);
                if (station == null)
                {
                    return;
                }
                info.Address = station.Address;
                if (string.IsNullOrEmpty(info.PlanNum))
                {
                    info.PlanNum = excel.ProjectSerial;
                }
            }, excel =>
            {
                var candidates = Towns.Select(x => new { x.TownName, x.Id }).ToList();
                var result     = candidates.FirstOrDefault(x => excel.ENodebName.Contains(x.TownName));
                if (result != null)
                {
                    return(result.Id);
                }
                var station = _stationDictionary.FirstOrDefault(x => x.StationNum == excel.StationNum);
                if (station == null)
                {
                    return(-1);
                }
                result = candidates.FirstOrDefault(x =>
                                                   station.ElementName.Contains(x.TownName) || station.Address.Contains(x.TownName));
                if (result != null)
                {
                    return(result.Id);
                }
                return(-1);
            });

            return(true);
        }
Example #2
0
        public int ImportStationENodebs(string path)
        {
            var repo = new ExcelQueryFactory {
                FileName = path
            };
            var excels = (from c in repo.Worksheet <ENodebBaseExcel>("Sheet1") select c).ToList();

            foreach (var eNodebBaseExcel in excels)
            {
                ENodebBases.Push(eNodebBaseExcel);
            }

            return(ENodebBases.Count);
        }