private Expression BuildExpressionInternal(ComponentFilter componentFilter,
                                                   ParameterExpression componentParameter)
        {
            Expression expression;

            switch (componentFilter.Type.Value)
            {
            case FilterType.FilterGroup:
                expression = BuildFilterGroupExpression(componentFilter.FilterGroup, componentParameter);
                break;

            case FilterType.Comparison:
                expression = BuildComparisonExpression(componentFilter.ComparisonFilter, componentParameter);
                break;

            default:
                throw new InvalidOperationException($"Unknown filter type \"{componentFilter.Type}\"");
            }

            if (componentFilter.IsNegate)
            {
                expression = Expression.Negate(expression);
            }

            return(expression);
        }
Пример #2
0
        private void CreateDifferentPositionsConstr()
        {
            string           domainConstraintName = "All with different positions";
            BinaryRelation   relation;
            ComponentFilter  comp1Filter;
            ComponentFilter  comp2Filter;
            GKOAttribute     attribute;
            DomainConstraint domConstraint;

            // For all components / no filter
            comp1Filter = new ComponentFilter()
            {
                Filter = null,
                ComponentTypeFilter = null
            };
            comp2Filter = new ComponentFilter()
            {
                Filter = null,
                ComponentTypeFilter = null
            };
            // For the "Position" attribute
            attribute = this.KnowledgeBase.Attributes[7];
            // Not equals relations must apply
            relation = StructuralRelationsManager.GetRelation(RelationFamilyNames.MetricRelationsName, MetricRelationNames.NotEquals);

            // Creating the domain constraint
            domConstraint = new DomainConstraint(domainConstraintName, relation, false);
            domConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(comp1Filter, attribute));
            domConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(comp2Filter, attribute));

            this.DomainConstraints.Add(domConstraint);
        }
        public Expression <Func <IComponent, bool> > BuildFilterExpression(ComponentFilter componentFilter)
        {
            var componentParameter = Expression.Parameter(typeof(IComponent));
            var filterExpression   = BuildExpressionInternal(componentFilter, componentParameter);

            return(Expression.Lambda <Func <IComponent, bool> >(filterExpression, componentParameter));
        }
Пример #4
0
        /// <summary>
        /// Gets GeoPoint by address
        /// </summary>
        /// <param name="address">Address to search for</param>
        /// <param name="component">Component filter.</param>
        /// <param name="language">Language filter.</param>
        /// <param name="region">Region filter.</param>
        /// <param name="boundsBias">Bounds filter.</param>
        /// <param name="cancellationToken">Cancellation token to use.</param>
        /// <returns>GeocodeResponnse as a sting according to specified format(JSON, XML)</returns>
        public async Task <string> GeocodeJsonAsync(string address, ComponentFilter component = null, string language = "", string region = "", Bounds boundsBias = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Dictionary <string, string> values = new Dictionary <string, string>();

            if (!string.IsNullOrWhiteSpace(address))
            {
                values.Add(GlobalConstants.ADDRES_REQUEST_PARAM.Replace("&", string.Empty).Replace("=", string.Empty).Replace("?", string.Empty), address);
            }

            if (!string.IsNullOrWhiteSpace(language))
            {
                values.Add(GlobalConstants.LANGUAGE_REQUEST_PARAMETER.Replace("&", string.Empty).Replace("=", string.Empty).Replace("?", string.Empty), language);
            }

            if (!string.IsNullOrWhiteSpace(region))
            {
                values.Add(GlobalConstants.REGION_REQUEST_PARAMETER.Replace("&", string.Empty).Replace("=", string.Empty).Replace("?", string.Empty), region);
            }

            if ((boundsBias != null) && boundsBias.HasBounds)
            {
                values.Add(GlobalConstants.BOUNDS_REQUEST_PARAMETER.Replace("&", string.Empty).Replace("=", string.Empty).Replace("?", string.Empty), boundsBias.ToQueryString());
            }

            if (component != null)
            {
                values.Add(GlobalConstants.COMPONTENTS_REQUEST_PARAMETER.Replace("&", string.Empty).Replace("=", string.Empty).Replace("?", string.Empty), component.ToQueryString());
            }

            var requestUriString = BuildGoogleRequest(values);

            return(await GetContentAsync(requestUriString, cancellationToken));
        }
Пример #5
0
 /// <summary>
 /// Test for empty object
 /// </summary>
 /// <returns>bool</returns>
 public bool IsEmpty()
 {
     return(IfcProductFilter.IsEmpty() && IfcTypeObjectFilter.IsEmpty() && IfcAssemblyFilter.IsEmpty() &&
            ZoneFilter.IsEmpty() && TypeFilter.IsEmpty() && SpaceFilter.IsEmpty() &&
            FloorFilter.IsEmpty() && FacilityFilter.IsEmpty() && SpareFilter.IsEmpty() &&
            ComponentFilter.IsEmpty() && CommonFilter.IsEmpty());
 }
Пример #6
0
        public Component GetClosestComponent(int x, int y, ComponentFilter cf)
        {
            Component result           = null;
            var       componentType    = cf.Type;
            var       components       = this.Components[componentType];
            var       v                = new Vector(x, y);
            double    maxLengthSquared = 0;

            if (components.Count > 0)
            {
                foreach (var c in components)
                {
                    if (cf.TestComponent(c))
                    {
                        var go            = c.GetParent;
                        var lengthSquared = (v - go.GetPosition()).LengthSquared;
                        if (lengthSquared < maxLengthSquared || result == null)
                        {
                            maxLengthSquared = lengthSquared;
                            result           = c;
                        }
                    }
                }
            }
            return(result);
        }
Пример #7
0
        /// <summary>
        /// Returns all components of the specified type, or derived from the specified type, within the Scene.
        /// Initially, this method will loop through each Component within the Scene, and add them to the filtered list.
        /// Afterwards, the list will be updated automatically as Components are added and removed, allowing for efficient lookups.
        /// </summary>
        protected IEnumerable <T> GetFilteredComponents <T>() where T : Component
        {
            ComponentFilter Filter = Filters.FirstOrDefault(c => c.ComponentType == typeof(T));

            if (Filter.ComponentType == null)              // Filter not found, default(ComponentFilter).
            // We're not tracking this type, so find every Component and return it.
            // If we find a Component, make sure that Entity is being tracked.
            {
                List <Component> Components = new List <Component>();
                foreach (var Entity in Scene.Entities)
                {
                    bool Any = false;
                    foreach (var Component in Entity.Components)
                    {
                        var ComponentType = Component.GetType();
                        if (ComponentType == typeof(T) || ComponentType.IsSubclassOf(typeof(T)))
                        {
                            Components.Add(Component);
                            Any = true;
                        }
                    }
                    if (Any)
                    {
                        RegisterEntity(Entity);
                    }
                }
                Filter = new ComponentFilter(typeof(T), Components);
                Filters.Add(Filter);
            }
            // TODO: I'd imagine that this Select will pretty much destroy performance if we get too many Components.
            return(Filter.Components.Select(c => (T)c));
        }
Пример #8
0
    public void FilterPackagesTest()
    {
        List <GameObject> testComponents = new List <GameObject>();

        int countDocuments   = 20;
        int countDirectories = 7;

        for (int i = 0; i < countDocuments; i++)
        {
            GameObject g = new GameObject();
            g.AddComponent <BaseInformation>();
            g.GetComponent <BaseInformation>().UpdateValues(GetDocumentTreeComponent());
            testComponents.Add(g);
        }

        for (int i = 0; i < countDirectories; i++)
        {
            GameObject g = new GameObject();
            g.AddComponent <BaseInformation>();
            g.GetComponent <BaseInformation>().UpdateValues(GetDirectoryTreeComponent());
            testComponents.Add(g);
        }

        Assert.AreEqual(ComponentFilter.FilterPackages(testComponents).Count, countDirectories);
    }
Пример #9
0
        public BindingList <ComponentData> GetComponentsForPopup(int supplyID, ComponentFilter filter)
        {
            var query = Context.Components
                        .Where(x => !x.SupplyItems.Any(y => y.SupplyID == supplyID));

            if (filter.ComponentTypeID.HasValue)
            {
                query = query.Where(x => x.ComponentTypeID == filter.ComponentTypeID);
            }
            if (filter.Name.IsNotNullOrEmpty())
            {
                query = query.Where(x => x.Name.Contains(filter.Name));
            }
            if (filter.ProductID.HasValue)
            {
                query = query.Where(x => x.Product_Component.Any(y => y.ProductID == filter.ProductID));
            }

            var list = query.Select(x => new ComponentData
            {
                ID = x.ID,
                ComponentTypeName = x.ComponentType.Name,
                Name     = x.Name,
                Quantity = x.Quantity
            })
                       .OrderBy(x => x.Name)
                       .ToList();

            return(new BindingList <ComponentData>(list));
        }
Пример #10
0
        private void CreateNoGapsConstr()
        {
            string           domainConstraintName = "No position gaps";
            BinaryRelation   relation;
            ComponentFilter  comp1Filter;
            GKOAttribute     attribute;
            DomainConstraint domConstraint;

            // For all components / no filter
            comp1Filter = new ComponentFilter()
            {
                Filter = null,
                ComponentTypeFilter = null
            };
            // For the "Position" attribute
            attribute = this.KnowledgeBase.Attributes[7];
            // Less than relations must apply
            relation = StructuralRelationsManager.GetRelation(RelationFamilyNames.MetricRelationsName, MetricRelationNames.LessOrEqualsN);

            // Creating the domain constraint
            domConstraint = new DomainConstraint(domainConstraintName, relation, false);
            domConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(comp1Filter, attribute));
            domConstraint.DomainRelationParts.Add(new MetricDomainRelationPart(SpecialMetricValue.ComponentsCount));

            this.DomainConstraints.Add(domConstraint);
        }
Пример #11
0
        public GeocodeTransform(IContext context) : base(context, "object")
        {
            ProducesFields = true;

            if (context.Operation.Parameters.Any())
            {
                var lat = context.Operation.Parameters.FirstOrDefault(p => p.Name.ToLower().In("lat", "latitude"));
                if (lat == null)
                {
                    Error("The fromaddress (geocode) transform requires an output field named lat, or latitude.");
                    Run = false;
                    return;
                }
                if (lat.Type != "double")
                {
                    Error($"The goecode {lat.Name} field must be of type double.");
                    Run = false;
                    return;
                }

                var lon = context.Operation.Parameters.FirstOrDefault(p => p.Name.ToLower().In("lon", "long", "longitude"));
                if (lon == null)
                {
                    Error("The fromaddress (geocode) transform requires an output field named lon, long, or longitude.");
                    Run = false;
                    return;
                }
                if (lon.Type != "double")
                {
                    Error($"The goecode {lon.Name} field must be of type double.");
                    Run = false;
                    return;
                }
            }
            else
            {
                Error("The fromaddress (geocode) transform requires a collection of output fields; namely: latitude, longitude, and formattedaddress (optional).");
                Run = false;
                return;
            }

            _input  = SingleInput();
            _output = MultipleOutput();
            if (context.Operation.Key != string.Empty)
            {
                GoogleSigned.AssignAllServices(new GoogleSigned(context.Operation.Key));
            }
            _originalConnectionLimit = ServicePointManager.DefaultConnectionLimit;
            ServicePointManager.DefaultConnectionLimit = 255;
            _rateGate        = new RateGate(context.Operation.Limit, TimeSpan.FromMilliseconds(context.Operation.Time));
            _componentFilter = new ComponentFilter {
                AdministrativeArea = context.Operation.AdministrativeArea,
                Country            = context.Operation.Country,
                Locality           = context.Operation.Locality,
                PostalCode         = context.Operation.PostalCode,
                Route = context.Operation.Route
            };
        }
        public ActionResult Filter(string type, string value)
        {
            var filter = new ComponentFilter()
            {
                Name = value,
                Type = type
            };

            if (type == "type")
            {
                filter.Predicate = (x => x.Type == value);
            }
            else if (type == "producer")
            {
                filter.Predicate = (x => x.Producer == value);
            }

            var filters = new List <ComponentFilter>();

            if (Session["ComponentFilter"] != null)
            {
                filters = Session["ComponentFilter"] as List <ComponentFilter>;
            }

            var found = filters.FirstOrDefault(f => f.Name == value && f.Type == type);

            if (found != null)
            {
                filters.Remove(found);
            }
            else
            {
                filters.Add(filter);
            }

            Session["ComponentFilter"] = filters;
            // BUG to fix [start] ->
            if (filters.Count == 0)
            {
                return(RedirectToAction("Index"));
            }
            // <- [end]
            List <ComponentViewModel> components = _mapper.Map <List <ComponentDTO>, List <ComponentViewModel> >(_storeService.GetAllComponents(filters).ToList());

            SetViewBag();

            if (components.Count != 0)
            {
                return(PartialView("ComponentsPartial", components));
            }

            return(HttpNotFound());
        }
Пример #13
0
        public void ExcludeDoesNotMatchhWhenEmpty()
        {
            var componentFilter = new ComponentFilter()
            {
                Include     = false,
                Expressions = new List <string>()
            };

            var match = componentFilter.Match("not matched project name");

            Assert.True(match);
        }
Пример #14
0
        private void FilterButton_Click(object sender, EventArgs e)
        {
            var filter = new ComponentFilter
            {
                ComponentTypeID   = (FilterComponentTypeDropDown.SelectedValue.AsByte() == 0) ? null : FilterComponentTypeDropDown.SelectedValue.AsByte(),
                Name              = FilterNameTextBox.Text,
                ProductID         = (FilterProductDropDown.SelectedValue.AsInt() == 0) ? null : FilterProductDropDown.SelectedValue.AsInt(),
                IsNotAssignedOnly = FilterIsNotAssignedOnlyCheckBox.Checked
            };

            ComponentGrid.DataSource = ComponentRepository.GetComponents(filter);
            ComponentGrid.ClearSelection();
        }
Пример #15
0
 public Query(
     IEnumerable <ComponentTypeCode> componentFilter,
     IEnumerable <QueryParameter> parameters) : this()
 {
     foreach (var typeCode in componentFilter ?? Array.Empty <ComponentTypeCode>())
     {
         ComponentFilter.Add(typeCode);
     }
     foreach (var parameter in parameters ?? Array.Empty <QueryParameter>())
     {
         Add(parameter);
     }
 }
Пример #16
0
        private void Create6thBefore10th()
        {
            string           domainConstraintName = "Every 6th Before every 10th";
            BinaryRelation   relation;
            ComponentFilter  comp1Filter;
            ComponentFilter  comp2Filter;
            GKOAttribute     attribute;
            DomainConstraint domConstraint;

            // For all components / no filter
            comp1Filter = new ComponentFilter()
            {
                Filter = null,
                ComponentTypeFilter = null,
                AttributeFilters    = new List <AttributeFilter>()
                {
                    new AttributeFilter(this.KnowledgeBase.Attributes[3], new List <string>()
                    {
                        true.ToString()
                    })
                }
            };
            comp2Filter = new ComponentFilter()
            {
                Filter = null,
                ComponentTypeFilter = null,
                AttributeFilters    = new List <AttributeFilter>()
                {
                    new AttributeFilter(this.KnowledgeBase.Attributes[0], new List <string>()
                    {
                        true.ToString()
                    }),
                    new AttributeFilter(this.KnowledgeBase.Attributes[2], new List <string>()
                    {
                        true.ToString()
                    }),
                }
            };
            // For the "Position" attribute
            attribute = this.KnowledgeBase.Attributes[7];
            // Not equals relations must apply
            relation = StructuralRelationsManager.GetRelation(RelationFamilyNames.MetricRelationsName, MetricRelationNames.GreaterThan);

            // Creating the domain constraint
            domConstraint = new DomainConstraint(domainConstraintName, relation, false);
            domConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(comp1Filter, attribute));
            domConstraint.DomainRelationParts.Add(new AttributeDomainRelationPart(comp2Filter, attribute));
            //domConstraint.DomainRelationParts.Add(new MetricDomainRelationPart(SpecialMetricValue.ComponentsCount));

            this.DomainConstraints.Add(domConstraint);
        }
Пример #17
0
        /// <summary>
        /// Test Property Set Names against sheets
        /// </summary>
        /// <param name="testStr">Name string to test</param>
        /// <param name="parent">Parent object</param>
        /// <returns>bool</returns>
        public bool PSetNameFilterOnSheetName(string testStr, CobieObject parent = null)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(testStr))
            {
                result = CommonFilter.PSetNameFilter(testStr);
                if (!result)
                {
                    if (parent == null)
                    {
                        result = false;
                    }
                    else if ((parent is Zone) && (ZoneFilter != null))
                    {
                        result = ZoneFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is AssetType) && (TypeFilter != null))
                    {
                        result = TypeFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Space) && (SpaceFilter != null))
                    {
                        result = SpaceFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Floor) && (FloorFilter != null))
                    {
                        result = FloorFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Facility) && (FacilityFilter != null))
                    {
                        result = FacilityFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Spare) && (SpareFilter != null))
                    {
                        result = SpareFilter.PSetNameFilter(testStr);
                    }
                    else if ((parent is Asset) && (ComponentFilter != null))
                    {
                        result = ComponentFilter.PSetNameFilter(testStr);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            //don't flip property sets as this excludes all the attributes, so we do not see attribute name exclusions as all property sets get excluded
            //return FlipResult ? !result : result;
            return(result);
        }
Пример #18
0
        private void FilterButton_Click(object sender, EventArgs e)
        {
            RibbonMode = RibbonMode.Listing;

            var filter = new ComponentFilter
            {
                ComponentTypeID   = (FilterComponentTypeDropDown.SelectedValue.AsByte() == 0) ? null : FilterComponentTypeDropDown.SelectedValue.AsByte(),
                Name              = FilterNameTextBox.Text,
                ProductID         = (FilterProductDropDown.SelectedValue.AsInt() == 0) ? null : FilterProductDropDown.SelectedValue.AsInt(),
                IsNotAssignedOnly = FilterIsNotAssignedOnlyCheckBox.Checked
            };

            ComponentGrid.DataSource = ProductRepository.GetComponentsForPopup(productID, filter);
        }
Пример #19
0
        //TODO: IfcProperty filterining on IfcObjects

        /// <summary>
        /// Test property Names against sheets
        /// </summary>
        /// <param name="testStr">Name string to test</param>
        /// <param name="parent">Parent object</param>
        /// <returns>bool</returns>
        public bool NameFilterOnParent(string testStr, CobieObject parent = null)
        {
            var result = false;

            if (!string.IsNullOrEmpty(testStr))
            {
                result = CommonFilter.NameFilter(testStr);
                if (!result)
                {
                    if (parent == null)
                    {
                        result = false;
                    }
                    else if ((parent is Zone) && (ZoneFilter != null))
                    {
                        result = ZoneFilter.NameFilter(testStr);
                    }
                    else if ((parent is AssetType) && (TypeFilter != null))
                    {
                        result = TypeFilter.NameFilter(testStr);
                    }
                    else if ((parent is Space) && (SpaceFilter != null))
                    {
                        result = SpaceFilter.NameFilter(testStr);
                    }
                    else if ((parent is Floor) && (FloorFilter != null))
                    {
                        result = FloorFilter.NameFilter(testStr);
                    }
                    else if ((parent is Facility) && (FacilityFilter != null))
                    {
                        result = FacilityFilter.NameFilter(testStr);
                    }
                    else if ((parent is Spare) && (SpareFilter != null))
                    {
                        result = SpareFilter.NameFilter(testStr);
                    }
                    else if ((parent is Asset) && (ComponentFilter != null))
                    {
                        result = ComponentFilter.NameFilter(testStr);
                    }
                    else
                    {
                        result = false;
                    }
                }
            }
            return(FlipResult ? !result : result);
        }
Пример #20
0
        public void IncludeMatch()
        {
            var componentFilter = new ComponentFilter()
            {
                Include     = true,
                Expressions = new List <string>()
                {
                    "^project.*$"
                }
            };

            var match = componentFilter.Match("project name");

            Assert.True(match);
        }
Пример #21
0
        /// <summary>
        /// Merge OutPutFilters
        /// </summary>
        /// <param name="mergeFilter">OutPutFilters</param>
        public void Merge(OutPutFilters mergeFilter)
        {
            IfcProductFilter.MergeInc(mergeFilter.IfcProductFilter);
            IfcTypeObjectFilter.MergeInc(mergeFilter.IfcTypeObjectFilter);
            IfcAssemblyFilter.MergeInc(mergeFilter.IfcAssemblyFilter);

            ZoneFilter.Merge(mergeFilter.ZoneFilter);
            TypeFilter.Merge(mergeFilter.TypeFilter);
            SpaceFilter.Merge(mergeFilter.SpaceFilter);
            FloorFilter.Merge(mergeFilter.FloorFilter);
            FacilityFilter.Merge(mergeFilter.FacilityFilter);
            SpareFilter.Merge(mergeFilter.SpareFilter);
            ComponentFilter.Merge(mergeFilter.ComponentFilter);
            CommonFilter.Merge(mergeFilter.CommonFilter);
        }
Пример #22
0
        private void FilterButton_Click(object sender, EventArgs e)
        {
            RibbonMode = RibbonMode.Listing;

            var filter = new ComponentFilter
            {
                ComponentTypeID = (FilterComponentTypeDropDown.SelectedValue.AsByte() == 0) ? null : FilterComponentTypeDropDown.SelectedValue.AsByte(),
                Name            = FilterNameTextBox.Text,
                ProductID       = (FilterProductDropDown.SelectedValue.AsInt() == 0) ? null : FilterProductDropDown.SelectedValue.AsInt()
            };

            using (var repository = new InventoryRepository())
            {
                ComponentGrid.DataSource = repository.GetComponentsForPopup(inventoryID, filter);
            }
        }
Пример #23
0
        public async Task <List <CoordinateInfo> > FindCoordinates(string locationName)
        {
            var locationResults = new List <CoordinateInfo>();

            var client = new GeocodeClient(new OldGoogleForwarderProxy(), "");

            // we only want US addresses
            var countryFilter = new ComponentFilter()
            {
                Country = "US"
            };

            try
            {
                // Let Google figure out the geocoded address
                var geocodedResults = await client.GeocodeAddress(locationName, null, countryFilter);

                // Only do something if Google says we're OK
                if (geocodedResults.Status == GeocodeStatus.Ok)
                {
                    // Make sure the results are based on a city name
                    var allCityResults = geocodedResults.Results.Where(gr => gr.PartialMatch == false && gr.Types.Any(t => t.Equals("locality")));

                    // Build up the locationResults list
                    foreach (var city in allCityResults)
                    {
                        // Grab the lat & long
                        var coordInfo = new CoordinateInfo()
                        {
                            Latitude = city.Geometry.Location.Latitude, Longitude = city.Geometry.Location.Longitude
                        };

                        // Grab the city & state name out from the address component of the results
                        coordInfo.CityName = city.AddressComponents.First(ac => ac.Types.Any(t => t.Equals("locality"))).ShortName;
                        coordInfo.State    = city.AddressComponents.First(ac => ac.Types.Any(t => t.Equals("administrative_area_level_1"))).ShortName;

                        locationResults.Add(coordInfo);
                    }
                }
            } catch (Exception ex)
            {
                var s = ex.ToString();
            }

            return(locationResults);
        }
Пример #24
0
        /// <summary>
        /// Clear OutPutFilters
        /// </summary>
        public void Clear()
        {
            AppliedRoles = 0;

            IfcProductFilter.Clear();
            IfcTypeObjectFilter.Clear();
            IfcAssemblyFilter.Clear();

            ZoneFilter.Clear();
            TypeFilter.Clear();
            SpaceFilter.Clear();
            FloorFilter.Clear();
            FacilityFilter.Clear();
            SpareFilter.Clear();
            ComponentFilter.Clear();
            CommonFilter.Clear();
        }
Пример #25
0
        /// <summary>
        /// Copy the OutPutFilters
        /// </summary>
        /// <param name="copyFilter">OutPutFilters to copy </param>
        public void Copy(OutPutFilters copyFilter)
        {
            AppliedRoles = copyFilter.AppliedRoles;

            IfcProductFilter.Copy(copyFilter.IfcProductFilter);
            IfcTypeObjectFilter.Copy(copyFilter.IfcTypeObjectFilter);
            IfcAssemblyFilter.Copy(copyFilter.IfcAssemblyFilter);

            ZoneFilter.Copy(copyFilter.ZoneFilter);
            TypeFilter.Copy(copyFilter.TypeFilter);
            SpaceFilter.Copy(copyFilter.SpaceFilter);
            FloorFilter.Copy(copyFilter.FloorFilter);
            FacilityFilter.Copy(copyFilter.FacilityFilter);
            SpareFilter.Copy(copyFilter.SpareFilter);
            ComponentFilter.Copy(copyFilter.ComponentFilter);
            CommonFilter.Copy(copyFilter.CommonFilter);
        }
Пример #26
0
 public GeocodeTransform(IContext context) : base(context, "object")
 {
     _input  = SingleInput();
     _output = MultipleOutput();
     if (context.Transform.Key != string.Empty)
     {
         GoogleSigned.AssignAllServices(new GoogleSigned(context.Transform.Key));
     }
     _originalConnectionLimit = ServicePointManager.DefaultConnectionLimit;
     ServicePointManager.DefaultConnectionLimit = 255;
     _rateGate        = new RateGate(Context.Transform.Limit, TimeSpan.FromMilliseconds(Context.Transform.Time));
     _componentFilter = new ComponentFilter {
         AdministrativeArea = Context.Transform.AdministrativeArea,
         Country            = Context.Transform.Country,
         Locality           = Context.Transform.Locality,
         PostalCode         = Context.Transform.PostalCode,
         Route = Context.Transform.Route
     };
 }
        public void BranchDeployment()
        {
            if (!CanBranchDeployment)
            {
                return;
            }

            IsLoadingData = true;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    var deploymentPlanner = new OctopusDeploymentPlanner(_octopusUrl, _octopusApiKey);
                    var componentFilter   = new ComponentFilter
                    {
                        Expressions = ComponentFilterExpressions.Select(x => x.Text).ToList(),
                        Include     = ComponentFilterInclude
                    };

                    var branchDeploymentPlans = deploymentPlanner.GetBranchDeploymentPlans(_selectedBranchDeploymentEnvironment.Name, _selectedBranchDeploymentBranch.Name, _doNotUseDifferentialDeploymentForBranchDeployment, componentFilter);
                    EnvironmentDeploymentPlan = branchDeploymentPlans.EnvironmentDeploymentPlan;

                    var deploymentScheduler = new DeploymentScheduler();

                    var componentGraph = deploymentScheduler.GetComponentDeploymentGraph(EnvironmentDeploymentPlan);
                    Graph = componentGraph.ToBidirectionalGraph();
                    EnvironmentDeployment             = deploymentScheduler.GetEnvironmentDeployment(componentGraph);
                    EnvironmentDeploymentSaveFileName = "branch " + _selectedBranchDeploymentBranch.Name + " to " + _selectedBranchDeploymentEnvironment.Name + ".json";
                    EnvironmentToDeployTo             = _selectedBranchDeploymentEnvironment;
                }
                catch
                {
                    EnvironmentDeploymentPlan = new EnvironmentDeploymentPlan(new List <ComponentDeploymentPlan>());
                    Graph = null;
                    EnvironmentDeployment             = new EnvironmentDeployment(new List <ProductDeployment>());
                    EnvironmentDeploymentSaveFileName = string.Empty;
                    EnvironmentToDeployTo             = null;
                }
            }).ContinueWith(task =>
            {
                IsLoadingData = false;
            });
        }
Пример #28
0
        public static void Main(string[] args)
        {
            var geocoder = new Geocoder(apiKey: null);

            var components = new ComponentFilter[] { ComponentFilter.Country("US") };

            var request = new GeocodingRequest()
            {
                Address    = "london",
                Components = components,
                //Location = new Location (37.785, -122.4),
            };
            var result = geocoder.GetAddressesAsync(request).Result;

            foreach (var r in result)
            {
                Console.WriteLine(r.FormattedAddress);
            }
        }
Пример #29
0
        private static List <string> GetComponentDependancies(ComponentFilter componentFilter, VariableSetResource projectVariables,
                                                              string releaseId)
        {
            var componentDependanciesVariables = projectVariables.Variables
                                                 .Where(x => x.Name == ComponentDependanciesVariableName && !string.IsNullOrEmpty(x.Value)).ToList();

            try
            {
                return(componentDependanciesVariables
                       .SelectMany(x => JsonConvert.DeserializeObject <string[]>(x.Value))
                       .Where(x => componentFilter == null || componentFilter.Match(x))
                       .ToList());
            }
            catch
            {
                var releaseUri = string.Format("/app#/releases/{0}", releaseId);

                throw new Exception(string.Format("The variable {0} is not a valid json string array. Please update at {1}\r\nCurrent value:\r\n{2}",
                                                  componentDependanciesVariables, releaseUri, componentDependanciesVariables.First().Value));
            }
        }
        public void SaveComponentFilterJson()
        {
            var saveFileDialog = new SaveFileDialog
            {
                DefaultExt = "json",
                Filter     = "Text files (*.json)|*.json|All files (*.*)|*.*",
                FileName   = ComponentFilterSaveFileName
            };

            if (saveFileDialog.ShowDialog() != true)
            {
                return;
            }

            var componentFilter = new ComponentFilter()
            {
                Include     = ComponentFilterInclude,
                Expressions = ComponentFilterExpressions.Select(x => x.Text).ToList()
            };

            var json = JsonConvert.SerializeObject(componentFilter, Formatting.Indented);

            File.WriteAllText(saveFileDialog.FileName, json);
        }