public bool ModifyBroker(int provider, bool warn) { if (!feedready) { return(false); } TLClient tl = getsearchclient(); if ((provider < 0) || (provider > ProvidersAvailable.Length)) { return(false); } Providers p = ProvidersAvailable[provider]; bool ok = hasminexec(tl, provider); if (!ok) { System.Windows.Forms.MessageBox.Show(p.ToString() + " does not support execution."); return(false); } this.v(tl.Name + " " + provider + " " + tl.BrokerName + (ok ? " has feed support." : " no feed support.")); _broker = p; tl.Disconnect(); Reset(); return(true); }
public override bool OnStartJob(JobParameters @params) { Task.Run(() => { // Work is happening asynchronously int messageCount = 0; database = new SQLiteRepository(); contactRepository = new ContactRepository(database); userRepository = new UserRepository(database); messageRepository = new MessageRepository(database); loginService = new LoginService(); messageService = new MessageService(); client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } messageCount = messageService.ReceiveMessages(client, messageRepository); //if (messageCount > 0) // Notification(messageCount.ToString()); // Have to tell the JobScheduler the work is done. JobFinished(@params, false); }); // Return true because of the asynchronous work return(false); }
/// <summary> /// start the tracker, required to process orders /// </summary> public void Start() { if ((_tl == null) || (_tl.ProvidersAvailable.Length == 0) || (_tl.ProviderSelected == -1)) { debug("Broker not connected. Start failed."); return; } if (_tl.BrokerName == Providers.Unknown) { debug("Unknown broker, not able to send orders."); _tl = null; } if (!_tl.RequestFeatureList.Contains(MessageTypes.SENDORDER)) { debug("broker " + _tl.BrokerName + " " + _tl.ServerVersion + " does not support sending orders."); _tl = null; } if (!_ordersend.IsBusy) { _processorderq = true; _ordersend.RunWorkerAsync(); debug("Starting sendorder tracker on: " + _tl.BrokerName + " connection: " + _tl.Name + " id: " + _tl.ProviderSelected); } else debug("Sendorder tracker is already running."); }
/// <summary> /// start the tracker, required to process orders /// </summary> public void Start() { if ((_tl == null) || (_tl.ProvidersAvailable.Length == 0) || (_tl.ProviderSelected == -1)) { debug("Broker not connected. Start failed."); return; } if (_tl.BrokerName == Providers.Unknown) { debug("Unknown broker, not able to send orders."); _tl = null; } if (!_tl.RequestFeatureList.Contains(MessageTypes.SENDORDER)) { debug("broker " + _tl.BrokerName + " " + _tl.ServerVersion + " does not support sending orders."); _tl = null; } if (!_ordersend.IsBusy) { _processorderq = true; _ordersend.RunWorkerAsync(); debug("Starting sendorder tracker on: " + _tl.BrokerName + " connection: " + _tl.Name + " id: " + _tl.ProviderSelected); } else { debug("Sendorder tracker is already running."); } }
public void Get() { int messageCount = 0; database = new SQLiteRepository(); contactRepository = new ContactRepository(database); userRepository = new UserRepository(database); messageRepository = new MessageRepository(database); loginService = new LoginService(); messageService = new MessageService(); client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } messageCount = messageService.ReceiveMessages(client, messageRepository); if (messageCount > 0) { Notification(messageCount.ToString()); context.SendBroadcast(new Intent(context, typeof(MisChats.BroadcastMisChats))); context.SendBroadcast(new Intent(context, typeof(SingleChat.BroadcastSingle))); } }
public bool GetContacts(TLClient client, ContactRepository contactRepo) { try { bool output = false; var c = Task.Run(() => client.GetContactsAsync()); c.Wait(); var contacts = c.Result.Users.ToList(); output = true; foreach (var co in contacts) { var cc = co as TLUser; Contact contacto = new Contact { Phone = string.IsNullOrEmpty(cc.Phone) ? "" : cc.Phone, Id = cc.Id, FirstName = string.IsNullOrEmpty(cc.FirstName) ? "" : cc.FirstName, LastName = string.IsNullOrEmpty(cc.LastName) ? "" : cc.LastName, Username = string.IsNullOrEmpty(cc.Username) ? "" : cc.Username, Status = cc.Status == null ? "" : cc.Status.ToString().Split('.')[2].ToString().Substring(12).ToString(), AccessHash = cc.AccessHash.Value, Blocked = false }; contactRepo.InsertContact(contacto); } return(output); } catch (Exception ex) { throw; } }
public static void UpgradeAlert(string Program, string ProgramUrl, bool checktradelink, bool checkbrokerserver, TLClient tl,bool pause) { if (Program != null) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.BuildFromRegistry(Program); if (current == 0) { string path = Util.ProgramPath(Program); current = Util.BuildFromFile(path + "\\VERSION.txt"); } if (current != 0) wc.DownloadStringAsync(new Uri(ProgramUrl), new verstate(Program, ProgramUrl, current,pause)); } if (checktradelink) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.BuildFromRegistry(Util.PROGRAM); if (current!=0) wc.DownloadStringAsync(new Uri(TLSITEURL), new verstate(Util.PROGRAM,TLSITEURL, current,pause)); } }
public static void UpgradeAlert(string Program, string ProgramUrl, bool checktradelink, bool checkbrokerserver, TLClient tl,bool pause) { if (Program != null) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.ProgramBuild(Program); if (current == 0) { string path = Util.ProgramPath(Program); current = Convert.ToInt32(Util.getfile(path + "\\VERSION.txt",null),System.Globalization.CultureInfo.InvariantCulture); } if (current != 0) ;// wc.DownloadStringAsync(new Uri(ProgramUrl), new verstate(Program, ProgramUrl, current, pause)); } if (checktradelink) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.ProgramBuild(Util.PROGRAM); if (current!=0) ;// wc.DownloadStringAsync(new Uri(TLSITEURL), new verstate(Util.PROGRAM, TLSITEURL, current, pause)); } }
public bool BlockKnownContact(TLClient client, Contact contact, ContactRepository contactRepository) { try { TLRequestBlock req = new TLRequestBlock { Id = new TLInputUser { UserId = contact.Id, AccessHash = contact.AccessHash } }; var result = Task.Run(() => client.SendRequestAsync <bool>(req)); result.Wait(); if (result.Result) { contact.Blocked = true; contactRepository.UpdateContact(contact); } return(result.Result); } catch (Exception ex) { throw; } }
public bool GetBlockedContacts(TLClient client, ContactRepository contactRepository) { try { bool output = false; TLRequestGetBlocked req = new TLRequestGetBlocked(); var l = Task.Run(() => client.SendRequestAsync <TLAbsBlocked>(req)); l.Wait(); List <TLAbsUser> list = new List <TLAbsUser>(); var c = l.Result as TLBlocked; list = c.Users.ToList(); output = true; foreach (var co in list) { var cc = co as TLUser; Contact contacto = new Contact { Phone = string.IsNullOrEmpty(cc.Phone) ? "" : cc.Phone, Id = cc.Id, FirstName = string.IsNullOrEmpty(cc.FirstName) ? "" : cc.FirstName, LastName = string.IsNullOrEmpty(cc.LastName) ? "" : cc.LastName, Username = string.IsNullOrEmpty(cc.Username) ? "" : cc.Username, Status = cc.Status == null ? "" : cc.Status.ToString().Split('.')[2].ToString().Substring(12).ToString(), AccessHash = cc.AccessHash.Value, Blocked = true }; contactRepository.InsertContact(contacto); } return(output); } catch (Exception ex) { throw; } }
public void setup() { //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (!isserverconok) { server = new TradeLink.Common.TLServer_WM(); con = new IQFeedHelper(server); con.VerboseDebugging = verbosesetting; con.SendDebug += new DebugDelegate(g.d); // get login information var data = Util.getfile(loginfile, g.d); Assert.IsFalse(string.IsNullOrWhiteSpace(data), "no login info"); var li = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(3, li.Length, "missing login info"); // attempt to startup connection con.Start(li[userr], li[pwr], li[prodr], Util.TLBuild()); // wait a moment Util.sleep(4000); Assert.IsTrue(isserverconok, "server connection failed"); } if (isserverconok && !isclientconok) { var c = new TLClient_WM("tempiqclient", false); c.VerboseDebugging = verbosesetting; c.SendDebugEvent += new DebugDelegate(g.d); if (c.ProvidersAvailable[0] != Providers.IQFeed) { throw new Exception("unable to find test server"); } c.Mode(0, false); client = c; client.gotUnknownMessage += new MessageDelegate(client_gotUnknownMessage); // verify Assert.IsTrue(isclientconok, "client connection failed"); } // reset everything mt = new MessageTracker(); mt.VerboseDebugging = verbosesetting; blt = new BarListTracker(); mt.BLT = blt; mt.SendDebug += new DebugDelegate(g.d); mt.GotNewBar += new SymBarIntervalDelegate(mt_GotNewBar); recvbarcount = 0; msgok = true; g.d("iqfeed started."); // wait a moment Util.sleep(1000); }
/// <summary> /// provide the estimated # of symbols and the client to use /// </summary> /// <param name="tl"></param> /// <param name="estSymbols"></param> public SendorderTracker(TLClient tl, int estSymbols) { _tl = tl; _estsymcount = estSymbols; _ordersend.DoWork += new DoWorkEventHandler(_ordersend_DoWork); _loaded = new GenericTracker <bool>(estSymbols); _loaded.NewTxt += new TextIdxDelegate(_loaded_NewTxt); _resendq = new RingBuffer <Order>(estSymbols); _orderq = new RingBuffer <Order>(estSymbols); _retries = new GenericTracker <int>(estSymbols * 10); }
/// <summary> /// provide the estimated # of symbols and the client to use /// </summary> /// <param name="tl"></param> /// <param name="estSymbols"></param> public SendorderTracker(TLClient tl, int estSymbols) { _tl = tl; _estsymcount = estSymbols; _ordersend.DoWork += new DoWorkEventHandler(_ordersend_DoWork); _loaded = new GenericTracker<bool>(estSymbols); _loaded.NewTxt += new TextIdxDelegate(_loaded_NewTxt); _resendq = new RingBuffer<Order>(estSymbols); _orderq = new RingBuffer<Order>(estSymbols); _retries = new GenericTracker<int>(estSymbols * 10); }
public bool UpdateContacts(TLClient client, ContactRepository contactRepository) { try { contactRepository.DeleteContacts(); return(GetContacts(client, contactRepository)); } catch (Exception ex) { throw; } }
public TLUser SignUp(TLClient client, string phone, string hash, string code, string firstname, string lastname) { try { var sign = Task.Run(() => client.SignUpAsync(phone, hash, code, firstname, lastname)); sign.Wait(); return(sign.Result); } catch (Exception ex) { throw; } }
public bool IsPhoneRegistered(TLClient client, string phone) { try { var r = Task.Run(() => client.IsPhoneRegisteredAsync(phone)); r.Wait(); return(r.Result); } catch (Exception ex) { throw; } }
public TLUser MakeAuth(TLClient client, string phone, string hash, string code) { try { var auth = Task.Run(() => client.MakeAuthAsync(phone, hash, code)); auth.Wait(); return(auth.Result); } catch (Exception ex) { throw; } }
private TLDialogs GetUserDialogs(TLClient client) { try { var dialo = Task.Run(() => client.GetUserDialogsAsync()); dialo.Wait(); var dialogs = dialo.Result as TLDialogs; return(dialogs); } catch (Exception ex) { return(null); } }
private TLAbsMessages GetHistory(TLClient client, TLInputPeerUser target, TLDialog dia) { try { var historyAsync = Task.Run(() => client.GetHistoryAsync(target, 0, -1, dia.UnreadCount)); historyAsync.Wait(); var hist = historyAsync.Result; return(hist); } catch (Exception ex) { return(null); } }
public string SendCodeRequest(TLClient client, string phone) { try { var ha = Task.Run(() => client.SendCodeRequestAsync(phone)); //var ha = client.SendCodeRequestAsync(phone); ha.Wait(); return(ha.Result); } catch (Exception ex) { throw; } }
public RecordMain() { TrackEnabled = Util.TrackUsage(); Program = PROGRAM; InitializeComponent(); Text += " " + Util.TLVersion(); string ipaddr = Properties.Settings.Default.ServerIpAddresses; string[] servers = ipaddr.Split(','); if (ipaddr == string.Empty) { tl = new TLClient_WM(); } else { tl = new TLClient_IP(servers, Properties.Settings.Default.ServerPort, debug); } int pollms = (int)(((double)Properties.Settings.Default.brokertimeoutsec * 1000) / 2); _tlt = new TLTracker(pollms, Properties.Settings.Default.brokertimeoutsec, tl, Providers.Unknown, true); _tlt.GotConnect += new VoidDelegate(_tlt_GotConnect); _tlt.GotConnectFail += new VoidDelegate(_tlt_GotConnectFail); _tlt.GotDebug += new DebugDelegate(_tlt_GotDebug); ContextMenu = new ContextMenu(); ContextMenu.MenuItems.Add("SymbolList", new EventHandler(symlist)); ContextMenu.MenuItems.Add("Level2", new EventHandler(level2)); ContextMenu.MenuItems.Add("Timeout", new EventHandler(timeout)); ContextMenu.MenuItems.Add("ReportBug", new EventHandler(report)); ContextMenu.MenuItems.Add("Messages", new EventHandler(togdebug)); if (tl.ProvidersAvailable.Length > 0) { if (tl.BrokerName != Providers.TradeLink) { if (Environment.ProcessorCount == 1) { tl.gotTick += new TickDelegate(tl_gotTick); } else { tl.gotTick += new TickDelegate(tl_gotTick2); _ar.GotTick += new TickDelegate(tl_gotTick); } } } TradeLink.AppKit.Versions.UpgradeAlert(tl); FormClosing += new FormClosingEventHandler(RecordMain_FormClosing); // process command line processcommands(); }
/// <summary> /// create a tracker for preferred provider with custom tick timeout and poll frequency settings /// </summary> /// <param name="pollintervalms"></param> /// <param name="timeoutintervalsec"></param> /// <param name="client"></param> /// <param name="PreferredBroker"></param> /// <param name="connectany"></param> public TLTracker(int pollintervalms, int timeoutintervalsec, TLClient client, Providers PreferredBroker, bool connectany) { _tl = client; _tw = new TickWatcher(pollintervalms); _tw.AlertThreshold = timeoutintervalsec; _connected = (client.ProvidersAvailable.Length > 0) && (client.ProviderSelected >= 0); if (!_connected && (GotConnectFail!= null)) GotConnectFail(); if (_connected && (GotConnect != null)) GotConnect(); // handle situations when no ticks arrive _tw.GotMassAlert += new Int32Delegate(_tw_GotMassAlert); _broker = PreferredBroker; _connectany = connectany; }
public TLClient Connect() { try { FakeSessionStore session = new FakeSessionStore(); TLClient client = new TLClient(api_id, api_hash, session, "session"); var t = Task.Run(() => client.ConnectAsync()); t.Wait(); return(client); } catch (Exception ex) { throw; } }
public TLAbsUpdates SendMessage(TLClient client, int id, string message) { try { var sendm = Task.Run(() => client.SendMessageAsync(new TLInputPeerUser() { UserId = id }, message)); sendm.Wait(); return(sendm.Result); } catch (Exception ex) { throw; } }
//[TestFixtureTearDown] public void Stop() { // stop client if (client != null) { client.Disconnect(); } client = null; // stop server if (con != null) { con.Stop(); } con = null; g.d("iqfeed teardown"); }
public bool SendTyping(TLClient client, int id, long accesshash) { try { var sendtyping = Task.Run(() => client.SendTypingAsync(new TLInputPeerUser() { UserId = id, AccessHash = accesshash })); sendtyping.Wait(); return(sendtyping.Result); } catch (Exception ex) { return(false); } }
static bool hasminquote(TLClient tl, int provider) { try { bool v = (tl.ProviderSelected == provider) || tl.Mode(provider, false); bool test = true; int count = 0; while ((tl.BrokerName != Providers.Unknown) && (tl.BrokerName != Providers.Error) && (tl.RequestFeatureList.Count == 0) && (count++ < MAXFEATUREWAIT)) { Thread.Sleep(10); } test &= tl.RequestFeatureList.Contains(MessageTypes.TICKNOTIFY); tl.Disconnect(); return(test && v); } catch { return(false); } }
/// <summary> /// create a tracker for preferred provider with custom tick timeout and poll frequency settings /// </summary> /// <param name="pollintervalms"></param> /// <param name="timeoutintervalsec"></param> /// <param name="client"></param> /// <param name="PreferredBroker"></param> /// <param name="connectany"></param> public TLTracker(int pollintervalms, int timeoutintervalsec, TLClient client, Providers PreferredBroker, bool connectany) { _tl = client; _tw = new TickWatcher(pollintervalms); _tw.AlertThreshold = timeoutintervalsec; _connected = (client.ProvidersAvailable.Length > 0) && (client.ProviderSelected >= 0); if (!_connected && (GotConnectFail != null)) { GotConnectFail(); } if (_connected && (GotConnect != null)) { GotConnect(); } // handle situations when no ticks arrive _tw.GotMassAlert += new Int32Delegate(_tw_GotMassAlert); _broker = PreferredBroker; _connectany = connectany; }
public RecordMain() { TrackEnabled = Util.TrackUsage(); Program = PROGRAM; InitializeComponent(); Text += " " + Util.TLVersion(); string ipaddr = Properties.Settings.Default.ServerIpAddresses; string[] servers = ipaddr.Split(','); if (ipaddr==string.Empty) tl = new TLClient_WM(); else tl = new TLClient_IP(servers, Properties.Settings.Default.ServerPort, debug); int pollms = (int)(((double)Properties.Settings.Default.brokertimeoutsec * 1000) / 2); _tlt = new TLTracker(pollms, Properties.Settings.Default.brokertimeoutsec, tl, Providers.Unknown, true); _tlt.GotConnect += new VoidDelegate(_tlt_GotConnect); _tlt.GotConnectFail += new VoidDelegate(_tlt_GotConnectFail); _tlt.GotDebug += new DebugDelegate(_tlt_GotDebug); ContextMenu = new ContextMenu(); ContextMenu.MenuItems.Add("SymbolList", new EventHandler(symlist)); ContextMenu.MenuItems.Add("Level2", new EventHandler(level2)); ContextMenu.MenuItems.Add("Timeout", new EventHandler(timeout)); ContextMenu.MenuItems.Add("ReportBug", new EventHandler(report)); ContextMenu.MenuItems.Add("Messages", new EventHandler(togdebug)); if (tl.ProvidersAvailable.Length > 0) { if (tl.BrokerName != Providers.TradeLink) { if (Environment.ProcessorCount == 1) tl.gotTick += new TickDelegate(tl_gotTick); else { tl.gotTick += new TickDelegate(tl_gotTick2); _ar.GotTick += new TickDelegate(tl_gotTick); } } } TradeLink.AppKit.Versions.UpgradeAlert(tl); FormClosing += new FormClosingEventHandler(RecordMain_FormClosing); // process command line processcommands(); }
public TLUser UpdateUsername(TLClient client, string username, UserRepository userRepository) { try { TLUser user = null; TLRequestUpdateUsername request = new TLRequestUpdateUsername { Username = username }; var u = Task.Run(() => client.SendRequestAsync <TLUser>(request)); u.Wait(); user = u.Result; userRepository.UpdateUser(username); return(user); } catch (Exception ex) { throw; } }
public bool Logout(TLClient client) { try { TLRequestLogOut req = new TLRequestLogOut(); var result = Task.Run(() => client.SendRequestAsync <bool>(req)); result.Wait(); if (result.Result) { return(true); } else { return(false); } } catch (Exception ex) { throw; } }
public bool DeleteContact(TLClient client, Contact contact, ContactRepository contactRepository) { try { TLRequestDeleteContact req = new TLRequestDeleteContact { Id = new TLInputUser { UserId = contact.Id, AccessHash = contact.AccessHash } }; var result = Task.Run(() => client.SendRequestAsync <object>(req)); result.Wait(); contactRepository.DeleteContact(contact); return(true); } catch (Exception ex) { throw; } }
public ClientService(string phone) { if (CheckLimit().Result) { try { var store = new FileSessionStore(); client = new TLClient(ApiId, ApiHash, store, phone); var t = Task.Run(() => client.ConnectAsync()); t.Wait(); } catch (FloodException flood) { SetLimit(Convert.ToInt32(flood.TimeToWait)).Wait(); Thread.Sleep(flood.TimeToWait); new ClientService(phone); } catch (Exception ex) { Trace.TraceError(ex.InnerException.Message); } } }
public bool CheckUsername(TLClient client, string username) { try { TLRequestCheckUsername req = new TLRequestCheckUsername { Username = username }; var l = Task.Run(() => client.SendRequestAsync <bool>(req)); l.Wait(); if (l.Result) { return(true); } else { return(false); } } catch (Exception ex) { throw; } }
static bool hasminquote(TLClient tl, int provider) { try { bool v = (tl.ProviderSelected == provider) || tl.Mode(provider, false); bool test = true; int count = 0; while ((tl.BrokerName != Providers.Unknown) && (tl.BrokerName != Providers.Error) && (tl.RequestFeatureList.Count == 0) && (count++ < MAXFEATUREWAIT)) Thread.Sleep(10); test &= tl.RequestFeatureList.Contains(MessageTypes.TICKNOTIFY); tl.Disconnect(); return test && v; } catch { return false; } }
/// <summary> /// reset brokerfeed, look for any new servers and attempt to connect to current preferred providers /// </summary> public void Reset() { feedready = false; if (IPUtil.hasValidAddress(_servers)) debug("At least one valid IpAddress found, attempting IP transport."); else debug("No ip addresses specified, attempting Windows IPC."); TLClient tl = getsearchclient(); _pavail = tl.ProvidersAvailable; if (_pavail.Length == 0) debug("No providers were found. Ensure connectors are running."); bool setquote = false; bool setexec = false; // see if we can get preferred providers int xi = getproviderindex(_broker); int qi = getproviderindex(_feed); _isprefq = (qi != -1) && hasminquote(tl, qi); _isprefx = (xi != -1) && hasminexec(tl, xi); if (!isPreferredFeed) debug("preferred data not available: " + _feed); if (!isPreferredBroker) debug("preferred execute not available: " + _broker); // search for features for (int i = 0; i < ProvidersAvailable.Length; i++) { if ((qi != -1) && (xi != -1)) break; // switch to provider if ((qi == -1) && hasminquote(tl, i)) qi = i; if ((xi == -1) && hasminexec(tl, i)) xi = i; } // see if we're allowed to fallback // not allowed if (RequirePreferred) { setquote = isPreferredFeed ; setexec = isPreferredBroker ; } else // ok to fallback,but where { setquote = (qi != -1); setexec = (xi != -1); } // map handlers if (setquote) { quote = getrealclient(qi, PROGRAM + "quote"); quote.gotFeatures += new MessageTypesMsgDelegate(quote_gotFeatures); debug("DataFeed: " + quote.BrokerName + " " + quote.ServerVersion); _feed = quote.BrokerName; // clear any leftover subscriptions quote.Unsubscribe(); if (isThreadSafe) { quote.gotTick += new TickDelegate(quote_gotTick); quote.gotUnknownMessage += new MessageDelegate(quote_gotUnknownMessage); } else { quote.gotTick += new TickDelegate(quote_gotTick2); quote.gotUnknownMessage += new MessageDelegate(quote_gotUnknownMessage2); } quote.gotImbalance += new ImbalanceDelegate(quote_gotImbalance); } if (setexec) { execute = getrealclient(xi, PROGRAM + "exec"); _broker = execute.BrokerName; execute.gotFeatures += new MessageTypesMsgDelegate(execute_gotFeatures); if (isThreadSafe) { execute.gotAccounts += new DebugDelegate(execute_gotAccounts); execute.gotFill += new FillDelegate(execute_gotFill); execute.gotOrder += new OrderDelegate(execute_gotOrder); execute.gotOrderCancel += new LongDelegate(execute_gotOrderCancel); execute.gotPosition += new PositionDelegate(execute_gotPosition); execute.gotUnknownMessage += new MessageDelegate(execute_gotUnknownMessage); } else { execute.gotAccounts += new DebugDelegate(execute_gotAccounts2); execute.gotFill += new FillDelegate(execute_gotFill2); execute.gotOrder += new OrderDelegate(execute_gotOrder2); execute.gotOrderCancel += new LongDelegate(execute_gotOrderCancel2); execute.gotPosition += new PositionDelegate(execute_gotPosition2); execute.gotUnknownMessage += new MessageDelegate(execute_gotUnknownMessage2); } debug("Executions: " + execute.BrokerName + " " + execute.ServerVersion); if (RequestAccountsOnStartup) RequestAccounts(); } feedready = true; // connect to the rest for (int i = 0; i < ProvidersAvailable.Length; i++) { // skip existing connections if (i == xi) { _pcon.Add(execute); continue; } if ((xi!=qi) && (i == qi)) { _pcon.Add(quote); continue; } // add new connections TLClient newcon = getrealclient(i, PROGRAM); newcon.gotFeatures += new MessageTypesMsgDelegate(newcon_gotFeatures); newcon.gotUnknownMessage += new MessageDelegate(newcon_gotUnknownMessage); _pcon.Add(newcon); } tl.Disconnect(); tl = null; }
public static void UpgradeAlert(TLClient tl) { UpgradeAlert(null, null, true, true, tl); }
/// <summary> /// create a tracker for a preferred provider on client /// </summary> /// <param name="client"></param> /// <param name="PreferredBroker"></param> public TLTracker(TLClient client, Providers PreferredBroker) : this(DEFAULTPOLLMS,DEFAULTTIMEOUTSEC,client, PreferredBroker, false) { }
/// <summary> /// create a tracker for selected provider on client /// </summary> /// <param name="client"></param> public TLTracker(TLClient client) : this(DEFAULTPOLLMS,DEFAULTTIMEOUTSEC,client, Providers.Unknown, true) { }
public static void UpgradeAlert(TLClient tl,bool pause) { UpgradeAlert(null, null, true, true, tl,pause); }
//[TestFixtureTearDown] public void Stop() { // stop client if (client != null) { client.Disconnect(); } client = null; // stop server if (con != null) con.Stop(); con = null; g.d("iqfeed teardown"); }
public static void UpgradeAlert(string Program, string ProgramUrl, TLClient tl) { UpgradeAlert(Program, ProgramUrl, true, true, tl); }
public void setup() { //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); if (!isserverconok) { server = new TradeLink.Common.TLServer_WM(); con = new IQFeedHelper(server); con.VerboseDebugging = verbosesetting; con.SendDebug += new DebugDelegate(g.d); // get login information var data = Util.getfile(loginfile, g.d); Assert.IsFalse(string.IsNullOrWhiteSpace(data), "no login info"); var li = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(3, li.Length, "missing login info"); // attempt to startup connection con.Start(li[userr], li[pwr], li[prodr], Util.TLBuild()); // wait a moment Util.sleep(4000); Assert.IsTrue(isserverconok, "server connection failed"); } if (isserverconok && !isclientconok) { var c = new TLClient_WM("tempiqclient", false); c.VerboseDebugging = verbosesetting; c.SendDebugEvent += new DebugDelegate(g.d); if (c.ProvidersAvailable[0]!= Providers.IQFeed) throw new Exception("unable to find test server"); c.Mode(0, false); client = c; client.gotUnknownMessage += new MessageDelegate(client_gotUnknownMessage); // verify Assert.IsTrue(isclientconok, "client connection failed"); } // reset everything mt = new MessageTracker(); mt.VerboseDebugging = verbosesetting; blt = new BarListTracker(); mt.BLT = blt; mt.SendDebug += new DebugDelegate(g.d); mt.GotNewBar += new SymBarIntervalDelegate(mt_GotNewBar); recvbarcount = 0; msgok = true; g.d("iqfeed started."); // wait a moment Util.sleep(1000); }
/// <summary> /// create a message tracker that communicates with a TL client /// </summary> /// <param name="tl"></param> public MessageTracker(TLClient tl) { _tl = tl; }
public static void UpgradeAlert(string Program, string ProgramUrl, bool checktradelink, bool checkbrokerserver, TLClient tl, bool pause) { if (Program != null) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.ProgramBuild(Program); if (current == 0) { string path = Util.ProgramPath(Program); current = Convert.ToInt32(Util.getfile(path + "\\VERSION.txt", null), System.Globalization.CultureInfo.InvariantCulture); } if (current != 0) { wc.DownloadStringAsync(new Uri(ProgramUrl), new verstate(Program, ProgramUrl, current, pause)); } } if (checktradelink) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); int current = Util.ProgramBuild(Util.PROGRAM); if (current != 0) { wc.DownloadStringAsync(new Uri(TLSITEURL), new verstate(Util.PROGRAM, TLSITEURL, current, pause)); } } }
/// <summary> /// checks a url for all EXEs with version numbers. /// Finds highest version number and alerts if local version number is different /// </summary> /// <param name="Program"></param> /// <param name="ProgramUrl"></param> /// <param name="path"></param> /// <param name="checktradelink"></param> /// <param name="checkbrokerserver"></param> public static void UpgradeAlert(string Program, string ProgramUrl, bool checktradelink, bool checkbrokerserver, TLClient tl) { UpgradeAlert(Program, ProgramUrl, checktradelink, checkbrokerserver, tl,false); }