Exemplo n.º 1
0
        //public static MaintenanceData ToViewData(this Maintenance node, CategoryDictionary suffix = CategoryDictionary.None)
        //{
        //    if (node == null)
        //        return null;
        //    return new MaintenanceData()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription
        //        //User = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) && node.User != null ? node.User.ToViewData() : null,
        //        //MaintenanceCategory = node.MaintenanceCategory.ToViewData(),
        //        //State = node.MaintenanceState.ToViewData(),
        //        //ObjectCategory = node.MaintenanceObjectCategory.ToViewData()

        //    };
        //}

        //public static IList<MaintenanceData> ToViewList(this IQueryable<Maintenance> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        //{
        //    if (nodes == null)
        //        return null;
        //    var nodeList = nodes.ToList();
        //    //var results = nodes.ToList().Select(x => x.ToViewData(suffix)).ToList();
        //    var results = nodeList.Select(node => new MaintenanceData()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription,

        //    }).ToList();

        //    return results;
        //}

        //public static Maintenance ToModel(this MaintenanceData node)
        //{
        //    return new Maintenance()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription,

        //    };
        //}
        #endregion

        #region Maintenance
        public static MaintenanceData ToViewData(this Maintenance node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL     userBLL     = new UserBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new MaintenanceData()
            {
                Id = node.Id,
                MaintenanceCategoryId = node.MaintenanceCategoryId,
                StateId = node.StateId,
                UserId = node.UserId,
                BuildingId = node.BuildingId,
                ApproverId = node.ApproverId,
                OperatorId = node.OperatorId,
                Title = node.Title,
                Content = node.Content,
                PictureId = node.PictureId,
                CreateDate = node.CreateDate,
                Rating = node.Rating,
                MaintenanceTime = node.MaintenanceTime,
                PurchasingId = node.PurchasingId,
                PictureUrl = node.PictureUrl,
                User = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.User.ToViewData() : null,         // node.User == null ? userBLL.Find(node.UserId).ToViewData() : node.User.ToViewData(),
                Approver = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.Approver.ToViewData() : null, //node.ApproverId != null ? node.Approver == null ? userBLL.Find(node.ApproverId).ToViewData() : node.Approver.ToViewData() : null,
                Operator = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.Operator.ToViewData() : null, //node.OperatorId != null ? node.Operator == null ? userBLL.Find(node.OperatorId).ToViewData() : node.Operator.ToViewData() : null,
                //State = node.State.ToViewData(),
                StateName = DictionaryCache.Get()[(int)node.StateId].ChineseName,
                BuildingName = buildingBLL.Find(node.BuildingId).Name,
            });
        }
Exemplo n.º 2
0
        public static IList <MeterGroupData> ToViewList(this IQueryable <MeterGroup> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            //GroupBLL groupBLL = new GroupBLL();
            MeterBLL    meterBLL    = new MeterBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new MeterGroupData()
            {
                Id         = node.Id,
                GroupId    = node.GroupId,
                MeterId    = node.MeterId,
                BuildingId = node.BuildingId,
                Enable     = node.Enable,
                //Group = (suffix & CategoryDictionary.Group) == CategoryDictionary.Group ? (node.Group == null ? groupBLL.Find(node.GroupId).ToViewData() : node.Group.ToViewData()) : null,
                Meter    = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Group == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null,
            }).ToList();

            return(results);
        }
Exemplo n.º 3
0
        public static IQueryable <Building> Peers(this Building node, bool includeSelf = false)
        {
            var ctx  = new BuildingBLL();
            var list = ctx.Filter(x => x.Rank == node.Rank || (includeSelf && x.Id == node.Id)).AsQueryable();

            return(list);
        }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 public MessageBLL(EmpContext context = null)
     : base(context)
 {
     userBLL          = new UserBLL(this.db);
     subscribeBLL     = new SubscribeBLL(this.db);
     buildingBLL      = new BuildingBLL(this.db);
     organizationBLL  = new OrganizationBLL(this.db);
     messageRecordBLL = new MessageRecordBLL(this.db);
     userBLL          = new UserBLL(this.db);
     subscribeBLL     = new SubscribeBLL(this.db);
 }
Exemplo n.º 8
0
        public static IList <BalanceShortData> ToShortViewList(this IQueryable <Balance> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (nodes == null)
            {
                return(null);
            }
            var result = nodes.ToList().Select(node => node.ToShortViewData()).ToList();
            var ids    = result.Select(o => o.TargetId).ToList();

            if (nodes.Count() > 0)
            {
                Dictionary <long, string> nameDic = new Dictionary <long, string>();
                if (result[0].TargetCategory == (int)CategoryDictionary.Building)
                {
                    BuildingBLL buidingBLL = new BuildingBLL();
                    var         list       = buidingBLL.Filter(o => ids.Contains(o.Id)).Select(o => new
                    {
                        Id   = o.Id,
                        Name = o.Name
                    }).ToList();
                    foreach (var l in list)
                    {
                        nameDic.Add(l.Id, l.Name);
                    }
                }
                else if (result[0].TargetCategory == (int)CategoryDictionary.Organization)
                {
                    OrganizationBLL orgBLL = new OrganizationBLL();
                    var             list   = orgBLL.Filter(o => ids.Contains(o.Id)).Select(o => new
                    {
                        Id   = o.Id,
                        Name = o.Name
                    }).ToList();
                    foreach (var l in list)
                    {
                        nameDic.Add(l.Id, l.Name);
                    }
                }
                foreach (var r in result)
                {
                    r.Name = nameDic[r.TargetId];
                }
            }
            return(result);
        }
        public static BuildingMeterTypeUserData ToViewData(this BuildingMeterTypeUser node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL     userBLL     = new UserBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new BuildingMeterTypeUserData()
            {
                Id = node.Id,
                UserId = node.UserId,
                MeterTypeId = node.MeterTypeId,
                BuildingId = node.BuildingId,
                Enable = node.Enable,
                User = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? (node.User == null ? userBLL.Find(node.UserId).ToViewData() : node.User.ToViewData()) : null,
                MeterTypeName = node.MeterType == null?DictionaryCache.Get()[node.MeterTypeId].ChineseName : node.MeterType.ChineseName,
                //MeterType = node.MeterType == null ? DictionaryCache.Get()[node.MeterTypeId].ToViewData() : node.MeterType.ToViewData(),
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null
            });
        }
Exemplo n.º 10
0
        public static MeterGroupData ToViewData(this MeterGroup node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            //GroupBLL groupBLL = new GroupBLL();
            MeterBLL    meterBLL    = new MeterBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new MeterGroupData()
            {
                Id = node.Id,
                GroupId = node.GroupId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                Enable = node.Enable,
                //Group = (suffix & CategoryDictionary.Group) == CategoryDictionary.Group ? (node.Group == null ? groupBLL.Find(node.GroupId).ToViewData() : node.Group.ToViewData()) : null,
                Meter = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Meter == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null,
            });
        }
        public static IList <BuildingMeterTypeUserData> ToViewList(this IQueryable <BuildingMeterTypeUser> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL     userBLL     = new UserBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new BuildingMeterTypeUserData()
            {
                Id            = node.Id,
                UserId        = node.UserId,
                MeterTypeId   = node.MeterTypeId,
                BuildingId    = node.BuildingId,
                Enable        = node.Enable,
                User          = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? (node.User == null ? userBLL.Find(node.UserId).ToViewData() : node.User.ToViewData()) : null,
                MeterTypeName = node.MeterType == null ? DictionaryCache.Get()[node.MeterTypeId].ChineseName : node.MeterType.ChineseName,
                Building      = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null
            }).ToList();

            return(results);
        }
Exemplo n.º 12
0
        public static MessageData ToViewData(this Message node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new MessageData()
            {
                Id                    = node.Id,
                MessageTypeId         = node.MessageTypeId,
                CreateDate            = node.CreateDate,
                EndDate               = node.EndDate,
                MessageSourceTypeId   = node.MessageSourceTypeId,
                SrcId                 = node.SrcId,
                Subject               = node.Subject,
                Body                  = node.Body,
                Url                   = node.Url,
                ActiveDate            = node.ActiveDate,
                IsDeleted             = node.IsDeleted,
                NotActiveDate         = node.NotActiveDate,
                AlertLevelId          = node.AlertLevelId, //告警等级
                MessageTypeName       = node.MessageType == null?DictionaryCache.Get()[node.MessageTypeId].ChineseName                                                                        : node.MessageType.ChineseName,
                MessageSourceTypeName = node.MessageSourceType == null?DictionaryCache.Get()[node.MessageSourceTypeId].ChineseName                                                            : node.MessageSourceType.ChineseName,
                MessageRecords        = ((suffix & CategoryDictionary.MessageRecord) == CategoryDictionary.MessageRecord) ? node.MessageRecords.ToList().Select(x => x.ToViewData()).ToList() : null
            };

            string MessageSourceTypeStr = node.MessageSourceType == null?DictionaryCache.Get()[node.MessageSourceTypeId].Description : node.MessageSourceType.Description;

            if (MessageSourceTypeStr != null)
            {
                ViewMeterFullInfoBLL meterBLL        = new ViewMeterFullInfoBLL();
                BuildingBLL          buildingBLL     = new BuildingBLL();
                OrganizationBLL      organizationBLL = new OrganizationBLL();
                UserBLL  userBLL  = new UserBLL();
                BrandBLL brandBLL = new BrandBLL();
                try
                {
                    int id = -1;
                    if (model.SrcId != null && int.TryParse(model.SrcId, out id))
                    {
                        if (MessageSourceTypeStr.ToLower() == "meter")
                        {
                            var meter = meterBLL.Find(id).ToViewData();
                            model.MessageSource = meter;
                            model.SenderName    = meter.Name;
                        }
                        else if (MessageSourceTypeStr.ToLower() == "building")
                        {
                            var m = buildingBLL.Find(id).ToViewData();
                            model.MessageSource = m;
                            model.SenderName    = m.Name;
                        }
                        else if (MessageSourceTypeStr.ToLower() == "organization")
                        {
                            var m = organizationBLL.Find(id).ToViewData();
                            model.MessageSource = m;
                            model.SenderName    = m.Name;
                        }
                        else if (MessageSourceTypeStr.ToLower() == "brand")
                        {
                            var m = brandBLL.Find(id).ToViewData();
                            model.MessageSource = m;
                            model.SenderName    = m.Name;
                        }
                        else if (MessageSourceTypeStr.ToLower() == "user")
                        {
                            var m = userBLL.Find(model.SrcId).ToViewData();
                            model.MessageSource = m;
                            model.SenderName    = m.FullName;
                        }
                    }
                    else
                    {
                        var m = userBLL.Find(model.SrcId).ToViewData();
                        model.MessageSource = m;
                        model.SenderName    = m.FullName;
                    }
                }
                catch { }
            }

            return(model);
        }
Exemplo n.º 13
0
        public static BalanceData ToViewData(this Balance node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new BalanceData()
            {
                Id                = node.Id,
                TargetId          = node.TargetId,
                TargetCategory    = node.TargetCategory,
                EnergyCategory    = node.EnergyCategory,
                Price             = node.Price,
                EnergyConsumption = node.EnergyConsumption,
                Overplus          = node.Overplus,
                Prepay            = node.Prepay,
                Subsidy           = node.Subsidy,
                Recharge          = node.Recharge,
                CashCharge        = node.CashCharge,
                CashCorrect       = node.CashCorrect,
                Usage             = node.Usage,
                Refund            = node.Refund,
                BadDebt           = node.BadDebt,
                Total             = node.Total,
                AuditDate         = node.AuditDate,
                CreateDate        = node.CreateDate,
                OperatorId        = node.OperatorId,
                TotalCashCharge   = node.TotalCashCharge,
                TotalRecharge     = node.TotalRecharge,
                TotalSubsidy      = node.TotalSubsidy,
                BalanceDetails    = node.BalanceDetails.ToList().Select(x => x.ToViewData()).ToList()
            };

            if ((suffix & CategoryDictionary.Manager) == CategoryDictionary.Manager)
            {
                var ctx_user = new UserBLL();
                var op       = ctx_user.Find(model.OperatorId);
                if (op != null)
                {
                    model.Operator = op.ToViewData();
                }
            }
            if ((suffix & CategoryDictionary.Building) == CategoryDictionary.Building || (suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization)
            {
                if (model.TargetCategory == (int)CategoryDictionary.Building)
                {
                    var ctx_bid = new BuildingBLL();
                    var b       = ctx_bid.Find(model.TargetId);
                    if (b != null)
                    {
                        model.Target = b.ToViewData();
                    }
                }
                if (model.TargetCategory == (int)CategoryDictionary.Organization)
                {
                    var ctx_org = new OrganizationBLL();
                    var o       = ctx_org.Find(model.TargetId);
                    if (o != null)
                    {
                        model.Target = o.ToViewData();
                    }
                }
            }
            return(model);
        }
Exemplo n.º 14
0
 public ConfigDetailBLL(EmpContext context = null)
     : base(context)
 {
     meterActionBLL = new MetersActionBLL(meterBLL.db);
     buildingBLL    = new BuildingBLL(meterBLL.db);
 }
Exemplo n.º 15
0
        public static AttachmentData ToViewData(this Attachment node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new AttachmentData()
            {
                Id                 = node.Id,
                TargetId           = node.TargetId,
                AttachmentTypeId   = node.AttachmentTypeId,
                AttachmentFormatId = node.AttachmentFormatId,
                Description        = node.Description,
                Size               = node.Size,
                CreateTime         = node.CreateTime,
                Path               = node.Path,
                OriginalName       = node.OriginalName,
                LogicalName        = node.LogicalName,
                AttachmentType     = node.AttachmentType == null?DictionaryCache.Get()[node.AttachmentTypeId].ToViewData() : node.AttachmentType.ToViewData(),
                                         AttachmentFormat = node.AttachmentFormat == null?DictionaryCache.Get()[node.AttachmentFormatId].ToViewData() : node.AttachmentFormat.ToViewData(),
            };

            string AttachmentTypeStr = node.AttachmentType == null?DictionaryCache.Get()[node.AttachmentTypeId].Description : node.AttachmentType.Description;

            if (AttachmentTypeStr != null)
            {
                ViewMeterFullInfoBLL meterBLL        = new ViewMeterFullInfoBLL();
                BuildingBLL          buildingBLL     = new BuildingBLL();
                OrganizationBLL      organizationBLL = new OrganizationBLL();
                UserBLL    userBLL    = new UserBLL();
                BrandBLL   brandBLL   = new BrandBLL();
                MessageBLL messageBLL = new MessageBLL();
                int        id         = -1;
                if (model.TargetId != null && int.TryParse(model.TargetId, out id))
                {
                    if (AttachmentTypeStr.ToLower() == "meter")
                    {
                        model.Target = meterBLL.Find(id).ToViewData();
                    }
                    else if (AttachmentTypeStr.ToLower() == "building")
                    {
                        model.Target = buildingBLL.Find(id).ToViewData();
                    }
                    else if (AttachmentTypeStr.ToLower() == "organization")
                    {
                        model.Target = organizationBLL.Find(id).ToViewData();
                    }
                    else if (AttachmentTypeStr.ToLower() == "brand")
                    {
                        model.Target = brandBLL.Find(id).ToViewData();
                    }
                    else if (AttachmentTypeStr.ToLower() == "message")
                    {
                        model.Target = messageBLL.Find(id).ToViewData();
                    }
                }
                else
                {
                    model.Target = userBLL.Find(model.TargetId).ToViewData();
                }
            }
            return(model);
        }
Exemplo n.º 16
0
 public MonitoringConfigBLL(EmpContext context = null)
     : base(context)
 {
     meterActionBLL = new MetersActionBLL(meterBLL.db);
     buildingBLL    = new BuildingBLL(meterBLL.db);
 }