public NewInstrumentRequest() { this.InitializeComponent(); this.providerDict = new Dictionary <string, int>(); LicenseServiceClient licenseServiceClient = new LicenseServiceClient(); ProviderContract[] providers = licenseServiceClient.getProviders(new Trader() { Account = Settings.LocalSetting.User, Signature = Settings.LocalSetting.Config }); if (providers != null) { foreach (ProviderContract providerContract in providers) { this.providerDict.Add(providerContract.Name, providerContract.Id); this.cbProvider.Items.Add((object)providerContract.Name); } } licenseServiceClient.Close(); }
public void GetInstruments() { if (this.CQGInstruments != null) { this.CQGInstruments.Clear(); } if (this.SaxoInstruments != null) { this.SaxoInstruments.Clear(); } if (this.LmaxInstruments != null) { this.LmaxInstruments.Clear(); } if (this.rithmicSubscriptions != null) { this.rithmicSubscriptions.Clear(); } if (this.TWSInstruments != null) { this.TWSInstruments.Clear(); } if (this.IQInstruments != null) { this.IQInstruments.Clear(); } if (!new Security().connectToServer()) { return; } LicenseServiceClient licenseServiceClient = new LicenseServiceClient(); List <ProviderContract> list1 = ((IEnumerable <ProviderContract>)licenseServiceClient.getProviders(new Trader() { Account = this.User, Signature = this.Config })).ToList <ProviderContract>(); List <InstrumentsContract> list2 = ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader() { Account = this.User, Signature = this.Config })).ToList <InstrumentsContract>(); licenseServiceClient.Close(); if (list1 != null && list2 != null) { foreach (InstrumentsContract instrumentsContract in list2) { InstrumentsContract p = instrumentsContract; IEnumerable <ProviderContract> source = list1.Where <ProviderContract>((Func <ProviderContract, bool>)(pr => pr.Id == p.ProviderId)); if (source != null && source.Count <ProviderContract>() == 1) { string name = source.First <ProviderContract>().Name; if (!(name == "Lmax")) { if (!(name == "CQG")) { if (!(name == "Saxo")) { if (!(name == "Rithmic")) { if (!(name == "TWS")) { if (name == "IQFeed") { this.IQInstruments.Add(new Settings.IQFeedInstruments() { Id = p.Id, Symbol = p.DisplayId, Name = p.Description, Enabled = p.Enabled }); } } else { string[] strArray = p.DisplayId.Split('%'); this.TWSInstruments.Add(new Settings.TWSSubscription() { InstumentId = p.Id, Symbol = strArray[0], Currency = strArray[1], SecType = p.Parametr1, Exchange = p.Parametr2, Enabled = p.Enabled }); } } else { this.rithmicSubscriptions.Add(new Settings.rithmicSubscription() { InstumentId = p.Id, symbol = p.DisplayId, Description = p.Description, exchange = p.Parametr1, Enabled = p.Enabled }); } } else { this.SaxoInstruments.Add(new Settings.SaxoValues() { InstumentId = p.Id, InstrumentType = p.DisplayId, Name = p.Description, Enabled = p.Enabled }); } } else { this.CQGInstruments.Add(new Settings.CQGInstrument() { InstumentId = p.Id, Instrument = p.DisplayId, Enabled = p.Enabled }); } } else { int result = 0; if (int.TryParse(p.DisplayId, out result) && !this.LmaxInstruments.ContainsKey(result)) { this.LmaxInstruments.Add(result, new Settings.LmaxValues() { InstrumentId = p.Id, Name = p.Description, Enabled = p.Enabled }); } } } } } Settings.LocalSetting.rithmicSubscriptions = this.rithmicSubscriptions; }