/// <summary> /// TT Gateways deliver a list of contracts associated with the product /// </summary> /// <param name="Gateway">TT Gateway on which the product contracts trade</param> /// <param name="Product">Product associated with the contracts</param> /// <param name="contracts">Collection of the contracts available for the product</param> public void OnContracts(ITTGateway Gateway, ITTProduct Product, ITTContractCollection contracts) { TreeNode parentNode = null; TreeNode[] childNodes = new TreeNode[contracts.Count]; int counter = 0; // store our contracts in a hashtable so they can be accessed for drag and drop if (!m_currentContractsFound.ContainsKey(Product.Name.ToString())) m_currentContractsFound.Add(Product.Name.ToString(), contracts); foreach (ITTContractInfo contract in contracts) { TreeNode tmpChildNode = new TreeNode(); tmpChildNode.Text = contract.Name; childNodes[counter] = tmpChildNode; counter++; // GC should get it out of scope, but force release our resources tmpChildNode = null; } // push the parent node to the GUI to update parentNode = new TreeNode(Product.Name.ToString(), childNodes); PublishProducts(parentNode); // GC should get it out of scope, but force release our resources childNodes = null; parentNode = null; }
/// <summary> /// Status of a TT Gateway server change /// </summary> /// <param name="Gateway">Gateway affected by the server status change</param> /// <param name="service">Service whose status changed.</param> /// <param name="IsAvailable">Current status of the service</param> /// <param name="IsLoggedIn">Current logged in status</param> public void OnServerStatus(ITTGateway Gateway, enumServiceType service, int IsAvailable, int IsLoggedIn) { // before requesting products make sure we have a connection to the price server if ((service == enumServiceType.PRICE_SERVICE) && (IsAvailable == 1) && (IsLoggedIn == 1)) { // we're connected, let's make sure it's available while ((Gateway.get_IsAvailable(enumServiceType.PRICE_SERVICE) != 1) || (Gateway.get_IsLoggedIn(enumServiceType.PRICE_SERVICE) != 1)) { System.Threading.Thread.Sleep(25); } // set the flag that the gateway is available m_gatewayAvailable = true; } tsStatus.Text = Gateway.Name.ToString() + ": Connecting to Price Server..."; }
/// <summary> /// Gateway has been selected /// </summary> private void lbGateways_SelectedIndexChanged(object sender, EventArgs e) { // release the product event handler if one exists ReleaseProductEventHandlers(); // clear the current prodtype listbox and product treeview lboProductList.Nodes.Clear(); lboProductTypes.Items.Clear(); Application.DoEvents(); ListBox lbTemp = (ListBox)sender; m_productCollection = new Hashtable(); m_currentContractsFound = new Hashtable(); // release the previous gateway event handler if (m_selectedGateway != null) m_selectedGateway.UnregisterEventHandler(this); // get our gateway object so we can create our event handler m_selectedGateway = (ITTGateway)m_gatewayCollection[lbTemp.SelectedItem.ToString()]; if (m_selectedGateway.RegisterEventHandler(this) != enumRegisterReturnCode.RR_SUCCESS) lboInfo.Items.Add("ERROR: Gateway handler did not register properly."); }
/// <summary> /// Contract download times out /// </summary> /// <param name="Gateway">TT Gateway on which the contracts product trades</param> /// <param name="Product">Product associated with the contract</param> public void OnRequestContractsTimeout(ITTGateway Gateway, ITTProduct Product) { lboInfo.Items.Add("Timeout occured when requesting contracts for " + Gateway.Name.ToString() + " " + Product.Name.ToString()); }
/// <summary> /// TT Gateways timeout on a product request /// </summary> /// <param name="Gateway">TT Gateway which timed out</param> public void OnRequestProductsTimeout(ITTGateway Gateway) { lboInfo.Items.Add("Product Request Timeout for: " + Gateway.Name.ToString()); }
/// <summary> /// TT Gateways find no products matching a product request or query. /// </summary> /// <param name="Gateway">TT Gateway from which you requested products</param> public void OnProductsNotFound(ITTGateway Gateway) { lboInfo.Items.Add("No products found for " + Gateway.Name.ToString()); }
/// <summary> /// TT Gateways return a list of product types hosted on the TT Gateway /// </summary> /// <param name="Gateway">TT Gateway containing the product types</param> /// <param name="productTypes">Array of product type IDs</param> /// <param name="productTypesAsString">Array of product type names</param> public void OnProductTypes(ITTGateway Gateway, object productTypes, object productTypesAsString) { // push the product types to our GUI PublishProductTypes(productTypesAsString as string[], productTypes as int[]); }
/// <summary> /// TT Gateways find products that match a product request /// </summary> /// <param name="Gateway">TT Gateway containing the products</param> /// <param name="Products">Collection of products returned by the TT Gateway</param> public void OnProductsFound(ITTGateway Gateway, ITTProductCollection Products) { // set our global values containing our products m_currentRegisteredProducts = Products; }
/// <summary> /// TT Gateway recieves new products from an exchange. /// </summary> /// <param name="Gateway"></param> /// <param name="Product"></param> public void OnNewProduct(ITTGateway Gateway, ITTProduct Product) { lboInfo.Items.Add("New Product Found: " + Product.Name.ToString()); }
/// <summary> /// TT Gateways add new contracts for a product /// </summary> /// <param name="Gateway">TT Gateway on which the product was added</param> /// <param name="Product">Product associated with the new contract</param> /// <param name="contractInfo">New Contract</param> public void OnNewContract(ITTGateway Gateway, ITTProduct Product, ITTContractInfo contractInfo) { lboInfo.Items.Add("New Contract Found: " + Product.Name.ToString() + " " + contractInfo.Name.ToString()); }
/// <summary> /// MEAPI recieves the gateway attribute list (GAL settings) for the TT Gateway. /// </summary> /// <param name="Gateway">TT Gateway whose GAL settings changed</param> /// <param name="attributeList">Comma-separated list of GAL name-value pairs</param> /// <param name="service">Service that started or restarted</param> public void OnGatewayAttributes(ITTGateway Gateway, string attributeList, enumServiceType service) { // request the products and product types for our selected gateway if (Gateway.Name.ToString() == m_selectedGateway.Name.ToString()) { Gateway.RequestProductTypes(); Gateway.RequestProducts(0); } }
/// <summary> /// TT Gateways are found in response to a RequestGateways method call or when /// TT Gateways become available. /// </summary> /// <param name="Gateway">The TT Gateway object found by the MEAPI</param> public void OnGateway(ITTGateway Gateway) { // add the gateway to the collection so we can create our event handlers if (!m_gatewayCollection.ContainsKey(Gateway.Name.ToString())) m_gatewayCollection.Add(Gateway.Name.ToString(), Gateway); // push the gateway name to our mainform class PublishGatewayName(Gateway.Name.ToString()); }