mod_guiconsole.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. #include "stdafx2.h"
  2. #include "mod_GuiConsole.h"
  3. #include "guitask.h"
  4. #include "EventCode.h"
  5. #include "MaterialMgrCnn.h"
  6. #include "CardIssuer_client_g.h"
  7. using namespace CardIssuer;
  8. #include "MaintainWatcher_client_g.h"
  9. using namespace MaintainWatcher;
  10. void CGUIConsoleEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  11. {
  12. m_FSM.Init(this);
  13. auto rc = SubscribeEntitysEvents();
  14. if (rc != Error_Succeed)
  15. Dbg("subscribe MaintainWatcher event fail, %s", SpStrError(rc));
  16. else
  17. Dbg("subscribe MaintainWatcher event succeed");
  18. pTransactionContext->SendAnswer(Error_Succeed) ;
  19. }
  20. void CGUIConsoleEntity::OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  21. {
  22. m_FSM.PostExitEvent();
  23. UnsubscribeEntitysEvents();
  24. pTransactionContext->SendAnswer(Error_Succeed);
  25. }
  26. CServerSessionBase *CGUIConsoleEntity::OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszParam*/)
  27. {
  28. return new CGUIConsoleSession(this);
  29. }
  30. void CGUIConsoleEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  31. const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  32. const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage)
  33. {
  34. Dbg("OnLog(entity = %s, syscode = 0x%X, usercode = 0x%X", pszEntityName, dwSysError, dwUserCode);
  35. if (dwUserCode == EVENT_MACHINE_COVER_OPEN) // 机盖打开
  36. {
  37. Dbg("the machine cover open!!");
  38. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_CoverOpen));
  39. }
  40. else if (dwUserCode == EVENT_MACHINE_COVER_CLOSE) // 机盖关闭
  41. {
  42. Dbg("the machine cover close.");
  43. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_CoverClose));
  44. }
  45. else if (dwUserCode == EVENT_UKEY_INSERTED) // 证书插入
  46. {
  47. Dbg("the key inserted");
  48. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_UKeyInserted));
  49. }
  50. else if ((dwUserCode == EVENT_UKEY_LOW_LEVEL) // 具有维护权
  51. || (dwUserCode == EVENT_UKEY_HIGH_LEVEL)) // 具有高级权限)
  52. {
  53. bool bLowLevel = dwUserCode == EVENT_UKEY_LOW_LEVEL;
  54. if (bLowLevel)
  55. Dbg("lower priviledge");
  56. else
  57. Dbg("higher priviledge");
  58. // 调用UKey接口取维护人员信息
  59. m_strUserID = "";
  60. m_strUserName = "";
  61. m_strAuthorizer = "";
  62. m_strAuthTime = "";
  63. MaintainCertificate_ClientBase *pClient = new MaintainCertificate_ClientBase(this);
  64. auto rc = pClient->Connect();
  65. if (rc != Error_Succeed)
  66. {
  67. Dbg("connect to MaintainWatcher entity fail: %d", rc);
  68. pClient->SafeDelete();
  69. }
  70. else
  71. {
  72. MaintainCertificate_GetUserInfo_Req req = {};
  73. MaintainCertificate_GetUserInfo_Ans ans = {};
  74. rc = pClient->GetUserInfo(req, ans, 10000);
  75. if (rc != Error_Succeed)
  76. {
  77. Dbg("get userinfo fail from MaintainWatcher: %s", SpStrError(rc));
  78. }
  79. else
  80. {
  81. // UserID=SP00000004;UserName=RVC0001;AuthorierID=SP00000001;AuthorizeTime=2014/8/13 18:46:29;RecommenderSAP=80274390;RecommenderOfficeID=274390;
  82. CSimpleStringA &str = ans.UserInfo;
  83. Dbg("get maintainer info: %s", (const char*)str);
  84. auto arr = str.Split(';');
  85. for (int i = 0; i < arr.GetCount(); i++)
  86. {
  87. auto arr2 = arr[i].Split('=');
  88. if (arr2.GetCount() != 2)
  89. continue;
  90. if (arr2[0] == "UserID")
  91. m_strUserID = arr2[1];
  92. else if (arr2[0] == "UserName")
  93. m_strUserName = arr2[1];
  94. else if (arr2[0] == "AuthorierID")
  95. m_strAuthorizer = arr2[1];
  96. else if (arr2[0] == "AuthorizeTime")
  97. m_strAuthTime = arr2[1];
  98. }
  99. }
  100. pClient->GetFunction()->CloseSession();
  101. }
  102. pClient = NULL;
  103. m_strCurRight = bLowLevel ? "Low" : "High";
  104. m_dwBeginTime = CSmallDateTime::GetNow();
  105. auto pEvent = new FSMEvent(CGUIConsoleFSM::Event_CertVerified);
  106. pEvent->param1 = bLowLevel ? 1 : 2;
  107. m_FSM.PostEventFIFO(pEvent);
  108. }
  109. else if (dwUserCode == EVENT_UKEY_PULLOUT) // 证书拔出
  110. {
  111. m_strUserID = "";
  112. m_strUserName = "";
  113. m_strAuthorizer = "";
  114. m_strAuthTime = "";
  115. m_strCurRight = "";
  116. m_dwBeginTime = 0;
  117. Dbg("certificate key pull out");
  118. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_UKeyPulled));
  119. }
  120. else if (dwUserCode == LOG_EVT_HEALTH_FIRST_ENTER_MAINPADE)
  121. {
  122. // IE首页打开, 关闭运行输出
  123. Dbg("IE main page has been loaded successfully, close console terminal!");
  124. GetFunction()->GetPrivilegeFunction()->CloseOuputConsole();
  125. }
  126. }
  127. ErrorCodeEnum CGUIConsoleEntity::SubscribeEntitysEvents()
  128. {
  129. auto pFunc = GetFunction();
  130. auto rc = pFunc->SubscribeLog(m_SubLogID1, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "MaintainWatcher");
  131. rc = pFunc->SubscribeLog(m_SubLogID2, this, Log_Event, Severity_None, Error_IgnoreAll, -1, "Gpio");
  132. // 业务首页加载事件
  133. rc = pFunc->SubscribeLog(m_SubLogID3, this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_HEALTH_FIRST_ENTER_MAINPADE, "HealthManager");
  134. return rc;
  135. }
  136. ErrorCodeEnum CGUIConsoleEntity::UnsubscribeEntitysEvents()
  137. {
  138. auto pFunc = GetFunction();
  139. if ((__int64)m_SubLogID1 != 0)
  140. pFunc->UnsubscribeLog(m_SubLogID1);
  141. if ((__int64)m_SubLogID2 != 0)
  142. pFunc->UnsubscribeLog(m_SubLogID2);
  143. if ((__int64)m_SubLogID3 != 0)
  144. pFunc->UnsubscribeLog(m_SubLogID3);
  145. return Error_Succeed;
  146. }
  147. ErrorCodeEnum CGUIConsoleEntity::GetCurrentMaintainer(CSimpleStringA &strUserID, CSimpleStringA &strUserName, CSimpleStringA &strCurRight,
  148. CSimpleStringA &strAuthorizer, unsigned int &dwBeginTime)
  149. {
  150. strUserID = m_strUserID;
  151. strUserName = m_strUserName;
  152. strCurRight = m_strCurRight;
  153. strAuthorizer = m_strAuthorizer;
  154. dwBeginTime = m_dwBeginTime;
  155. return Error_Succeed;
  156. }
  157. ErrorCodeEnum CGUIConsoleEntity::Empower(const char *pszUserID)
  158. {
  159. if (m_strUserID.IsNullOrEmpty() || m_strUserID.Compare(pszUserID) != 0)
  160. return Error_NoPrivilege;
  161. m_strCurRight = "High";
  162. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_HighLevel));
  163. return Error_Succeed;
  164. }
  165. ErrorCodeEnum CGUIConsoleEntity::Takeover(const char *pszUserID)
  166. {
  167. if (m_strUserID.IsNullOrEmpty() || m_strUserID.Compare(pszUserID) != 0)
  168. return Error_NoPrivilege;
  169. m_strCurRight = "Low";
  170. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_Takeover));
  171. return Error_Succeed;
  172. }
  173. ErrorCodeEnum CGUIConsoleEntity::ForceQuit()
  174. {
  175. m_strUserID = "";
  176. m_strUserName = "";
  177. m_strAuthorizer = "";
  178. m_strAuthTime = "";
  179. m_strCurRight = "";
  180. m_dwBeginTime = 0;
  181. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_ForceQuit));
  182. return Error_Succeed;
  183. }
  184. ErrorCodeEnum CGUIConsoleEntity::PostUserLoginEvent(const char *pszUserID)
  185. {
  186. m_strUserID = pszUserID;
  187. m_strUserName = pszUserID;
  188. m_strAuthorizer = "";
  189. m_strAuthTime = "";
  190. m_strCurRight = "Low";
  191. m_dwBeginTime = CSmallDateTime::GetNow();
  192. m_FSM.PostEventFIFO(new FSMEvent(CGUIConsoleFSM::Event_CoverOpen));
  193. auto pEvent = new FSMEvent(CGUIConsoleFSM::Event_CertVerified);
  194. pEvent->param1 = 1;
  195. m_FSM.PostEventFIFO(pEvent);
  196. return Error_Succeed;
  197. }
  198. ErrorCodeEnum CGUIConsoleEntity::AddTradeManage(const char *pszTerminalNo, const char *pszAgentID, const char *pszTime)
  199. {
  200. Dbg("AddTradeManage: %s, %s, %s", pszTerminalNo, pszAgentID, pszTime);
  201. ErrorCodeEnum rc = Error_Succeed;
  202. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  203. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  204. {
  205. rc = pCnn->AddTradeManage(pszTerminalNo, pszAgentID, pszTime);
  206. pCnn->Close();
  207. }
  208. else
  209. {
  210. Dbg("连接物料服务失败");
  211. rc = Error_NetBroken;
  212. }
  213. pCnn->DecRefCount();
  214. pCnn = NULL;
  215. if (Error_Succeed != rc)
  216. Dbg("mod AddTradeManage return : %s", SpStrError(rc));
  217. return rc;
  218. }
  219. ErrorCodeEnum CGUIConsoleEntity::AddMaterialCounter(const char *pszMaterialCode)
  220. {
  221. // 递增后台计数
  222. Dbg("AddMaterialCounter: %s", pszMaterialCode);
  223. CSystemStaticInfo sysInfo;
  224. auto rc = GetFunction()->GetSystemStaticInfo(sysInfo);
  225. assert(rc == Error_Succeed);
  226. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  227. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  228. {
  229. rc = pCnn->AddMaterialCounter(sysInfo.strTerminalID, pszMaterialCode);
  230. pCnn->Close();
  231. }
  232. else
  233. {
  234. Dbg("Connect to MaterialMgrEntity failed!");
  235. rc = Error_NetBroken;
  236. }
  237. pCnn->DecRefCount();
  238. pCnn = NULL;
  239. if (rc == Error_Succeed)
  240. {
  241. Dbg("Add material counter for %s succ.", pszMaterialCode);
  242. }
  243. else
  244. {
  245. LogError(Severity_Middle, rc, 0, CSimpleStringA::Format("add material counter failed: %s", SpStrError(rc)));
  246. }
  247. return rc;
  248. }
  249. //查询物料信息
  250. ErrorCodeEnum CGUIConsoleEntity::QueryMaterialInfo(const char *pszDeviceNo, unsigned int &count, CAutoArray<CSimpleStringA> &arrDeviceNo, CAutoArray<CSimpleStringA> &arrMateriel,
  251. CAutoArray<CSimpleStringA> &CardGroove, CAutoArray<CSimpleStringA> &CardBoxNo, CAutoArray<CSimpleStringA> &PsbCode, CAutoArray<CSimpleStringA> &PsbName,
  252. CAutoArray<unsigned int> &CardInit, CAutoArray<unsigned int> &CardRemains, CAutoArray<unsigned int> &CardIssued, CAutoArray<unsigned int> &CardMixed,
  253. CAutoArray<unsigned int> &CardPercent, CAutoArray<CSimpleStringA> &TerminalNo, CAutoArray<CSimpleStringA> &Maintainer, CAutoArray<CSimpleStringA> &MaintainTime,
  254. CAutoArray<CSimpleStringA> &UpdateTime)
  255. {
  256. Dbg("QueryMaterialInfo DeviceNo = %s", pszDeviceNo);
  257. ErrorCodeEnum rc = Error_Succeed;
  258. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  259. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  260. {
  261. CSystemStaticInfo sysInfo;
  262. auto rc = GetFunction()->GetSystemStaticInfo(sysInfo);
  263. assert(rc == Error_Succeed);
  264. rc = pCnn->QueryMaterialInfo(pszDeviceNo, count, arrDeviceNo, arrMateriel, CardGroove, CardBoxNo, PsbCode, PsbName, CardInit, CardRemains, CardIssued, CardMixed,
  265. CardPercent, TerminalNo, Maintainer, MaintainTime, UpdateTime);
  266. pCnn->Close();
  267. }
  268. else
  269. {
  270. Dbg("Connect to MaterialMgr failed!");
  271. rc = Error_NetBroken;
  272. }
  273. pCnn->DecRefCount();
  274. pCnn = NULL;
  275. return rc;
  276. }
  277. ErrorCodeEnum CGUIConsoleEntity::GetMaterialCounter(const char *pszMaterial, unsigned int &dwLastCapacity, unsigned int &dwUsedCounter)
  278. {
  279. ErrorCodeEnum rc = Error_Succeed;
  280. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  281. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  282. {
  283. CSystemStaticInfo sysInfo;
  284. auto rc = GetFunction()->GetSystemStaticInfo(sysInfo);
  285. assert(rc == Error_Succeed);
  286. GetMaterialCounterRet ret = {};
  287. rc = pCnn->GetMaterialCounter(pszMaterial, (const char*)sysInfo.strTerminalID, (const char*)GetCurMaintainer(),
  288. dwLastCapacity, dwUsedCounter);
  289. pCnn->Close();
  290. }
  291. else
  292. {
  293. Dbg("Connect to MaterialMgrEntity failed!");
  294. rc = Error_NetBroken;
  295. }
  296. pCnn->DecRefCount();
  297. pCnn = NULL;
  298. return rc;
  299. }
  300. ErrorCodeEnum CGUIConsoleEntity::ResetMaterialCounter(const char *pszMaterial, unsigned int dwResetCapacity,
  301. unsigned int dwUsedCounter, unsigned int dwRemainCounter, const char *pszComment)
  302. {
  303. Dbg("ResetMaterialCounter: %s, reset: %d", pszMaterial, dwResetCapacity);
  304. // 重置硬件计数
  305. ErrorCodeEnum rc = Error_Succeed;
  306. CSimpleStringA strMaterialCode = pszMaterial;
  307. if (strMaterialCode == "DebitCard" || strMaterialCode == "RetainCard")
  308. {
  309. CardIssuerService_ClientBase *pClient = new CardIssuerService_ClientBase(this);
  310. rc = pClient->Connect();
  311. if (rc == Error_Succeed)
  312. {
  313. CardIssuerService_SetMaterialCount_Req req = {};
  314. if (strMaterialCode == "DebitCard")
  315. {
  316. req.bRemains = true;
  317. req.remains = dwResetCapacity;
  318. req.bIssued = true;
  319. req.issued = 0;
  320. req.bMixed = true;
  321. req.mixed = 0;
  322. req.bCaptured = false;
  323. }
  324. else if (strMaterialCode == "RetainCard")
  325. {
  326. req.bCaptured = true;
  327. req.captured = 0;
  328. req.bRemains = false;
  329. req.bIssued = false;
  330. req.bMixed = false;
  331. }
  332. CardIssuerService_SetMaterialCount_Ans ret = {};
  333. rc = pClient->SetMaterialCount(req, ret, 10000);
  334. pClient->GetFunction()->CloseSession();
  335. }
  336. else
  337. {
  338. Dbg("连接CardIssuer失败");
  339. pClient->SafeDelete();
  340. }
  341. }
  342. else
  343. {
  344. rc = Error_NoTarget;
  345. Dbg("Unknow material code: {%s}", (const char*)strMaterialCode);
  346. }
  347. if (rc != Error_Succeed)
  348. {
  349. LogError(Severity_Middle, rc, 0, CSimpleStringA::Format("Reset teminal material counter failed: %s", SpStrError(rc)));
  350. return rc;
  351. }
  352. // 重置后台计数
  353. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  354. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  355. {
  356. CSystemStaticInfo sysInfo;
  357. rc = GetFunction()->GetSystemStaticInfo(sysInfo);
  358. assert(rc == Error_Succeed);
  359. rc = pCnn->ResetMaterialCounter(strMaterialCode, sysInfo.strTerminalID, GetCurMaintainer(),
  360. dwResetCapacity, dwUsedCounter, dwRemainCounter, pszComment);
  361. pCnn->Close();
  362. }
  363. else {
  364. rc = Error_NetBroken;
  365. }
  366. pCnn->DecRefCount();
  367. pCnn = NULL;
  368. if (rc == Error_Succeed)
  369. {
  370. Dbg("Reset teminal material counter succ: %s", (const char*)strMaterialCode);
  371. }
  372. else
  373. {
  374. LogError(Severity_Middle, rc, 0, CSimpleStringA::Format("Reset teminal material counter from server failed:%s", SpStrError(rc)));
  375. }
  376. return rc;
  377. }
  378. ErrorCodeEnum CGUIConsoleEntity::RegistSwallowedCard(const char *pszCardNo, const char *pszReasonCode,
  379. const char *pszDate, const char *pszTime, const char *pszDeviceSciNo)
  380. {
  381. Dbg("RegistSwallowedCard card = %s, reson = %s", pszCardNo, pszReasonCode);
  382. // 20170210: 空卡或无卡号吞卡也要登记
  383. //if (pszCardNo == NULL || strlen(pszCardNo) == 0)
  384. // return Error_Param;
  385. // invoke material branch service
  386. ErrorCodeEnum rc = Error_Break;
  387. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  388. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  389. {
  390. CSystemStaticInfo sysInfo;
  391. rc = GetFunction()->GetSystemStaticInfo(sysInfo);
  392. assert(rc == Error_Succeed);
  393. rc = pCnn->RegistSwallowedCard(sysInfo.strMachineType, sysInfo.strTerminalID, pszCardNo, pszReasonCode, pszDate, pszTime, pszDeviceSciNo);
  394. pCnn->Close();
  395. }
  396. else {
  397. rc = Error_NetBroken;
  398. }
  399. pCnn->DecRefCount();
  400. pCnn = NULL;
  401. char tempCardNo[MAX_PATH] = "";
  402. int cardNoLen = strlen(pszCardNo);
  403. if (cardNoLen > 8)
  404. {
  405. for (int i = 0; i < 4; i++)
  406. *(tempCardNo + i) = *(pszCardNo + i);
  407. for (int i = 4; i < cardNoLen - 4; i++)
  408. *(tempCardNo + i) = '*';
  409. for (int i = cardNoLen - 4; i < cardNoLen; i++)
  410. *(tempCardNo + i) = *(pszCardNo + i);
  411. *(tempCardNo + cardNoLen) = '\0';
  412. }
  413. else
  414. strcpy(tempCardNo, pszCardNo);
  415. if (rc == Error_Succeed)
  416. Dbg("Register swallow card succ,cardno: %s, reason: %s", tempCardNo, pszReasonCode);
  417. else
  418. Dbg("Register swallow card failed(%s),cardno: %s, reason: %s", SpStrError(rc), tempCardNo, pszReasonCode);
  419. return rc;
  420. }
  421. ErrorCodeEnum CGUIConsoleEntity::SyncMaterialCount(const char *pszDeviceNo, DWORD dwCardBoxNum,
  422. CAutoArray<bool> &arrMaintainFlag, CAutoArray<CSimpleStringA> &arrMaintainer, CAutoArray<unsigned int> &arrMaintainTime,
  423. CAutoArray<CSimpleStringA> &arrCardBoxNo, CAutoArray<CSimpleStringA> &arrPsbCode,
  424. CAutoArray<CSimpleStringA> &arrPsbName, CAutoArray<unsigned int> &arrCardInit, CAutoArray<unsigned int> &arrCardRemains,
  425. CAutoArray<unsigned int> &arrCardIssued, CAutoArray<unsigned int> &arrCardMixed, CAutoArray<unsigned int> &arrCardPercent)
  426. {
  427. Dbg("SyncMaterialCount DeviceNo = %s, CardBoxNum = %d", pszDeviceNo, dwCardBoxNum);
  428. if (pszDeviceNo == NULL || strlen(pszDeviceNo) == 0)
  429. {
  430. Dbg("param [pszDeviceNo] invalid");
  431. return Error_Param;
  432. }
  433. if (dwCardBoxNum <= 0)
  434. {
  435. Dbg("param [dwCardBoxNum] invalid");
  436. return Error_Param;
  437. }
  438. if (arrCardBoxNo.GetCount() != (dwCardBoxNum+1)
  439. || arrCardBoxNo.GetCount() != (dwCardBoxNum + 1)
  440. || arrPsbCode.GetCount() != (dwCardBoxNum + 1)
  441. || arrPsbName.GetCount() != (dwCardBoxNum + 1)
  442. || arrCardInit.GetCount() != (dwCardBoxNum + 1)
  443. || arrCardRemains.GetCount() != (dwCardBoxNum + 1)
  444. || arrCardIssued.GetCount() != (dwCardBoxNum + 1)
  445. || arrCardMixed.GetCount() != (dwCardBoxNum + 1)
  446. || arrCardPercent.GetCount() != (dwCardBoxNum + 1)
  447. || arrMaintainFlag.GetCount() != (dwCardBoxNum + 1)
  448. || arrMaintainer.GetCount() != (dwCardBoxNum + 1)
  449. || arrMaintainTime.GetCount() != (dwCardBoxNum + 1))
  450. {
  451. Dbg("element count of array param invalid");
  452. return Error_Param;
  453. }
  454. // invoke material branch service
  455. ErrorCodeEnum rc = Error_Succeed;
  456. CMaterialMgrCnn *pCnn = new CMaterialMgrCnn(this);
  457. if (pCnn->ConnectFromCentralSetting() && pCnn->IsConnectionOK())
  458. {
  459. rc = pCnn->SyncMaterialCount(pszDeviceNo, dwCardBoxNum, arrMaintainFlag, arrMaintainer, arrMaintainTime,
  460. arrCardBoxNo, arrPsbCode, arrPsbName, arrCardInit, arrCardRemains, arrCardIssued, arrCardMixed, arrCardPercent);
  461. pCnn->Close();
  462. }
  463. else {
  464. rc = Error_NetBroken;
  465. }
  466. pCnn->DecRefCount();
  467. pCnn = NULL;
  468. if (rc == Error_Succeed)
  469. Dbg("计数同步成功");
  470. else
  471. Dbg("计数同步失败:%s", SpStrError(rc));
  472. return rc;
  473. }
  474. void CGUIConsoleSession::Handle_GetCurrentMaintainer(SpReqAnsContext<GUIConsoleService_GetCurrentMaintainer_Req, GUIConsoleService_GetCurrentMaintainer_Ans>::Pointer ctx)
  475. {
  476. auto rc = m_pEntity->GetCurrentMaintainer(ctx->Ans.strUserID, ctx->Ans.strUserName, ctx->Ans.strCurRight, ctx->Ans.strAuthorizer, ctx->Ans.dwBeginTime);
  477. ctx->Answer(rc);
  478. }
  479. void CGUIConsoleSession::Handle_Empower(SpReqAnsContext<GUIConsoleService_Empower_Req, GUIConsoleService_Empower_Ans>::Pointer ctx)
  480. {
  481. auto rc = m_pEntity->Empower(ctx->Req.strUserID);
  482. ctx->Answer(rc);
  483. }
  484. void CGUIConsoleSession::Handle_Takeover(SpReqAnsContext<GUIConsoleService_Takeover_Req, GUIConsoleService_Takeover_Ans>::Pointer ctx)
  485. {
  486. auto rc = m_pEntity->Takeover(ctx->Req.strUserID);
  487. ctx->Answer(rc);
  488. }
  489. void CGUIConsoleSession::Handle_ForceQuit(SpReqAnsContext<GUIConsoleService_ForceQuit_Req, GUIConsoleService_ForceQuit_Ans>::Pointer ctx)
  490. {
  491. auto rc = m_pEntity->ForceQuit();
  492. ctx->Answer(rc);
  493. }
  494. void CGUIConsoleSession::Handle_AddMaterialCounter(SpReqAnsContext<GUIConsoleService_AddMaterialCounter_Req, GUIConsoleService_AddMaterialCounter_Ans>::Pointer ctx)
  495. {
  496. auto rc = m_pEntity->AddMaterialCounter(ctx->Req.strMaterialCode);
  497. ctx->Answer(rc);
  498. }
  499. void CGUIConsoleSession::Handle_AddTradeManage(SpReqAnsContext<GUIConsoleService_AddTradeManage_Req, GUIConsoleService_AddTradeManage_Ans>::Pointer ctx)
  500. {
  501. auto rc = m_pEntity->AddTradeManage(ctx->Req.terminalNo, ctx->Req.AgentID, ctx->Req.time);
  502. ctx->Answer(rc);
  503. }
  504. //查询物料信息
  505. void CGUIConsoleSession::Handle_QueryMaterialInfo(SpReqAnsContext<GUIConsoleService_QueryMaterialInfo_Req, GUIConsoleService_QueryMaterialInfo_Ans>::Pointer ctx)
  506. {
  507. auto rc = m_pEntity->QueryMaterialInfo(ctx->Req.strDeviceNo, ctx->Ans.count, ctx->Ans.arrDeviceNo, ctx->Ans.arrMateriel, ctx->Ans.CardGroove, ctx->Ans.CardBoxNo, ctx->Ans.PsbCode,
  508. ctx->Ans.PsbName, ctx->Ans.CardInit, ctx->Ans.CardRemains, ctx->Ans.CardIssued, ctx->Ans.CardMixed, ctx->Ans.CardPercent, ctx->Ans.TerminalNo, ctx->Ans.Maintainer,
  509. ctx->Ans.MaintainTime, ctx->Ans.UpdateTime);
  510. ctx->Answer(rc);
  511. }
  512. void CGUIConsoleSession::Handle_GetMaterialCounter(SpReqAnsContext<GUIConsoleService_GetMaterialCounter_Req, GUIConsoleService_GetMaterialCounter_Ans>::Pointer ctx)
  513. {
  514. auto rc = m_pEntity->GetMaterialCounter(ctx->Req.strMaterialCode, ctx->Ans.dwLastCapacity, ctx->Ans.dwUsedCounter);
  515. ctx->Answer(rc);
  516. }
  517. void CGUIConsoleSession::Handle_ResetMaterialCounter(SpReqAnsContext<GUIConsoleService_ResetMaterialCounter_Req, GUIConsoleService_ResetMaterialCounter_Ans>::Pointer ctx)
  518. {
  519. auto rc = m_pEntity->ResetMaterialCounter(ctx->Req.strMaterialCode, ctx->Req.dwResetCapacity, ctx->Req.dwUsedCounter, ctx->Req.dwRemainCounter, ctx->Req.strComment);
  520. ctx->Answer(rc);
  521. }
  522. void CGUIConsoleSession::Handle_RegistSwallowedCard(SpReqAnsContext<GUIConsoleService_RegistSwallowedCard_Req, GUIConsoleService_RegistSwallowedCard_Ans>::Pointer ctx)
  523. {
  524. auto rc = m_pEntity->RegistSwallowedCard(ctx->Req.strCardNo, ctx->Req.strReasonCode, ctx->Req.strSwallowDate, ctx->Req.strSwallowTime, ctx->Req.strDeviceSciNo);
  525. ctx->Answer(rc);
  526. }
  527. void CGUIConsoleSession::Handle_SyncMaterialCount(SpOnewayCallContext<GUIConsoleService_SyncMaterialCount_Info>::Pointer ctx)
  528. {
  529. LOG_FUNCTION();
  530. m_pEntity->SyncMaterialCount(ctx->Info.strDeviceNo, ctx->Info.dwCardBoxNum, ctx->Info.arrMaintainFlag,
  531. ctx->Info.arrMaintainer, ctx->Info.arrMaintainTime, ctx->Info.arrCardBoxNo, ctx->Info.arrPsbCode,
  532. ctx->Info.arrPsbName, ctx->Info.arrCardInit, ctx->Info.arrCardRemains, ctx->Info.arrCardIssued,
  533. ctx->Info.arrCardMixed, ctx->Info.arrCardPercent);
  534. }
  535. SP_BEGIN_ENTITY_MAP()
  536. SP_ENTITY(CGUIConsoleEntity)
  537. SP_END_ENTITY_MAP()