CL_DATA.C
上传用户:bjghjy
上传日期:2007-01-07
资源大小:379k
文件大小:16k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <io.h>
  7. #include "dbf_data.h"
  8. #include "hq.h"
  9. #include "sv_hq.h"
  10. #include "data.h"
  11. #include "cl_hq.h"
  12. #include "cl_data.h"
  13. extern BOOL run_cancelled;
  14. extern HWND ghWndMain;
  15. extern int date_num, tim;
  16. extern void MsgLocal(LPSTR msg);
  17. extern BOOL ErrMsg(HWND, LPSTR);
  18. extern int UDPBlockingHook(void);
  19. extern void MsgRecv(char far *msg);
  20. //extern long oldCjss[2];
  21. extern char szDataPath[128];
  22. long zs_times[2][20];
  23. BOOL fWrited[2] ={FALSE, FALSE};
  24. int WriteHqAll(int jys)
  25. {
  26. if(WriteHqData(jys) <0) return -1;
  27. if(WriteMmpData(jys) <0) return -1;
  28. if(WriteMaxMinData(jys) <0) return -1;
  29. return 0;
  30. }
  31. int WriteHqData(int jys)
  32. {
  33. _llseek(hfHq[jys], 0, SEEK_SET);
  34. _lwrite(hfHq[jys], (char *)&HqData[jys].recCount, sizeof(short));
  35. if(_hwrite(hfHq[jys], (char *)HqData[jys].lpPreData,
  36. (long)HqData[jys].recCount*sizeof(HQ_PRE_DATA))
  37. !=(long)(HqData[jys].recCount*sizeof(HQ_PRE_DATA)))
  38. {
  39. ErrMsg(ghWndMain, "Error write hqdata");
  40. return -1;
  41. }
  42. if(_hwrite(hfHq[jys], (char *)HqData[jys].lpRefData,
  43. (long)HqData[jys].recCount*sizeof(HQ_REF_DATA))
  44. !=(long)(HqData[jys].recCount*sizeof(HQ_REF_DATA)))
  45. {
  46. ErrMsg(ghWndMain, "Error write hqdata");
  47. return -1;
  48. }
  49. CreateLzwFile(jys);
  50. return 0;
  51. }
  52. //////////////////////////////////////////////////////////////////////////
  53. //Function:to reduce transfer time between server and client,we must build
  54. //         compress data.this prog compress main mass data(szhq.dat.shhq.dat)
  55. //Para    :None
  56. //Return  :if successful return 0,otherwise return -1
  57. //Writer  :lym
  58. //Create  :1997/08/24
  59. //////////////////////////////////////////////////////////////////////////
  60. int CreateLzwFile(int jys)
  61. {
  62. char temp[256]; //,tmp[256];
  63.     OFSTRUCT os;                 
  64.     HQ_REF_DATA_V202  DataV202;
  65.     long i;
  66.     int lzw;
  67.     
  68.     //for(jys=0;jys<2;jys++)
  69.     //{   
  70. if(HqData[jys].recCount==0)
  71. return(-1);
  72. if(jys==0)
  73. sprintf(temp,"%s\hqdata\szhq.202",szDataPath);
  74. else
  75. sprintf(temp,"%s\hqdata\shhq.202",szDataPath);
  76. if((lzw=OpenFile(temp,&os,OF_WRITE|OF_SHARE_DENY_NONE))==HFILE_ERROR)
  77. if((lzw=OpenFile(temp,&os,OF_WRITE|OF_SHARE_DENY_NONE|OF_CREATE))==HFILE_ERROR)
  78. return(-1);
  79. _lwrite(lzw, (char *)&HqData[jys].recCount, sizeof(short));
  80. for(i=0;i<HqData[jys].recCount;i++)
  81. {
  82. if(run_cancelled) break;
  83. memset((char*)&DataV202,0,sizeof(HQ_REF_DATA_V202));
  84.  
  85.   strcpy(DataV202.zqdm,HqData[jys].lpPreData[i].zqdm);
  86.   strcpy(DataV202.zqmc,HqData[jys].lpPreData[i].zqmc);
  87.         
  88.          sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zdjg*100.00);
  89.   DataV202.zdjg =atol(temp);
  90.  
  91.   sprintf(temp,"%7.2f",HqData[jys].lpPreData[i].zrsp*100.00);
  92.   DataV202.zrsp =atol(temp)-DataV202.zdjg;
  93.  
  94.   sprintf(temp,"%7.2f",HqData[jys].lpPreData[i].jrkp*100.00);
  95.   DataV202.jrkp =atol(temp)-DataV202.zdjg;
  96.  
  97.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zgjg*100.00);
  98.   DataV202.zgjg =atol(temp)-DataV202.zdjg;
  99.  
  100.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zdjm*100.00);
  101.   DataV202.zdjm =atol(temp)-DataV202.zdjg;
  102.  
  103.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zgjm*100.00);
  104.   DataV202.zgjm =atol(temp)-DataV202.zdjg;
  105.  
  106.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zjcj*100.00);
  107.   DataV202.zjjg =atol(temp)-DataV202.zdjg;
  108.  
  109.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].wb*100.00);
  110.   DataV202.wb =atol(temp);
  111.  
  112.   DataV202.cjss =HqData[jys].lpRefData[i].cjss;
  113.   DataV202.npzl =HqData[jys].lpRefData[i].npzl;
  114.   DataV202.cjje =HqData[jys].lpRefData[i].cjje;
  115. _lwrite(lzw,(char *)&DataV202,sizeof(HQ_REF_DATA_V202));
  116. }
  117. _lclose(lzw);
  118. return TRUE;
  119. }
  120. int CreateLzwMemData(int jys)
  121. {
  122. char temp[256];
  123.     long i;
  124.     
  125. if(HqData[jys].recCount==0)
  126. return(-1);
  127. *LzwData202[jys].recCount =HqData[jys].recCount;
  128. for(i=0;i<HqData[jys].recCount;i++)
  129. {
  130. if(run_cancelled) break;
  131.   strcpy(LzwData202[jys].lpData202[i].zqdm,
  132. HqData[jys].lpPreData[i].zqdm);
  133.   strcpy(LzwData202[jys].lpData202[i].zqmc,
  134. HqData[jys].lpPreData[i].zqmc);
  135.         
  136.         sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zdjg*100.00);
  137.   LzwData202[jys].lpData202[i].zdjg =atol(temp);
  138.  
  139.   sprintf(temp,"%7.2f",HqData[jys].lpPreData[i].zrsp*100.00);
  140.   LzwData202[jys].lpData202[i].zrsp =
  141. atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  142.  
  143.   sprintf(temp,"%7.2f",HqData[jys].lpPreData[i].jrkp*100.00);
  144.   LzwData202[jys].lpData202[i].jrkp =atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  145.  
  146.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zgjg*100.00);
  147.   LzwData202[jys].lpData202[i].zgjg =atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  148.  
  149.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zdjm*100.00);
  150.   LzwData202[jys].lpData202[i].zdjm =atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  151.  
  152.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zgjm*100.00);
  153.   LzwData202[jys].lpData202[i].zgjm =atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  154.  
  155.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].zjcj*100.00);
  156.   LzwData202[jys].lpData202[i].zjjg =atol(temp)-LzwData202[jys].lpData202[i].zdjg;
  157.  
  158.   sprintf(temp,"%7.2f",HqData[jys].lpRefData[i].wb*100.00);
  159.   LzwData202[jys].lpData202[i].wb =atol(temp);
  160.  
  161.   LzwData202[jys].lpData202[i].cjss =HqData[jys].lpRefData[i].cjss;
  162.   LzwData202[jys].lpData202[i].npzl =HqData[jys].lpRefData[i].npzl;
  163.   LzwData202[jys].lpData202[i].cjje =HqData[jys].lpRefData[i].cjje;
  164. }
  165. return TRUE;
  166. }
  167. int WriteDpData(int jys)
  168. {
  169. _llseek(hfDp, jys*sizeof(DpData[jys]), SEEK_SET);
  170. _lwrite(hfDp, (char*)&DpData[jys], sizeof(DpData[jys]));
  171. return 0;
  172. }
  173. int WriteMmpData(int jys)
  174. {
  175. _llseek(hfMmp[jys], 0, SEEK_SET);
  176. if(_hwrite(hfMmp[jys], (char *)MmpData[jys].lpMmp, (long)sizeof(MMP)*HqData[jys].recCount)
  177. !=(long)sizeof(MMP)*HqData[jys].recCount)
  178. {
  179. ErrMsg(NULL, "Write mmp failed");
  180. return -1;
  181. }
  182. return 0;
  183. }
  184. int WriteMaxMinData(int jys)
  185. {
  186. _llseek(hfMaxMin[jys], 0, SEEK_SET);
  187. _lwrite(hfMaxMin[jys], (char *)&MaxMinData[jys], sizeof(MAXMIN_DATA)*2);
  188. return 0;
  189. }
  190. long max_l(long val1, long val2)
  191. {
  192. return (val1>val2)? val1:val2;
  193. }
  194. long min_l(long val1, long val2)
  195. {
  196. return (val1<val2)? val1:val2;
  197. }
  198. float max_f(float val1, float val2)
  199. {
  200. return (val1>val2)? val1:val2;
  201. }
  202. float min_f(float val1, float val2)
  203. {
  204. return (val1<val2)? val1:val2;
  205. }
  206. //////////////////////////////////////////////////
  207. //功能 :读取分时数据文件,初始化内存分时数据头部信息
  208. //参数 :
  209. //    jys---交易所编码
  210. //返回码 :
  211. //    0  ---成功
  212. //         -1 ---失败
  213. //修改日期 :1997/10/15
  214.   
  215. int CheckGraHead(int jys)
  216. {
  217. int i;
  218. char temp[128];
  219. HFILE hFile;
  220. OFSTRUCT os;
  221. wsprintf(temp, "检查分时数据头:%d", jys);
  222. MsgLocal(temp);
  223. for(i =0; i<HqData[jys].recCount; i++)
  224. {
  225. while(UDPBlockingHook());
  226. if(run_cancelled) break;
  227. wsprintf(temp, "%s\%s.dat",
  228. GraphData[jys].szGraPath,
  229. HqData[jys].lpPreData[i].zqdm);
  230. hFile =OpenFile(temp, &os, OF_SHARE_DENY_NONE|OF_READ);
  231. //打开文件失败,必需重新初始化内存分时数据头部信息
  232. if(hFile ==HFILE_ERROR)
  233. goto reset_values;
  234. else
  235. {
  236. //该内存分时数据头部信息读不出,必需重新初始化
  237. if(_lread(hFile, &GraphData[jys].lpGraHead[i],
  238. sizeof(GRA_HEAD)) !=sizeof(GRA_HEAD))
  239. goto reset_values;
  240. //该内存分时数据头部信息日期错,必需重新初始化
  241. if(GraphData[jys].lpGraHead[i].dateNum !=date_num)
  242. goto reset_values;
  243. _lclose(hFile);
  244. //至此说明该内存分时数据头部信息正确,但如存在成交量查,则必须调整
  245. //内存行情数据的内盘总量
  246. HqData[jys].lpRefData[i].npzl =GraphData[jys].lpGraHead[i].npzl
  247. +(HqData[jys].lpRefData[i].cjss-GraphData[jys].lpGraHead[i].npzl
  248. -GraphData[jys].lpGraHead[i].wpzl)/2;
  249. continue;
  250. }
  251. reset_values:
  252. HqData[jys].lpRefData[i].npzl =HqData[jys].lpRefData[i].cjss/2;
  253. memset(&GraphData[jys].lpGraHead[i], 0, sizeof(GRA_HEAD));
  254. GraphData[jys].lpGraHead[i].dateNum =date_num;
  255. GraphData[jys].lpGraHead[i].zrsp =HqData[jys].lpPreData[i].zrsp;
  256. GraphData[jys].lpGraHead[i].zgjg =GraphData[jys].lpGraHead[i].zdjg
  257. =HqData[jys].lpRefData[i].zjcj-HqData[jys].lpPreData[i].zrsp;
  258. if(hFile ==HFILE_ERROR)
  259. {
  260. hFile =OpenFile(temp, &os, OF_SHARE_DENY_NONE|OF_CREATE|OF_READWRITE);
  261. if(hFile ==HFILE_ERROR) continue;
  262. }
  263. _lclose(hFile);
  264. }
  265. return 0;
  266. }
  267. BOOL WriteGraData(int jys,int i)
  268. char tmp[50];
  269. HFILE hFile;
  270. OFSTRUCT os;
  271. UINT ret;
  272. wsprintf(tmp, "%s\%s.dat", GraphData[jys].szGraPath,
  273. HqData[jys].lpPreData[i].zqdm);
  274. //GraphData[jys].lpGraHead[i].dateNum =date_num;
  275. //GraphData[jys].lpGraHead.zrsp =HqData[jys].lpRefData[i].zrsp;
  276. //GraphData[jys].lpGraData[i].tim =tim;
  277. hFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  278. if(hFile ==HFILE_ERROR)
  279. return FALSE;
  280. if(_llseek(hFile, sizeof(GRA_HEAD)+(GraphData[jys].lpGraHead[i].recCount-1)*sizeof(GRA_DATA),
  281. SEEK_SET) ==HFILE_ERROR)
  282. {
  283. _lclose(hFile);
  284. return FALSE;
  285. }
  286. ret =_lwrite(hFile, (char *)&GraphData[jys].lpGraData[i],sizeof(GRA_DATA));
  287. _llseek(hFile, 0, SEEK_SET);
  288. ret =_lwrite(hFile, (char *)&GraphData[jys].lpGraHead[i],sizeof(GRA_HEAD));
  289. _lclose(hFile);
  290. return TRUE;
  291. }
  292. int WriteMinData(int jys)
  293. {
  294. return 0;
  295. }
  296. BOOL WriteDayData(int jys)
  297. {
  298. int i;
  299. long day_cur;
  300. char tmp[128];
  301. DAY_DATA dayData;
  302. HFILE hFile;
  303. OFSTRUCT os;
  304. time_t ltime;
  305. struct tm *ptm;
  306. //static BOOL fWrited[2] ={FALSE, FALSE};
  307. long len;
  308.     
  309. if(fWrited[jys])
  310. {
  311. MsgLocal("history data already writed!");
  312. return TRUE;
  313. }
  314. MsgLocal("Write day data...");
  315.     
  316. time(&ltime);
  317. ptm =localtime(&ltime);
  318. day_cur =(long)(1900+ptm->tm_year)*10000+(long)(ptm->tm_mon+1)*100+ptm->tm_mday;
  319. for (i=0;i<HqData[jys].recCount;i++) 
  320. {         
  321. while(UDPBlockingHook());
  322. if(run_cancelled) break;
  323. if(GraphData[jys].lpGraHead[i].recCount <=0) continue;
  324. wsprintf(tmp, "%s\%s\%s.day", szDataPath, (jys ==0)?"SZDAY":"SHDAY",
  325. HqData[jys].lpPreData[i].zqdm);                          
  326. hFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  327. if(hFile ==HFILE_ERROR)
  328. {
  329. hFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_CREATE|OF_READWRITE);
  330. if(hFile ==HFILE_ERROR)
  331. {
  332. ErrMsg(NULL, "Create file failed");
  333. ErrMsg(NULL, tmp);
  334. continue;
  335. }
  336. }
  337. else
  338. {
  339. _llseek(hFile, 0, SEEK_SET);
  340. len =_llseek(hFile, 0, SEEK_END);
  341. if(len!=0)
  342. {
  343. if(_llseek(hFile, len-sizeof(dayData), SEEK_SET) ==HFILE_ERROR)
  344. {
  345. _llseek(hFile, 0, SEEK_SET);
  346. }
  347. else if(_lread(hFile, &dayData, sizeof(dayData))
  348. !=sizeof(dayData))
  349. {
  350. ErrMsg(NULL, "Read file failed");
  351. ErrMsg(NULL, tmp);
  352. _lclose(hFile);
  353. continue;
  354. }
  355. else if(dayData.day ==day_cur)
  356. {
  357. _lclose(hFile);
  358. continue;
  359. }
  360. }
  361. }
  362. dayData.day =day_cur;
  363. dayData.kpjg =HqData[jys].lpPreData[i].jrkp;
  364. dayData.spjg =HqData[jys].lpRefData[i].zjcj;
  365. dayData.zgjg =HqData[jys].lpRefData[i].zgjg;
  366. dayData.zdjg =HqData[jys].lpRefData[i].zdjg;
  367. dayData.cjss =HqData[jys].lpRefData[i].cjss;
  368. dayData.cjje =HqData[jys].lpRefData[i].cjje;
  369. _lwrite(hFile,(char *)&dayData,sizeof(DAY_DATA));
  370. _lclose(hFile);
  371. }    
  372. MsgLocal("Write day data ok");
  373. fWrited[jys] =TRUE;
  374. return TRUE;
  375. }
  376. BOOL WriteWeekData(int jys)
  377. {
  378. int i,j;
  379. char tmp[100];
  380. HISTORY_DATA WeekData,DayData,NextDayData;
  381. HFILE hWeekFile,hDayFile;
  382. OFSTRUCT os;
  383. time_t c_time1,c_time2;
  384. static BOOL fWrited[2] ={FALSE, FALSE};
  385.     
  386. if(fWrited[jys])
  387. {
  388. MsgLocal("week data already writed");
  389. return TRUE;
  390. }
  391. MsgLocal("Write week data...");
  392. for (i=0;i<HqData[jys].recCount;i++) 
  393. {   
  394. while(UDPBlockingHook());
  395. if(run_cancelled) break;
  396. //打开日线文件
  397. memset(tmp,0,100);                                                              
  398. if(jys==0)
  399. wsprintf(tmp, "%s%s.day","szase\day\" ,
  400. HqData[jys].lpPreData[i].zqdm);                          
  401. else
  402. wsprintf(tmp, "%s%s.day","shase\day\" ,
  403. HqData[jys].lpPreData[i].zqdm);                          
  404. //MsgLocal(HqData[jys].lpPreData[i].zqdm);      
  405. hDayFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  406. if(hDayFile ==HFILE_ERROR)
  407. {
  408. _lclose(hDayFile);
  409. continue;               
  410. }
  411. _llseek(hDayFile,-1*(long)(sizeof(HISTORY_DATA)),SEEK_END);
  412. if(_lread(hDayFile,&DayData,sizeof(HISTORY_DATA))!=
  413. sizeof(HISTORY_DATA))
  414. {          
  415. _lclose(hDayFile);      
  416. continue;
  417. }        
  418. memcpy(&WeekData,&DayData,sizeof(HISTORY_DATA));        
  419. memcpy(&c_time1,DayData.date+6,sizeof(time_t));
  420. j=2;            
  421. while(TRUE)
  422. {   
  423. if(j>7) break;
  424.     _llseek(hDayFile,-j*(long)(sizeof(HISTORY_DATA)),SEEK_END);
  425. if(_lread(hDayFile,&NextDayData,sizeof(HISTORY_DATA))!=
  426. sizeof(HISTORY_DATA))                           
  427. break;                          
  428. memcpy(&c_time2,NextDayData.date+6,sizeof(time_t));      
  429. if((int)(difftime(c_time1,c_time2)/(24.00*60.00))>=7)
  430. break;
  431. //计算周线  
  432. WeekData.ks=NextDayData.ks;
  433. WeekData.cj+=NextDayData.cj;
  434. if(WeekData.zg<NextDayData.zg)  WeekData.zg=NextDayData.zg;
  435. if(WeekData.zd>NextDayData.zd)  WeekData.zg=NextDayData.zd;                     
  436. j++;    
  437. }               
  438. //写周线文件            
  439. if(jys==0)
  440. wsprintf(tmp, "%s%s.wek","szase\week\",
  441. HqData[jys].lpPreData[i].zqdm);
  442. else
  443. wsprintf(tmp, "%s%s.wek","shase\week\",
  444. HqData[jys].lpPreData[i].zqdm);
  445. hWeekFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  446. if(hWeekFile ==HFILE_ERROR)
  447. {
  448. hWeekFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_CREATE|OF_READWRITE);
  449. }  
  450. _llseek(hWeekFile,0L,SEEK_END);
  451. _lwrite(hWeekFile,(char*)&WeekData,sizeof(HISTORY_DATA));
  452. _lclose(hWeekFile);
  453. _lclose(hDayFile);
  454.     }
  455. MsgLocal("Write week data ok");
  456. fWrited[jys] =TRUE;
  457. return TRUE;
  458. }
  459. BOOL WriteMonthData(int jys)
  460. {
  461.     int i,j;
  462.     char tmp[100];
  463.     HISTORY_DATA WeekData,MonthData,NextWeekData;
  464. HFILE hWeekFile,hMonthFile;
  465. OFSTRUCT os;
  466. static BOOL fWrited[2] ={FALSE, FALSE};
  467. if(fWrited[jys])
  468. {
  469. MsgLocal("month data already writed!");
  470. return TRUE;
  471. }
  472. MsgLocal("Write month data...");
  473. for (i=0;i<HqData[jys].recCount;i++) 
  474. {   
  475. while(UDPBlockingHook());
  476. if(run_cancelled) break;
  477. //打开周线文件
  478.     if(jys==0)
  479. wsprintf(tmp, "%s%s.wek","szase\week\" ,
  480. HqData[jys].lpPreData[i].zqdm);                          
  481. else
  482. wsprintf(tmp, "%s%s.wek","shase\week\" ,
  483. HqData[jys].lpPreData[i].zqdm);                          
  484. //MsgLocal(HqData[jys].lpPreData[i].zqdm);      
  485. hWeekFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  486. if(hWeekFile ==HFILE_ERROR)
  487. {
  488. _lclose(hWeekFile);
  489. continue;               
  490. }
  491. _llseek(hWeekFile,-1*(long)(sizeof(HISTORY_DATA)),SEEK_END);
  492. if(_lread(hWeekFile,&WeekData,sizeof(HISTORY_DATA))!=
  493. sizeof(HISTORY_DATA))
  494. {          
  495. _lclose(hWeekFile);     
  496. continue;
  497. }        
  498. memcpy(&MonthData,&WeekData,sizeof(HISTORY_DATA));        
  499. j=2;            
  500. while(TRUE)
  501. {   
  502. if(j>31)        break;
  503.     _llseek(hWeekFile,-j*(long)(sizeof(HISTORY_DATA)),SEEK_END);
  504. if(_lread(hWeekFile,&NextWeekData,sizeof(HISTORY_DATA))!=
  505. sizeof(HISTORY_DATA))                           
  506. break;                  
  507. if(!strncmp(WeekData.date+2,NextWeekData.date+2,2))
  508. break;
  509. //计算月线  
  510. MonthData.ks=NextWeekData.ks;
  511. MonthData.cj+=NextWeekData.cj;
  512. if(MonthData.zg<NextWeekData.zg)  MonthData.zg=NextWeekData.zg;
  513. if(MonthData.zd>NextWeekData.zd)  MonthData.zg=NextWeekData.zd;                 
  514. j++;    
  515. }               
  516. //写月线文件            
  517. if(jys==0)
  518. wsprintf(tmp, "%s%s.mot","szase\month\",
  519. HqData[jys].lpPreData[i].zqdm);
  520. else
  521. wsprintf(tmp, "%s%s.mot","shase\month\",
  522. HqData[jys].lpPreData[i].zqdm);
  523. hMonthFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READWRITE);
  524. if(hMonthFile ==HFILE_ERROR)
  525. {
  526. hMonthFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_CREATE|OF_READWRITE);
  527. }  
  528. _llseek(hMonthFile,0L,SEEK_END);
  529. _lwrite(hMonthFile,(char*)&MonthData,sizeof(HISTORY_DATA));
  530. _lclose(hMonthFile);
  531. _lclose(hWeekFile);
  532.     }
  533. MsgLocal("Write month data ok");
  534. fWrited[jys] =TRUE;
  535. return TRUE;
  536. }