Esempio n. 1
0
        /// <summary>
        /// 查询分站
        /// </summary>
        /// <param name="totalCount">总数量</param>
        /// <param name="recentCount">最近数量</param>
        /// <param name="recentDate">最近数量计算时间起</param>
        /// <param name="groupdArea">分组区域</param>
        public void QuerySubstation(out int totalCount, out int recentCount, out DateTime recentDate, out Dictionary <string, List <string> > groupdArea)
        {
            string subStationRole = "SubStation";
            IQueryable <UserBackendDbModel> query = ReadOnlyRepository.Query(e => e.Roles.Contains(subStationRole));
            var dbResult           = query.Select(e => new { Areas = e.Areas, CreateDate = e.CreateDate, });
            HashSet <string> areas = new HashSet <string>();

            foreach (var area in dbResult)
            {
                foreach (var item in area.Areas.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    areas.Add(item);
                }
            }
            //City = AreaService.GetCityModelFromAreaCode(e).Name
            var substationModel = areas.OrderBy(e => e).Select(e => new
            {
                Code = e,

                /*
                 * Povince = AreaService.GetAreaName(e.Substring(0, 2) + "0000"),
                 * City = AreaService.GetAreaName(e),
                 */
                Povince = AreaService.GetProvinceModelFromCode(e).Name,
                City    = AreaService.GetCityModelFromAreaCode(e).Name +
                          (e.EndsWith("00") ? "" : AreaService.GetAreaViewByCode(e).Name),
            });

            totalCount = substationModel.Count();
            var recentD = DateTime.Now.AddDays(-7);

            recentCount = dbResult.Where(e => e.CreateDate > recentD).Count();
            groupdArea  = substationModel.GroupBy(e => e.Povince).ToDictionary(g => g.Key, g => g.ToList().Select(e => e.City).ToList());
            recentDate  = dbResult.OrderByDescending(e => e.CreateDate).Select(e => e.CreateDate).FirstOrDefault();
        }
Esempio n. 2
0
        public ActionResult Edit(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var model = ReadOnlyRepository.Query().Where(e => e.Code == id).FirstOrDefault();

            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            return(View(model));
        }
Esempio n. 3
0
 private Dictionary <string, AreaViewModel> QueryArea()
 {
     if (_singleArea == null)
     {
         lock (lockAreaCach)
         {
             if (_singleArea == null)
             {
                 var dbModel = ReadOnlyRepository.Query().ToList();
                 _singleArea = converDbToView(dbModel);
             }
         }
     }
     return(_singleArea);
 }