123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- #include "StdAfx.h"
- #include "lyfzLoadLibrary.h"
- namespace lyfzLibrary
- {
- CString g_strCloundHost = _T("http://121.42.170.207"); // 云服务器主机地址;
- HMODULE g_hCloudSelectionLib = NULL;
- API_uploadorder g_uploadorder = NULL;
- API_uploadgoodinfo g_uploadgoodinfo = NULL;
- API_uploadimg g_uploadimg = NULL;
- API_getcloundresult g_getcloundresult = NULL;
- BOOL LoadCloudSelectionLib()
- {
- if ( g_hCloudSelectionLib == NULL )
- g_hCloudSelectionLib = LoadLibrary(_T("lyfzCloudSelection.dll"));
- if ( !g_hCloudSelectionLib )
- {
- //AfxMessageBox(_T("打开云链接库失败"));
- return FALSE;
- }
- g_uploadorder = (API_uploadorder)GetProcAddress(g_hCloudSelectionLib, "uploadorder");
- if ( g_uploadorder == NULL )
- {
- //AfxMessageBox(_T("获取生成云接口失败"));
- return FALSE;
- }
- g_uploadgoodinfo = (API_uploadgoodinfo)GetProcAddress(g_hCloudSelectionLib, "uploadgoodinfo");
- if ( g_uploadgoodinfo == NULL )
- {
- //AfxMessageBox(_T("获取生成云接口失败"));
- return FALSE;
- }
- g_uploadimg = (API_uploadimg)GetProcAddress(g_hCloudSelectionLib, "uploadImg");
- if ( g_uploadimg == NULL )
- {
- //AfxMessageBox(_T("获取生成云接口失败"));
- return FALSE;
- }
- g_getcloundresult = (API_getcloundresult)GetProcAddress(g_hCloudSelectionLib, "getresult");
- if ( g_getcloundresult == NULL )
- {
- return FALSE;
- }
-
- return TRUE;
- }
- void FreeCloudSelectionLib()
- {
- if ( g_hCloudSelectionLib )
- {
- if ( FreeLibrary(g_hCloudSelectionLib) )
- {
- g_hCloudSelectionLib = NULL;
- g_uploadorder = NULL;
- g_uploadgoodinfo = NULL;
- g_uploadimg = NULL;
- g_getcloundresult = NULL;
- }
- }
- }
- void getXPJsonresult(IN CString strJson, IN CArray<CStringArray,CStringArray>& AryResult)
- {
- INT i = 0;
- INT nIndex = 0;
- INT nCount = 0;
- CString strTemp = _T("");
- CString strTemp2 = _T("");
- CString strMark = _T("{\"photo_list\": ");
- nCount = strJson.Replace(strMark, strMark);
- strJson += _T(", {\"photo_list\": ");
- AryResult.SetSize(nCount,1);
- strJson = strJson.Mid(strMark.GetLength());
- while ( strJson.Find(strMark) != -1 )
- {
- nIndex = strJson.Find(strMark);
- strTemp = strJson.Left(nIndex - 3);
- strJson = strJson.Mid(nIndex + strMark.GetLength());
- // 解析出Json内容;
- AryResult.ElementAt(i).RemoveAll();
- // 相片串;
- nIndex = strTemp.Find(_T(", "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- strTemp2.TrimLeft(_T("\""));
- strTemp2.TrimRight(_T("\""));
- AryResult.ElementAt(i).Add(strTemp2);
- strTemp = strTemp.Mid(nIndex + 2);
- }
- // 商品数量;
- nIndex = strTemp.Find(_T("\"num\": "));
- if ( nIndex != -1)
- {
- strTemp = strTemp.Mid(nIndex + 7);
- nIndex = strTemp.Find(_T(", \"product_id\": "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- AryResult.ElementAt(i).Add(strTemp2);
- strTemp = strTemp.Mid(nIndex + strlen(_T(", \"product_id\": ")));
- }
- }
- // 商品ID;
- nIndex = strTemp.Find(_T(", \"name\": "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- strTemp2.TrimLeft(_T("\""));
- strTemp2.TrimRight(_T("\""));
- AryResult.ElementAt(i).Add(strTemp2);
- strTemp = strTemp.Mid(nIndex + _tcslen(_T(", \"name\": ")));
- }
- // 商品名称;
- if ( strTemp.GetLength() )
- {
- strTemp.TrimLeft(_T("\""));
- strTemp.TrimRight(_T("\""));
- AryResult.ElementAt(i).Add(strTemp);
- }
- i++;
- }
- }
- void getXPJsonresult(IN CString strJson, IN vector<STSpJson>& vtSpJson)
- {
- INT i = 0;
- INT nIndex = 0;
- INT nCount = 0;
- CString strTemp = _T("");
- CString strTemp2 = _T("");
- CString strMark = _T("{\"photo_list\": ");
- nCount = strJson.Replace(strMark, strMark);
- strJson += _T(", {\"photo_list\": ");
- strJson = strJson.Mid(strMark.GetLength());
- while ( strJson.Find(strMark) != -1 )
- {
- STSpJson tagJson;
- nIndex = strJson.Find(strMark);
- strTemp = strJson.Left(nIndex - 3);
- strJson = strJson.Mid(nIndex + strMark.GetLength());
- // 解析出Json内容;
- // 相片串;
- nIndex = strTemp.Find(_T(", "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- strTemp2.TrimLeft(_T("\""));
- strTemp2.TrimRight(_T("\""));
- //AryResult.ElementAt(i).Add(strTemp2);
- tagJson.strImgs = strTemp2;
- strTemp = strTemp.Mid(nIndex + 2);
- }
- // 商品数量;
- nIndex = strTemp.Find(_T("\"num\": "));
- if ( nIndex != -1)
- {
- strTemp = strTemp.Mid(nIndex + 7);
- nIndex = strTemp.Find(_T(", \"product_id\": "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- //AryResult.ElementAt(i).Add(strTemp2);
- tagJson.strSpCount = strTemp2;
- strTemp = strTemp.Mid(nIndex + strlen(_T(", \"product_id\": ")));
- }
- }
- // 商品ID;
- nIndex = strTemp.Find(_T(", \"name\": "));
- if ( nIndex != -1)
- {
- strTemp2 = strTemp.Left(nIndex);
- strTemp2.TrimLeft(_T("\""));
- strTemp2.TrimRight(_T("\""));
- //AryResult.ElementAt(i).Add(strTemp2);
- tagJson.strSpId = strTemp2;
- strTemp = strTemp.Mid(nIndex + _tcslen(_T(", \"name\": ")));
- }
- // 商品名称;
- if ( strTemp.GetLength() )
- {
- strTemp.TrimLeft(_T("\""));
- strTemp.TrimRight(_T("\""));
- //AryResult.ElementAt(i).Add(strTemp);
- tagJson.strSpName = strTemp;
- }
- vtSpJson.push_back(tagJson);
- i++;
- }
- }
- void getXYJsonresult(IN CString strJson, OUT CString& strResult)
- {
- //CString strResult = _T("");
- CString strTemp = _T("");
- CString strSubJson = _T("");
- CString strMark = _T("\"general_require\": ");
- CString strMark2 = _T("");
- CString strImgName = _T(""); // 相片名;
- CString strImgctx = _T(""); // 相片修改要求;
- INT nIndex = strJson.Find(strMark);
- if ( nIndex != -1 )
- strJson = strJson.Mid(nIndex + strMark.GetLength());
- strMark = _T(", \"sample_list\": [{");
- nIndex = strJson.Find(strMark);
- if ( nIndex != -1 )
- {
- // 总的要求;
- strTemp = strJson.Left(nIndex);
- strTemp.TrimLeft(_T("\""));
- strTemp.TrimRight(_T("\""));
- if ( !strTemp.IsEmpty() )
- strResult += strTemp + _T(";");
- strJson = strJson.Mid(nIndex + strMark.GetLength());
- }
- strMark = _T("\"modify\": ");
- strJson += strMark;
- nIndex = strJson.Find(strMark) ;
- if ( nIndex != -1 )
- {
- strJson = strJson.Mid(nIndex + strMark.GetLength());
- while( strJson.Find(strMark) != -1 )
- {
- nIndex = strJson.Find(strMark);
- strSubJson = strJson.Left(nIndex);
- strJson = strJson.Mid(nIndex+ strMark.GetLength());
- if ( nIndex != -1 )
- {
- strMark2 = _T(", \"modify_note\": ");
- nIndex = strSubJson.Find(strMark2);
- if ( nIndex != -1)
- {
- // 相片选样类型 2 = 修改, 1 = 确认;
- strTemp = strSubJson.Left(nIndex);
- if ( strTemp == _T("2") )
- {
- strSubJson = strSubJson.Mid(nIndex + strMark2.GetLength() );
- strMark2 = _T("\", \"photo_name\": ");
- nIndex = strSubJson.Find(strMark2);
- if ( nIndex != -1 )
- {
- strImgctx = strSubJson.Left(nIndex);
- strImgctx.TrimLeft(_T("\""));
- strImgName = strSubJson.Mid(nIndex + strMark2.GetLength()+1);
- strImgName = strImgName.Left(strImgName.Find(_T("\"")));
- strResult += strImgName + _T(":") + strImgctx + _T(";");
- }
- }
- }
- }
- }
- }
- OutputDebugString(strResult + _T("\n"));
- }
- //////////////////////////////////////////////////////////////////////////
- HMODULE g_hQRCodeLibrary = NULL;
- API_GetQRCodeImg g_GetQRCodeImg = NULL;
- API_ShowQRCodeBitmap g_ShowQRCodeBitmap = NULL;
- API_ShowQRCodeOnDC g_ShowQRCodeOnDC = NULL;
- BOOL LoadQRCodeLibrary()
- {
- if ( g_hQRCodeLibrary == NULL )
- {
- g_hQRCodeLibrary = ( HMODULE )LoadLibrary(_T("QRCode.dll"));
- if ( g_hQRCodeLibrary == NULL )
- return FALSE;
- }
- g_GetQRCodeImg = (API_GetQRCodeImg)GetProcAddress(g_hQRCodeLibrary, "GetQRCodeBitmap");
- if ( g_GetQRCodeImg == NULL )
- {
- FreeLibrary(g_hQRCodeLibrary);
- return FALSE;
- }
- g_ShowQRCodeBitmap = (API_ShowQRCodeBitmap)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeBitmap");
- if ( g_ShowQRCodeBitmap == NULL )
- {
- FreeLibrary(g_hQRCodeLibrary);
- return FALSE;
- }
- g_ShowQRCodeOnDC = (API_ShowQRCodeOnDC)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeOnDC");
- if ( g_ShowQRCodeOnDC == NULL )
- {
- FreeLibrary(g_hQRCodeLibrary);
- return FALSE;
- }
- return TRUE;
- }
- void FreeQRCodeLibrary()
- {
- if ( g_hQRCodeLibrary )
- {
- if ( FreeLibrary(g_hQRCodeLibrary) )
- {
- g_hQRCodeLibrary = NULL;
- g_GetQRCodeImg = NULL;
- g_ShowQRCodeBitmap = NULL;
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////
- // 微信模块;
- HMODULE g_hWeiXinLibaray = NULL;
- API_ShowWeiXingDialog g_PtrShowWeiXinDialog = NULL;
- API_ShowWeiXingDialog g_PtrShowWXMsgconfigDialog = NULL;
- API_ShowWeiXingDialog g_PtrShowWXMsgRcordDialog = NULL;
- API_ShowSoftRunTimeDialog g_PtrShowSoftRunTimeDialog = NULL;
- BOOL LoadWeiXinLibaray()
- {
- if ( g_hWeiXinLibaray == NULL )
- {
- g_hWeiXinLibaray = (HMODULE)LoadLibrary(_T("lyfzWeiXin"));
- if (!g_hWeiXinLibaray)
- return FALSE;
- }
- g_PtrShowWeiXinDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWeiXinDialog");
- if ( !g_PtrShowWeiXinDialog )
- {
- FreeLibrary(g_hWeiXinLibaray);
- return FALSE;
- }
- g_PtrShowWXMsgconfigDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWXMsgConfigDialog");
- if ( !g_PtrShowWXMsgconfigDialog )
- {
- FreeLibrary(g_hWeiXinLibaray);
- return FALSE;
- }
- g_PtrShowWXMsgRcordDialog = (API_ShowWeiXingDialog) GetProcAddress(g_hWeiXinLibaray, "ShowWXMsgRecordDialog");
- if ( !g_PtrShowWXMsgRcordDialog )
- {
- FreeLibrary(g_hWeiXinLibaray);
- return FALSE;
- }
- g_PtrShowSoftRunTimeDialog = (API_ShowSoftRunTimeDialog) GetProcAddress(g_hWeiXinLibaray, "ShowSoftRunTimeDialog");
- if ( !g_PtrShowSoftRunTimeDialog )
- {
- FreeLibrary(g_hWeiXinLibaray);
- return FALSE;
- }
- return TRUE;
- }
- void FreeWeiXinLibaray()
- {
- if ( g_hWeiXinLibaray )
- {
- if ( FreeLibrary(g_hWeiXinLibaray) )
- {
- g_hWeiXinLibaray = NULL;
- g_PtrShowWeiXinDialog = NULL;
- g_PtrShowWXMsgconfigDialog = NULL;
- g_PtrShowWXMsgRcordDialog = NULL;
- g_PtrShowSoftRunTimeDialog = NULL;
- }
- }
- }
- };
|