lyfzLoadLibrary.cpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. #include "StdAfx.h"
  2. #include "lyfzLoadLibrary.h"
  3. namespace lyfzLibrary
  4. {
  5. CString g_strCloundHost = _T("http://121.42.170.207"); // 云服务器主机地址;
  6. HMODULE g_hCloudSelectionLib = NULL;
  7. API_uploadorder g_uploadorder = NULL;
  8. API_uploadgoodinfo g_uploadgoodinfo = NULL;
  9. API_uploadimg g_uploadimg = NULL;
  10. API_getcloundresult g_getcloundresult = NULL;
  11. BOOL LoadCloudSelectionLib()
  12. {
  13. if ( g_hCloudSelectionLib == NULL )
  14. g_hCloudSelectionLib = LoadLibrary(_T("lyfzCloudSelection.dll"));
  15. if ( !g_hCloudSelectionLib )
  16. {
  17. //AfxMessageBox(_T("打开云链接库失败"));
  18. return FALSE;
  19. }
  20. g_uploadorder = (API_uploadorder)GetProcAddress(g_hCloudSelectionLib, "uploadorder");
  21. if ( g_uploadorder == NULL )
  22. {
  23. //AfxMessageBox(_T("获取生成云接口失败"));
  24. return FALSE;
  25. }
  26. g_uploadgoodinfo = (API_uploadgoodinfo)GetProcAddress(g_hCloudSelectionLib, "uploadgoodinfo");
  27. if ( g_uploadgoodinfo == NULL )
  28. {
  29. //AfxMessageBox(_T("获取生成云接口失败"));
  30. return FALSE;
  31. }
  32. g_uploadimg = (API_uploadimg)GetProcAddress(g_hCloudSelectionLib, "uploadImg");
  33. if ( g_uploadimg == NULL )
  34. {
  35. //AfxMessageBox(_T("获取生成云接口失败"));
  36. return FALSE;
  37. }
  38. g_getcloundresult = (API_getcloundresult)GetProcAddress(g_hCloudSelectionLib, "getresult");
  39. if ( g_getcloundresult == NULL )
  40. {
  41. return FALSE;
  42. }
  43. return TRUE;
  44. }
  45. void FreeCloudSelectionLib()
  46. {
  47. if ( g_hCloudSelectionLib )
  48. {
  49. if ( FreeLibrary(g_hCloudSelectionLib) )
  50. {
  51. g_hCloudSelectionLib = NULL;
  52. g_uploadorder = NULL;
  53. g_uploadgoodinfo = NULL;
  54. g_uploadimg = NULL;
  55. g_getcloundresult = NULL;
  56. }
  57. }
  58. }
  59. void getXPJsonresult(IN CString strJson, IN CArray<CStringArray,CStringArray>& AryResult)
  60. {
  61. INT i = 0;
  62. INT nIndex = 0;
  63. INT nCount = 0;
  64. CString strTemp = _T("");
  65. CString strTemp2 = _T("");
  66. CString strMark = _T("{\"photo_list\": ");
  67. nCount = strJson.Replace(strMark, strMark);
  68. strJson += _T(", {\"photo_list\": ");
  69. AryResult.SetSize(nCount,1);
  70. strJson = strJson.Mid(strMark.GetLength());
  71. while ( strJson.Find(strMark) != -1 )
  72. {
  73. nIndex = strJson.Find(strMark);
  74. strTemp = strJson.Left(nIndex - 3);
  75. strJson = strJson.Mid(nIndex + strMark.GetLength());
  76. // 解析出Json内容;
  77. AryResult.ElementAt(i).RemoveAll();
  78. // 相片串;
  79. nIndex = strTemp.Find(_T(", "));
  80. if ( nIndex != -1)
  81. {
  82. strTemp2 = strTemp.Left(nIndex);
  83. strTemp2.TrimLeft(_T("\""));
  84. strTemp2.TrimRight(_T("\""));
  85. AryResult.ElementAt(i).Add(strTemp2);
  86. strTemp = strTemp.Mid(nIndex + 2);
  87. }
  88. // 商品数量;
  89. nIndex = strTemp.Find(_T("\"num\": "));
  90. if ( nIndex != -1)
  91. {
  92. strTemp = strTemp.Mid(nIndex + 7);
  93. nIndex = strTemp.Find(_T(", \"product_id\": "));
  94. if ( nIndex != -1)
  95. {
  96. strTemp2 = strTemp.Left(nIndex);
  97. AryResult.ElementAt(i).Add(strTemp2);
  98. strTemp = strTemp.Mid(nIndex + strlen(_T(", \"product_id\": ")));
  99. }
  100. }
  101. // 商品ID;
  102. nIndex = strTemp.Find(_T(", \"name\": "));
  103. if ( nIndex != -1)
  104. {
  105. strTemp2 = strTemp.Left(nIndex);
  106. strTemp2.TrimLeft(_T("\""));
  107. strTemp2.TrimRight(_T("\""));
  108. AryResult.ElementAt(i).Add(strTemp2);
  109. strTemp = strTemp.Mid(nIndex + _tcslen(_T(", \"name\": ")));
  110. }
  111. // 商品名称;
  112. if ( strTemp.GetLength() )
  113. {
  114. strTemp.TrimLeft(_T("\""));
  115. strTemp.TrimRight(_T("\""));
  116. AryResult.ElementAt(i).Add(strTemp);
  117. }
  118. i++;
  119. }
  120. }
  121. void getXPJsonresult(IN CString strJson, IN vector<STSpJson>& vtSpJson)
  122. {
  123. INT i = 0;
  124. INT nIndex = 0;
  125. INT nCount = 0;
  126. CString strTemp = _T("");
  127. CString strTemp2 = _T("");
  128. CString strMark = _T("{\"photo_list\": ");
  129. nCount = strJson.Replace(strMark, strMark);
  130. strJson += _T(", {\"photo_list\": ");
  131. strJson = strJson.Mid(strMark.GetLength());
  132. while ( strJson.Find(strMark) != -1 )
  133. {
  134. STSpJson tagJson;
  135. nIndex = strJson.Find(strMark);
  136. strTemp = strJson.Left(nIndex - 3);
  137. strJson = strJson.Mid(nIndex + strMark.GetLength());
  138. // 解析出Json内容;
  139. // 相片串;
  140. nIndex = strTemp.Find(_T(", "));
  141. if ( nIndex != -1)
  142. {
  143. strTemp2 = strTemp.Left(nIndex);
  144. strTemp2.TrimLeft(_T("\""));
  145. strTemp2.TrimRight(_T("\""));
  146. //AryResult.ElementAt(i).Add(strTemp2);
  147. tagJson.strImgs = strTemp2;
  148. strTemp = strTemp.Mid(nIndex + 2);
  149. }
  150. // 商品数量;
  151. nIndex = strTemp.Find(_T("\"num\": "));
  152. if ( nIndex != -1)
  153. {
  154. strTemp = strTemp.Mid(nIndex + 7);
  155. nIndex = strTemp.Find(_T(", \"product_id\": "));
  156. if ( nIndex != -1)
  157. {
  158. strTemp2 = strTemp.Left(nIndex);
  159. //AryResult.ElementAt(i).Add(strTemp2);
  160. tagJson.strSpCount = strTemp2;
  161. strTemp = strTemp.Mid(nIndex + strlen(_T(", \"product_id\": ")));
  162. }
  163. }
  164. // 商品ID;
  165. nIndex = strTemp.Find(_T(", \"name\": "));
  166. if ( nIndex != -1)
  167. {
  168. strTemp2 = strTemp.Left(nIndex);
  169. strTemp2.TrimLeft(_T("\""));
  170. strTemp2.TrimRight(_T("\""));
  171. //AryResult.ElementAt(i).Add(strTemp2);
  172. tagJson.strSpId = strTemp2;
  173. strTemp = strTemp.Mid(nIndex + _tcslen(_T(", \"name\": ")));
  174. }
  175. // 商品名称;
  176. if ( strTemp.GetLength() )
  177. {
  178. strTemp.TrimLeft(_T("\""));
  179. strTemp.TrimRight(_T("\""));
  180. //AryResult.ElementAt(i).Add(strTemp);
  181. tagJson.strSpName = strTemp;
  182. }
  183. vtSpJson.push_back(tagJson);
  184. i++;
  185. }
  186. }
  187. void getXYJsonresult(IN CString strJson, OUT CString& strResult)
  188. {
  189. //CString strResult = _T("");
  190. CString strTemp = _T("");
  191. CString strSubJson = _T("");
  192. CString strMark = _T("\"general_require\": ");
  193. CString strMark2 = _T("");
  194. CString strImgName = _T(""); // 相片名;
  195. CString strImgctx = _T(""); // 相片修改要求;
  196. INT nIndex = strJson.Find(strMark);
  197. if ( nIndex != -1 )
  198. strJson = strJson.Mid(nIndex + strMark.GetLength());
  199. strMark = _T(", \"sample_list\": [{");
  200. nIndex = strJson.Find(strMark);
  201. if ( nIndex != -1 )
  202. {
  203. // 总的要求;
  204. strTemp = strJson.Left(nIndex);
  205. strTemp.TrimLeft(_T("\""));
  206. strTemp.TrimRight(_T("\""));
  207. if ( !strTemp.IsEmpty() )
  208. strResult += strTemp + _T(";");
  209. strJson = strJson.Mid(nIndex + strMark.GetLength());
  210. }
  211. strMark = _T("\"modify\": ");
  212. strJson += strMark;
  213. nIndex = strJson.Find(strMark) ;
  214. if ( nIndex != -1 )
  215. {
  216. strJson = strJson.Mid(nIndex + strMark.GetLength());
  217. while( strJson.Find(strMark) != -1 )
  218. {
  219. nIndex = strJson.Find(strMark);
  220. strSubJson = strJson.Left(nIndex);
  221. strJson = strJson.Mid(nIndex+ strMark.GetLength());
  222. if ( nIndex != -1 )
  223. {
  224. strMark2 = _T(", \"modify_note\": ");
  225. nIndex = strSubJson.Find(strMark2);
  226. if ( nIndex != -1)
  227. {
  228. // 相片选样类型 2 = 修改, 1 = 确认;
  229. strTemp = strSubJson.Left(nIndex);
  230. if ( strTemp == _T("2") )
  231. {
  232. strSubJson = strSubJson.Mid(nIndex + strMark2.GetLength() );
  233. strMark2 = _T("\", \"photo_name\": ");
  234. nIndex = strSubJson.Find(strMark2);
  235. if ( nIndex != -1 )
  236. {
  237. strImgctx = strSubJson.Left(nIndex);
  238. strImgctx.TrimLeft(_T("\""));
  239. strImgName = strSubJson.Mid(nIndex + strMark2.GetLength()+1);
  240. strImgName = strImgName.Left(strImgName.Find(_T("\"")));
  241. strResult += strImgName + _T(":") + strImgctx + _T(";");
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. OutputDebugString(strResult + _T("\n"));
  249. }
  250. //////////////////////////////////////////////////////////////////////////
  251. HMODULE g_hQRCodeLibrary = NULL;
  252. API_GetQRCodeImg g_GetQRCodeImg = NULL;
  253. API_ShowQRCodeBitmap g_ShowQRCodeBitmap = NULL;
  254. API_ShowQRCodeOnDC g_ShowQRCodeOnDC = NULL;
  255. BOOL LoadQRCodeLibrary()
  256. {
  257. if ( g_hQRCodeLibrary == NULL )
  258. {
  259. g_hQRCodeLibrary = ( HMODULE )LoadLibrary(_T("QRCode.dll"));
  260. if ( g_hQRCodeLibrary == NULL )
  261. return FALSE;
  262. }
  263. g_GetQRCodeImg = (API_GetQRCodeImg)GetProcAddress(g_hQRCodeLibrary, "GetQRCodeBitmap");
  264. if ( g_GetQRCodeImg == NULL )
  265. {
  266. FreeLibrary(g_hQRCodeLibrary);
  267. return FALSE;
  268. }
  269. g_ShowQRCodeBitmap = (API_ShowQRCodeBitmap)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeBitmap");
  270. if ( g_ShowQRCodeBitmap == NULL )
  271. {
  272. FreeLibrary(g_hQRCodeLibrary);
  273. return FALSE;
  274. }
  275. g_ShowQRCodeOnDC = (API_ShowQRCodeOnDC)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeOnDC");
  276. if ( g_ShowQRCodeOnDC == NULL )
  277. {
  278. FreeLibrary(g_hQRCodeLibrary);
  279. return FALSE;
  280. }
  281. return TRUE;
  282. }
  283. void FreeQRCodeLibrary()
  284. {
  285. if ( g_hQRCodeLibrary )
  286. {
  287. if ( FreeLibrary(g_hQRCodeLibrary) )
  288. {
  289. g_hQRCodeLibrary = NULL;
  290. g_GetQRCodeImg = NULL;
  291. g_ShowQRCodeBitmap = NULL;
  292. }
  293. }
  294. }
  295. //////////////////////////////////////////////////////////////////////////
  296. // 微信模块;
  297. HMODULE g_hWeiXinLibaray = NULL;
  298. API_ShowWeiXingDialog g_PtrShowWeiXinDialog = NULL;
  299. API_ShowWeiXingDialog g_PtrShowWXMsgconfigDialog = NULL;
  300. API_ShowWeiXingDialog g_PtrShowWXMsgRcordDialog = NULL;
  301. API_ShowSoftRunTimeDialog g_PtrShowSoftRunTimeDialog = NULL;
  302. BOOL LoadWeiXinLibaray()
  303. {
  304. if ( g_hWeiXinLibaray == NULL )
  305. {
  306. g_hWeiXinLibaray = (HMODULE)LoadLibrary(_T("lyfzWeiXin"));
  307. if (!g_hWeiXinLibaray)
  308. return FALSE;
  309. }
  310. g_PtrShowWeiXinDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWeiXinDialog");
  311. if ( !g_PtrShowWeiXinDialog )
  312. {
  313. FreeLibrary(g_hWeiXinLibaray);
  314. return FALSE;
  315. }
  316. g_PtrShowWXMsgconfigDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWXMsgConfigDialog");
  317. if ( !g_PtrShowWXMsgconfigDialog )
  318. {
  319. FreeLibrary(g_hWeiXinLibaray);
  320. return FALSE;
  321. }
  322. g_PtrShowWXMsgRcordDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWXMsgRecordDialog");
  323. if ( !g_PtrShowWXMsgRcordDialog )
  324. {
  325. FreeLibrary(g_hWeiXinLibaray);
  326. return FALSE;
  327. }
  328. g_PtrShowSoftRunTimeDialog = (API_ShowSoftRunTimeDialog) GetProcAddress(g_hWeiXinLibaray, "ShowSoftRunTimeDialog");
  329. if ( !g_PtrShowSoftRunTimeDialog )
  330. {
  331. FreeLibrary(g_hWeiXinLibaray);
  332. return FALSE;
  333. }
  334. return TRUE;
  335. }
  336. void FreeWeiXinLibaray()
  337. {
  338. if ( g_hWeiXinLibaray )
  339. {
  340. if ( FreeLibrary(g_hWeiXinLibaray) )
  341. {
  342. g_hWeiXinLibaray = NULL;
  343. g_PtrShowWeiXinDialog = NULL;
  344. g_PtrShowWXMsgconfigDialog = NULL;
  345. g_PtrShowWXMsgRcordDialog = NULL;
  346. g_PtrShowSoftRunTimeDialog = NULL;
  347. }
  348. }
  349. }
  350. };