예제 #1
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);
 }
예제 #2
0
        public static MonitoringConfigData ToViewData(this MonitoringConfig node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            MonitoringConfigBLL MonitoringConfigBLL = new MonitoringConfigBLL();

            if (node == null)
            {
                return(null);
            }
            var model = new MonitoringConfigData()
            {
                Id                                          = node.Id,
                Name                                        = node.Name,
                Description                                 = node.Description,
                TargetTypeId                                = node.TargetTypeId,
                TargetId                                    = node.TargetId,
                EnergyCategoryId                            = node.EnergyCategoryId,
                ConfigTypeId                                = node.ConfigTypeId,
                WayId                                       = node.WayId,
                UnitValue                                   = node.UnitValue,
                LowerLimit                                  = node.LowerLimit,
                UpperLimit                                  = node.UpperLimit,
                Value                                       = node.Value,
                ValidStartTime                              = node.ValidStartTime,
                ValidEndTime                                = node.ValidEndTime,
                Priority                                    = node.Priority,
                Enabled                                     = node.Enabled,
                StartTime                                   = node.StartTime,
                EndTime                                     = node.EndTime,
                RegeneratorId                               = node.RegeneratorId,
                RegeneratorName                             = node.RegeneratorName,
                UpdatingTime                                = node.UpdatingTime,
                ParameterId                                 = node.ParameterId,
                TemplateId                                  = node.TemplateId,
                OverTimeDate                                = node.OverTimeDate,
                CycleTime                                   = node.CycleTime,
                CycleTypeId                                 = node.CycleTypeId,
                AlarmLevelId                                = node.AlarmLevelId,
                IsvalidNextCycle                            = node.IsvalidNextCycle,
                ValidTypeId                                 = node.ValidTypeId,
                ValidType                                   = node.ValidTypeId == null ? null : node.ValidType == null?DictionaryCache.Get()[(int)node.ValidTypeId].ToViewData() : node.ValidType.ToViewData(),
                                                 AlarmLevel = node.AlarmLevelId == null ? null : node.AlarmLevel == null?DictionaryCache.Get()[(int)node.AlarmLevelId].ToViewData() : node.AlarmLevel.ToViewData(),
                                                                  ConfigType = node.ConfigType == null?DictionaryCache.Get()[(int)node.ConfigTypeId].ToViewData() : node.ConfigType.ToViewData(),
                                                                                   CycleType = node.CycleTypeId == null ? null : node.CycleType == null?DictionaryCache.Get()[(int)node.CycleTypeId].ToViewData() : node.CycleType.ToViewData(),
                                                                                                   EnergyCategory = node.EnergyCategoryId == null ? null : node.EnergyCategory == null?DictionaryCache.Get()[(int)node.EnergyCategoryId].ToViewData() : node.EnergyCategory.ToViewData(),
                                                                                                                        TargetType                     = node.TargetType == null?DictionaryCache.Get()[(int)node.TargetTypeId].ToViewData() : node.TargetType.ToViewData(),
                                                                                                                                                   Way = node.WayId == null ? null : node.Way == null?DictionaryCache.Get()[(int)node.WayId].ToViewData() : node.Way.ToViewData(),
                                                                                                                                                             TemplateName = node.TemplateId.HasValue ? null : MonitoringConfigBLL.Filter(o => o.TemplateId == node.TemplateId).Take(1).Select(o => o.Name).ToList()[0]
            };

            //模板联动动作
            if (node.Value.HasValue)
            {
                try
                {
                    int actionId = Convert.ToInt32(node.Value);
                    model.ActionName = DictionaryCache.Get()[actionId].ChineseName;
                }
                catch { }
            }

            if (node.ConfigCycleSettings != null)
            {
                ConfigCycleSettingBLL ConfigCycleSettingBLL = new ConfigCycleSettingBLL();
                int id = model.Id;
                model.ConfigCycleSettings = ConfigCycleSettingBLL.Filter(o => o.ConfigId == id).ToViewList();
            }


            if (node.CycleTypeId != null)
            {
                if (model.CycleType.ChineseName == "每年")
                {
                    //model.CycleTimeName = "按年";
                    //model.CycleTimeDesc = Convert.ToDateTime(node.CycleTime).Year + "年";
                    model.CycleTimeName = model.CycleType.ChineseName;
                    model.CycleTimeDesc = Convert.ToDateTime(node.CycleTime).Month + "月" + Convert.ToDateTime(node.CycleTime).Day + "日" + Convert.ToDateTime(node.CycleTime).Hour + "时";
                }
                else if (model.CycleType.ChineseName == "每月")
                {
                    model.CycleTimeName = model.CycleType.ChineseName;
                    model.CycleTimeDesc = Convert.ToDateTime(node.CycleTime).Day + "日" + Convert.ToDateTime(node.CycleTime).Hour + "时";
                    //model.CycleTimeName = model.CycleType.ChineseName;
                    //model.CycleTimeDesc = Convert.ToDateTime(node.CycleTime).Month + "月"+Convert.ToDateTime(node.CycleTime).Day + "日"+Convert.ToDateTime(node.CycleTime).Hour + "时";
                }
                else if (model.CycleType.ChineseName == "每周")
                {
                    model.CycleTimeName = model.CycleType.ChineseName;
                    model.CycleTimeDesc = "第" + Convert.ToDateTime(node.CycleTime).DayOfWeek + "日" + Convert.ToDateTime(node.CycleTime).Hour + "时";
                    //model.CycleTimeName = "每周";
                    //model.CycleTimeDesc = "第" + Convert.ToDateTime(node.CycleTime).DayOfWeek + "日";
                }
                else if (model.CycleType.ChineseName == "每日")
                {
                    model.CycleTimeName = model.CycleType.ChineseName;
                    model.CycleTimeDesc = Convert.ToDateTime(node.CycleTime).Hour + "时";
                    //model.CycleTimeName = "每月";
                    //model.CycleTimeDesc = "第" + Convert.ToDateTime(node.CycleTime).Day + "日";
                }
                else if (model.CycleType.ChineseName == "每小时")
                {
                    model.CycleTimeName = model.CycleType.ChineseName;
                    //model.CycleTimeName = "每天";
                    //model.CycleTimeDesc = "第" + Convert.ToDateTime(node.CycleTime).Year + "时";
                }
            }
            if (node.ValidTypeId != null)
            {
                if (model.ValidType.ChineseName == "每年")
                {
                    model.ValidTypeDesc = "检测";
                    model.ValidTypeDesc = model.ValidTypeDesc + Convert.ToDateTime(model.ValidStartTime).Year;
                    if (Convert.ToDateTime(model.ValidStartTime).Year != Convert.ToDateTime(model.ValidEndTime).Year)
                    {
                        model.ValidTypeDesc = model.ValidTypeDesc + "至" + Convert.ToDateTime(model.ValidEndTime).Year;
                    }
                    model.ValidTypeDesc = model.ValidTypeDesc + "年数据";
                }
                else if (model.ValidType.ChineseName == "每月")
                {
                    model.ValidTypeDesc = "每年检测";
                    model.ValidTypeDesc = model.ValidTypeDesc + Convert.ToDateTime(model.ValidStartTime).Month;
                    if (Convert.ToDateTime(model.ValidStartTime).Month != Convert.ToDateTime(model.ValidEndTime).Month)
                    {
                        model.ValidTypeDesc = model.ValidTypeDesc + "至" + Convert.ToDateTime(model.ValidEndTime).Month;
                    }
                    model.ValidTypeDesc = model.ValidTypeDesc + "月数据";
                }
                else if (model.ValidType.ChineseName == "每周")
                {
                    model.ValidTypeDesc = "每周检测周";
                    model.ValidTypeDesc = model.ValidTypeDesc + Convert.ToDateTime(model.ValidStartTime).DayOfWeek;
                    if (Convert.ToDateTime(model.ValidStartTime).DayOfWeek != Convert.ToDateTime(model.ValidEndTime).DayOfWeek)
                    {
                        model.ValidTypeDesc = model.ValidTypeDesc + "至" + Convert.ToDateTime(model.ValidEndTime).DayOfWeek;
                    }
                    model.ValidTypeDesc = model.ValidTypeDesc + "数据";
                }
                else if (model.ValidType.ChineseName == "每日")
                {
                    model.ValidTypeDesc = "每月检测第";
                    model.ValidTypeDesc = model.ValidTypeDesc + Convert.ToDateTime(model.ValidStartTime).Day;
                    if (Convert.ToDateTime(model.ValidStartTime).Day != Convert.ToDateTime(model.ValidEndTime).Day)
                    {
                        model.ValidTypeDesc = model.ValidTypeDesc + "至" + Convert.ToDateTime(model.ValidEndTime).Day;
                    }
                    model.ValidTypeDesc = model.ValidTypeDesc + "日数据";
                }
                else if (model.ValidType.ChineseName == "每小时")
                {
                    model.ValidTypeDesc = "每天检测第";
                    model.ValidTypeDesc = model.ValidTypeDesc + Convert.ToDateTime(model.ValidStartTime).Hour;
                    if (Convert.ToDateTime(model.ValidStartTime).Hour != Convert.ToDateTime(model.ValidEndTime).Hour)
                    {
                        model.ValidTypeDesc = model.ValidTypeDesc + "至" + Convert.ToDateTime(model.ValidEndTime).Hour;
                    }
                    model.ValidTypeDesc = model.ValidTypeDesc + "时数据";
                }
            }
            if (node.ParameterId != null && (suffix & CategoryDictionary.Parameter) == CategoryDictionary.Parameter)
            {
                if (node.Parameter != null)
                {
                    model.Parameter = node.Parameter.ToViewData();
                }
                else
                {
                    ParameterBLL parameterBLL = new ParameterBLL();
                    model.Parameter = parameterBLL.Find(node.ParameterId).ToViewData();
                }
            }

            //string TargetTypeStr = node.TargetType == null ? DictionaryCache.Get()[node.TargetTypeId].Description : node.TargetType.Description;
            //if (TargetTypeStr != null)
            //{
            //    ViewMeterFullInfoBLL meterBLL = new ViewMeterFullInfoBLL();
            //    BuildingBLL buildingBLL = new BuildingBLL();
            //    OrganizationBLL organizationBLL = new OrganizationBLL();
            //    BrandBLL brandBLL = new BrandBLL();
            //    MessageBLL messageBLL = new MessageBLL();
            //    int id = -1;
            //    if (model.TargetId != null)
            //    {
            //        id=model.TargetId;
            //        if (TargetTypeStr.ToLower() == "meter")
            //            model.Target = meterBLL.Find(id).ToViewData();
            //        else if (TargetTypeStr.ToLower() == "building")
            //            model.Target = buildingBLL.Find(id).ToViewData();
            //        else if (TargetTypeStr.ToLower() == "organization")
            //            model.Target = organizationBLL.Find(id).ToViewData();
            //        else if (TargetTypeStr.ToLower() == "brand")
            //            model.Target = brandBLL.Find(id).ToViewData();
            //        else if (TargetTypeStr.ToLower() == "message")
            //            model.Target = messageBLL.Find(id).ToViewData();
            //    }
            //}
            return(model);
        }
예제 #3
0
        public static ConfigDetailData ToAllViewData(this ConfigDetail node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
                return null;
            var result = new ConfigDetailData()
            {
                Id = node.Id,
                TemplateId = node.TemplateId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                OrganizationId = node.OrganizationId,
                Enabled = node.Enabled,
                OperatorId = node.OperatorId,
                OperatorName = node.OperatorName,
                CreateTime = node.CreateTime,
                BuildingCategoryId = node.BuildingCategoryId,
                EnergyCategoryId = node.EnergyCategoryId,
                IsOpenOverLoadAlert = node.IsOpenOverLoadAlert,
                IsOpenMalignantLoadAlert = node.IsOpenMalignantLoadAlert,
                IsControlPower = node.IsControlPower,
                IsControlWater = node.IsControlWater,
                IsControlWaterByPower = node.IsControlWaterByPower,
                VacationTimeControlTemplateId = node.VacationTimeControlTemplateId,
                HolidayTimeControlTemplateId = node.HolidayTimeControlTemplateId,
                WeekEndTimeControlTemplateId = node.WeekEndTimeControlTemplateId,
                PeacetimeTimeControlTemplateId = node.PeacetimeTimeControlTemplateId,
                IsControlByAccount = node.IsControlByAccount,
                IsControlByTime = node.IsControlByTime,
                MinThresholdForMalignantLoad = node.MinThresholdForMalignantLoad,
                MinThresholdForOverLoad = node.MinThresholdForOverLoad

            };
            using (MonitoringConfigBLL configBLL = new MonitoringConfigBLL())
            {
                if (node.Template.ConfigTypeId != (DictionaryCache.MonitoringConfigTypePrice.Id + 5))
                    if (node.MonitoringConfigTemplate != null)
                        result.Template = node.MonitoringConfigTemplate.ToViewData();
                    else
                    {

                        result.Template = configBLL.Find(node.TemplateId).ToViewData();
                    }
                if (node.MonitoringConfigTemplate == null)
                    result.VacationTimeControlTemplate = configBLL.Find(node.VacationTimeControlTemplateId).ToViewData();
                else
                    result.VacationTimeControlTemplate = node.VacationTimeControlTemplate.ToViewData();

                if (node.HolidayTimeControlTemplate == null)
                    result.HolidayTimeControlTemplate = configBLL.Find(node.HolidayTimeControlTemplateId).ToViewData();
                else
                    result.HolidayTimeControlTemplate = node.HolidayTimeControlTemplate.ToViewData();

                if (node.WeekEndTimeControlTemplate == null)
                    result.WeekEndTimeControlTemplate = configBLL.Find(node.WeekEndTimeControlTemplateId).ToViewData();
                else
                    result.WeekEndTimeControlTemplate = node.WeekEndTimeControlTemplate.ToViewData();

                if (node.PeacetimeTimeControlTemplate == null)
                    result.PeacetimeTimeControlTemplate = configBLL.Find(node.PeacetimeTimeControlTemplateId).ToViewData();
                else
                    result.PeacetimeTimeControlTemplate = node.PeacetimeTimeControlTemplate.ToViewData();

            }
            return result;
        }
예제 #4
0
        public static IList<ConfigDetailData> ToViewList(this IQueryable<ConfigDetail> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (nodes == null)
                return null;
            var nodeList = nodes.ToList();
            var results = nodeList.Select(node => new ConfigDetailData()
            {
                Id = node.Id,
                TemplateId = node.TemplateId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                OrganizationId = node.OrganizationId,
                Enabled = node.Enabled,
                OperatorId = node.OperatorId,
                OperatorName = node.OperatorName,
                CreateTime = node.CreateTime,
                BuildingCategoryId = node.BuildingCategoryId,
                EnergyCategoryId = node.EnergyCategoryId,
                IsOpenOverLoadAlert = node.IsOpenOverLoadAlert,
                IsOpenMalignantLoadAlert = node.IsOpenMalignantLoadAlert,
                IsControlPower = node.IsControlPower,
                IsControlWater = node.IsControlWater,
                IsControlWaterByPower = node.IsControlWaterByPower,
                VacationTimeControlTemplateId = node.VacationTimeControlTemplateId,
                HolidayTimeControlTemplateId = node.HolidayTimeControlTemplateId,
                WeekEndTimeControlTemplateId = node.WeekEndTimeControlTemplateId,
                PeacetimeTimeControlTemplateId = node.PeacetimeTimeControlTemplateId,
                IsControlByAccount = node.IsControlByAccount,
                IsControlByTime = node.IsControlByTime,
                MinThresholdForMalignantLoad = node.MinThresholdForMalignantLoad,
                MinThresholdForOverLoad = node.MinThresholdForOverLoad

            }).ToList();
            using (MonitoringConfigBLL configBLL = new MonitoringConfigBLL())
            {
                for (int i = 0; i < results.Count; i++)
                {
                    if (nodeList[i].MonitoringConfigTemplate != null)
                        results[i].Template = nodeList[i].MonitoringConfigTemplate.ToViewData();
                    else
                    {

                        MonitoringConfigData config = null;
                        for (int j = 0; j < i; j++)
                        {
                            if (results[j].TemplateId == results[i].TemplateId)
                                config = results[j].Template;
                        }
                        if (config == null)
                            results[i].Template = configBLL.Find(nodeList[i].TemplateId).ToViewData();
                        else
                            results[i].Template = config;
                    }
                    if (nodeList[i].MonitoringConfigTemplate == null)
                        results[i].VacationTimeControlTemplate = configBLL.Find(nodeList[i].VacationTimeControlTemplateId).ToViewData();
                    else
                        results[i].VacationTimeControlTemplate = nodeList[i].VacationTimeControlTemplate.ToViewData();

                    if (nodeList[i].HolidayTimeControlTemplate == null)
                        results[i].HolidayTimeControlTemplate = configBLL.Find(nodeList[i].HolidayTimeControlTemplateId).ToViewData();
                    else
                        results[i].HolidayTimeControlTemplate = nodeList[i].HolidayTimeControlTemplate.ToViewData();

                    if (nodeList[i].WeekEndTimeControlTemplate == null)
                        results[i].WeekEndTimeControlTemplate = configBLL.Find(nodeList[i].WeekEndTimeControlTemplateId).ToViewData();
                    else
                        results[i].WeekEndTimeControlTemplate = nodeList[i].WeekEndTimeControlTemplate.ToViewData();

                    if (nodeList[i].PeacetimeTimeControlTemplate == null)
                        results[i].PeacetimeTimeControlTemplate = configBLL.Find(nodeList[i].PeacetimeTimeControlTemplateId).ToViewData();
                    else
                        results[i].PeacetimeTimeControlTemplate = nodeList[i].PeacetimeTimeControlTemplate.ToViewData();

                }
            }
            return results;
        }