Пример #1
0
        public static IQueryable <Organization> Peers(this Organization node, bool includeSelf = false)
        {
            var ctx  = new OrganizationBLL();
            var list = ctx.Filter(x => x.Rank == node.Rank || (includeSelf && x.Id == node.Id)).AsQueryable();

            return(list);
        }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #5
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);
 }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
0
 public BuildingBLL(EmpContext context = null, string userName = null)
     : base(context, string.IsNullOrEmpty(userName) ? null : (Expression <Func <Building, bool> >)(x => x.Organization.Users.Any(u => u.UserName == userName)))
 {
     organizationBLL = new OrganizationBLL(this.db);
 }