代码拉取完成,页面将自动刷新
同步操作将从 海风/data_publish 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NetMQ;
using NetMQ.Sockets;
using static data_publish.PublishDepth;
namespace data_publish
{
class Program
{
private static string _errLog = string.Empty;
readonly static ManualResetEvent _terminateEvent = new ManualResetEvent(false);
//params: port , mongorul: "mongodb://root:kingisgod.@172.111.111.210:27017/?authenticationDatabase=admin"
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("params: port , mongorul(eg: mongodb://root:kingisgod.@172.111.111.210:27017/?authenticationDatabase=admin");
Console.ReadLine();
return;
}
Console.Title = "数据发布服务器";
_errLog = "err.log";
//处理非UI线程异常
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
DisableCloseButton(Console.Title);
int client = 0;
if (client == 0)
{
//var rsp = new Response("*:8888",args[0] );
var rsp = new Response($"*:{args[0]}", args[1]);
Console.WriteLine("listen to port: *:5055 ( internet 5055 )");
new Thread(() =>
{
rsp.ResponseData();
}).Start();
//var req = new Request();
//foreach (var b in req.QueryMin("cu1610", "20120501", "20160623"))
// Console.WriteLine($"{b._id}, {b.Open}, {b.High}, {b.Low}, {b.Close}, {b.Volume}, {b.OpenInterest}");
//foreach (var b in req.QueryDay("cu1610", "20120501", "20160623"))
// Console.WriteLine($"{b._id}, {b.Open}, {b.High}, {b.Low}, {b.Close}, {b.Volume}, {b.OpenInterest}");
//foreach (var b in req.QueryReal("IF1609"))
// Console.WriteLine($"{b._id}, {b.Open}, {b.High}, {b.Low}, {b.Close}, {b.Volume}, {b.OpenInterest}");
//foreach (var b in req.QueryDate())
// Console.WriteLine(b);
//foreach (var b in req.QueryProduct())
// Console.WriteLine(b._id);
//foreach (var b in req.QueryTime())
// Console.WriteLine(b.GroupId);
//深度行情
//var pub = new PublishDepth("*:5058"); //公网 5058
//Console.WriteLine("listen to port: *:5058 ( internet 5058 )");
//new Thread(() =>
//{
// pub.Publish();
//}).Start();
}
else//20档接受
{
Thread.Sleep(1000);
using (var sub = new SubscriberSocket())
{
sub.Options.ReceiveHighWatermark = 1000;
//sub.Connect("tcp://58.247.171.146:5058");
sub.Connect("tcp://192.168.105.197:5058");
sub.Subscribe("rb1610");
sub.Subscribe("cu1610");
int size = Marshal.SizeOf(typeof(Level20));
byte[] buf = new byte[size];
IntPtr buffer = Marshal.AllocHGlobal(size);
while (true)
{
string inst = sub.ReceiveFrameString();
var bytes = sub.ReceiveFrameBytes();
if (bytes.Length > 6)
{
Marshal.Copy(bytes, 0, buffer, size);
Level20 f = (Level20)Marshal.PtrToStructure(buffer, typeof(Level20));
Console.WriteLine(f.Instrument);
}
}
}
}
while (true) ;
}
#region 禁用关闭按钮
[DllImport("User32.dll", EntryPoint = "FindWindow")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
static extern IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert);
[DllImport("user32.dll", EntryPoint = "RemoveMenu")]
static extern IntPtr RemoveMenu(IntPtr hMenu, uint uPosition, uint uFlags);
///<summary>
/// 禁用关闭按钮
///</summary>
///<param name="consoleName">控制台名字</param>
public static void DisableCloseButton(string title)
{
//线程睡眠,确保closebtn中能够正常FindWindow,否则有时会Find失败。。
//Thread.Sleep(100);
IntPtr windowHandle = FindWindow(null, title);
IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);
uint SC_CLOSE = 0xF060;
RemoveMenu(closeMenu, SC_CLOSE, 0x0);
}
public static bool IsExistsConsole(string title)
{
IntPtr windowHandle = FindWindow(null, title);
if (windowHandle.Equals(IntPtr.Zero)) return false;
return true;
}
#endregion
#region 处理未捕获异常的挂钩函数
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception error = e.ExceptionObject as Exception;
if (error != null)
{
using (StreamWriter sw = new StreamWriter(_errLog, true))
{
sw.WriteLine(DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "\t" + string.Format("Application UnhandledException:{0}; 堆栈信息:{1}", error.Message, error.StackTrace));
}
}
else
{
using (StreamWriter sw = new StreamWriter(_errLog, true))
{
sw.WriteLine(DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "\t" + string.Format("Application UnhandledError:{0}", e));
}
}
}
#endregion
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。