Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

802 lines
19 KiB

  1. // CountDaily.cpp : Implementation of CCountDaily
  2. #include "stdafx.h"
  3. #include "CountDaily.h"
  4. #include "ReportCountDaily.h"
  5. #include "ReportDailyBuckets.h"
  6. #include "ReportAnonUsers.h"
  7. #include "ReportSpecificSolutions.h"
  8. #include "ReportGeneralSolutions.h"
  9. #include "ReportGetHelpInfo.h"
  10. #include "ReportGetAutoUploads.h"
  11. #include "ReportGetManualUploads.h"
  12. #include "ReportGetIncompleteUploads.h"
  13. #include "ATLComTime.h"
  14. #include <comutil.h>
  15. #include <stdio.h>
  16. #import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
  17. no_namespace rename("EOF", "EndOfFile")
  18. const CComBSTR cScore = "_";
  19. const CComBSTR cDash = "-";
  20. // CCountDaily
  21. /*************************************************************************************
  22. * module: CountDaily.cpp
  23. *
  24. * author: Tim Ragain
  25. * date: Jan 2, 2002
  26. *
  27. * Purpose: To return the incident count for a specific date. This uses OLEDB template
  28. * CReportCountDaily.h that calls stored procedure ReportCountDaily.
  29. *
  30. *************************************************************************************/
  31. STDMETHODIMP CCountDaily::GetDailyCount(DATE dDate, LONG* iCount)
  32. {
  33. CReportCountDaily pRep;
  34. COleDateTime pDate(dDate);
  35. long lCount = 0;
  36. pRep.m_ReportDate.year = pDate.GetYear();
  37. pRep.m_ReportDate.day = pDate.GetDay();
  38. pRep.m_ReportDate.month = pDate.GetMonth();
  39. pRep.m_ReportDate.hour = 0;
  40. pRep.m_ReportDate.minute = 0;
  41. pRep.m_ReportDate.second = 0;
  42. pRep.m_ReportDate.fraction = 0;
  43. HRESULT hr = pRep.OpenAll();
  44. _ASSERTE(SUCCEEDED(hr));
  45. if(SUCCEEDED(hr)==false)
  46. {
  47. Error(_T("Unable to open the database"));
  48. return E_FAIL;
  49. }
  50. hr = S_OK;
  51. hr = pRep.MoveFirst();
  52. _ASSERTE(SUCCEEDED(hr));
  53. if(SUCCEEDED(hr)==false)
  54. {
  55. Error(_T("No data was returned"));
  56. return E_FAIL;
  57. }
  58. lCount = pRep.m_IncidentID;
  59. *iCount = lCount;
  60. pRep.CloseAll();
  61. return S_OK;
  62. }
  63. /*************************************************************************************
  64. * module: CountDaily.cpp
  65. *
  66. * author: Tim Ragain
  67. * date: Jan 2, 2002
  68. *
  69. * Purpose: To return an ado recordset from the results of calling stored procedure
  70. * ReportCountDaily. Presently this is not used but left for future implementation.
  71. *
  72. *************************************************************************************/
  73. STDMETHODIMP CCountDaily::GetDailyCountADO(DATE dDate, LONG* iCount)
  74. {
  75. _RecordsetPtr pRs("ADODB.Recordset");
  76. _ConnectionPtr pCn("ADODB.Connection");
  77. _CommandPtr pCm("ADODB.Command");
  78. _ParameterPtr pPa("ADODB.Parameter");
  79. VARIANT v_stamp;
  80. ErrorPtr pErr = NULL;
  81. COleDateTime pDate(dDate);
  82. v_stamp.vt = VT_CY;
  83. v_stamp.date = dDate;
  84. pCn->Open(L"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=KaCustomer2;Data Source=OCATOOLSDB;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=TIMRAGAIN05;Use Encryption for Data=False;Tag with column collation when possible=False","", "", NULL);
  85. if((pCn->Errors->Count) > 0)
  86. {
  87. pErr = pCn->Errors->GetItem(0);
  88. return E_FAIL;
  89. }
  90. pCm->ActiveConnection = pCn;
  91. pCm->CommandText = "ReportCountDaily";
  92. pCm->CommandType = adCmdText;
  93. pPa = pCm->CreateParameter("ReportDate", adDBTimeStamp, adParamInput, NULL, dDate);
  94. pCm->Parameters->Append(pPa);
  95. pPa->Value = v_stamp.date;
  96. pRs = pCm->Execute(NULL, NULL, adCmdStoredProc);
  97. if((pCn->Errors->Count) > 0)
  98. {
  99. pErr = pCn->Errors->GetItem(0);
  100. return E_FAIL;
  101. }
  102. if(pRs->State != adStateOpen)
  103. {
  104. return E_FAIL;
  105. }
  106. HRESULT hr = pRs->MoveFirst();
  107. _ASSERTE(SUCCEEDED(hr));
  108. if(SUCCEEDED(hr)==false)
  109. {
  110. return E_FAIL;
  111. }
  112. *iCount = pRs->Fields->Item["iCount"]->Value;
  113. pRs->Close();
  114. pCn->Close();
  115. pPa = NULL;
  116. pCm = NULL;
  117. pCn = NULL;
  118. pRs = NULL;
  119. return S_OK;
  120. }
  121. /*************************************************************************************
  122. * module: CountDaily.cpp
  123. *
  124. * author: Tim Ragain
  125. * date: Jan 2, 2002
  126. *
  127. * Purpose: To return an ADO recordset of daily buckets for a specific date.
  128. * This is presently not used but remains for future use.
  129. *
  130. *************************************************************************************/
  131. STDMETHODIMP CCountDaily::ReportDailyBuckets(DATE dDate, IDispatch** p_Rs)
  132. {
  133. CReportDailyBuckets pRep;
  134. COleDateTime pDate(dDate);
  135. pRep.m_ReportDate.year = pDate.GetYear();
  136. pRep.m_ReportDate.day = pDate.GetDay();
  137. pRep.m_ReportDate.month = pDate.GetMonth();
  138. pRep.m_ReportDate.hour = 0;
  139. pRep.m_ReportDate.minute = 0;
  140. pRep.m_ReportDate.second = 0;
  141. pRep.m_ReportDate.fraction = 0;
  142. HRESULT hr = pRep.OpenAll();
  143. _ASSERTE(SUCCEEDED(hr));
  144. if(SUCCEEDED(hr)==false)
  145. {
  146. return E_FAIL;
  147. }
  148. hr = pRep.MoveFirst();
  149. _ASSERTE(SUCCEEDED(hr));
  150. if(SUCCEEDED(hr)==false)
  151. {
  152. return E_FAIL;
  153. }
  154. ADORecordsetConstructionPtr pCRS;
  155. _RecordsetPtr pTempRS(__uuidof(Recordset));
  156. pCRS = pTempRS;
  157. hr = pCRS->put_Rowset((LPUNKNOWN)(pRep.m_spRowset));
  158. _ASSERTE(SUCCEEDED(hr));
  159. if(SUCCEEDED(hr)==false)
  160. {
  161. return E_FAIL;
  162. }
  163. hr = pCRS->QueryInterface(__uuidof(_Recordset),(void **)p_Rs);
  164. if(SUCCEEDED(hr)==false)
  165. {
  166. return E_FAIL;
  167. }
  168. pRep.CloseAll();
  169. return S_OK;
  170. }
  171. /*************************************************************************************
  172. * module: CountDaily.cpp
  173. *
  174. * author: Tim Ragain
  175. * date: Jan 2, 2002
  176. *
  177. * Purpose: to count the specific files for a specific date on the Watson or Archive server.
  178. * The directory format is different on each server. The watson uses "1_2_2002" while the Archive uses
  179. * "1-2-2002".
  180. *************************************************************************************/
  181. STDMETHODIMP CCountDaily::GetFileCount(ServerLocation eServer, BSTR b_Location, DATE d_Date, LONG* iCount)
  182. {
  183. HANDLE hSearch=NULL;
  184. WIN32_FIND_DATA FileData;
  185. LONG l_FileCount = 0;
  186. CComBSTR b_Path, b_DateDirectory;
  187. COleDateTime pDate(d_Date);
  188. LONG l_Day = 0, l_Year = 0, l_Month = 0;
  189. char * s_Temp;
  190. //LPCSTR szFindFiles;
  191. TCHAR * szFindFiles;
  192. USES_CONVERSION;
  193. s_Temp = new char;
  194. b_Path.AppendBSTR(b_Location);
  195. l_Day = pDate.GetDay();
  196. l_Year = pDate.GetYear();
  197. l_Month = pDate.GetMonth();
  198. //month
  199. _itoa(l_Month, s_Temp, 10);
  200. b_DateDirectory.Append(s_Temp);
  201. if(eServer==0)
  202. {
  203. b_DateDirectory.Append(cScore);
  204. }
  205. else
  206. {
  207. b_DateDirectory.Append(cDash);
  208. }
  209. //Day
  210. _itoa(l_Day, s_Temp, 10);
  211. b_DateDirectory.Append(s_Temp);
  212. if(eServer==0)
  213. {
  214. b_DateDirectory.Append(cScore);
  215. }
  216. else
  217. {
  218. b_DateDirectory.Append(cDash);
  219. }
  220. //Year
  221. _itoa(l_Year, s_Temp, 10);
  222. b_DateDirectory.Append(s_Temp);
  223. b_Path.AppendBSTR(b_DateDirectory);
  224. b_Path.Append("\\");
  225. b_Path.Append("*.cab");
  226. szFindFiles = OLE2T(b_Path);
  227. hSearch = FindFirstFile(szFindFiles, &FileData);
  228. if (hSearch == INVALID_HANDLE_VALUE)
  229. {
  230. l_FileCount = 0;
  231. *iCount = l_FileCount;
  232. return S_OK;
  233. }
  234. l_FileCount = 0;
  235. do
  236. {
  237. l_FileCount++;
  238. } while(FindNextFile(hSearch, &FileData));
  239. *iCount = l_FileCount;
  240. FindClose(hSearch);
  241. return S_OK;
  242. }
  243. /*************************************************************************************
  244. * module: CountDaily.cpp
  245. *
  246. * author: Tim Ragain
  247. * date: Jan 2, 2002
  248. *
  249. * Purpose: To count the anonymous users uploading files for a specific date. This uses
  250. * the OLEDB template CReportAnonUsers.h that calls the stored procedure ReportGetAnonUsers.
  251. *
  252. *************************************************************************************/
  253. STDMETHODIMP CCountDaily::GetDailyAnon(DATE dDate, LONG* iCount)
  254. {
  255. CReportAnonUsers pRep;
  256. COleDateTime pDate(dDate);
  257. long lCount = 0;
  258. pRep.m_ReportDate.year = pDate.GetYear();
  259. pRep.m_ReportDate.day = pDate.GetDay();
  260. pRep.m_ReportDate.month = pDate.GetMonth();
  261. pRep.m_ReportDate.hour = 0;
  262. pRep.m_ReportDate.minute = 0;
  263. pRep.m_ReportDate.second = 0;
  264. pRep.m_ReportDate.fraction = 0;
  265. HRESULT hr = pRep.OpenAll();
  266. _ASSERTE(SUCCEEDED(hr));
  267. if(SUCCEEDED(hr)==false)
  268. {
  269. return E_FAIL;
  270. }
  271. hr = S_OK;
  272. hr = pRep.MoveFirst();
  273. _ASSERTE(SUCCEEDED(hr));
  274. if(SUCCEEDED(hr)==false)
  275. {
  276. return E_FAIL;
  277. }
  278. lCount = pRep.m_Count;
  279. *iCount = lCount;
  280. pRep.CloseAll();
  281. return S_OK;
  282. }
  283. /*************************************************************************************
  284. * module: CountDaily.cpp
  285. *
  286. * author: Tim Ragain
  287. * date: Jan 2, 2002
  288. *
  289. * Purpose: To count the specific solutions, SBuckets, for a specific date. This calls
  290. * the OLEDB template CReportSpecificSolutions.h that uses the stored procedure
  291. * ReportGetSBuckets.
  292. *************************************************************************************/
  293. STDMETHODIMP CCountDaily::GetSpecificSolutions(DATE dDate, LONG* iCount)
  294. {
  295. CReportSpecificSolutions pRep;
  296. COleDateTime pDate(dDate);
  297. long lCount = 0;
  298. pRep.m_ReportDate.year = pDate.GetYear();
  299. pRep.m_ReportDate.day = pDate.GetDay();
  300. pRep.m_ReportDate.month = pDate.GetMonth();
  301. pRep.m_ReportDate.hour = 0;
  302. pRep.m_ReportDate.minute = 0;
  303. pRep.m_ReportDate.second = 0;
  304. pRep.m_ReportDate.fraction = 0;
  305. HRESULT hr = pRep.OpenAll();
  306. _ASSERTE(SUCCEEDED(hr));
  307. if(SUCCEEDED(hr)==false)
  308. {
  309. return E_FAIL;
  310. }
  311. hr = S_OK;
  312. hr = pRep.MoveFirst();
  313. _ASSERTE(SUCCEEDED(hr));
  314. if(SUCCEEDED(hr)==false)
  315. {
  316. return E_FAIL;
  317. }
  318. lCount = pRep.m_Count;
  319. *iCount = lCount;
  320. pRep.CloseAll();
  321. return S_OK;
  322. }
  323. /*************************************************************************************
  324. * module: CountDaily.cpp
  325. *
  326. * author: Tim Ragain
  327. * date: Jan 2, 2002
  328. *
  329. * Purpose: To obtain a count for a specific date of the GBuckets that have no solved SBucket. This
  330. * uses the OLEDB template located in CReportGeneralSolutions.h file that calls the stored procedure
  331. * ReportGetGBucket.
  332. *************************************************************************************/
  333. STDMETHODIMP CCountDaily::GetGeneralSolutions(DATE dDate, LONG* iCount)
  334. {
  335. CReportGeneralSolutions pRep;
  336. COleDateTime pDate(dDate);
  337. long lCount = 0;
  338. pRep.m_ReportDate.year = pDate.GetYear();
  339. pRep.m_ReportDate.day = pDate.GetDay();
  340. pRep.m_ReportDate.month = pDate.GetMonth();
  341. pRep.m_ReportDate.hour = 0;
  342. pRep.m_ReportDate.minute = 0;
  343. pRep.m_ReportDate.second = 0;
  344. pRep.m_ReportDate.fraction = 0;
  345. HRESULT hr = pRep.OpenAll();
  346. _ASSERTE(SUCCEEDED(hr));
  347. if(SUCCEEDED(hr)==false)
  348. {
  349. return E_FAIL;
  350. }
  351. hr = S_OK;
  352. hr = pRep.MoveFirst();
  353. _ASSERTE(SUCCEEDED(hr));
  354. if(SUCCEEDED(hr)==false)
  355. {
  356. return E_FAIL;
  357. }
  358. lCount = pRep.m_Count;
  359. *iCount = lCount;
  360. pRep.CloseAll();
  361. return S_OK;
  362. }
  363. /*************************************************************************************
  364. * module: CountDaily.cpp
  365. *
  366. * author: Tim Ragain
  367. * date: Jan 2, 2002
  368. *
  369. * Purpose: To obtain the count of incidents on a specific date that have StopCode solutions
  370. * but they do not have a SBucket or GBucket. This uses the OLEDB template located in CReportGetHelpInfo.h
  371. * and the stored procedure ReportGetHelpInfo
  372. *************************************************************************************/
  373. STDMETHODIMP CCountDaily::GetStopCodeSolutions(DATE dDate, LONG* iCount)
  374. {
  375. CReportGetHelpInfo pRep;
  376. COleDateTime pDate(dDate);
  377. long lCount = 0;
  378. pRep.m_dDate.year = pDate.GetYear();
  379. pRep.m_dDate.day = pDate.GetDay();
  380. pRep.m_dDate.month = pDate.GetMonth();
  381. pRep.m_dDate.hour = 0;
  382. pRep.m_dDate.minute = 0;
  383. pRep.m_dDate.second = 0;
  384. pRep.m_dDate.fraction = 0;
  385. CComPtr<ICommand> cm = pRep.m_spCommand;
  386. HACCESSOR ac = pRep.m_hParameterAccessor;
  387. HRESULT hr = pRep.OpenAll();
  388. _ASSERTE(SUCCEEDED(hr));
  389. if(SUCCEEDED(hr)==false)
  390. {
  391. return E_FAIL;
  392. }
  393. hr = S_OK;
  394. hr = pRep.MoveFirst();
  395. _ASSERTE(SUCCEEDED(hr));
  396. if(SUCCEEDED(hr)==false)
  397. {
  398. return E_FAIL;
  399. }
  400. lCount = pRep.m_iCount;
  401. *iCount = lCount;
  402. pRep.CloseAll();
  403. return S_OK;
  404. }
  405. /*************************************************************************************
  406. * module: CountDaily.cpp
  407. *
  408. * author: Tim Ragain
  409. * date: Jan 2, 2002
  410. *
  411. * Purpose: to count the files on the Watson or Archive server that contain "Mini" in the file name.
  412. * This is a physical count of the actual files on the servers that were manually uploaded.
  413. *
  414. *************************************************************************************/
  415. STDMETHODIMP CCountDaily::GetFileMiniCount(ServerLocation eServer, BSTR b_Location, DATE d_Date, LONG* iCount)
  416. {
  417. HANDLE hSearch=NULL;
  418. WIN32_FIND_DATA FileData;
  419. LONG l_FileCount = 0;
  420. CComBSTR b_Path, b_DateDirectory;
  421. COleDateTime pDate(d_Date);
  422. LONG l_Day = 0, l_Year = 0, l_Month = 0;
  423. char * s_Temp;
  424. //LPCSTR szFindFiles;
  425. TCHAR * szFindFiles = new TCHAR[MAX_PATH];
  426. USES_CONVERSION;
  427. s_Temp = new char;
  428. b_Path.AppendBSTR(b_Location);
  429. l_Day = pDate.GetDay();
  430. l_Year = pDate.GetYear();
  431. l_Month = pDate.GetMonth();
  432. //month
  433. _itoa(l_Month, s_Temp, 10);
  434. b_DateDirectory.Append(s_Temp);
  435. if(eServer==0)
  436. {
  437. b_DateDirectory.Append(cScore);
  438. }
  439. else
  440. {
  441. b_DateDirectory.Append(cDash);
  442. }
  443. //Day
  444. _itoa(l_Day, s_Temp, 10);
  445. b_DateDirectory.Append(s_Temp);
  446. if(eServer==0)
  447. {
  448. b_DateDirectory.Append(cScore);
  449. }
  450. else
  451. {
  452. b_DateDirectory.Append(cDash);
  453. }
  454. //Year
  455. _itoa(l_Year, s_Temp, 10);
  456. b_DateDirectory.Append(s_Temp);
  457. b_Path.AppendBSTR(b_DateDirectory);
  458. b_Path.Append("\\");
  459. b_Path.Append("*Mini.cab");
  460. szFindFiles = OLE2T(b_Path);
  461. hSearch = FindFirstFile(szFindFiles, &FileData);
  462. if (hSearch == INVALID_HANDLE_VALUE)
  463. {
  464. *iCount = 0;
  465. return S_OK;
  466. }
  467. l_FileCount = 0;
  468. do
  469. {
  470. l_FileCount++;
  471. } while(FindNextFile(hSearch, &FileData));
  472. *iCount = l_FileCount;
  473. FindClose(hSearch);
  474. return S_OK;
  475. }
  476. /*************************************************************************************
  477. * module: CountDaily.cpp
  478. *
  479. * author: Tim Ragain
  480. * date: Jan 23, 2002
  481. *
  482. * Purpose: Routine return the count for auto uploads by checking where null is in the path
  483. * set in the database. Null indicates a failed upload. The routine calls CReportGetIncompleteUploads.h
  484. * OLEDB template, which uses the ReportGetIncompleteUploads stored procedure.
  485. *************************************************************************************/
  486. STDMETHODIMP CCountDaily::GetIncompleteUploads(DATE dDate, LONG* iCount)
  487. {
  488. CReportGetIncompleteUploads pRep;
  489. COleDateTime pDate(dDate);
  490. long lCount = 0;
  491. pRep.m_ReportDate.year = pDate.GetYear();
  492. pRep.m_ReportDate.day = pDate.GetDay();
  493. pRep.m_ReportDate.month = pDate.GetMonth();
  494. pRep.m_ReportDate.hour = 0;
  495. pRep.m_ReportDate.minute = 0;
  496. pRep.m_ReportDate.second = 0;
  497. pRep.m_ReportDate.fraction = 0;
  498. HRESULT hr = pRep.OpenAll();
  499. _ASSERTE(SUCCEEDED(hr));
  500. if(SUCCEEDED(hr)==false)
  501. {
  502. return E_FAIL;
  503. }
  504. hr = S_OK;
  505. hr = pRep.MoveFirst();
  506. _ASSERTE(SUCCEEDED(hr));
  507. if(SUCCEEDED(hr)==false)
  508. {
  509. return E_FAIL;
  510. }
  511. lCount = pRep.m_Count;
  512. *iCount = lCount;
  513. pRep.CloseAll();
  514. return S_OK;
  515. }
  516. /*************************************************************************************
  517. * module: CountDaily.cpp
  518. *
  519. * author: Tim Ragain
  520. * date: Jan 23, 2002
  521. *
  522. * Purpose: Routine return the count for auto uploads by checking where "Mini" is in the path
  523. * set in the database. Mini indicates a manual upload. The routine calls CReportGetManualUploads.h
  524. * OLEDB template, which uses the ReportGetManualUploads stored procedure.
  525. *************************************************************************************/
  526. STDMETHODIMP CCountDaily::GetManualUploads(DATE dDate, LONG* iCount)
  527. {
  528. CReportGetManualUploads pRep;
  529. COleDateTime pDate(dDate);
  530. long lCount = 0;
  531. pRep.m_ReportDate.year = pDate.GetYear();
  532. pRep.m_ReportDate.day = pDate.GetDay();
  533. pRep.m_ReportDate.month = pDate.GetMonth();
  534. pRep.m_ReportDate.hour = 0;
  535. pRep.m_ReportDate.minute = 0;
  536. pRep.m_ReportDate.second = 0;
  537. pRep.m_ReportDate.fraction = 0;
  538. HRESULT hr = pRep.OpenAll();
  539. _ASSERTE(SUCCEEDED(hr));
  540. if(SUCCEEDED(hr)==false)
  541. {
  542. return E_FAIL;
  543. }
  544. hr = S_OK;
  545. hr = pRep.MoveFirst();
  546. _ASSERTE(SUCCEEDED(hr));
  547. if(SUCCEEDED(hr)==false)
  548. {
  549. return E_FAIL;
  550. }
  551. lCount = pRep.m_Count;
  552. *iCount = lCount;
  553. pRep.CloseAll();
  554. return S_OK;
  555. }
  556. /*************************************************************************************
  557. * module: CountDaily.cpp
  558. *
  559. * author: Tim Ragain
  560. * date: Jan 23, 2002
  561. *
  562. * Purpose: Routine return the count for auto uploads by checking where "Mini" is not in the path
  563. * set in the database. Mini indicates a manual upload. The routine calls CReportGetAutoUploads.h
  564. * OLEDB template, which uses the ReportGetAutoUploads stored procedure.
  565. *************************************************************************************/
  566. STDMETHODIMP CCountDaily::GetAutoUploads(DATE dDate, LONG* iCount)
  567. {
  568. CReportGetAutoUploads pRep;
  569. COleDateTime pDate(dDate);
  570. long lCount = 0;
  571. pRep.m_ReportDate.year = pDate.GetYear();
  572. pRep.m_ReportDate.day = pDate.GetDay();
  573. pRep.m_ReportDate.month = pDate.GetMonth();
  574. pRep.m_ReportDate.hour = 0;
  575. pRep.m_ReportDate.minute = 0;
  576. pRep.m_ReportDate.second = 0;
  577. pRep.m_ReportDate.fraction = 0;
  578. HRESULT hr = pRep.OpenAll();
  579. _ASSERTE(SUCCEEDED(hr));
  580. if(SUCCEEDED(hr)==false)
  581. {
  582. return E_FAIL;
  583. }
  584. hr = S_OK;
  585. hr = pRep.MoveFirst();
  586. _ASSERTE(SUCCEEDED(hr));
  587. if(SUCCEEDED(hr)==false)
  588. {
  589. return E_FAIL;
  590. }
  591. lCount = pRep.m_Count;
  592. *iCount = lCount;
  593. pRep.CloseAll();
  594. return S_OK;
  595. }
  596. //ICreateErrorInfo * err;
  597. //HRESULT HRerr;
  598. //HRerr = CreateErrorInfo(&err);
  599. //MessageBox(NULL, "Failed to open database!", "Database Error", MB_OK);
  600. //if(SUCCEEDED(HRerr))
  601. //{
  602. // err->SetDescription(L"Failed to open the database");
  603. // IErrorInfo *pEI;
  604. // HR2 = err->QueryInterface(IID_IErrorInfo, (void**)&pEI);
  605. // if(SUCCEEDED(HR2))
  606. // {
  607. // SetErrorInfo(0, pEI);
  608. // err->Release();
  609. // }
  610. // pEI->Release();
  611. //}
  612. /*
  613. char * sDate = new char;
  614. int iDate = oDate.GetDay();
  615. itoa(iDate, sDate, 10);
  616. MessageBox(NULL, sDate, "Year", MB_OK);
  617. return S_OK;
  618. delete(sDate);
  619. //memset(szFindFiles, 0, sizeof(szFindFiles));
  620. //TCHAR * t_Temp;
  621. //t_Temp = (TCHAR *)b_Location;
  622. */
  623. STDMETHODIMP CCountDaily::GetTest(ServerLocation eServer, BSTR b_Location, DATE d_Date, LONG* iCount)
  624. {
  625. HANDLE hSearch=NULL;
  626. WIN32_FIND_DATA FileData;
  627. LONG l_FileCount = 0;
  628. CComBSTR b_Path, b_DateDirectory;
  629. COleDateTime pDate(d_Date);
  630. LONG l_Day = 0, l_Year = 0, l_Month = 0;
  631. char * s_Temp;
  632. //LPCSTR szFindFiles;
  633. TCHAR * szFindFiles;
  634. USES_CONVERSION;
  635. s_Temp = new char;
  636. b_Path.AppendBSTR(b_Location);
  637. l_Day = pDate.GetDay();
  638. l_Year = pDate.GetYear();
  639. l_Month = pDate.GetMonth();
  640. //month
  641. _itoa(l_Month, s_Temp, 10);
  642. b_DateDirectory.Append(s_Temp);
  643. if(eServer==0)
  644. {
  645. b_DateDirectory.Append(cScore);
  646. }
  647. else
  648. {
  649. b_DateDirectory.Append(cDash);
  650. }
  651. //Day
  652. _itoa(l_Day, s_Temp, 10);
  653. b_DateDirectory.Append(s_Temp);
  654. if(eServer==0)
  655. {
  656. b_DateDirectory.Append(cScore);
  657. }
  658. else
  659. {
  660. b_DateDirectory.Append(cDash);
  661. }
  662. //Year
  663. _itoa(l_Year, s_Temp, 10);
  664. b_DateDirectory.Append(s_Temp);
  665. b_Path.AppendBSTR(b_DateDirectory);
  666. b_Path.Append("\\\\");
  667. b_Path.Append("*.cab");
  668. szFindFiles = OLE2T(b_Path);
  669. hSearch = FindFirstFile(szFindFiles, &FileData);
  670. if (hSearch == INVALID_HANDLE_VALUE)
  671. {
  672. l_FileCount = 0;
  673. *iCount = l_FileCount;
  674. return S_OK;
  675. }
  676. l_FileCount = 0;
  677. do
  678. {
  679. l_FileCount++;
  680. } while(FindNextFile(hSearch, &FileData));
  681. *iCount = l_FileCount;
  682. FindClose(hSearch);
  683. return S_OK;
  684. }