Example #1
0
        }//ProcessMarketCatalogUpdate()

        //
        // *****************************************************************
        // ****             ProcessProductCatalogUpdate()               ****
        // *****************************************************************
        /// <summary>
        /// TT sent us a ProductCatalogUpdate event. Update our list of internal products.
        /// Called by hub thread.
        /// </summary>
        /// <param name="eventArg"></param>
        private void ProcessProductCatalogUpdate(ProductCatalogUpdatedEventArgs eventArg)
        {
            List <Misty.Lib.Products.Product> productList = new List <MistyProds.Product>();

            foreach (Product ttProduct in eventArg.Added)                    // loop thru each ttProduct found in event.
            {
                Misty.Lib.Products.Product ourProduct;
                if (TTConvert.TryConvert(ttProduct, out ourProduct)) // Create one of our product objects for each.
                {                                                    // Success!
                    productList.Add(ourProduct);
                    Log.NewEntry(LogLevel.Minor, "ProcessProductCatalogUpdate: Found product {0} -> {1}. ", ttProduct.Name, ourProduct);
                    if (!m_Products.ContainsKey(ttProduct.Key))
                    {
                        m_Products.Add(ttProduct.Key, ttProduct);           // store the actual TT product.
                        lock (m_ProductMapLock)
                        {
                            m_ProductMap.Add(ourProduct, ttProduct.Key);    // my product -->  productKey map
                            m_ProductMapKey.Add(ttProduct.Key, ourProduct); // product key --> my product map
                        }
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Warning, "ProcessProductCatalogUpdate: Received duplicate product! Received {0} <--> {1}", ttProduct.Name, ourProduct);
                    }
                }
                else
                {   // Since products include server name, there should never be two duplicates!
                    Log.NewEntry(LogLevel.Minor, "ProcessProductCatalogUpdate: Unknown product type {0}. ", ttProduct.Name);
                }
            }
            // Fire the event to our subscribers.
            OnMarketFoundResource(productList);                      // TODO: Send all products, all for this server, or just the new ones?
        }//ProcessProductCatalogUpdate()
Example #2
0
 //
 private void ProductCatalog_Updated(object sender, ProductCatalogUpdatedEventArgs eventArg)
 {
     if (eventArg.Error == null)
     {
         HubEventEnqueue(eventArg);
     }
     else
     {
         Log.NewEntry(LogLevel.Major, "ProductCatalog error. {0}", eventArg.Error.Message);
     }
 }
Example #3
0
        /// <summary>
        /// ProductCatalogSubscription ProductsUpdated event.
        /// This will update the product list in the product TreeView.
        /// </summary>
        /// <param name="sender">ProductCatalogSubscription</param>
        /// <param name="e">ProductCatalogUpdatedEventArgs</param>
        private void productsUpdated(object sender, ProductCatalogUpdatedEventArgs e)
        {
            var sub = (ProductCatalogSubscription)sender;

            List <ProductType>    selectedTypes = BuildSelectedTypes();
            IEnumerable <Product> products;

            treeViewProductList.Nodes.Clear();

            // If a search filter is set filter the product list by that filter.
            // If no search filter is set list all products for the selected market.
            if (String.IsNullOrEmpty(m_searchFilter))
            {
                // Please refer to MSDN for more information about Lambda expressions used to Query collections. http://msdn.microsoft.com/en-us/library/bb397675
                products = from Product product in sub.Products.Values
                           join type in selectedTypes on product.Type equals type
                           orderby product.Name
                           select product;
            }
            else
            {
                // Please refer to MSDN for more information about Lambda expressions used to Query collections. http://msdn.microsoft.com/en-us/library/bb397675
                products = from Product product in sub.Products.Values
                           join type in selectedTypes on product.Type equals type
                           where product.Name.Contains(m_searchFilter)
                           orderby product.Name
                           select product;
            }

            // Add product nodes to the TreeView.
            // Set the default child node as "loading..." This node will be replaced when the node is expanded and
            // the instrument catalog is downloaded for the given product.
            foreach (Product product in products)
            {
                TreeNode prodNode = treeViewProductList.Nodes.Add(product.Name);
                prodNode.Tag = (object)product;
                prodNode.SelectedImageIndex = prodNode.ImageIndex = GetImageCode(product.Type);

                TreeNode childNode = new TreeNode("Loading ...", GetImageCode(product.Type), GetImageCode(product.Type));
                prodNode.Nodes.Add(childNode);
            }

            // Clean up this ProductCatalog subscription.
            if (m_prodCat != null)
            {
                m_prodCat.ProductsUpdated -= new EventHandler <ProductCatalogUpdatedEventArgs>(productsUpdated);
                m_prodCat.Dispose();
                m_prodCat = null;
            }

            toolStripStatusLabel.Text = "There are " + Convert.ToString(products.Count()) + " products";
            Cursor = Cursors.Default;
        }
Example #4
0
        /// <summary>
        /// ProductCatalogSubscription ProductsUpdated event.
        /// This will update the option list in the option TreeView.
        /// </summary>
        /// <param productName="sender">ProductCatalogSubscription</param>
        /// <param productName="e">ProductCatalogUpdatedEventArgs</param>
        private void ProductsUpdated(object sender, ProductCatalogUpdatedEventArgs e)
        {
            var sub = (ProductCatalogSubscription)sender;
            IEnumerable <Product> products = from Product product in sub.Products.Values
                                             select product;

            foreach (var product in products)
            {
                string productKey = product.Market + "_" + product.Type + "_" + product.Name;

                if (!_availableProductsDico.ContainsKey(productKey))
                {
                    _availableProductsDico.Add(productKey, product);
                }

                UpdateProductSubscription(productKey);
            }
        }
 void pcs_ProductsUpdated(object sender, ProductCatalogUpdatedEventArgs e)
 {
 }
        /// <summary>
        /// ProductCatalogSubscription ProductsUpdated event.
        /// This will update the product list in the product TreeView.
        /// </summary>
        /// <param name="sender">ProductCatalogSubscription</param>
        /// <param name="e">ProductCatalogUpdatedEventArgs</param>
        private void productsUpdated(object sender, ProductCatalogUpdatedEventArgs e)
        {
            var sub = (ProductCatalogSubscription)sender;

            List<ProductType> selectedTypes = BuildSelectedTypes();
            IEnumerable<Product> products;
            treeViewProductList.Nodes.Clear();

            // If a search filter is set filter the product list by that filter.
            // If no search filter is set list all products for the selected market.
            if (String.IsNullOrEmpty(m_searchFilter))
            {
                // Please refer to MSDN for more information about Lambda expressions used to Query collections. http://msdn.microsoft.com/en-us/library/bb397675
                products = from Product product in sub.Products.Values
                           join type in selectedTypes on product.Type equals type
                           orderby product.Name
                           select product;
            }
            else
            {
                // Please refer to MSDN for more information about Lambda expressions used to Query collections. http://msdn.microsoft.com/en-us/library/bb397675
                products = from Product product in sub.Products.Values
                           join type in selectedTypes on product.Type equals type
                           where product.Name.Contains(m_searchFilter)
                           orderby product.Name
                           select product;
            }

            // Add product nodes to the TreeView.
            // Set the default child node as "loading..." This node will be replaced when the node is expanded and
            // the instrument catalog is downloaded for the given product.
            foreach (Product product in products)
            {
                TreeNode prodNode = treeViewProductList.Nodes.Add(product.Name);
                prodNode.Tag = (object)product;
                prodNode.SelectedImageIndex = prodNode.ImageIndex = GetImageCode(product.Type);

                TreeNode childNode = new TreeNode("Loading ...", GetImageCode(product.Type), GetImageCode(product.Type));
                prodNode.Nodes.Add(childNode);
            }

            // Clean up this ProductCatalog subscription.
            if (m_prodCat != null)
            {
                m_prodCat.ProductsUpdated -= new EventHandler<ProductCatalogUpdatedEventArgs>(productsUpdated);
                m_prodCat.Dispose();
                m_prodCat = null;
            }

            toolStripStatusLabel.Text = "There are " + Convert.ToString(products.Count()) + " products";
            Cursor = Cursors.Default;
        }