public static MeterDiagram ToViewDiagram(this MeterFullInfo node /*, int layer = 0 */) { var model = new MeterDiagram() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, ParentName = node.ParentName, BrandId = node.BrandId, Type = node.Type, EnergyCategoryId = node.EnergyCategoryId, TypeName = node.TypeName, BrandType = node.brandName, Name = node.Name, Enable = node.Enable, Access = node.Access, Address = node.Address, HasPrivilege = 0, MacAddress = node.MacAddress, HasChildren = (node.HasChildren == null ? 0 : (int)node.HasChildren), IsTurnOn = node.IsTurnOn }; var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Meter" && x.JoinId == node.Id).ToViewList(); return(model); }
public static MeterData ToViewData(this MeterFullInfo node, CategoryDictionary suffix = CategoryDictionary.None) { if (node == null) { return(null); } var model = new MeterData() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? new MeterData { Id = (int)node.ParentId, Name = node.ParentName } : null, HasChildren = (node.HasChildren == null ? 0 : (int)node.HasChildren), BuildingId = node.BuildingId, Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building && node.BuildingId.HasValue ? new BuildingData { Id = (int)node.BuildingId, Name = node.BuildingName, OrganizationId = node.OrganizationId, BuildingCategoryId = node.BuildingCategoryId == null ? -1 : (int)node.BuildingCategoryId, GbCode = node.BuildingGBCode, } : null, EnergyCategoryId = node.EnergyCategoryId, EnergyCategory = (suffix & CategoryDictionary.EnergyCategory) == CategoryDictionary.EnergyCategory ? new DictionaryData { Id = node.EnergyCategoryId, ChineseName = DictionaryCache.Get()[node.EnergyCategoryId].ChineseName } : null, BrandId = node.BrandId, Brand = (suffix & CategoryDictionary.Brand) == CategoryDictionary.Brand ? new BrandData { Id = node.BrandId, Name = node.brandName, Description = node.BrandDescription, MeterTypeName = node.TypeName, Model = node.Model, Producer = node.Producer } : null, CoordinateMapId = node.CoordinateMapId, Coordinate2dId = node.Coordinate2dId, Coordinate3dId = node.Coordinate3dId, Code = node.Code, GbCode = node.GbCode, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, Type = node.Type, Access = node.Access, Sequence = node.Sequence, Address = node.Address, MacAddress = node.MacAddress, Enable = node.Enable, StatusNote = node.StatusNote, GetInterval = node.GetInterval, BranchName = node.BranchName, BranchEnable = node.BranchEnable, Rate = node.Rate, Description = node.Description }; if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Meter" && x.JoinId == node.Id).ToViewList(); } return(model); }