Ejemplo n.º 1
0
        public ViewResult KpiImport()
        {
            var message            = new List <string>();
            var httpPostedFileBase = Request.Files["dailyKpi"];

            if (httpPostedFileBase == null || httpPostedFileBase.FileName == "")
            {
                ViewBag.ErrorMessage = "上传文件为空!请先上传文件。";
            }
            else
            {
                var fields      = httpPostedFileBase.FileName.GetSplittedFields(new [] { '.', '\\' });
                var city        = fields[fields.Length - 2];
                var legalCities = _townService.GetCities();
                if (legalCities.Count > 0 && legalCities.FirstOrDefault(x => x == city) == null)
                {
                    ViewBag.WarningMessage = "上传文件名对应的城市" + city + "找不到。使用'" + legalCities[0] + "'代替";
                    city = legalCities[0];
                }
                var regions = _townService.GetRegions(city);
                var path    = httpPostedFileBase.UploadKpiFile();
                message = _importService.Import(path, regions);
            }
            ViewBag.Message = message;
            return(View("Import"));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Get()
        {
            var query = _service.GetCities();

            return(query.Count == 0 ? (IHttpActionResult)BadRequest("Empty City List!") : Ok(query));
        }
Ejemplo n.º 3
0
        public List <string> Get()
        {
            var query = _service.GetCities();

            return(query);
        }