Beispiel #1
0
        public static UserData ToViewData(this User node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var results = new UserData()
            {
                Id             = node.Id,
                OrganizationId = node.OrganizationId,
                Email          = node.Email,
                EmailConfirmed = node.EmailConfirmed,
                //PasswordHash = node.PasswordHash,
                //SecurityStamp = node.SecurityStamp,
                PhoneNumber          = node.PhoneNumber,
                PhoneNumberConfirmed = node.PhoneNumberConfirmed,
                TwoFactorEnabled     = node.TwoFactorEnabled,
                LockoutEndDateUtc    = node.LockoutEndDateUtc,
                LockoutEnabled       = node.LockoutEnabled,
                AccessFailedCount    = node.AccessFailedCount,
                UserName             = node.UserName,
                FullName             = node.FullName,
                IdentityNo           = node.IdentityNo,
                IsResignOrGraduate   = node.IsResignOrGraduate,
                IsRightInfo          = node.IsRightInfo,
                ForeignId            = node.ForeignId,
                EnrollDate           = node.EnrollDate,
                StaffNo       = node.StaffNo,
                QQ            = node.QQ,
                WeChat        = node.WeChat,
                UserType      = node.UserType,
                Gender        = node.Gender ?? true,
                Organizations = ((suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization) ? node.Organizations.ToList().Select(x => x.ToViewData()).ToList() : null,
                Buildings     = ((suffix & CategoryDictionary.Building) == CategoryDictionary.Building) ? node.Buildings.ToList().Select(x => x.ToViewData()).ToList() : null,
                Roles         = ((suffix & CategoryDictionary.Role) == CategoryDictionary.Role) ? node.Roles.ToList().Select(x => x.ToViewData()).ToList() : null
            };

            if ((suffix & CategoryDictionary.Org) == CategoryDictionary.Org)
            {
                OrganizationBLL OrganizationBLL = new BLL.OrganizationBLL();
                results.Org = (results.OrganizationId != null && (suffix & CategoryDictionary.Org) == CategoryDictionary.Org) ? OrganizationBLL.Find(results.OrganizationId).ToViewData() : null;
            }

            if ((suffix & CategoryDictionary.Account) == CategoryDictionary.Account)
            {
                UserAccountBLL userAccountBLL = new UserAccountBLL();
                results.Account = userAccountBLL.Filter(o => o.UserId == node.Id && o.Enable == true).ToViewList();
            }

            if ((suffix & CategoryDictionary.UserType) == CategoryDictionary.UserType)
            {
                if (results.UserType != null)
                {
                    DictionaryBLL dictBLL = new DictionaryBLL();
                    results.UserTypeName = dictBLL.Find(results.UserType).ChineseName;
                }
            }

            return(results);
        }
Beispiel #2
0
 public UserAccountBLL(EmpContext context = null)
     : base(context)
 {
     userBLL         = new UserBLL(this.db);
     buildingBLL     = new BuildingBLL(this.db);
     organizationBLL = new OrganizationBLL(this.db);
     dictionaryBLL   = new DictionaryBLL(this.db);
     roleBLL         = new RoleBLL(this.db);
 }
Beispiel #3
0
 public BalanceDetailBLL(EmpContext context = null)
     : base(context)
 {
     dictionaryBLL       = new DictionaryBLL(this.db);
     buildingBLL         = new BuildingBLL(this.db);
     organizationBLL     = new OrganizationBLL(this.db);
     monitoringConfigBLL = new MonitoringConfigBLL(this.db);
     meterBLL            = new MeterBLL(this.db);
     userBLL             = new UserBLL(this.db);
 }
Beispiel #4
0
 public HistoryBillBLL(EmpContext context = null)
     : base(context)
 {
     dictionaryBLL   = new DictionaryBLL(this.db);
     buildingBLL     = new BuildingBLL(this.db);
     organizationBLL = new OrganizationBLL(this.db);
     //monitoringConfigBLL = new MonitoringConfigBLL(this.db);
     meterBLL   = new MeterBLL(this.db);
     userBLL    = new UserBLL(this.db);
     messageBLL = new MessageBLL(this.db);
 }
Beispiel #5
0
        public static async Task <bool> HasMonthly(List <int> targets, int energy, int paramter, TimeUnits unit, DateTime start, DateTime finish)
        {
            var node = new StatisticalNode(targets, energy, new List <int> {
                paramter
            }, unit, start, finish, StatisticalModes.Building, StatisticalWay.Total, null, null);

            var dicBLL    = new DictionaryBLL();
            var meterBLL  = new MeterBLL();
            var parameter = dicBLL.Get(node.ParameterTypeId).Select(d => d.Id).ToList();

            // 获取关联的一级统计设备
            IEnumerable <int> meters = (await meterBLL.GetStatisticalObj(node)).SelectMany(x => x.Meters).Select(x => x.Id);

            // 统计能耗结果
            return(meterBLL.Count(x => meters.Contains(x.Id) && x.MeterMonthlyResults.Any(m => m.StartTime >= start)) > 0);
        }
Beispiel #6
0
        //public static IEnumerable<GisBuildingData> ToGisList(IQueryable<Building> nodes)
        //{
        //    var start_month = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-01"));
        //    var start_year = DateTime.Parse(DateTime.Today.ToString("yyyy-01-01"));
        //    var ids = nodes.Select(x => x.Id).ToList();
        //    var cids = nodes.SelectMany(x => x.Children).Select(x => x.Id).ToList();
        //    var arr = ids.Concat(cids).Distinct().ToList();
        //    var list = nodes.ToList().Select(node => new GisBuildingData()
        //    {
        //        Id = node.Id,
        //        Name = node.Name,
        //        BuildingCategoryName = node.BuildingCategoryDict.ChineseName,
        //        //Year = node.BuildingInfo.Year,
        //        //UpFloor = node.BuildingInfo.UpFloor,
        //        ManagerCount = node.ManagerCount,
        //        CustomerCount = node.CustomerCount,
        //        TotalArea = node.TotalArea,
        //        LivingArea = node.LivingArea,
        //        WorkingArea = node.WorkingArea,
        //        ReceptionArea = node.ReceptionArea,
        //        Year = node.Year,
        //        UpFloor = node.UpFloor,
        //        //Electric = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //Water = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //ElectricYear = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        //WaterYear = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //        Icon = "",
        //        Children = node.Children.Select(c => new GisBuildingData()
        //        {
        //            Id = c.Id,
        //            Name = c.Name,
        //            BuildingCategoryName = node.BuildingCategoryDict.ChineseName,
        //            ManagerCount = node.ManagerCount,
        //            CustomerCount = node.CustomerCount,
        //            TotalArea = node.TotalArea,
        //            LivingArea = node.LivingArea,
        //            WorkingArea = node.WorkingArea,
        //            ReceptionArea = node.ReceptionArea,
        //            Year = node.Year,
        //            UpFloor = node.UpFloor,
        //            //Electric = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //Water = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //ElectricYear = GetTotal(new List<int>() { node.Id }, 90001, 60019, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            //WaterYear = GetTotal(new List<int>() { node.Id }, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Today).SelectMany(x => x.Result).Sum(x => x.Value),
        //            Icon = ""
        //        }).ToList(),
        //        Meters = node.Meters.Select(m => m.ToGisData(1)).ToList()
        //    });
        //    var water_month = GetTotal(arr, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Now);
        //    var elec_month = GetTotal(arr, 90031, 60023, TimeUnits.Monthly, start_month, DateTime.Now);
        //    var water_year = GetTotal(arr, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Now);
        //    var elec_year = GetTotal(arr, 90031, 60023, TimeUnits.Yearly, start_year, DateTime.Now);
        //    foreach (var item in list)
        //    {
        //        var elec_m = elec_month.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (elec_m != null) item.Electric = elec_m.Result.Sum(x => x.Value);
        //        var water_m = water_month.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (water_m != null) item.Water = water_m.Result.Sum(x => x.Value);
        //        var elec_y = elec_year.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (elec_y != null) item.ElectricYear = elec_y.Result.Sum(x => x.Value);
        //        var water_y = water_year.FirstOrDefault(x => x.StatisticalId == item.Id);
        //        if (water_y != null) item.WaterYear = water_y.Result.Sum(x => x.Value);
        //    }
        //    return list;
        //}

        public static async Task <IEnumerable <StatisticalData> > GetTotal(List <int> targets, int energy, int paramter, TimeUnits unit, DateTime start, DateTime finish)
        {
            var node = new StatisticalNode(targets, energy, new List <int> {
                paramter
            }, unit, start, finish, StatisticalModes.Building, StatisticalWay.Total, null, null);

            var dicBLL   = new DictionaryBLL();
            var meterBLL = new MeterBLL();
            var statBLL  = new MeterResultBLL();
            // 获取参数对象
            var parameter = dicBLL.Get(node.ParameterTypeId).Select(d => d.Id).ToList();

            // 获取关联的一级统计设备
            IList <StatisticalTransfer> meters = await meterBLL.GetStatisticalObj(node);

            // 统计能耗结果
            var result = await statBLL.Statistics(meters, node.TimeUnit.Value, node.StartTime.Value, node.FinishTime.Value, parameter, node.StatWay.Value);

            return(result);
        }