void Run() { _rtd = new CryptoRtdServer(); _rtd.ServerStart(this); const string BINANCE = "BINANCE"; foreach (string field in RtdFields.ALL_FIELDS) { Sub(BINANCE, "ETHUSDT", field); } Sub(CryptoRtdServer.GDAX, "BTC-USD", "BID"); Sub(CryptoRtdServer.GDAX, "BTC-USD", "ASK"); Sub(CryptoRtdServer.GDAX, "BTC-USD", "LAST_PRICE"); Sub(CryptoRtdServer.GDAX, "BTC-USD", "LAST_SIZE"); Sub(CryptoRtdServer.GDAX, "BTC-USD", "LAST_SIDE"); //Sub(CryptoRtdServer.GDAX, "ETH-USD", "BID"); //Sub(CryptoRtdServer.GDAX, "ETH-USD", "ASK"); //Sub(CryptoRtdServer.GDAX, "ETH-USD", "LAST_PRICE"); //Sub(CryptoRtdServer.GDAX, "ETH-USD", "LAST_SIZE"); //Sub(CryptoRtdServer.GDAX, "ETH-USD", "LAST_SIDE"); // Start up a Windows message pump and spin forever. Dispatcher.Run(); }
void CreateWrappedServer() { _wrappedServer = (IRtdServer)Activator.CreateInstance(_wrappedServerType); // Would be nice to combine the initialization here and in ExcelRtd.Rtd ... ExcelRtdServer rtdServer = _wrappedServer as ExcelRtdServer; if (rtdServer != null) { rtdServer.RegisteredProgId = _wrappedServerRegisteredProgId; } }
public RtdServerWrapper(object rtdServer, string progId) { // CAREFUL: ProgId passed in might be token used from regular ClassFactory. _progId = progId; _rtdServer = rtdServer as IRtdServer; if (_rtdServer == null) { // The RtdServer implements another instance of IRtdServer (maybe from some office PIA). // We put together some delegates to call through. Type[] itfs = rtdServer.GetType().GetInterfaces(); foreach (Type itf in itfs) { if (itf.GUID == ComAPI.guidIRtdServer) { InterfaceMapping map = rtdServer.GetType().GetInterfaceMap(itf); for (int i = 0; i < map.InterfaceMethods.Length; i++) { MethodInfo mi = map.InterfaceMethods[i]; switch (mi.Name) { case "ConnectData": _ConnectData = (delConnectData)Delegate.CreateDelegate(typeof(delConnectData), rtdServer, map.TargetMethods[i]); break; case "DisconnectData": _DisconnectData = (delDisconnectData)Delegate.CreateDelegate(typeof(delDisconnectData), rtdServer, map.TargetMethods[i]); break; case "Heartbeat": _Heartbeat = (delHeartbeat)Delegate.CreateDelegate(typeof(delHeartbeat), rtdServer, map.TargetMethods[i]); break; case "RefreshData": _RefreshData = (delRefreshData)Delegate.CreateDelegate(typeof(delRefreshData), rtdServer, map.TargetMethods[i]); break; case "ServerStart": // ServerStart is tricky because of the parameter type mapping. MethodInfo serverStartMethod = map.TargetMethods[i]; _ServerStart = delegate(IRTDUpdateEvent updateEvent) { return((int)serverStartMethod.Invoke(rtdServer, new object[] { updateEvent })); }; break; case "ServerTerminate": _ServerTerminate = (delServerTerminate)Delegate.CreateDelegate(typeof(delServerTerminate), rtdServer, map.TargetMethods[i]); break; } } } } } }
void Run() { _rtd = new RabbitRtdServer(); _rtd.ServerStart(this); Sub("BTC-USD", "BID"); Sub("BTC-USD", "ASK"); // Start up a Windows message pump and spin forever. Dispatcher.Run(); }
public void ServerTerminate() { // We might already have terminated the wrapped server .... if (_wrappedServer != null) { Debug.Assert(_activeTopics.Count == 0); _wrappedServer.ServerTerminate(); _wrappedServer = null; } // Now remove this wrapper from the list _wrappers.Remove(_wrappedServerRegisteredProgId); UninstallAfterCalculateHandler(); }
/// <summary> /// connect to a RTD Server /// </summary> /// <param name="progID">RTD Server ProgID</param> /// <param name="refreshRate">data refresh rate, default = -1</param> /// <returns>true if connected successfully, false otherwise</returns> public bool Connect(string progID, int refreshRate) { if (!connected) { // create RTD server instance if (rtdServer == null) { Type rtd = Type.GetTypeFromProgID(progID); if (rtd == null) { return(false); } rtdServer = (IRtdServer)Activator.CreateInstance(rtd); } // create updateEvent UpdateEvent updateEvent = new UpdateEvent(NewDataEvent, refreshRate); // connect object ret = rtdServer.ServerStart(updateEvent); if (ret != null) { if ((int)ret >= 0) { connected = true; OnConnect(); // establish heartbeat timer = new Timer(new TimerCallback(TimerEventHandler), null, 0, 5000); return(true); } else { return(false); } } else { return(false); } } else { return(true); } }
void Run() { _rtd = new RedisRtdServer(); _rtd.ServerStart(this); CancellationTokenSource cts = new CancellationTokenSource(); for (int i = 0; i < 3; i++) { var json = "JSON_" + i; var raw = "RAW_" + i; Task.Run(() => PublishRedis(json, "FIELD", true, cts.Token)); Task.Run(() => PublishRedis(raw, "FIELD", false, cts.Token)); } // Start up a Windows message pump and spin forever. Dispatcher.Run(); }
public void DisconnectData(int topicId) { // CONSIDER: But what if we previously ServerTerminated, and only now Excel is figuring out it must DisconnectData? Debug.Assert(_wrappedServer != null); // This is called both by the DisconnectOrphans handler and Excel regularly foreach (KeyValuePair <string, int> activeTopic in _activeTopics) { if (activeTopic.Value != topicId) { continue; } // Only call the wrapped Disconnect if the topic is still active _wrappedServer.DisconnectData(topicId); Debug.Print("DisconnectData " + _wrappedServerRegisteredProgId + ":" + topicId); _activeTopics.Remove(activeTopic.Key); foreach (ExcelReference caller in _activeTopicCallers[topicId]) { TopicIdList callerTopics; if (_activeCallerTopics.TryGetValue(caller, out callerTopics)) { callerTopics.Remove(topicId); if (callerTopics.Count == 0) { _activeCallerTopics.Remove(caller); } } } _activeTopicCallers.Remove(topicId); return; } // We might have to let the server instance go. // (Even though Excel thinks there are some active topics, there aren't really.) if (_activeTopics.Count == 0) { _wrappedServer.ServerTerminate(); // CONSIDER: Is this safe ...? What if Excel tried to Connect again later...? _wrappedServer = null; } }
/// <summary> /// Initializes a new instance of the <see cref="RTDWrapper" /> class. /// </summary> /// <param name="logger"> /// The logging instance /// </param> /// <param name="progId"> /// The prog id. /// </param> public RTDWrapper(ILogger logger, string progId = ProgId) { this.logger = logger; Contract.Requires <ArgumentNullException>(progId != null); // No topics by default this.topicIndex = -1; // gets the type for an rtd server var type = Type.GetTypeFromProgID(progId); // get the server from COM this.server = (IRtdServer)Activator.CreateInstance(type); // start the server and throw away the callback this.server.ServerStart(null); // creates a new hashset to contain the registered topics this.topics = new HashSet <int>(); }
public void ServerTerminate() { Debug.Print("### ServerTerminate " + _wrappedServerRegisteredProgId); // We might already have terminated the wrapped server .... if (_wrappedServer != null) { // TODO: This assertion is not quite right // If Excel is shutting down, the RTD server will receive a ServerTerminate, // even though there weren't DisconnectData calls for each Topic. // (Is there a way to know that we're shutting down, so that we can // make the check only when required?) Debug.Assert(_activeTopics.Count == 0); _wrappedServer.ServerTerminate(); _wrappedServer = null; } // Now remove this wrapper from the list _wrappers.Remove(_wrappedServerRegisteredProgId); UninstallAfterCalculateHandler(); }
void Run() { _rtd = new WebSocketRtdServer(); _rtd.ServerStart(this); Sub("BTC-USD", "BID"); Sub("BTC-USD", "ASK"); Sub("BTC-USD", "LAST_PRICE"); Sub("BTC-USD", "LAST_SIZE"); Sub("BTC-USD", "LAST_SIDE"); Sub("ETH-USD", "BID"); Sub("ETH-USD", "ASK"); Sub("ETH-USD", "LAST_PRICE"); Sub("ETH-USD", "LAST_SIZE"); Sub("ETH-USD", "LAST_SIDE"); // Start up a Windows message pump and spin forever. Dispatcher.Run(); }
void Run() { _rtd = new RabbitRtdServer(); _rtd.ServerStart(this); CancellationTokenSource cts = new CancellationTokenSource(); for (int i = 0; i < 3; i++) { var rk = "ROUTING_KEY_" + i; var b = i % 2 == 0; Task.Run(() => PublishRabbit("EXCHANGE", rk, "FIELD", b, cts.Token)); if (consoleAppTest) { Sub("EXCHANGE", rk, "FIELD"); } } // Start up a Windows message pump and spin forever. Dispatcher.Run(); }
public void serverintitilization() { string terminal = ConfigurationManager.AppSettings["terminal"]; if (terminal == "NEST") { type = Type.GetTypeFromProgID("nest.scriprtd"); } else if (terminal == "NOW") { type = Type.GetTypeFromProgID("now.scriprtd"); } try { m_server = (IRtdServer)Activator.CreateInstance(type); } catch { System.Windows.MessageBox.Show("Server Not Found "); return; } RtdataRecall(); }
public object ConnectData(int topicId, ref Array strings, ref bool newValues) { Debug.Print("ConnectData " + _wrappedServerRegisteredProgId + ":" + topicId); if (_wrappedServer == null) { // We have to create and start a new server instance CreateWrappedServer(); int startResult = _wrappedServer.ServerStart(_callbackObject); if (startResult == 0) { // TODO: Deal with error here... _wrappedServer.ServerTerminate(); _wrappedServer = null; return(ExcelErrorUtil.ToComError(ExcelError.ExcelErrorValue)); } } string topicKey = GetTopicKey(strings); _activeTopics[topicKey] = topicId; _activeTopicCallers[topicId] = new ExcelReferenceSet(); // Everything is fine return(_wrappedServer.ConnectData(topicId, ref strings, ref newValues)); }
void Connect() { _server = RtdClient.COMCreateObject(_rtd_name) as IRtdServer; _server.ServerStart(this); }
public RtdServerWrapper(object rtdServer, string progId) { // CAREFUL: ProgId passed in might be token used from regular ClassFactory. _progId = progId; _rtdServer = rtdServer as IRtdServer; if (_rtdServer == null) { // The RtdServer implements another instance of IRtdServer (maybe from some office PIA). // We put together some delegates to call through. Type[] itfs = rtdServer.GetType().GetInterfaces(); foreach (Type itf in itfs) { if (itf.GUID == ComAPI.guidIRtdServer) { InterfaceMapping map = rtdServer.GetType().GetInterfaceMap(itf); for (int i = 0; i < map.InterfaceMethods.Length; i++) { MethodInfo mi = map.InterfaceMethods[i]; switch (mi.Name) { case "ConnectData": _ConnectData = (delConnectData)Delegate.CreateDelegate(typeof(delConnectData), rtdServer, map.TargetMethods[i]); break; case "DisconnectData": _DisconnectData = (delDisconnectData)Delegate.CreateDelegate(typeof(delDisconnectData), rtdServer, map.TargetMethods[i]); break; case "Heartbeat": _Heartbeat = (delHeartbeat)Delegate.CreateDelegate(typeof(delHeartbeat), rtdServer, map.TargetMethods[i]); break; case "RefreshData": _RefreshData = (delRefreshData)Delegate.CreateDelegate(typeof(delRefreshData), rtdServer, map.TargetMethods[i]); break; case "ServerStart": // ServerStart is tricky because of the parameter type mapping. MethodInfo serverStartMethod = map.TargetMethods[i]; _ServerStart = delegate(IRTDUpdateEvent updateEvent) { return (int)serverStartMethod.Invoke(rtdServer, new object[] {updateEvent}); }; break; case "ServerTerminate": _ServerTerminate = (delServerTerminate)Delegate.CreateDelegate(typeof(delServerTerminate), rtdServer, map.TargetMethods[i]); break; } } } } } }
public void rtddata() { try { yahoortdata.Clear(); using (var reader = new StreamReader("c:\\ShubhaRtsymbollist.txt")) { string line = null; int i = 0; while ((line = reader.ReadLine()) != null) { yahoortname.Add(line); Array retval; MethodInfo method; Type type = Type.GetTypeFromProgID("now.scriprtd"); IRtdServer m_server = (IRtdServer)Activator.CreateInstance(type); int j = m_server.Heartbeat(); if (flag == 0) { bool bolGetNewValue = true; object[] array = new object[3]; array[0] = "MktWatch"; array[1] = line; array[2] = "Last Trade Time"; Array sysArrParams = (Array)array; m_server.ConnectData(i, sysArrParams, bolGetNewValue); i++; object[] array1 = new object[3]; array1[0] = "MktWatch"; array1[1] = line; array1[2] = "Best Buy Rate"; Array sysArrParams1 = (Array)array1; m_server.ConnectData(i, sysArrParams1, bolGetNewValue); i++; object[] array2 = new object[3]; array2[0] = "MktWatch"; array2[1] = line; array2[2] = "Best Buy Qty"; Array sysArrParams2 = (Array)array2; m_server.ConnectData(i, sysArrParams2, bolGetNewValue); retval = m_server.RefreshData(10); i++; //imp it change topic id foreach (var item in retval) { yahoortdata.Add(item.ToString()); } } } string tempfilepath = "C:\\YahooRealTimeData.txt"; log4net.Config.XmlConfigurator.Configure(); ILog log = LogManager.GetLogger(typeof(MainWindow)); log.Debug("Data Capturing At" + DateTime.Now.TimeOfDay); using (var writer = new StreamWriter(tempfilepath)) for (int c = 1; c <= yahoortdata.Count - 1; c = c + 2) { writer.WriteLine(yahoortdata[c].ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void StartRt_Click(object sender, EventArgs e) { //check sp user or trial version /////////////////////////////// RegistryKey regKey = Registry.CurrentUser; regKey = regKey.CreateSubKey(@"windows-data\"); try { var registerdate = regKey.GetValue("sd"); var paidornot = regKey.GetValue("sp"); DateTime reg = Convert.ToDateTime(registerdate); reg = reg.AddDays(2); if (paidornot.ToString() == "Key for xp") { if (reg < DateTime.Today.Date) { Uri a = new System.Uri("http://besttester.com/lic/licforami.txt"); // webBrowser1.Source = a; string credentials = "liccheck:lic123!@#"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(a); request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials))); request.PreAuthenticate = true; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); //////////////////////////////////////////// string[] serverdata = reader.ReadToEnd().Split(','); string[] serverdata1 = null; int flagforuserpresentonserver = 0; for (int i = 0; i < serverdata.Count(); i++) { serverdata1 = serverdata[i].Split(' '); DateTime dateonserver = Convert.ToDateTime(serverdata1[1]); ManagementObject dsk1 = new ManagementObject(@"win32_logicaldisk.deviceid=""c:"""); dsk1.Get(); string id1 = dsk1["VolumeSerialNumber"].ToString(); if (id1 == serverdata1[0]) { flagforuserpresentonserver = 1; if (dateonserver < DateTime.Today.Date) { System.Windows.Forms.MessageBox.Show("Trial version expired please contact to [email protected] "); this.Close(); return; } } } if (flagforuserpresentonserver == 0) { System.Windows.Forms.MessageBox.Show("Trial version expired please contact to [email protected] "); this.Close(); return; } } else { } } else { if (paidornot.ToString() == "1001") { } else { MessageBox.Show("Trial version expired please contact to [email protected] "); this.Close(); return; } } } catch (Exception ex) { } string targetpath = ConfigurationManager.AppSettings["txtTargetFolderforami"]; //ExcelType = Type.GetTypeFromProgID("Broker.Application"); //ExcelInst = Activator.CreateInstance(ExcelType); //ExcelType.InvokeMember("Visible", BindingFlags.SetProperty, null, // ExcelInst, new object[1] { true }); //ExcelType.InvokeMember("LoadDatabase", BindingFlags.InvokeMethod | BindingFlags.Public, null, // ExcelInst, new string[1] { "c://RTDATA//amirtdatabase" }); /////////////////////////////////////////////////////////// /////////////////////////////////// //start server or terminal string terminalname = ConfigurationManager.AppSettings["terminal"]; try { Type type = Type.GetTypeFromProgID(terminalname); m_server = (IRtdServer)Activator.CreateInstance(type); config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("timerflag"); config.AppSettings.Settings.Add("timerflag", "1"); config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appSettings"); this.Hide(); } catch { System.Windows.Forms.MessageBox.Show("Please start your terminal "); return; } /////////////////////////////////////////////////////////// RtdataRecall(); }
public void getsymbol() { string preset = ConfigurationManager.AppSettings["preset"]; Process[] processes = null; Type type; if (preset == "NEST") { try { type = Type.GetTypeFromProgID("nest.scriprtd"); m_server = (IRtdServer)Activator.CreateInstance(type); processes = Process.GetProcessesByName("NestTrader"); } catch { MessageBox.Show(" Please start Teminal as Run as Administrator"); return; } } else if (preset == "NOW") { try { type = Type.GetTypeFromProgID("now.scriprtd"); m_server = (IRtdServer)Activator.CreateInstance(type); processes = Process.GetProcessesByName("NOW"); } catch { MessageBox.Show(" Please start Teminal as Run as Administrator"); return; } } IntPtr abcd = new IntPtr(); IntPtr abcd1 = new IntPtr(); IntPtr windowHandle = new IntPtr(); List <Thread> processtostartback = new List <Thread>(); SystemAccessibleObject sao, f, finalobject; foreach (Process p in processes) { windowHandle = p.MainWindowHandle; //System.Windows.Forms.MessageBox.Show(p.HandleCount.ToString()); abcd = FindChildWindow(windowHandle, IntPtr.Zero, "#32770", ""); abcd1 = FindChildWindow(abcd, IntPtr.Zero, "SysListView32", ""); // do something with windowHandle } SystemWindow a = new SystemWindow(abcd1); // sao = SystemAccessibleObject.FromPoint(4, 200); try { string marketwatch = abcd1.ToString(); if (marketwatch == "0") { MessageBox.Show("Nest is not running or Market Watch not present "); } sao = SystemAccessibleObject.FromWindow(a, AccessibleObjectID.OBJID_WINDOW); } catch { MessageBox.Show("Market Watch not found "); return; } f = sao.Children[3]; ////////////////////////////// //checking nest fileds finalobject = f.Children[0]; string s1 = finalobject.Description; int flag = 0; string[] checkterminalcol = s1.Split(','); string marketwathrequiredfield = ""; try { for (int i = 0; i < 20; i++) { marketwathrequiredfield = marketwathrequiredfield + checkterminalcol[i].ToString(); } } catch { } if (!marketwathrequiredfield.Contains("Exchange")) { flag = 1; } if (flag == 1) { MessageBox.Show("Trading symbol or Exchange column is missing \n Trading Symbol must be first column "); return; } /////////////////////////////// //dataGridView2.Columns.Clear(); //dataGridView2.Columns.Add("Symbol", "Symbol"); //dataGridView2.Columns.Add("Mapping Symbol", "Mapping Symbol"); //dataGridView2.Columns[0].Width = 200; //dataGridView2.Columns[1].Width = 200; try { for (int i = 0; i < 50; i++) { s1 = f.Children[i].Description; string [] exchage = null; string exchagename = ""; checkterminalcol = s1.Split(','); try { for (int j = 0; j < 20; j++) { if (checkterminalcol[j].Contains("Exchange")) { exchage = checkterminalcol[j].Split(':'); if (exchage[1].Contains("NSE")) { exchagename = "nse_cm"; } else if (exchage[1].Contains("NFO")) { exchagename = "nse_fo"; } else if (exchage[1].Contains("MCX")) { exchagename = "mcx_fo"; } else if (exchage[1].Contains("CDE")) { exchagename = "cde_fo"; } } } } catch { } if (exchagename != "" && f.Children[i].Name != "" && f.Children[i].Name != null) { int flagforsym = 0; try { //check symbol already present or not for (int j = 0; j < tradingsymbolname.Count - 1; j++) { if (tradingsymbolname[j] == exchagename + "|" + f.Children[i].Name) { flagforsym = 1; } } foreach (DataGridViewRow row in dataGridView2.Rows) { // MessageBox.Show(row.Cells[0].Value.ToString()); if (exchagename + "|" + f.Children[i].Name == row.Cells[0].Value.ToString()) { flagforsym = 1; } } } catch (Exception ex) { // MessageBox.Show(ex.Message); } //add symbol if not present if (flagforsym == 0) { DataGridViewRow row = (DataGridViewRow)dataGridView2.Rows[0].Clone(); row.Cells[0].Value = exchagename + "|" + f.Children[i].Name; row.Cells[1].Value = f.Children[i].Name; dataGridView2.Rows.Add(row); flagforsym = 0; } } } } catch { } }