Example #1
0
 private CostBatch addConnection(IControllerConnection connection)
 {
     if (!connection.IsTypical)
     {
         CostBatch deltas = new CostBatch();
         foreach (TECConnectionType connectionType in connection.Protocol.ConnectionTypes)
         {
             deltas += (WireSummaryVM.AddRun(connectionType, connection.Length, connection.IsPlenum));
         }
         if (connection.ConduitType != null)
         {
             deltas += (ConduitSummaryVM.AddRun(connection.ConduitType, connection.ConduitLength));
         }
         return(deltas);
     }
     else
     {
         return(new CostBatch());
     }
 }
Example #2
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));
                    }
                }
            }