コード例 #1
0
        public IPagedList <CleanRateView> GetPagedCleanRateView(int page, int pageSize, string queryName, out int count, List <Expression <Func <DataStatistics, bool> > > conditions = null)
        {
            var deviceModel = Repo <LampblackDeviceModelRepository>().GetAllModels().First().Id;
            var rater       = (CleanessRate)PlatformCaches.GetCache($"CleanessRate-{deviceModel}").CacheItem;
            var hotels      = Repo <HotelRestaurantRepository>().GetAllModels();
            var dayStatics  = conditions?.Aggregate(
                Repo <DataStatisticsRepository>()
                .GetModels(obj => obj.Type == StatisticsType.Day && obj.CommandDataId == CommandDataId.CleanerCurrent),
                (current, condition) => current.Where(condition))
                              .GroupBy(item => item.ProjectIdentity)
                              ?? Repo <DataStatisticsRepository>()
                              .GetModels(obj => obj.Type == StatisticsType.Day && obj.CommandDataId == CommandDataId.CleanerCurrent)
                              .GroupBy(item => item.ProjectIdentity);
            var cleanRateView = (from dayStatic in dayStatics
                                 select new CleanRateView
            {
                HotelName = hotels.FirstOrDefault(obj => obj.Identity == dayStatic.Key).ProjectName,
                Failed = dayStatic.Count(obj => obj.DoubleValue <= rater.Fail),
                Worse = dayStatic.Count(obj => obj.DoubleValue > rater.Fail && obj.DoubleValue <= rater.Worse),
                Qualified = dayStatic.Count(obj => obj.DoubleValue > rater.Worse && obj.DoubleValue <= rater.Qualified),
                Good = dayStatic.Count(obj => obj.DoubleValue > rater.Good)
            }).OrderBy(view => view.HotelName).Where(ret => ret.HotelName != null);

            count = hotels.Count();
            return(cleanRateView.ToPagedList(page, pageSize));
        }
コード例 #2
0
        private void SetActionContext(ActionExecutingContext ctx, HttpContext context)
        {
            var currentUser = !string.IsNullOrWhiteSpace(LoginName)
                ? _controllerProcess.GetCurrentUser(LoginName)
                : _controllerProcess.GetCurrentUser(context);


            if (currentUser == null)
            {
                FormsAuthentication.SignOut();
                ctx.Result = RedirectToAction("Login", "Account");
                return;
            }
            WdContext = new WdContext(currentUser);
            if (!context.Items.Contains("WdContext"))
            {
                context.Items.Add("WdContext", WdContext);
            }
            var userDistricts = ((IList <SysDictionary>)PlatformCaches.GetCache("userDistrict").CacheItem)
                                .Where(obj => obj.ItemKey == currentUser.Id.ToString().ToUpper()).ToList();

            foreach (var userDistrict in userDistricts)
            {
                WdContext.UserContext.Add("district", Guid.Parse(userDistrict.ItemValue));
            }
        }
コード例 #3
0
        public ActionResult Index()
        {
            var model = new IndexViewModel();

            var rates =
                (List <WebViewModels.ViewDataModel.HotelCleaness>)PlatformCaches.GetCache("Cleaness").CacheItem;

            if (WdContext.UserDistricts != null)
            {
                rates = rates.Where(obj => WdContext.UserDistricts.Contains(obj.DistrictGuid)).ToList();
            }

            foreach (var rate in rates)
            {
                model.HotelCleanessList.Add(new HotelCleaness()
                {
                    HotelName = rate.ProjectName, CleanessRate = rate.ProjectCleaness
                });
            }

            model.NoData = rates.Count(obj => obj.ProjectCleaness == CleanessRateResult.NoData);

            model.Faild = rates.Count(obj => obj.ProjectCleaness == CleanessRateResult.Fail);

            model.Worse = rates.Count(obj => obj.ProjectCleaness == CleanessRateResult.Worse);

            model.Qualified = rates.Count(obj => obj.ProjectCleaness == CleanessRateResult.Qualified);

            model.Good = rates.Count(obj => obj.ProjectCleaness == CleanessRateResult.Good);

            ViewBag.Areas = ProcessInvoke <UserDictionaryProcess>().GetDistrictSelectList();

            return(View(model));
        }
コード例 #4
0
        private string GetCleanRateByDeviceModel(double?current, Guid deviceModelId)
        {
            if (deviceModelId == Guid.Empty)
            {
                return("无数据");
            }
            var rater = (CleanessRate)PlatformCaches.GetCache($"CleanessRate-{deviceModelId}").CacheItem;

            return(Lampblack.GetCleanessRate(current, rater));
        }
コード例 #5
0
        /// <summary>
        /// 获取清洁度值
        /// </summary>
        /// <param name="current"></param>
        /// <param name="deviceIdentity"></param>
        /// <returns></returns>
        private string GetCleanRate(double?current, long deviceIdentity)
        {
            var model = Repo <RestaurantDeviceRepository>()
                        .GetDeviceIncludesByIdentity(deviceIdentity, new List <string> {
                "LampblackDeviceModel"
            })
                        .LampblackDeviceModel;

            var rater = (CleanessRate)PlatformCaches.GetCache($"CleanessRate-{model.Id}").CacheItem;

            return(Lampblack.GetCleanessRate(current, rater));
        }
コード例 #6
0
        public ActionResult GetHotelInfo()
        {
            var hotelLocation = ((List <HotelLocations>)PlatformCaches.GetCache("HotelLocations").CacheItem);

            if (WdContext.UserDistricts != null)
            {
                hotelLocation = hotelLocation.Where(obj => WdContext.UserDistricts.Contains(obj.DistrictGuid)).ToList();
            }
            return(Json(new JsonStruct()
            {
                Result = hotelLocation
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public Dictionary <string, string> GetBasePageInformation(IWdUser user)
        {
            var cache = PlatformCaches.GetCache($"{user.DomainId}-{SystemCacheNames.DomainCompany}");

            if (cache != null)
            {
                return((Dictionary <string, string>)cache.CacheItem);
            }

            var repo = Repo <SysConfigRepository>();

            var information = repo.GetSysConfigDictionary(config => config.SysConfigType == SystemConfigType.DomainCompanyConfig);

            PlatformCaches.Add($"{user.DomainId}-{SystemCacheNames.DomainCompany}", information);

            return(information);
        }
コード例 #8
0
        /// <summary>
        /// 获取系统权限列表
        /// </summary>
        /// <returns></returns>
        public static List <Permission> GetSysPeremissions()
        {
            var cache = PlatformCaches.GetCache("Permissions");

            if (cache == null)
            {
                using (var context = new RepositoryDbContext())
                {
                    var sysPeremissions = context.Set <Permission>().ToList();
                    PlatformCaches.Add("Permissions", sysPeremissions, false, "System");
                    return(sysPeremissions);
                }
            }

            var permissions = cache.CacheItem as List <Permission>;

            return(permissions);
        }
コード例 #9
0
ファイル: WdContext.cs プロジェクト: SHWDTech/WDYunPlatform
        private void GetPermissions()
        {
            var permissionCache = (List <Permission>)PlatformCaches.GetCache($"User[{WdUser.Id}]-Permissions").CacheItem;

            Permissions = new List <Permission>();
            Permissions.AddRange(permissionCache);
            foreach (var wdRole in Roles)
            {
                var rolePermissions = (List <Permission>)PlatformCaches.GetCache($"Role[{wdRole.Id}]-Permissions").CacheItem;
                foreach (var rolePermission in rolePermissions)
                {
                    if (!Permissions.Contains(rolePermission))
                    {
                        Permissions.Add(rolePermission);
                    }
                }
            }
        }