Ejemplo n.º 1
0
        public static BuildingDiagram ToViewDiagram(this Building node, int layer = 0, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node.Parent != null)
            {
                node.Parent.Parent = null;
            }
            var model = new BuildingDiagram()
            {
                Id                 = node.Id,
                ParentId           = node.ParentId,
                OrganizationId     = node.OrganizationId,
                BuildingCategoryId = node.BuildingCategoryId,
                CoordinateMapId    = node.CoordinateMapId,
                Coordinate2dId     = node.Coordinate2dId,
                Coordinate3dId     = node.Coordinate3dId,
                GbCode             = node.GbCode,
                Name               = node.Name,
                AliasName          = node.AliasName,
                Initial            = node.Initial,
                Type               = node.Type,
                ManagerCount       = node.ManagerCount,
                CustomerCount      = node.CustomerCount,
                TotalArea          = node.TotalArea,
                WorkingArea        = node.WorkingArea,
                LivingArea         = node.LivingArea,
                ReceptionArea      = node.ReceptionArea,
                Enable             = node.Enable,
                Description        = node.Description,
                UpFloor            = node.UpFloor,
                Year               = node.Year,
                Sort               = node.Sort,
                Parent             = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent ? (node.Parent == null ? null : node.Parent.ToViewDiagram()) : null,
                Organization       = (suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization ? (node.Organization == null ? null : node.Organization.ToViewDiagram()) : null
            };

            if (layer > 0 && node.Children != null && node.Children.Count() != 0 && (suffix & CategoryDictionary.Children) == CategoryDictionary.Children)
            {
                model.Children = node.Children.Select(o => o.ToViewDiagram(--layer));
            }
            else
            {
                model.Children = null;
            }
            if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField)
            {
                var ctx = new EmpContext();
                model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Building" && x.JoinId == node.Id).ToViewList();
            }
            return(model);
        }
Ejemplo n.º 2
0
        public static BuildingDiagram ToViewDiagram(this BuildingFullInfo node, int layer = 0)
        {
            var model = new BuildingDiagram()
            {
                Id                 = node.Id,
                ParentId           = node.ParentId,
                OrganizationId     = node.OrganizationId,
                BuildingCategoryId = node.BuildingCategoryId,
                CoordinateMapId    = node.CoordinateMapId,
                Coordinate2dId     = node.Coordinate2dId,
                Coordinate3dId     = node.Coordinate3dId,
                GbCode             = node.GbCode,
                Name               = node.Name,
                AliasName          = node.AliasName,
                Initial            = node.Initial,
                Type               = node.Type,
                ManagerCount       = node.ManagerCount,
                CustomerCount      = node.CustomerCount,
                TotalArea          = node.TotalArea,
                WorkingArea        = node.WorkingArea,
                LivingArea         = node.LivingArea,
                ReceptionArea      = node.ReceptionArea,
                Enable             = node.BuildingEnable,
                Description        = node.Description,
                UpFloor            = node.UpFloor,
                Year               = node.Year,
                Sort               = node.Sort,
                Parent             = (node.ParentId.HasValue && layer == 0) ? new BuildingDiagram
                {
                    Id                 = (int)node.ParentId,
                    OrganizationId     = node.ParentOrganizationId,
                    BuildingCategoryId = node.BuildingCategoryId,
                    GbCode             = node.ParentGbCode,
                    Name               = node.ParentName,
                    AliasName          = node.ParentAliasName,
                    Type               = node.ParentType == null ? -1 : (int)node.ParentType,
                } : null,
                Organization = node.OrganizationId == null ? null : new OrganizationDiagram
                {
                    Id        = (int)node.OrganizationId,
                    TreeId    = node.TreeId,
                    Rank      = node.Rank,
                    ParentId  = node.OrganizationParentId,
                    Name      = node.OrganizationName,
                    AliasName = node.OrganizationAliasName,
                    Enable    = node.OrganizationEnable == null ? true : (bool)node.OrganizationEnable
                },
            };

            if (layer > 0 && node.HasChildren != null && node.HasChildren != 0)
            {
                ViewBuildingFullInfoBLL buildingBLL = new ViewBuildingFullInfoBLL();
                var l = layer - 1;
                model.Children = buildingBLL.Filter(o => o.ParentId == node.Id).Select(o => o.ToViewDiagram(l));
            }
            else
            {
                model.Children = null;
            }


            var ctx = new EmpContext();

            model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Building" && x.JoinId == node.Id).ToViewList();

            return(model);
        }