Пример #1
0
        public static void AssignSecondaryProperties(TECScope scope, TECCatalogs catalogs)
        {
            if (scope.Tags.Count == 0)
            {
                scope.Tags.Add(catalogs.Tags[0]);
            }
            bool tecAdded  = false;
            bool elecAdded = false;

            foreach (TECAssociatedCost cost in catalogs.AssociatedCosts)
            {
                if (cost.Type == CostType.TEC)
                {
                    if (!tecAdded)
                    {
                        scope.AssociatedCosts.Add(cost);
                        tecAdded = true;
                    }
                }
                else if (cost.Type == CostType.Electrical)
                {
                    if (!elecAdded)
                    {
                        scope.AssociatedCosts.Add(cost);
                        elecAdded = true;
                    }
                }
                if (tecAdded && elecAdded)
                {
                    break;
                }
            }
        }
        private void testForCosts(TECScope scope)
        {
            bool foundICost          = false;
            bool foundElectricalCost = false;

            foreach (ICost cost in scope.AssociatedCosts)
            {
                if (cost.Guid == TEST_TEC_COST_GUID)
                {
                    foundICost = true;
                    break;
                }
            }
            foreach (ICost cost in scope.AssociatedCosts)
            {
                if (cost.Guid == TEST_ELECTRICAL_COST_GUID)
                {
                    foundElectricalCost = true;
                    break;
                }
            }

            Assert.IsTrue(foundICost, "TEC Cost not loaded properly into scope.");
            Assert.IsTrue(foundElectricalCost, "Electrical Cost not loaded properly into scope.");
        }
 private void testForScopeChildren(TECScope scope)
 {
     testForTag(scope);
     testForCosts(scope);
     if (scope is TECLocated located)
     {
         testForLocation(located);
     }
 }
Пример #4
0
 public static void CopyPropertiesFromScope(this TECScope scope, TECScope otherScope)
 {
     if (scope == otherScope)
     {
         return;
     }
     scope.Name        = otherScope.Name;
     scope.Description = otherScope.Description;
     CopyChildrenFromScope(scope, otherScope);
 }
        private void testForTag(TECScope scope)
        {
            bool foundTag = false;

            foreach (TECTag tag in scope.Tags)
            {
                if (tag.Guid == TEST_TAG_GUID)
                {
                    foundTag = true;
                    break;
                }
            }

            Assert.IsTrue(foundTag, "Tag not loaded properly into scope.");
        }
        public static void AssignRandomScopeProperties(this TECScope scope, TECCatalogs catalogs, Random rand)
        {
            scope.AssignRandomTaggedProperties(catalogs, rand);
            TECAssociatedCost randTECCost  = catalogs.RandomCost(rand, CostType.TEC);
            TECAssociatedCost randElecCost = catalogs.RandomCost(rand, CostType.Electrical);

            if (randTECCost != null)
            {
                scope.AssociatedCosts.Add(randTECCost);
            }
            if (randElecCost != null)
            {
                scope.AssociatedCosts.Add(randElecCost);
            }
        }
Пример #7
0
 public static void CopyChildrenFromScope(this TECScope scope, TECScope otherScope)
 {
     if (scope == otherScope)
     {
         return;
     }
     scope.Tags.ObservablyClear();
     foreach (TECTag tag in otherScope.Tags)
     {
         scope.Tags.Add(tag);
     }
     scope.AssociatedCosts.ObservablyClear();
     foreach (TECAssociatedCost cost in otherScope.AssociatedCosts)
     {
         scope.AssociatedCosts.Add(cost);
     }
 }
Пример #8
0
 private void checkScopeChildrenCatalogLinks(TECScope scope, TECCatalogs catalogs)
 {
     foreach (TECAssociatedCost cost in scope.AssociatedCosts)
     {
         if (!catalogs.AssociatedCosts.Contains(cost))
         {
             Assert.Fail("Associated cost in scope not linked.");
         }
     }
     foreach (TECTag tag in scope.Tags)
     {
         if (!catalogs.Tags.Contains(tag))
         {
             Assert.Fail("Tag in scope not linked.");
         }
     }
 }
Пример #9
0
        static private void linkTagsInScope(IEnumerable <TECTag> tags, TECScope scope)
        {
            ObservableCollection <TECTag> linkedTags = new ObservableCollection <TECTag>();

            foreach (TECTag tag in scope.Tags)
            {
                bool found = false;
                foreach (TECTag referenceTag in tags)
                {
                    if (tag.Guid == referenceTag.Guid)
                    {
                        linkedTags.Add(referenceTag);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    throw new Exception("Tag not found.");
                }
            }
            scope.Tags.ObservablyClear();
            scope.Tags.AddRange(linkedTags);
        }
Пример #10
0
        private static (int nextRow, int nextColumn) addScopeRow(IXLWorksheet worksheet, TECScope scope, int startRow, int startColumn)
        {
            int x = startRow;
            int y = startColumn;

            worksheet.Cell(x, y).Value = scope.Name;
            y++;
            worksheet.Cell(x, y).Value = scope.Description;
            return(x + 1, y + 1);
        }
Пример #11
0
        private void removeFromCollection(ObservableCollection <ScopeSummaryItem> list, TECScope scope)
        {
            ScopeSummaryItem toRemove = null;

            foreach (var item in list)
            {
                if (item.Scope == scope)
                {
                    toRemove = item;
                    break;
                }
            }
            if (toRemove != null)
            {
                list.Remove(toRemove);
            }
        }
 public ScopeSummaryItem(TECScope scope, TECParameters parameters, double duration = 0.0)
 {
     this.Scope = scope;
     watcher    = new ChangeWatcher(scope);
     Estimate   = new TECEstimator(scope, parameters, new TECExtraLabor(Guid.NewGuid()), duration, watcher);
 }
Пример #13
0
        static private void linkAssociatedCostsInScope(IEnumerable <TECAssociatedCost> costs, TECScope scope)
        {
            ObservableCollection <TECAssociatedCost> costsToAssign = new ObservableCollection <TECAssociatedCost>();

            foreach (TECAssociatedCost scopeCost in scope.AssociatedCosts)
            {
                bool found = false;
                foreach (TECAssociatedCost catalogCost in costs)
                {
                    if (scopeCost.Guid == catalogCost.Guid)
                    {
                        costsToAssign.Add(catalogCost);
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    throw new Exception("Associated cost not found.");
                }
            }
            scope.AssociatedCosts.ObservablyClear();
            scope.AssociatedCosts.AddRange(costsToAssign);
        }
Пример #14
0
 private static void linkScopeChildrenToCatalogs(TECScope scope, TECCatalogs catalogs)
 {
     linkAssociatedCostsInScope(catalogs.AssociatedCosts, scope);
     linkTagsInScope(catalogs.Tags, scope);
 }
Пример #15
0
 public static void LinkScopeItem(TECScope scope, TECScopeManager manager)
 {
     linkScopeChildrenToCatalogs(scope, manager.Catalogs);
 }