protected Entity(INode parent, string entityName, EntityType type, EntityVisibility visibility, string formalPublicIdentifier, string entityValue, string nData) : base(parent) { this.entityName = entityName; this.type = type; this.visibility = visibility; this.formalPublicIdentifier = formalPublicIdentifier; this.entityValue = entityValue; this.nData = nData; }
private DocumentType(INode parent, string rootElement, EntityVisibility visibility, string formalPublicIdentifier, string systemIdentifier, string internalSubset) : base(parent) { if (string.IsNullOrEmpty(rootElement)) throw new ArgumentException("rootElement cannot be null or empty"); this.rootElement = rootElement; this.visibility = visibility; this.formalPublicIdentifier = formalPublicIdentifier; this.systemIdentifier = systemIdentifier; this.internalSubset = internalSubset; }
private DocumentType(INode parent, string rootElement, EntityVisibility visibility, string formalPublicIdentifier, string systemIdentifier, string internalSubset) : base(parent) { if (string.IsNullOrEmpty(rootElement)) { throw new ArgumentException("rootElement cannot be null or empty"); } this.rootElement = rootElement; this.visibility = visibility; this.formalPublicIdentifier = formalPublicIdentifier; this.systemIdentifier = systemIdentifier; this.internalSubset = internalSubset; }
public static IDocumentType Parse(INode parent, string rootElement, string formalPublicIdentifier, string systemIdentifier, string internalSubset, string outerXml) { var visibility = EntityVisibility.Unspecified; if (outerXml != null && outerXml.Contains(" PUBLIC ")) { visibility = EntityVisibility.Public; } else if (outerXml != null && outerXml.Contains(" SYSTEM ")) { visibility = EntityVisibility.System; } return(new DocumentType(parent, rootElement, visibility, formalPublicIdentifier, systemIdentifier, internalSubset)); }
internal ZonedPolygonGroup(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure, List <ZonedPolygon> _zps) : base(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure) { this.ContainedEntities = new List <Entity>(); foreach (ZonedPolygon zp in _zps) { zp.PropertyChanged += polygon_PropertyChanged; this.ContainedEntities.Add(zp); } ContainedEnditiesToGeometryDef(); CalculateAvgHeight(); this.IsDirty = true; this.OpeningsDirty = true; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && parameter != null) { if (value is EntityVisibility) { EntityVisibility vis1 = (EntityVisibility)value; EntityVisibility vis2 = Entity.ConvertStringToVis(parameter.ToString()); if (vis1 == vis2) { return(true); } else { return(false); } } } return(false); }
internal Entity(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure) { this.ID = _id; this.EntityName = _name; this.EntityColor = _color; this.visibility = _vis; this.IsValid = true; this.AssociatedWComp = _assoc_w_comp; this.LineThicknessGUI = _line_thickness_GUI; this.Text = _mLtext; this.IsTopClosure = _is_top_closure; this.IsBottomClosure = _is_bottom_closure; this.ContainedEntities = null; // will be handled separately in the specialised .ctors this.ShowZones = false; this.ShowCtrlPoints = true; this.HasGeometry = false; this.HasGeometryType = EnityGeometryType.NONE; this.IsExpanded = false; this.IsSelected = false; }
internal ZonedVolume ReconstructZonedVolume(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure, Layer _layer, bool _color_by_layer, List <ZonedPolygonGroup> _rulingLevels, Dictionary <int, ComponentInteraction.Material> _material_per_level, Dictionary <Utils.Composite4IntKey, ComponentInteraction.Material> _material_per_label) { // reconstruct the volume ZonedVolume created = new ZonedVolume(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure, _layer, _color_by_layer, _rulingLevels, _material_per_level, _material_per_label); Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; // setting the layer adds the ZonedVolume to the ContainedEntities of the layer (see DXFLayer) return(created); }
internal ZonedPolygonGroup ReconstructZonedLevel(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure, List <long> _zoned_polygon_ids) { // find all polygons contained in the group (level) if (_zoned_polygon_ids == null) { return(null); } if (_zoned_polygon_ids.Count < 1) { return(null); } List <ZonedPolygon> level_polygons = new List <ZonedPolygon>(); foreach (long id in _zoned_polygon_ids) { GeometricEntity ge_found = this.parsed_GE_before_adding_to_Layer.FirstOrDefault(x => x.ID == id); if (ge_found == null) { continue; } ZonedPolygon zp_found = ge_found as ZonedPolygon; if (zp_found == null) { continue; } level_polygons.Add(zp_found); } if (level_polygons.Count < 1) { return(null); } // reconstruct the grouop (level) ZonedPolygonGroup created = new ZonedPolygonGroup(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure, level_polygons); Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; return(created); }
internal ZonedPolygon ReconstructZonedPolygon(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure, Layer _layer, bool _color_by_layer, List <Point3D> _coords, float _height, List <int> _zone_inds) { // create the polygon ZonedPolygon zp = new ZonedPolygon(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure, _layer, _color_by_layer, _coords, _height); if (_zone_inds != null && _zone_inds.Count == _coords.Count) { zp.ReDefineAllZones(_zone_inds); } Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; // setting the layer adds the ZonedPolygon to the ContainedEntities of its layer // (see DXFLayer and Property GeometricEntity.EnitiyLayer) // add to temporary container this.parsed_GE_before_adding_to_Layer.Add(zp); return(zp); }
internal Layer ReconstructLayer(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure) { // create the layer Layer created = new Layer(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure); Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; // add (for the time being) to the manager this.AddLayer(created); // if it is a sub-Layer of another one, it will be removed later... return(created); }
private void RegisterDataTableConfigurations(Type controllerType) { var methods = controllerType.GetMethods() .Where(m => (typeof(DataTableConfig).IsAssignableFrom(m.ReturnType) && m.IsStatic && !m.GetGenericArguments().Any()) && !m.GetParameters().Any()) .ToList(); using (var uow = _unitOfWorkManager.Begin()) { foreach (var method in methods) { try { var tableConfig = method.Invoke(null, null); if (tableConfig is DataTableConfig config) { var tableId = config.Id; if (_dataTableConfigurations.ContainsKey(tableId)) { throw new Exception( $"Table configuration with the same Id already registered, (tableId: {tableId}, controller: {controllerType.FullName})"); } // Get all filters of the given data table var existingFilters = _filterContainerRepository.GetAll() .Where(f => f.OwnerType == "" && f.OwnerId == tableId && !f.Filter.IsDeleted).Select(f => f.Filter) .OrderBy(f => f.OrderIndex).ToList(); var maxSortIndex = existingFilters.Max(f => (int?)f.OrderIndex).GetValueOrDefault(); // 1. Store any new filters registered using an attribute var storedFilterAttributeRegistrations = method.GetCustomAttributes(typeof(StoredFilterAttribute), false); foreach (StoredFilterAttribute filterRegistration in storedFilterAttributeRegistrations) { // Check if a filter with the same name already exists var existingFilter = _storedFilterRepository.GetAll() .FirstOrDefault(f => f.Id == filterRegistration.Id); // Add new definition to DB var orderIndex = filterRegistration.OrderIndex; if (orderIndex != null && existingFilters.Any(f => f.OrderIndex == orderIndex)) { // If the same index already exists, we append to the end of the list orderIndex = ++maxSortIndex; } if (existingFilter == null) { existingFilter = new StoredFilter { Id = filterRegistration.Id, Name = filterRegistration.Name, ExpressionType = filterRegistration.ExpressionType, Expression = filterRegistration.Expression, OrderIndex = orderIndex ?? ++maxSortIndex, IsExclusive = true }; _storedFilterRepository.InsertAndGetId(existingFilter); } else { // Update data if (existingFilter.Name != filterRegistration.Name && !string.IsNullOrEmpty(filterRegistration.Name)) { existingFilter.Name = filterRegistration.Name; } if (existingFilter.ExpressionType != filterRegistration.ExpressionType) { existingFilter.ExpressionType = filterRegistration.ExpressionType; } if (existingFilter.Expression != filterRegistration.Expression && !string.IsNullOrEmpty(filterRegistration.Expression)) { existingFilter.Expression = filterRegistration.Expression; } if (existingFilter.OrderIndex != filterRegistration.OrderIndex && filterRegistration.OrderIndex != null) { existingFilter.OrderIndex = filterRegistration.OrderIndex.GetValueOrDefault(); } _storedFilterRepository.Update(existingFilter); } if (!existingFilter.ContainerEntities.Any( c => c.OwnerType == "" && c.OwnerId == tableId)) { // Add to the container (current datatable ID) var newContainer = new StoredFilterContainer { Id = Guid.NewGuid(), Filter = existingFilter, OwnerType = "", OwnerId = tableId }; _filterContainerRepository.Insert(newContainer); // Add to bag existingFilter.ContainerEntities.Add(newContainer); } // Configure visibility if (!string.IsNullOrEmpty(filterRegistration.VisibilityRoleName)) { var role = _roleRepository.GetAll().FirstOrDefault(r => r.NameSpace == filterRegistration.VisibilityRoleNamespace && r.Name == filterRegistration.Name); if (role != null) { if (!existingFilter.VisibleBy.Any(v => v.OwnerId == role.Id.ToString() && v.OwnerType == role.GetTypeShortAlias())) { var newVisibility = new EntityVisibility { Id = Guid.NewGuid(), EntityType = existingFilter.GetTypeShortAlias(), EntityId = existingFilter.Id.ToString(), OwnerType = role.GetTypeShortAlias(), OwnerId = role.Id.ToString(), EntityAccess = RefListEntityAccess.ReadAccess }; _entityVisibilityRepository.Insert(newVisibility); // Add to bag existingFilter.VisibleBy.Add(newVisibility); } } else { throw new Exception("EntityVisibility: Workflow role not found. namespace: " + filterRegistration.VisibilityRoleNamespace + ". name: " + filterRegistration.VisibilityRoleName); } } } // Get the filter list from DB (this may include user filters as well as previously registered filters) //config.StoredFilters = GetStoredFilters(config); config.StoredFilters = existingFilters.OrderBy(f => f.OrderIndex).Select(_mapper.Map <DataTableStoredFilter>).ToList(); _dataTableConfigurations.Add(config.Id, () => { var instance = method.Invoke(null, null) as DataTableConfig; if (instance != null) { instance.StoredFilters = GetStoredFilters(config); } return(instance); }); /* todo: the configuration now partially depends on user because of tags like {userId} in filters and * also because of Index View Selector filers visibility settings * make sure Store updates configuration for current user before sending it out to client. */ } } catch (Exception ex) { Logger.Warn("Error whilst loading configuration", ex); } } uow.Complete(); } }
// only for parsing internal Layer(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp, float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure) : base(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure) { this.ContainedEntities = new List <Entity>(); }
public static IDocumentType Parse(INode parent, string rootElement, string formalPublicIdentifier, string systemIdentifier, string internalSubset, string outerXml) { var visibility = EntityVisibility.Unspecified; if (outerXml != null && outerXml.Contains(" PUBLIC ")) visibility = EntityVisibility.Public; else if (outerXml != null && outerXml.Contains(" SYSTEM ")) visibility = EntityVisibility.System; return new DocumentType(parent, rootElement, visibility, formalPublicIdentifier, systemIdentifier, internalSubset); }