摘要:
1.数据的安装有两处,网络下载安装和手工安装
安装原理:读取第三方板块或通用板块数据,写入容器,然后从容器中写入gruop.dat
策略为王源代码分析-主菜单-数据(D)-数据管理(M)-板块财务F10导入
第一部分 数据调用链条
1.1 从网络下载数据并安装
G:\stock\TskingVS2019\src\Client\StkNet\Src\NetDB.cpp
BOOL CNetDatabase::InstallPackage( CPackage &pac, const char *pacfile,
PROGRESS_CALLBACK fnCallback, void *cookie )
{
CString strFilenameOrg;
if( pac.m_bIsZipped )
strFilenameOrg = pacfile;
.....
if( bOK && CPackage::packageCode == pac.m_nType )
{
CString strDomainFile = AfxGetProfile().GetDomainFile();
int nIndex = strDomainFile.ReverseFind( '/' );
if( -1 != nIndex )
strDomainFile = strDomainFile.Mid( nIndex + 1 );
nIndex = strDomainFile.ReverseFind( '\\' );
if( -1 != nIndex )
strDomainFile = strDomainFile.Mid( nIndex + 1 );
if( 0 == strFilenameOrg.CompareNoCase( strDomainFile ) ) //安装板块数据
bOK = (InstallCodetblBlock( pacfile, strFilenameOrg ) >= 0 );
else if( 0 == strFilenameOrg.Right(4).CompareNoCase( ".blk" ) ) // 安装分析家板块数据
bOK = (InstallCodetblFxjBlock( pacfile, strFilenameOrg ) >= 0 );
else
bOK = (InstallCodetbl( pacfile, strFilenameOrg ) > 0 );
}
.....
}
G:\stock\TskingVS2019\src\Client\StkLib\Src\Database.cpp
int CStDatabase::InstallCodetblBlock( const char * filename, const char *orgname )
{ if(!IsOK()) return 0;
return m_pStore->InstallCodetblBlock( filename, orgname ); }
int CStDatabase::InstallCodetblFxjBlock( const char * filename, const char *orgname )
{ if(!IsOK()) return 0;
return m_pStore->InstallCodetblFxjBlock( filename, orgname ); }
1.2 主程序启动时从本地数据安装板块数据
G:\stock\TskingVS2019\src\Client\StkUI\StkUI.cpp
BOOL CStkUIApp::InitInstance()
{
....
// 初始化股票容器,把从本地数据库的数据填充到股票数组容器中
AfxGetStockContainer().Load(&AfxGetDB(), NULL, NULL); // 这里只读取证券代码表、财务。
AfxGetDomainContainer().Load(AfxGetProfile().GetDomainFile()); // 读取板块 ;AfxGetProfile().GetDomainFile()=GetWorkDirectory() + "data\\domain.dat" by freeman
AfxGetGroupContainer().Load(AfxGetProfile().GetGroupFile()); // 读取自选板块。实际是自选股和省份板块。AfxGetProfile().GetGroupFile()=GetWorkDirectory() + "data\\group.dat" by freeman
....
}
1.3 从数据管理->版块财务F10 对话框中安装导入
G:\stock\TskingVS2019\src\Client\StkUI\Dialog\SetBaseDlg.cpp
选择分析家板块导入目录
G:\stock\TskingVS2019\src\Client\StkUI\StkUI.rc
IDD_SETBASE DIALOGEX 0, 0, 360, 209
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "板块财务F10导入"
FONT 9, "宋体", 0, 0, 0x1
BEGIN
EDITTEXT IDC_FILE_F10,78,28,186,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "浏览...",IDC_F10FILE_EXPLORER,267,26,48,14,BS_FLAT
EDITTEXT IDC_FILE_TDX,78,66,186,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "浏览...",IDC_TDXFILE_EXPLORER,267,64,48,14,BS_FLAT
EDITTEXT IDC_FILE_FXJ,78,104,186,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "浏览...",IDC_FXJFILE_EXPLORER,267,102,48,14,BS_FLAT
EDITTEXT IDC_PATH_FXJBLOCK,78,142,186,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "浏览...",IDC_FXJBLOCKPATH_EXPLORER,268,140,48,14,BS_FLAT
DEFPUSHBUTTON "开始导入",IDC_START,288,168,50,14,BS_FLAT
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | NOT WS_VISIBLE,21,170,203,10,WS_EX_STATICEDGE
LTEXT "",IDC_STATIC_PROGRESS,233,170,33,9
LTEXT "选择F10资料导入文件(.txt,.zip)",IDC_STATIC,34,15,86,8
LTEXT "选择通达信财务资料导入文件",IDC_STATIC,34,53,111,8
LTEXT "选择分析家财务资料导入文件",IDC_STATIC,34,91,111,8
LTEXT "选择分析家板块导入目录",IDC_STATIC,34,129,111,8
END
文件位置目录:
src\Client\Bin\data
group.dat
实际上是一个文本文件
自选股
1A0001
399001
399006
399005
600000
600004
600007
600008
600009
603895
002930
688001
黑龙江板块
000587
000711
000901
000922
添加到板块代码
/添加到板块 by freeman
void CFilterInfoDlg::OnAddtogroup()
{
CSelectGrpDlg dlg;
dlg.SetMode( CSelectGrpDlg::modeGroup );
if( IDOK == dlg.DoModal() )
{
CString strGrpName = dlg.GetSelectedName();
CDomainContainer & groups = AfxGetGroupContainer();
CSPStringArray astrStocks;
astrStocks.SetSize( 0, m_listResult.GetCount() );
for( int i=0; i<m_listResult.GetCount(); i++ )
{
CString rString;
m_listResult.GetText( i, rString );
if( rString.GetLength() > 0 )
{
int nIndex = rString.Find( "(" );
if( -1 != nIndex )
rString = rString.Left(nIndex);
astrStocks.Add( rString );
}
}
groups.AddDomainStock( strGrpName, astrStocks );
}
}