internal static void AddControllersSheet(XLWorkbook workbook, TECBid bid, string sheetName = "Controllers")
        {
            IXLWorksheet worksheet = workbook.Worksheets.Add(sheetName);


            throw new NotImplementedException();
        }
        internal static void AddPanelsSheet(XLWorkbook workbook, TECBid bid, string sheetName = "Panels")
        {
            List <TECPanel>            panels     = getAllPanels(bid);
            List <HardwareSummaryItem> panelItems = consolidateHardware(panels.Select(panel => panel.Type));
            List <CostSummaryItem>     costItems  = consolidateCostInPanels(panels);

            IXLWorksheet worksheet = workbook.Worksheets.Add(sheetName);
            int          row       = 1;

            row = worksheet.insertTitleRow(sheetName, row);
            row++;

            row = worksheet.insertHardwareHeaders(row);
            foreach (HardwareSummaryItem item in panelItems)
            {
                row = worksheet.insertHardwareItem(item, row);
            }
            row++;

            row = worksheet.insertTitleRow("AssociatedCosts", row);
            row++;

            row = worksheet.insertCostHeaders(row);
            foreach (CostSummaryItem item in costItems)
            {
                row = worksheet.insertCostItem(item, row);
            }
            row++;

            worksheet.formatFinal();
        }
Пример #3
0
        public static TECBid CreateEmptyCatalogBid()
        {
            TECBid bid = new TECBid();

            bid.Catalogs = CreateTestCatalogs();
            return(bid);
        }
Пример #4
0
        public void SaveAs_Bid_Estimate()
        {
            TECBid       saveBid           = ModelCreation.TestBid(rand);
            var          watcher           = new ChangeWatcher(saveBid);
            TECEstimator estimate          = new TECEstimator(saveBid, watcher);
            var          expectedTotalCost = estimate.TotalCost;
            double       delta             = 0.0001;

            Dictionary <Guid, INotifyCostChanged> saveCostDictionary = new Dictionary <Guid, INotifyCostChanged>();

            addToCost(saveCostDictionary, saveBid, saveBid);

            //Act
            path = Path.GetTempFileName();
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(saveBid);
            TECBid       loadedBid      = manager.Load() as TECBid;
            var          loadedWatcher  = new ChangeWatcher(loadedBid);
            TECEstimator loadedEstimate = new TECEstimator(loadedBid, loadedWatcher);

            Dictionary <Guid, INotifyCostChanged> loadCostDictionary = new Dictionary <Guid, INotifyCostChanged>();

            addToCost(loadCostDictionary, loadedBid, loadedBid);

            compareCosts(saveCostDictionary, loadCostDictionary);
            compareEstimators(estimate, loadedEstimate);
            Assert.AreEqual(expectedTotalCost, loadedEstimate.TotalCost, delta);
        }
        private static List <TECValve> getAllValves(TECBid bid)
        {
            List <TECValve> valves = new List <TECValve>();

            foreach (TECTypical typ in bid.Systems)
            {
                foreach (TECSystem instance in typ.Instances)
                {
                    foreach (TECEquipment equip in instance.Equipment)
                    {
                        foreach (TECSubScope ss in equip.SubScope)
                        {
                            foreach (IEndDevice endDev in ss.Devices)
                            {
                                if (endDev is TECValve valve)
                                {
                                    valves.Add(valve);
                                }
                            }
                        }
                    }
                }
            }
            return(valves);
        }
Пример #6
0
        public void SaveAs_Bid_UserAdjustments()
        {
            //Arrange
            TECBid bid = new TECBid();

            bid.ExtraLabor.PMExtraHours    = 0.5;
            bid.ExtraLabor.ENGExtraHours   = 0.5;
            bid.ExtraLabor.CommExtraHours  = 0.5;
            bid.ExtraLabor.SoftExtraHours  = 0.5;
            bid.ExtraLabor.GraphExtraHours = 0.5;

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            //Assert
            Assert.AreEqual(bid.ExtraLabor.PMExtraHours, loadedBid.ExtraLabor.PMExtraHours);
            Assert.AreEqual(bid.ExtraLabor.ENGExtraHours, loadedBid.ExtraLabor.ENGExtraHours);
            Assert.AreEqual(bid.ExtraLabor.CommExtraHours, loadedBid.ExtraLabor.CommExtraHours);
            Assert.AreEqual(bid.ExtraLabor.SoftExtraHours, loadedBid.ExtraLabor.SoftExtraHours);
            Assert.AreEqual(bid.ExtraLabor.GraphExtraHours, loadedBid.ExtraLabor.GraphExtraHours);
        }
Пример #7
0
 public static void AssignAllSecondaryProperties(TECBid bid)
 {
     foreach (TECTypical system in bid.Systems)
     {
         AssignSecondaryProperties(system, bid);
         foreach (TECEquipment equipment in system.Equipment)
         {
             AssignSecondaryProperties(equipment, bid);
             foreach (TECSubScope subScope in equipment.SubScope)
             {
                 AssignSecondaryProperties(subScope, bid);
             }
         }
         foreach (TECSystem instance in system.Instances)
         {
             AssignSecondaryProperties(instance, bid);
             foreach (TECEquipment equipment in instance.Equipment)
             {
                 AssignSecondaryProperties(equipment, bid);
                 foreach (TECSubScope subScope in equipment.SubScope)
                 {
                     AssignSecondaryProperties(subScope, bid);
                 }
             }
         }
     }
 }
Пример #8
0
        public void SaveAs_Bid_Note()
        {
            //Arrange
            TECBid     bid          = new TECBid();
            TECLabeled expectedNote = new TECLabeled();

            expectedNote.Label = "test";
            bid.Notes.Add(expectedNote);

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            TECLabeled actualNote = null;

            foreach (TECLabeled note in loadedBid.Notes.Where(item => item.Guid == expectedNote.Guid))
            {
                actualNote = note;
            }

            //Assert
            Assert.AreEqual(expectedNote.Label, actualNote.Label);
        }
Пример #9
0
        private static void createProjectInfoSection(IXLWorksheet worksheet, TECBid bid, int startRow)
        {
            int x = startRow;

            worksheet.Cell(x, 1).Value = "Project Information";
            worksheet.Cell(x, 1).Style.Font.SetBold();
            worksheet.Cell(x, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
            x++;

            worksheet.Cell(x, 1).Value = "Name";
            worksheet.Cell(x, 2).Value = bid.Name;
            x++;
            worksheet.Cell(x, 1).Value = "Bid Number";
            worksheet.Cell(x, 2).Value = bid.BidNumber;
            x++;
            worksheet.Cell(x, 1).Value = "Salesperson";
            worksheet.Cell(x, 2).Value = bid.Salesperson;
            x++;
            worksheet.Cell(x, 1).Value = "Estimator";
            worksheet.Cell(x, 2).Value = bid.Estimator;
            x++;

            x = startRow + 1;
            worksheet.Cell(x, 4).Value = "Tax Exempt";
            worksheet.Cell(x, 5).Value = bid.Parameters.IsTaxExempt ? "Yes" : "No";
            x++;
            worksheet.Cell(x, 4).Value = "Bond Required";
            worksheet.Cell(x, 5).Value = bid.Parameters.RequiresBond ? "Yes" : "No";
        }
Пример #10
0
        public void AddRemoveSystemInstanceWithBidConnection()
        {
            var bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand);
            var bidController = new TECProvidedController(bid.Catalogs.ControllerTypes.RandomElement(rand));

            bid.AddController(bidController);

            var system    = new TECTypical();
            var equipment = new TECEquipment();
            var subScope  = new TECSubScope();

            TECDevice dev = bid.Catalogs.Devices.First(x => x.HardwiredConnectionTypes.Count > 0);

            subScope.Devices.Add(dev);

            TECHardwiredProtocol hardProt = subScope.AvailableProtocols.First(x => x is TECHardwiredProtocol) as TECHardwiredProtocol;

            system.Equipment.Add(equipment);
            equipment.SubScope.Add(subScope);
            var instance         = system.AddInstance();
            var instanceSubScope = instance.GetAllSubScope().First();

            bidController.Connect(instanceSubScope, hardProt);

            Assert.AreEqual(1, bidController.ChildrenConnections.Count, "Connection not added");

            system.Instances.Remove(instance);

            Assert.AreEqual(0, bidController.ChildrenConnections.Count, "Connection not removed");
        }
Пример #11
0
 private void checkScopeLocationLinks(TECLocated scope, TECBid bid)
 {
     if (scope.Location != null && !bid.Locations.Contains(scope.Location))
     {
         Assert.Fail("Location in scope not linked.");
     }
 }
Пример #12
0
        public void EditInstances()
        {
            TECBid bid = new TECBid();
            int    qty = 3;

            bid.Catalogs = ModelCreation.TestCatalogs(rand);
            TECTypical system = ModelCreation.TestTypical(bid.Catalogs, rand);

            bid.Systems.Add(system);
            for (int x = 0; x < qty; x++)
            {
                system.AddInstance();
            }

            system.Equipment.Add(ModelCreation.TestEquipment(bid.Catalogs, rand));
            system.AddController(ModelCreation.TestProvidedController(bid.Catalogs, rand));
            system.Panels.Add(ModelCreation.TestPanel(bid.Catalogs, rand));

            foreach (TECSystem instance in system.Instances)
            {
                Assert.AreEqual(system.Equipment.Count, instance.Equipment.Count);
                Assert.AreEqual(system.Controllers.Count, instance.Controllers.Count);
                Assert.AreEqual(system.Panels.Count, instance.Panels.Count);
            }
        }
Пример #13
0
        public void RemoveInstanceWithGlobalConnectionToController()
        {
            TECBid bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand);

            TECControllerType type = bid.Catalogs.ControllerTypes.RandomElement(rand);

            TECController controller = new TECProvidedController(type);

            bid.AddController(controller);

            TECTypical    typical           = new TECTypical();
            TECController typicalController = new TECProvidedController(type);

            typical.AddController(typicalController);

            bid.Systems.Add(typical);
            TECSystem     system             = typical.AddInstance();
            TECController instanceController = typical.GetInstancesFromTypical(typicalController).First();

            Assert.IsTrue(controller.CanConnect(instanceController));

            IControllerConnection connection = controller.Connect(instanceController, instanceController.AvailableProtocols.First());

            Assert.IsTrue(connection is TECNetworkConnection);

            typical.Instances.Remove(system);

            Assert.IsTrue((connection as TECNetworkConnection).Children.Count == 0);
        }
Пример #14
0
        public void SaveAs_Bid_SystemInstances()
        {
            TECBid saveBid = new TECBid();

            saveBid.Catalogs = ModelCreation.TestCatalogs(rand, 5);
            TECTypical system = ModelCreation.TestTypical(saveBid.Catalogs, rand);

            saveBid.Systems.Add(system);

            //Act
            path = Path.GetTempFileName();
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(saveBid);
            TECBid     loadedBid    = manager.Load() as TECBid;
            TECTypical loadedSystem = loadedBid.Systems[0];

            Assert.AreEqual(system.Instances.Count, loadedSystem.Instances.Count);
            foreach (TECSystem loadedInstance in loadedSystem.Instances)
            {
                foreach (TECSystem saveInstance in system.Instances)
                {
                    if (loadedInstance.Guid == saveInstance.Guid)
                    {
                        Assert.AreEqual(loadedInstance.Equipment.Count, saveInstance.Equipment.Count);
                        Assert.AreEqual(loadedInstance.Panels.Count, saveInstance.Panels.Count);
                        Assert.AreEqual(loadedInstance.Controllers.Count, saveInstance.Controllers.Count);
                        Assert.IsTrue(compareCosts(loadedInstance.CostBatch, saveInstance.CostBatch));
                    }
                }
            }
        }
Пример #15
0
 public SystemSummaryVM(TECBid bid, ChangeWatcher watcher)
 {
     this.bid = bid;
     setupExtraLaborEstimate(bid);
     populateAll(bid);
     watcher.Changed += changed;
 }
Пример #16
0
        public void SaveAs_Bid_SubScope()
        {
            //Arrange
            TECBid bid = new TECBid();

            bid.Catalogs = ModelCreation.TestCatalogs(rand, 5);
            TECTypical   system            = new TECTypical();
            TECEquipment expectedEquipment = new TECEquipment();
            TECSubScope  expectedSubScope  = ModelCreation.TestSubScope(bid.Catalogs, rand);

            expectedEquipment.SubScope.Add(expectedSubScope);
            system.Equipment.Add(expectedEquipment);

            bid.Systems.Add(system);

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            TECSubScope actualSubScope = loadedBid.FindChild(expectedSubScope.Guid) as TECSubScope;

            //Assert
            Assert.AreEqual(expectedSubScope.Name, actualSubScope.Name);
            Assert.AreEqual(expectedSubScope.Description, actualSubScope.Description);
            Assert.AreEqual(expectedSubScope.Interlocks.Count, actualSubScope.Interlocks.Count);
            Assert.AreEqual(expectedSubScope.ScopeBranches.Count, actualSubScope.ScopeBranches.Count);
            Assert.IsTrue(compareCosts(expectedSubScope.CostBatch, actualSubScope.CostBatch));
        }
Пример #17
0
        public void Refresh(TECScopeManager scopeManager)
        {
            var bid       = scopeManager as TECBid;
            var templates = scopeManager as TECTemplates;

            if (bid != null)
            {
                QuantityVisibility = Visibility.Visible;
                if (_bid != null)
                {
                    _bid.MiscCosts.CollectionChanged -= MiscCosts_CollectionChanged;
                }

                bid.MiscCosts.CollectionChanged += MiscCosts_CollectionChanged;
                _bid             = bid;
                sourceCollection = bid.MiscCosts;
                populateCollections();
            }
            else if (templates != null)
            {
                QuantityVisibility = Visibility.Collapsed;
                if (templates != null)
                {
                    templates.Templates.MiscCostTemplates.CollectionChanged -= MiscCosts_CollectionChanged;
                }

                templates.Templates.MiscCostTemplates.CollectionChanged += MiscCosts_CollectionChanged;
                _templates       = templates;
                sourceCollection = templates.Templates.MiscCostTemplates;
                populateCollections();
            }
        }
        internal static void AddDevicesSheet(XLWorkbook workbook, TECBid bid, string sheetName = "Devices")
        {
            List <TECDevice>           devices     = getAllDevices(bid);
            List <HardwareSummaryItem> deviceItems = consolidateHardware(devices);
            List <CostSummaryItem>     costItems   = consolidateCostInDevices(devices);

            IXLWorksheet worksheet = workbook.Worksheets.Add(sheetName);
            int          row       = 1;

            row = worksheet.insertTitleRow(sheetName, row);
            row++;

            row = worksheet.insertHardwareHeaders(row);
            foreach (HardwareSummaryItem item in deviceItems)
            {
                row = worksheet.insertHardwareItem(item, row);
            }
            row++;

            row = worksheet.insertTitleRow("AssociatedCosts", row);
            row++;

            row = worksheet.insertCostHeaders(row);
            foreach (CostSummaryItem item in costItems)
            {
                row = worksheet.insertCostItem(item, row);
            }
            row++;

            worksheet.formatFinal();
        }
Пример #19
0
 public EBDebugWindow(TECBid bid)
 {
     InitializeComponent();
     this.bid = bid;
     setupCommands();
     addResources();
 }
Пример #20
0
        public void SaveAs_Bid_Info()
        {
            //Arrange
            TECBid bid = new TECBid();

            bid.Name        = "Test name";
            bid.BidNumber   = "1234";
            bid.DueDate     = new DateTime();
            bid.Salesperson = "Ms. Salesperson";
            bid.Estimator   = "Mr. Estimator";
            path            = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            //Assert
            Assert.AreEqual(bid.Name, loadedBid.Name);
            Assert.AreEqual(bid.BidNumber, loadedBid.BidNumber);
            Assert.AreEqual(bid.DueDate, loadedBid.DueDate);
            Assert.AreEqual(bid.Salesperson, loadedBid.Salesperson);
            Assert.AreEqual(bid.Estimator, loadedBid.Estimator);
        }
Пример #21
0
        public void SaveAs_Bid_LaborConstants()
        {
            //Arrange
            TECBid bid = new TECBid();

            bid.Parameters.PMCoef      = 0.5;
            bid.Parameters.PMRate      = 0.5;
            bid.Parameters.ENGCoef     = 0.5;
            bid.Parameters.ENGRate     = 0.5;
            bid.Parameters.CommCoef    = 0.5;
            bid.Parameters.CommRate    = 0.5;
            bid.Parameters.SoftCoef    = 0.5;
            bid.Parameters.SoftRate    = 0.5;
            bid.Parameters.GraphCoef   = 0.5;
            bid.Parameters.GraphRate   = 0.5;
            bid.Parameters.IsTaxExempt = true;

            bid.Parameters.ElectricalRate              = 0.5;
            bid.Parameters.ElectricalNonUnionRate      = 0.5;
            bid.Parameters.ElectricalSuperRate         = 0.5;
            bid.Parameters.ElectricalSuperNonUnionRate = 0.5;
            bid.Parameters.ElectricalIsOnOvertime      = true;
            bid.Parameters.ElectricalIsUnion           = false;

            path = Path.GetTempFileName();

            //Act
            DatabaseManager <TECBid> manager = new DatabaseManager <TECBid>(path);

            manager.New(bid);
            TECBid loadedBid = manager.Load() as TECBid;

            //Assert
            Assert.AreEqual(bid.Parameters.IsTaxExempt, loadedBid.Parameters.IsTaxExempt);

            Assert.AreEqual(bid.Parameters.PMCoef, loadedBid.Parameters.PMCoef);
            Assert.AreEqual(bid.Parameters.PMRate, loadedBid.Parameters.PMRate);

            Assert.AreEqual(bid.Parameters.ENGCoef, loadedBid.Parameters.ENGCoef);
            Assert.AreEqual(bid.Parameters.ENGRate, loadedBid.Parameters.ENGRate);

            Assert.AreEqual(bid.Parameters.CommCoef, loadedBid.Parameters.CommCoef);
            Assert.AreEqual(bid.Parameters.CommRate, loadedBid.Parameters.CommRate);

            Assert.AreEqual(bid.Parameters.SoftCoef, loadedBid.Parameters.SoftCoef);
            Assert.AreEqual(bid.Parameters.SoftRate, loadedBid.Parameters.SoftRate);

            Assert.AreEqual(bid.Parameters.GraphCoef, loadedBid.Parameters.GraphCoef);
            Assert.AreEqual(bid.Parameters.GraphRate, loadedBid.Parameters.GraphRate);

            //Assert
            Assert.AreEqual(bid.Parameters.ElectricalRate, loadedBid.Parameters.ElectricalRate);
            Assert.AreEqual(bid.Parameters.ElectricalNonUnionRate, loadedBid.Parameters.ElectricalNonUnionRate);
            Assert.AreEqual(bid.Parameters.ElectricalSuperRate, loadedBid.Parameters.ElectricalSuperRate);
            Assert.AreEqual(bid.Parameters.ElectricalSuperNonUnionRate, loadedBid.Parameters.ElectricalSuperNonUnionRate);

            Assert.AreEqual(bid.Parameters.ElectricalIsOnOvertime, loadedBid.Parameters.ElectricalIsOnOvertime);
            Assert.AreEqual(bid.Parameters.ElectricalIsUnion, loadedBid.Parameters.ElectricalIsUnion);
        }
Пример #22
0
 public ScheduleVM(TECBid bid, ChangeWatcher watcher)
 {
     this.Schedule        = bid.Schedule;
     this.AddTableCommand = new RelayCommand(addTableExecute, canAddTable);
     watcher.Changed     += changed;
     this.ScopeCollection = populateScopeCollection(bid);
     this.Locations       = bid.Locations;
 }
Пример #23
0
 public ProposalVM(TECBid bid)
 {
     Bid = bid;
     AddScopeBranchCommand = new RelayCommand <TECScopeBranch>(addScopBranchExecute);
     AddNoteCommand        = new RelayCommand(addNoteExecute);
     AddExclusionCommand   = new RelayCommand(addExclusionExecute);
     AddSystemNoteCommand  = new RelayCommand <TECSystem>(addSystemNoteExecute);
 }
Пример #24
0
 public AddInstanceVM(TECTypical typical, TECBid bid) : base(bid)
 {
     toAdd             = new TECSystem(typical);
     parent            = typical;
     this.bid          = bid;
     Locations         = this.bid.Locations;
     AddCommand        = new RelayCommand(addExecute, canAdd);
     AddPatternCommand = new RelayCommand(addPatternExecute, canAddPattern);
 }
Пример #25
0
 public static void LinkScopeItem(TECSubScope scope, TECBid bid)
 {
     linkScopeChildrenToCatalogs(scope, bid.Catalogs);
     linkLocation(scope, bid.Locations);
     foreach (TECDevice dev in scope.Devices)
     {
         LinkScopeItem(dev, bid);
     }
 }
Пример #26
0
        public LaborVM(TECBid bid, TECEstimator estimate)
        {
            Bid               = bid;
            Estimate          = estimate;
            DesiredConfidence = bid.Parameters.DesiredConfidence;

            SetParametersCommand        = new RelayCommand <TECParameters>(SetParametersExecute);
            SetDesiredConfidenceCommand = new RelayCommand(SetConfidenceExecute, CanSetConfidence);
        }
Пример #27
0
        public void TestInitialize()
        {
            rand = new Random(0);
            TECCatalogs catalogs = ModelCreation.TestCatalogs(rand);

            bid          = new TECBid();
            bid.Catalogs = catalogs;
            cw           = new ChangeWatcher(bid);
        }
Пример #28
0
 public static void LinkScopeItem(TECEquipment scope, TECBid bid)
 {
     linkScopeChildrenToCatalogs(scope, bid.Catalogs);
     linkLocation(scope, bid.Locations);
     foreach (TECSubScope ss in scope.SubScope)
     {
         LinkScopeItem(ss, bid);
     }
 }
Пример #29
0
 private void setupAddRemoveMethods(TECBid bid)
 {
     addControllerMethod    = bid.AddController;
     addPanelMethod         = bid.Panels.Add;
     deleteControllerMethod = controller => {
         bid.RemoveController(controller);
     };
     deletePanelMethod = panel => { bid.Panels.Remove(panel); };
 }
Пример #30
0
        public void DragDropCopyTest()
        {
            TECBid    bid = new TECBid();
            TECDevice dev = new TECDevice(new List <TECConnectionType>(), new List <TECProtocol>(), new TECManufacturer());

            bid.Catalogs.Add(dev);
            var copy = dev.DropData();

            Assert.AreEqual(dev, copy);
        }