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); }
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)); } } }