Ejemplo n.º 1
0
 public static BuildingData ToViewData(this BuildingFullInfo node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node != null)
     {
         var model = new BuildingData()
         {
             Id       = node.Id,
             ParentId = node.ParentId,
             Parent   = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? new BuildingData
             {
                 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,
             HasChildren        = node.HasChildren == null ? 0 : (int)node.HasChildren,
             OrganizationId     = node.OrganizationId,
             BuildingCategoryId = node.BuildingCategoryId,
             CoordinateMapId    = node.CoordinateMapId,
             Coordinate2dId     = node.Coordinate2dId,
             TreeId             = node.TreeId,
             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,
             MaxCustomerCount = node.MaxCustomerCount,
             Purpose          = node.Purpose
         };
         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);
     }
     else
     {
         return(null);
     }
 }
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);
        }