コード例 #1
0
 public static int ImportRegionStats(this IKpiImportController controller, HttpPostedFileBase httpPostedFileBase,
     string[] sheetNames, IRegionRepository regionRepository, ITopCellRepository<CdmaRegionStat> cdmaStatRepository)
 {
     List<CdmaRegionStat> statList =
         httpPostedFileBase.ImportInfo(
             x =>
             {
                 List<CdmaRegionStat> stats = new List<CdmaRegionStat>();
                 using (ExcelImporter excelImporter = new ExcelImporter(x, sheetNames))
                 {
                     foreach (string sheetName in sheetNames)
                     {
                         using (DataTable statTable = excelImporter[sheetName])
                         {
                             ImportExcelListService<CdmaRegionStat> service =
                                 new ImportExcelListService<CdmaRegionStat>(stats, statTable);
                             service.Import();
                         }
                     }
                 }
                 return stats;
             }, "佛山");
     if (statList.Count > 0)
     {
         OptimizeRegion firstOrDefault = regionRepository.GetAllList().FirstOrDefault(
             x => x.Region == statList[0].Region);
         if (firstOrDefault != null)
         {
             controller.SaveTimeKpiStatsService.CurrentCity = firstOrDefault.City;
             controller.Save3GStatsService.CurrentCity = firstOrDefault.City;
         }
     }
     return cdmaStatRepository.SaveStats(statList);
 }
コード例 #2
0
        public static KpiImportResult Import(this IKpiImportController controller,
            HttpPostedFileBase httpPostedFileBase, string[] sheetNames,
            IRegionRepository regionRepository, ITopCellRepository<CdmaRegionStat> cdmaStatRepository)
        {
            List<CdmaRegionStat> statList =
                httpPostedFileBase.ImportInfo(
                    x =>
                    {
                        List<CdmaRegionStat> stats = new List<CdmaRegionStat>();
                        using (ExcelImporter excelImporter = new ExcelImporter(x, sheetNames))
                        {
                            foreach (string sheetName in sheetNames)
                            {
                                using (DataTable statTable = excelImporter[sheetName])
                                {
                                    ImportExcelListService<CdmaRegionStat> service =
                                        new ImportExcelListService<CdmaRegionStat>(stats, statTable);
                                    service.Import();
                                }
                            }
                        }
                        return stats;
                    }, "佛山");
            if (statList.Count > 0)
            {
                OptimizeRegion firstOrDefault = regionRepository.GetAllList().FirstOrDefault(
                    x => x.Region == statList[0].Region);
                if (firstOrDefault != null)
                {
                    controller.SaveTimeKpiStatsService.CurrentCity = firstOrDefault.City;
                    controller.Save3GStatsService.CurrentCity = firstOrDefault.City;
                }
            }
            int regionStatsSaved = cdmaStatRepository.SaveStats(statList);
            ExcelStatsImportRepository<TopDrop2GCellExcel> drop2GExcelRepository =
                httpPostedFileBase.ImportInfo(
                    x => new ExcelStatsImportRepository<TopDrop2GCellExcel>(x, "掉话TOP30小区"), "佛山");
            int topDrop2GSaved = controller.SaveTimeKpiStatsService.Save(drop2GExcelRepository.StatList);
            ExcelStatsImportRepository<TopConnection3GCellExcel> connection3GExcelRepository =
                httpPostedFileBase.ImportInfo(
                    x => new ExcelStatsImportRepository<TopConnection3GCellExcel>(x, "连接TOP30小区"), "佛山");
            int topConnection3GSaved = controller.Save3GStatsService.Save(connection3GExcelRepository.StatList);

            return new KpiImportResult
            {
                RegionStatsSaved = regionStatsSaved,
                TopDrop2GSaved = topDrop2GSaved,
                TopConnection3GSaved = topConnection3GSaved
            };
        }