예제 #1
0
        private CostBatch addSubScope(TECSubScope ss)
        {
            CostBatch deltas = new CostBatch();

            foreach (IEndDevice endDev in ss.Devices)
            {
                if (endDev is TECDevice dev)
                {
                    deltas += (DeviceSummaryVM.AddHardware(dev));
                }
                else if (endDev is TECValve valve)
                {
                    deltas += (ValveSummaryVM.AddValve(valve));
                }
                else
                {
                    logger.Error("IEndDevice isn't recognized. Not valve or device. " +
                                 "MaterialSummaryVM cannot add IEndDevice. IEndDevice: {0}", endDev.Name);
                }
            }
            foreach (ICost cost in ss.AssociatedCosts)
            {
                deltas += (MiscSummaryVM.AddCost(cost));
            }
            return(deltas);
        }
예제 #2
0
        private CostBatch addSystem(TECSystem system)
        {
            CostBatch deltas = new CostBatch();

            foreach (TECEquipment equip in system.Equipment)
            {
                deltas += (addEquipment(equip));
            }
            foreach (TECController controller in system.Controllers)
            {
                deltas += addController(controller);
            }
            foreach (TECPanel panel in system.Panels)
            {
                deltas += addPanel(panel);
            }
            foreach (TECMisc misc in system.MiscCosts)
            {
                deltas += (MiscSummaryVM.AddCost(misc));
            }
            foreach (ICost cost in system.AssociatedCosts)
            {
                deltas += (MiscSummaryVM.AddCost(cost));
            }
            return(deltas);
        }
예제 #3
0
        private CostBatch addEquipment(TECEquipment equip)
        {
            CostBatch deltas = new CostBatch();

            foreach (TECSubScope ss in equip.SubScope)
            {
                deltas += (addSubScope(ss));
            }
            foreach (ICost cost in equip.AssociatedCosts)
            {
                deltas += (MiscSummaryVM.AddCost(cost));
            }
            return(deltas);
        }
예제 #4
0
 private void loadBid(TECBid bid)
 {
     foreach (TECTypical typical in bid.Systems)
     {
         foreach (TECSystem instance in typical.Instances)
         {
             updateTotals(addSystem(instance));
         }
     }
     foreach (TECController controller in bid.Controllers)
     {
         updateTotals(addController(controller));
     }
     foreach (TECPanel panel in bid.Panels)
     {
         updateTotals(addPanel(panel));
     }
     foreach (TECMisc misc in bid.MiscCosts)
     {
         updateTotals(MiscSummaryVM.AddCost(misc));
     }
 }
예제 #5
0
        private void instanceChanged(TECChangedEventArgs args)
        {
            //Checks for a material change in the bid
            if (args.Sender is IRelatable rel && args.Value != null)
            {
                bool hasLinked = rel.LinkedObjects.Contains(args.PropertyName);
                bool isCatalog = (args.Value.GetType().IsImplementationOf(typeof(ICatalog <>)));
                if (hasLinked && !isCatalog)
                {
                    return;
                }
            }

            if (args.Change == Change.Add)
            {
                if (args.Value is TECSystem system)
                {
                    updateTotals(addSystem(system));
                }
                else if (args.Value is TECEquipment equip)
                {
                    updateTotals(addEquipment(equip));
                }
                else if (args.Value is TECSubScope ss)
                {
                    updateTotals(addSubScope(ss));
                }
                else if (args.Value is TECController controller)
                {
                    updateTotals(addController(controller));
                }
                else if (args.Value is TECIOModule module)
                {
                    updateTotals(addIOModule(module));
                }
                else if (args.Value is TECPanel panel)
                {
                    updateTotals(addPanel(panel));
                }
                else if (args.Value is IControllerConnection connection)
                {
                    updateTotals(addConnection(connection));
                }
                else if (args.Value is IEndDevice endDev && args.Sender is TECSubScope sub)
                {
                    if (endDev is TECDevice dev)
                    {
                        updateTotals(DeviceSummaryVM.AddHardware(dev));
                    }
                    else if (endDev is TECValve valve)
                    {
                        updateTotals(ValveSummaryVM.AddValve(valve));
                    }
                    else
                    {
                        logger.Error("IEndDevice isn't recognized. Not valve or device. " +
                                     "MaterialSummaryVM cannot add IEndDevice. IEndDevice: {0}", endDev.Name);
                    }

                    if (sub.Connection != null)
                    {
                        foreach (TECConnectionType connectionType in sub.Connection.Protocol.ConnectionTypes)
                        {
                            updateTotals(WireSummaryVM.AddRun(connectionType, sub.Connection.Length, sub.Connection.IsPlenum));
                        }
                    }
                }
                else if (args.Value is TECMisc misc)
                {
                    updateTotals(MiscSummaryVM.AddCost(misc));
                }
                else if (args.Value is ICost cost)
                {
                    if (args.Sender is TECHardware hardware)
                    {
                        logger.Error("TECHardware raised as value in instance changed args. Item: {0}, Parent:{1}",
                                     hardware.Name,
                                     args.Sender.Guid.ToString());
                    }
                    else if (args.Sender is TECElectricalMaterial elecMat)
                    {
                        logger.Error("TECElectricalMaterial raise as value in instance changed args. Item: {0}, Parent:{1}",
                                     elecMat.Name,
                                     args.Sender.Guid.ToString());
                    }
                    else
                    {
                        updateTotals(MiscSummaryVM.AddCost(cost));
                    }
                }
            }