-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.cpp
91 lines (86 loc) · 2.54 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "mainConnection.h"
int main(int argc, char *argv[])
{
//调用参数配置
bool ishelp = false;
InitializeCriticalSection(&cs_fileWriting);
if (argc > 1)
{
for (int i = 1; i < argc;)
{
if (strcmp(argv[i], "--real") == 0)
{
server = "realServer";
database = "MarketData.tick";
instdatabase = "MarketData.instrument";
++i;
}
else if (strcmp(argv[i], "--ip") == 0)
{
if (argc < i + 2)
{
cout << "参数错误" << endl;
return -1;
}
ip = argv[i + 1];
i += 2;
}
else if (strcmp(argv[i], "--help") == 0)
{
if (i == 1)
{
ishelp = true;
showhelp();
++i;
}
else
{
cout << "错误的help调用" << endl;
return -1;
}
}
else if (strcmp(argv[i], "--inipath") == 0)
{
if (argc < i + 2)
{
cout << "参数错误" << endl;
return -1;
}
inipath = argv[i + 1];
i += 2;
}
else if (strcmp(argv[i], "--logpath") == 0)
{
if (argc < i + 2)
{
cout << "参数错误" << endl;
return -1;
}
logpath = argv[i + 1];
i += 2;
}
else
{
cout << "没有找到指定操作" << endl;
return -1;
}
}
}
if (!ishelp)
{
GetLocalTime(&st);
stringstream ss, sss;
ss << st.wYear * 10000 + st.wMonth * 100 + st.wDay;
logpath = logpath + string(ss.str()) + ".log";
filestream.open(logpath, ios::app);
sss<< "获取当前交易日: " << st.wYear*10000 + st.wMonth*100 + st.wDay;
string tradingdaytxt = string(sss.str());
PrintLog(filestream, tradingdaytxt.c_str());
void* h_main = CreateThread(NULL, 0, MainThread, NULL, 0, NULL);
void* h_heart = CreateThread(NULL, 0, HeartBeatThread, NULL, 0, NULL);
WaitForSingleObject(h_heart, INFINITE);
filestream.close();
}
DeleteCriticalSection(&cs_fileWriting);
return 0;
}