private bool SetAssociatedProducts()
        {
            Ticket.AssociatedProductList.Clear();

            try
            {
                foreach (ScenarioProduct assocProduct in _scenarioProducts)
                {
                    var item = new AssociatedProductSerializable()
                    {
                        AssociatedProductId = assocProduct.ProductId,
                        Vendor  = assocProduct.Vendor,
                        Name    = assocProduct.Name,
                        Version = assocProduct.Version,
                        Active  = assocProduct.Active
                    };
                    Ticket.AssociatedProductList.Add(item);
                }

                //Clear any previous error
                _errorProvider.SetError(associatedProducts_TabPage, string.Empty);
                return(true);
            }
            catch (Exception ex)
            {
                UpdateDebug(ex.ToString());
                TraceFactory.Logger.Error("Error loading Associated Products.", ex);
                _errorProvider.SetError(settings_TabControl, ex.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        private void SetAssociatedProducts(EnterpriseTestContext context, IEnumerable <EnterpriseScenario> scenarios)
        {
            // We have to track what has already been added to the Ticket.  List of Guids seems the most efficient way,
            // given the fact that the list is potentially growing with each loop.  Array.Contains is faster than List.Contains,
            // but List<> is better suited to the changing collection size.
            List <Guid> added = new List <Guid>();

            Ticket.AssociatedProductList.Clear();

            try
            {
                IEnumerable <ScenarioProduct> scenarioProducts = null;
                foreach (EnterpriseScenario scenario in scenarios)
                {
                    scenarioProducts = WizardPageManager.GetAssociatedProducts(context, scenario);
                    foreach (ScenarioProduct assocProduct in scenarioProducts)
                    {
                        if (!added.Contains(assocProduct.ProductId))
                        {
                            var item = new AssociatedProductSerializable()
                            {
                                AssociatedProductId = assocProduct.ProductId,
                                Vendor  = assocProduct.Vendor,
                                Name    = assocProduct.Name,
                                Version = assocProduct.Version,
                                Active  = assocProduct.Active
                            };
                            Ticket.AssociatedProductList.Add(item);
                            added.Add(assocProduct.ProductId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Error loading Associated Products.", ex);
            }
        }