主类中文定义

#include <QtGui/QApplication>
#include <QTextCodec>QTextCodec::setCodecForTr(QTextCodec::codecForLocale());QTextCodec::setCodecForLocale(QTextCodec::codecForLocale());QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());

宏定义:

enum dll_error_codes
{STATUS_OK = 1,   //成功状态DOG_NOTFOUND=-1, //加密狗不存在DOG_INVVCODE = -2, //加密狗论证失败DOG_SNERROR = -3, //加密狗序列号错误DOG_NOLOCAL =-4,  //非本机加密狗DOG_GETDTAERROR =-5,  //获取加密狗数据失败DOG_DATAERROR =-6,  //加密狗数据非法DOG_CDSCOMERROR =-7,  //服务器非本机加密狗硬盘序列号不匹配DOG_MACCOMERROR =-8,  //服务器非本机加密狗MAC不匹配DOG_STATEERROR =-9,  //加密狗使用状态错误DOG_STATECLOSE =-10, //加密狗禁用DOG_TOOLERROR =-11, //工具类型不匹配DOG_TIMESRROR =-12, //注册次数错误DOG_NOTIMES =-13, //注册次数不足,请重新注册DOG_VAILDATE =-14, //有效时间范围错误DOG_WRITEERROR =-15, //加密狗写入数据失败DOG_REPLACERERROR =-16, //注册时候拔出加密狗,更换了另外一个加密狗DOG_SERVERSN_ERROR =-17, //平台下发序列号与本机获取序列号不一致PC_TIMEERROR =-20,  //本机电脑时间不正确PC_DOGDATAERROR =-21, //获取本地磁盘与MAC失败PC_DOG_CDSCOMERROR =-22,//非本机加密狗硬盘序列号不匹配PC_DOG_MACCOMERROR =-23,//非本机加密狗硬盘序列号不匹配PC_REGDATA_ERROR =-24, //接收到的PC注册数据错误无法分割PC_REGTOOL_ERROR =-25, //平台注册类型不支持当前 工具PC_REGAUTH_NOERROR=-26, //授权码不存在PC_REGAUTH_CKERROR =-27, //授权码校验值错误PC_REGAUTH_STATEERROR =-28, //授权码状态错误PC_TOOL_TYPEERROR =-29, //工具类型不正确,不能大于99SERVER_DOG_NOREGISTER =-30, //服务器加密狗不存在SERVER_DOG_CKERROR =-31, //加密狗校验值错误SERVER_DOG_VENIDERROR =-32, //服务器加密狗VENID不匹配SERVER_DOG_DENIED =-33, //服务器禁用加密狗SERVER_DOG_DATAERROR =-34, //接收到服务器数据错误NET_PARM_ERROR =-40, //网络参数错误IP端口配置错误config配置错误NET_WSAS_ERROR =-41, //网络准备连接WSAStartup错误NET_CONN_ERROR =-42,  //网络连接错误NET_SEND_ERROR =-43,  //网络发送失败NET_READ_ERROR =-44,  //网络接收失败NET_DATA_INVALID =-45, //接收数据非法REG_OPEN_ERROR =-51, //打开注册表失败REG_DATA_ERROR =-52, //获取注册表信息失败REG_WIITE_ERROR =-53, //写入注册表信息失败COMMPORT_STATEERROR =-61,  //通讯口未打开COMMPORT_READERROR =-62,  //读取数据失败RSP_NO_TRAN    = -94,  //无此交易类型RSP_NO_PARSE=-95, //接收报文错误RSP_SYS_ERR =-96,  //系统错误DATABASE_ERROR  =-60,  //服务器数据库异常INIT_DENIED = -99, //动态库未初始化};

调用动态库:
MinipaydllFunction.h

在这里插入代码片
// MinipaydllFunction.h: interface for the CMinipaydllFunction class.
//
//#if !defined(AFX_MINIPAYDLLFUNCTION_H__6617657F_2139_4A1D_B647_604E4F16D86D__INCLUDED_)
#define AFX_MINIPAYDLLFUNCTION_H__6617657F_2139_4A1D_B647_604E4F16D86D__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//#include<windef.h>#include <list>
#include <vector>
#include <iostream>
#include <Windows.h>
//初始化
#include "publicfunction.h"
//typedef list<FuWuQiData> LISTINTData;
typedef vector<FuWuQiData> LISTINTVector;
typedef int (__stdcall *InitDll)(int ttype,int &nTimes);
/************************************************************************/
/* 获取加密狗序列号                                                     */
/************************************************************************/
typedef int (__stdcall *GetDogInfo)(unsigned char *idinfo,unsigned char *veninfo);
/************************************************************************/
/* 注册加密狗                                                           */
/************************************************************************/
typedef int (__stdcall *RegIsterDog)(unsigned char *authcodeinfo,int &nTimes);//打开通讯口
typedef bool (__stdcall *OpenDevice)(DWORD dwVid, DWORD dwPid,int commType);//写入蓝牙名称
typedef int (__stdcall *WriteSerialNum)(byte CmdHead,byte CmdKey,char *sSerialNumber,char *Masterkey,int nIndex,int &nTimes);
//写入21号文件数据
typedef int (__stdcall *Write21SnMainKey)(char *sSerialNumber,char *Masterkey,char *MasterkeyCk);
//写入时间
typedef int (__stdcall *WriteDateTime)();//次数递减
typedef int (__stdcall *ReduDogTimes)(int &nTimes);//检查服务工具版本是否可用
typedef int (__stdcall *TkVersion)(char* appid, char *VerBuf,char* outBuffer);//保存基本信息
typedef int (__stdcall *SaveBaseVersion)(char *VerBuf,int vsize,char *outBuf,int &outlen);//保存入库基本信息
typedef int (__stdcall *SaveRkVersion)(char *VerBuf,int vsize,char *outBuf,int &outlen);//查询基本信息
typedef int (__stdcall *SelectBaseVersion)(char *VerBuf,int vsize,char *outBuf,int &outlen);//从终端读取设备基本信息
typedef int (__stdcall *ReadSnVersion)(char *outBuf,int &outlen);//查询终端型号
typedef int (__stdcall *SelectModelInfo)(char *outBuf,int &outlen);//查询终端颜色
typedef int (__stdcall *SelectProcColour)(char *outBuf,int &outlen);//查询产品配置
typedef int (__stdcall *SelectProcName)(char *outBuf,int &outlen);//联网查询发送网络心跳包
typedef int (__stdcall *Heartbeatpack)(char *outBuf,int &outlen);typedef int (__stdcall *SelectSNAndTUSN)(char *TUSN,int &iErrCode,char *outBuf);/发送SN号获取秘钥
typedef int (__stdcall *GetKeyToDevice)(char *VerBuf,int vsize,int &iErrCode,char *outBuf);//发送确认信息
typedef int (__stdcall *InfoReportSever)(char *TUSN,char  *ERcode);下载成功返回0,失败返回0x01//转加密
typedef int (__stdcall *TransEncry)(unsigned char *keybuf,int keylen,unsigned char *keybufck,int keycklen,unsigned char *ranbuf,int ranlen,unsigned char *okeybuf,int *okeylen,unsigned char *okeybufck,int *okeycklen,unsigned char *oranbuf,int *oranlen,int *keymode,int *oindex);
typedef int (__stdcall *CheckSaftdog)(unsigned char *outdata,int &nTimes,int itype);
typedef int (__stdcall *UseSaftdog)(unsigned char *outdata,int &nTimes,int itype);
typedef int (__stdcall *GeneratePollCode2)(char *pollCode);
typedef int (__stdcall *RegerSaftdogTimes)(unsigned char *olddata,unsigned char *indata,unsigned char *erroutdata,int itype);
/获取售后维修数据
typedef int (__stdcall *ShouHouWeiXiu)(char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode);//
/获取售后维修数据明细
typedef int (__stdcall *ShouHouWeiXiuDetail)(char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode);
/上送数据到数据库
typedef int (__stdcall *ShouHouInforToSQL)(char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode);
/
typedef int (__stdcall *GetShouHouWeiXiuRecord)(char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode);class CMinipaydllFunction
{public:CMinipaydllFunction();virtual ~CMinipaydllFunction();bool init();public: InitDll           m_InitDll;GetDogInfo        m_GetDogInfo;RegIsterDog        m_RegIsterDog;OpenDevice        m_OpenDevice;WriteSerialNum    m_WriteSerialNum;Write21SnMainKey  m_Write21SnMainKey;WriteDateTime     m_WriteDateTime;ReduDogTimes     m_ReduDogTimes;TkVersion         m_TkVersion;SaveBaseVersion   m_SaveBaseVersion;SaveRkVersion     m_SaveRkVersion;SelectBaseVersion m_SelectBaseVersion;ReadSnVersion     m_ReadSnVersion;SelectModelInfo   m_SelectModelInfo;SelectProcColour  m_SelectProcColour;
//  SelectProcName    m_SelectProcName;Heartbeatpack     m_Heartbeatpack;SelectSNAndTUSN   m_SelectSNAndTUSN;GetKeyToDevice    m_GetKeyToDevice;InfoReportSever   m_InfoReportSever;TransEncry        m_TransEncry;ShouHouWeiXiu     m_ShouHouWeiXiu;ShouHouWeiXiuDetail m_ShouHouWeiXiuDetail;ShouHouInforToSQL m_ShouHouInforToSQL;GetShouHouWeiXiuRecord m_GetShouHouWeiXiuRecord;//调用加密狗注册CheckSaftdog      m_checkSaftdog;UseSaftdog m_useSaftdog;GeneratePollCode2 m_generatePollCode2;RegerSaftdogTimes m_RegerSaftdogTimes;private:HMODULE m_hlib;HMODULE m_hTranslib;HMODULE m_hdoglib;
};#endif // !defined(AFX_MINIPAYDLLFUNCTION_H__6617657F_2139_4A1D_B647_604E4F16D86D__INCLUDED_)

MinipaydllFunction.cpp

// MinipaydllFunction.cpp: implementation of the CMinipaydllFunction class.
//
//
#include "MinipaydllFunction.h"
#include <QMessageBox>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//
// Construction/Destruction
//
CMinipaydllFunction::CMinipaydllFunction()
{m_hlib = NULL;
//  m_hTranslib=NULL;init();
}CMinipaydllFunction::~CMinipaydllFunction()
{}bool CMinipaydllFunction::init()
{//QMessageBox::information(NULL, "Title", "调用开始", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);m_hlib = LoadLibrary(L"minipaydll.dll");if (m_hlib != NULL){//QMessageBox::information(NULL, "Title", "调用成功", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);m_InitDll =(InitDll)GetProcAddress(m_hlib, "InitDll");m_GetDogInfo =(GetDogInfo)GetProcAddress(m_hlib, "GetDogInfo");m_RegIsterDog =(RegIsterDog)GetProcAddress(m_hlib, "RegIsterDog");   m_OpenDevice = (OpenDevice)GetProcAddress(m_hlib, "OpenDevice");m_WriteSerialNum = (WriteSerialNum)GetProcAddress(m_hlib, "WriteSerialNum");m_Write21SnMainKey = (Write21SnMainKey)GetProcAddress(m_hlib, "Write21SnMainKey");m_WriteDateTime = (WriteDateTime)GetProcAddress(m_hlib, "WriteDateTime");m_ReduDogTimes = (ReduDogTimes)GetProcAddress(m_hlib, "ReduDogTimes");    m_TkVersion = (TkVersion)GetProcAddress(m_hlib, "TkVersion");    m_SaveBaseVersion = (SaveBaseVersion)GetProcAddress(m_hlib, "SaveBaseVersion");m_SaveRkVersion = (SaveRkVersion)GetProcAddress(m_hlib, "SaveRkVersion");  m_SelectBaseVersion = (SelectBaseVersion)GetProcAddress(m_hlib, "SelectBaseVersion");m_ReadSnVersion = (ReadSnVersion)GetProcAddress(m_hlib, "ReadSnVersion");m_SelectModelInfo = (SelectModelInfo)GetProcAddress(m_hlib, "SelectModelInfo");m_SelectProcColour = (SelectProcColour)GetProcAddress(m_hlib, "SelectProcColour");
//      m_SelectProcName = (SelectProcName)GetProcAddress(m_hlib, "SelectProcName");m_Heartbeatpack = (Heartbeatpack)GetProcAddress(m_hlib, "Heartbeatpack");m_SelectSNAndTUSN = (SelectSNAndTUSN)GetProcAddress(m_hlib, "SelectSNAndTUSN");m_GetKeyToDevice = (GetKeyToDevice)GetProcAddress(m_hlib, "GetKeyToDevice");m_InfoReportSever = (InfoReportSever)GetProcAddress(m_hlib, "InfoReportSever");  m_ShouHouWeiXiu = (ShouHouWeiXiu)GetProcAddress(m_hlib, "ShouHouWeiXiu");m_ShouHouWeiXiuDetail = (ShouHouWeiXiuDetail)GetProcAddress(m_hlib, "ShouHouWeiXiuDetail");m_ShouHouInforToSQL =   (ShouHouInforToSQL)GetProcAddress(m_hlib, "ShouHouInforToSQL");m_GetShouHouWeiXiuRecord = (GetShouHouWeiXiuRecord)GetProcAddress(m_hlib,"GetShouHouWeiXiuRecord");  //FreeLibrary(m_hlib);}else{return false;}m_hTranslib = LoadLibrary(L"secFunction.dll");if (m_hTranslib != NULL){   m_TransEncry = (TransEncry)GetProcAddress(m_hTranslib, "TransEncry");}m_hdoglib= LoadLibrary(L"dog_minipaydll.dll");if (m_hdoglib != NULL){m_checkSaftdog      = (CheckSaftdog)GetProcAddress(m_hdoglib, "CheckSaftdog");m_useSaftdog        = (UseSaftdog)GetProcAddress(m_hdoglib, "UseSaftdog");m_generatePollCode2 = (GeneratePollCode2)GetProcAddress(m_hdoglib, "GeneratePollCode2"); m_RegerSaftdogTimes = (RegerSaftdogTimes)GetProcAddress(m_hdoglib, "RegerSaftdogTimes");}else{return false;}return true;
}

主类函数.h

#ifndef SHOUHOUTOOL_H
#define SHOUHOUTOOL_H#include "json/cJSON.h"
#include "json/minipay_code.h"
#include "MinipaydllFunction.h"
#include <QtGui/QDialog>
#include "ui_shouhoutool.h"
#include <QMessageBox>
#include <QMenu>
#include <QSettings>
#include <QtCore/QtCore>
#include <QDebug>
#include <QStandardItemModel>
#include <QListWidgetItem>
#include <QListWidget>#include "inputsn.h"class ShouHouTool : public QDialog
{Q_OBJECTpublic:ShouHouTool(QWidget *parent = 0, Qt::WFlags flags = 0);~ShouHouTool();void InitPara();CMinipaydllFunction *g_minipaydllFunction;QString m_qstrfatherJieDian;LISTINTVector  list1;LISTINTVector m_vecmain;LISTINTVector m_vecmini;QString  m_qstrMain;QString  m_qstrmini;int m_recordtableLine;void objconnect();void addconfigini();bool bjudcomb;int ShouHouWeiXiuDeal( char *VerBuf,int vsize,char *outBuf,int &outlen,LISTINTVector &listvector);int ShouHouWeiXiuDetailDeal( char *VerBuf,int vsize,int errcode);int GetShouHouWeiXiuRecord( char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode);static DWORD WINAPI ReadVersion(LPVOID pParam);//发送线程private slots:void on_exit();void slotLoadList(int);void SendToSQL();void getPadIds();/*按钮添加*/void onbutaddtoDetailInformation();//void startThread();
private:Ui::ShouHouToolClass ui;void mousePressEvent (QMouseEvent * event );
};#endif // SHOUHOUTOOL_H

主函数.cpp

#include "shouhoutool.h"ShouHouTool::ShouHouTool(QWidget *parent, Qt::WFlags flags): QDialog(parent, flags)
{ui.setupUi(this);g_minipaydllFunction=new CMinipaydllFunction();objconnect();//addconfigini();
}ShouHouTool::~ShouHouTool()
{delete[] g_minipaydllFunction;
}void ShouHouTool::addconfigini()
{QString ininame="";char tempbuf[1024]={0};char* tempname=NULL;QString iniFilePath = "/../config.ini"; iniFilePath = QCoreApplication::applicationDirPath() + "/Config.ini";QSettings settings(iniFilePath,QSettings::IniFormat);    QString G1_fileName = settings.value("Setting/FactoryName").toString();    // ui.lineEdit_factory->setText(G1_fileName);
}void ShouHouTool::objconnect()
{//connect(ui.lineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_lineEdit_sendNew()));//没有QString,一调用就会死connect(ui.pushButton_getInfo,SIGNAL(clicked()), this, SLOT(startThread()));//添加//connect(ui.tableWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(deleteCurrentLine(QPoint)));return;
}
void ShouHouTool::InitPara()
{//ui.lineEdit->setStyleSheet(   normalStyle);
}void ShouHouTool::on_exit()
{QApplication* app;app->exit(0);
}void ShouHouTool::slotLoadList(int i)
{char ch[1024]={0};char  outBuf[1024]={0x00};int   outlen=0;int   iErrCode=0;cJSON *rootdata;rootdata=cJSON_CreateObject();cJSON_AddStringToObject(rootdata,"info","");char *jsonBuf=cJSON_PrintUnformatted(rootdata);int result = g_minipaydllFunction->m_GetShouHouWeiXiuRecord(jsonBuf,strlen(jsonBuf),outBuf,outlen,iErrCode);if(iErrCode!=0){QString qstrmessage=outBuf;QMessageBox::warning(this,tr("Warning"),qstrmessage);return ;}return;
}void ShouHouTool::SendToSQL()
{cJSON *rootdata;rootdata=cJSON_CreateObject();/*cJSON_AddStringToObject(rootdata,"FAC_ID","");cJSON_AddStringToObject(rootdata,"MIDDLE_CODE","");cJSON_AddStringToObject(rootdata,"SERIAL_NO","");cJSON_AddStringToObject(rootdata,"FAULT_CLASS","");cJSON_AddStringToObject(rootdata,"FAULT_CAUSE","");cJSON_AddStringToObject(rootdata,"RETEST_FAILURE","");cJSON_AddStringToObject(rootdata,"FAULT_NUM","");cJSON_AddStringToObject(rootdata,"FAULT_LOCATION","");cJSON_AddStringToObject(rootdata,"REWORK_REP_TIMES","");cJSON_AddStringToObject(rootdata,"ABILITY","");cJSON_AddStringToObject(rootdata,"PROCESSING_METHOD","");cJSON_AddStringToObject(rootdata,"TESTER_CODE","");cJSON_AddStringToObject(rootdata,"MAINTENANCE_PER_CODE","");cJSON_AddStringToObject(rootdata,"STATE","");cJSON_AddStringToObject(rootdata,"INPUT_TIME","");cJSON_AddStringToObject(rootdata,"COMPLEITION_TIME","");cJSON_AddStringToObject(rootdata,"MAINT_DETAILS","");*///QString qstrmain="";QString qstrmini="";QString str ="";QString strmini ="";QMessageBox::warning(this,tr("Warning"),qstrmain);char main[50]={0};QByteArray ba = qstrmain.toLocal8Bit();memcpy(main,ba.data(),ba.size()+1);cJSON_AddStringToObject(rootdata,"FAULT_CLASS",main);char mini[50]={0};ba = qstrmini.toLocal8Bit();memcpy(mini,ba.data(),ba.size()+1);cJSON_AddStringToObject(rootdata,"FAULT_CAUSE",mini);int aa=0;FuWuQiData fad;char senddata[1024]={0};//memcpy(senddata,);char *jsonBuf=cJSON_PrintUnformatted(rootdata);char  outBuf[1024]={0x00};int   outlen=0;int   iErrCode=-1;QMessageBox::warning(this,tr("Warning"),tr("开始发数据"));int result = g_minipaydllFunction->m_ShouHouInforToSQL(jsonBuf,strlen(jsonBuf),outBuf,outlen,iErrCode);if(iErrCode==0){QMessageBox::warning(this,tr("Warning"),tr("数据发完"));}return;
}void ShouHouTool::mousePressEvent ( QMouseEvent * event )
{//QMessageBox::warning(this,tr("Warning"),tr("鼠标操作"));
}
void ShouHouTool::getPadIds()
{QMessageBox::warning(this,tr("Warning"),tr("父类调用成功"));
}void ShouHouTool::onbutaddtoDetailInformation()
{char outValue[2048]={0x00};byte outTemp[512]={0x00};int iErrCode=-1;int outlen=0;cJSON *MBSInformation;cJSON *arrayItem;MBSInformation=cJSON_CreateObject();cJSON_AddStringToObject(MBSInformation,"SERIAL_NO","0000290220068442");cJSON_AddStringToObject(MBSInformation,"Position_number","");cJSON_AddStringToObject(MBSInformation,"MIDDLE_CODE","");cJSON_AddStringToObject(MBSInformation,"TOOLS_INFO"  ,"");cJSON_AddStringToObject(MBSInformation,"TOOLS_ALIAS" ,"");char *jsonBuf=cJSON_PrintUnformatted(MBSInformation);int result=g_minipaydllFunction->m_GetShouHouWeiXiuRecord(jsonBuf,strlen(jsonBuf),outValue,outlen,iErrCode);if(result==STATUS_OK){ShouHouWeiXiuDetailDeal( outValue,outlen,iErrCode);}else{ui.textEditInfor->setText("获取服务器数据失败");}cJSON_Delete(MBSInformation);return ;
}int  ShouHouTool::ShouHouWeiXiuDeal( char *VerBuf,int vsize,char *outBuf,int &outlen,LISTINTVector &listvector)
{char outValue[2048]={0x00};char outTemp[512]={0x00};QString strTemp="";   listvector.clear();int  olen=0;int  nlen=0;   char*MySQLConnet=("服务器连接异常");  cJSON *MBSInformation;cJSON *object;MBSInformation=cJSON_CreateObject();       if (outValue[0] ==0x00){        outlen=0x00;nlen = ((VerBuf[1] << 8) & 0xFF00);nlen |= VerBuf[2] & 0xFF; memcpy(outTemp,VerBuf+3,nlen);MBSInformation=cJSON_Parse((char *)outTemp);              cJSON *arrayItem = cJSON_GetObjectItem(MBSInformation,"FAULT_CODE");char data[1024]={0};if (arrayItem >0){strTemp =arrayItem->valuestring;   int inum=cJSON_GetArraySize(arrayItem);cJSON*item;for(int i=0;i<inum;i++) {FuWuQiData fw;memset(fw.datafwq,0x00,sizeof(fw.datafwq));object=cJSON_GetArrayItem(arrayItem,i);item=cJSON_GetObjectItem(object,"id");memcpy((char*)(LPCTSTR)fw.id,item->valuestring,strlen(item->valuestring));item=cJSON_GetObjectItem(object,"text");memcpy((char*)(LPCTSTR)fw.datafwq,item->valuestring,strlen(item->valuestring));                         listvector.push_back(fw);}}}   cJSON_Delete(MBSInformation);return 0;
}void ShouHouTool::startThread()
{DWORD m_dwOpThreadID;          //线程IDHANDLE m_hOpThread;           //发送线程句柄m_hOpThread = CreateThread(NULL,0,ReadVersion,this,0,&m_dwOpThreadID);}DWORD WINAPI ShouHouTool::ReadVersion(LPVOID pParam)
{ShouHouTool* dlg = (ShouHouTool*)pParam;dlg->onbutaddtoDetailInformation();return 0;
}int  ShouHouTool::ShouHouWeiXiuDetailDeal( char *VerBuf,int vsize,int iEEcode)
{char outValue[2048]={0x00};char outTemp[1024]={0x00};QString strTemp="";  int  olen=0;int  nlen=0;  QString strid="",strFAC_ID="",strMIDDLE_CODE="";QString strSERIAL_NO="",strFAULT_CLASS="", strFAULT_CAUSE="",strRETEST_FAILURE="";QString strFAULT_NUM="",strFAULT_LOCATION="", strREWORK_REP_TIMES="",strABILITY="";      QString strPROCESSING_METHOD="",strTESTER_CODE="",strMAINTENANCE_PER_CODE="",strSTATE="",strINPUT_TIME="",strCOMPLEITION_TIME="";QString strMAINT_DETAILS="",  strCREATE_USER_NAME="",strCREATE_DATE_TIME="",strUPDATE_USER_NAME="",strUPDATE_DATE_TIME="";cJSON *MBSInformation,*arrayItem;MBSInformation=cJSON_CreateObject();        if (VerBuf[0] ==0x00 && olen > 0){                           nlen = ((VerBuf[1] << 8) & 0xFF00);nlen |= VerBuf[2] & 0xFF; memcpy(outTemp,VerBuf+3,nlen);if (nlen >0){MBSInformation=cJSON_Parse((char *)outTemp);   arrayItem = cJSON_GetObjectItem(MBSInformation,"ID");if (arrayItem >0){strid =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAC_ID");if (arrayItem >0){strFAC_ID =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"MIDDLE_CODE");if (arrayItem >0){strMIDDLE_CODE =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"SERIAL_NO");if (arrayItem >0){strSERIAL_NO =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_CLASS");if (arrayItem >0){strFAULT_CLASS =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_CAUSE");if (arrayItem >0){strFAULT_CAUSE =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"RETEST_FAILURE");if (arrayItem >0){strRETEST_FAILURE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_NUM");if (arrayItem >0){strFAULT_NUM =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_LOCATION");if (arrayItem >0){strFAULT_LOCATION =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"REWORK_REP_TIMES");if (arrayItem >0){strREWORK_REP_TIMES =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"ABILITY");if (arrayItem >0){strABILITY =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"PROCESSING_METHOD");if (arrayItem >0){strPROCESSING_METHOD =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"TESTER_CODE");if (arrayItem >0){strTESTER_CODE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"MAINTENANCE_PER_CODE");if (arrayItem >0){strMAINTENANCE_PER_CODE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"STATE");if (arrayItem >0){strSTATE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"INPUT_TIME");if (arrayItem >0){strINPUT_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"COMPLEITION_TIME");if (arrayItem >0){strCOMPLEITION_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"MAINT_DETAILS");if (arrayItem >0){strMAINT_DETAILS =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"CREATE_USER_NAME");if (arrayItem >0){strCREATE_USER_NAME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"CREATE_DATE_TIME");if (arrayItem >0){strCREATE_DATE_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"UPDATE_USER_NAME");if (arrayItem >0){strUPDATE_USER_NAME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"UPDATE_DATE_TIME");if (arrayItem >0){strUPDATE_DATE_TIME =arrayItem->valuestring;}//        strTemp =strMIDDLE_CODE+"|"+strSERIAL_NO+"|"+strFAULT_CLASS+"|"+strFAULT_CAUSE+"|"+strRETEST_FAILURE+"|"+strFAULT_NUM+"|"+strFAULT_LOCATION+"|"+strREWORK_REP_TIMES+"|"+strABILITY+"|"+strPROCESSING_METHOD+"|"+strTESTER_CODE+"|"+strMAINTENANCE_PER_CODE+"|"+strINPUT_TIME+"|"+strCOMPLEITION_TIME+"|"+strMAINT_DETAILS+"|"+strCREATE_USER_NAME+"|"+strCREATE_DATE_TIME+"|"+strUPDATE_USER_NAME+"|"+strUPDATE_DATE_TIME;ui.textEditInfor->setText(strTemp);}else{///ui.textEditInfor->setText("无法解析到数据");}   }else {     nlen = ((VerBuf[1] << 8) & 0xFF00);nlen |= VerBuf[2] & 0xFF; memcpy(outTemp,VerBuf+3,nlen);MBSInformation=cJSON_Parse((char *)outTemp);           arrayItem =cJSON_GetObjectItem (MBSInformation,"msg");if (arrayItem >0){strTemp =arrayItem->valuestring;}ui.textEditInfor->setText(strTemp);}  cJSON_Delete(MBSInformation);return 0;
}int  ShouHouTool::GetShouHouWeiXiuRecord( char *VerBuf,int vsize,char *outBuf,int &outlen,int &iErrCode)
{char outValue[2048]={0x00};byte outTemp[512]={0x00};QString strTemp="";   QString strid="",strFAC_ID="",strMIDDLE_CODE="";QString strSERIAL_NO="",strFAULT_CLASS="", strFAULT_CAUSE="",strRETEST_FAILURE="";QString strFAULT_NUM="",strFAULT_LOCATION="", strREWORK_REP_TIMES="",strABILITY="";      QString strPROCESSING_METHOD="",strTESTER_CODE="",strMAINTENANCE_PER_CODE="",strSTATE="",strINPUT_TIME="",strCOMPLEITION_TIME="";QString strMAINT_DETAILS="",  strCREATE_USER_NAME="",strCREATE_DATE_TIME="",strUPDATE_USER_NAME="",strUPDATE_DATE_TIME="";cJSON *MBSInformation;cJSON *arrayItem;MBSInformation=cJSON_CreateObject();cJSON_AddStringToObject(MBSInformation,"TUSN","");cJSON_AddStringToObject(MBSInformation,"Position_number","");cJSON_AddStringToObject(MBSInformation,"order_number","");cJSON_AddStringToObject(MBSInformation,"TOOLS_INFO"  ,"");cJSON_AddStringToObject(MBSInformation,"TOOLS_ALIAS" ,"");char *jsonBuf=cJSON_PrintUnformatted(MBSInformation);g_minipaydllFunction->m_GetShouHouWeiXiuRecord(jsonBuf,strlen(jsonBuf),outBuf,outlen,iErrCode);int  olen=0;int  nlen=0; char*MySQLConnet=("服务器连接异常");  g_minipaydllFunction->m_GetShouHouWeiXiuRecord(jsonBuf,strlen(jsonBuf),outBuf,outlen,iErrCode);iErrCode=VerBuf[0]&0xff;if (VerBuf[0] ==0x00 && olen > 0){                            nlen = ((VerBuf[1] << 8) & 0xFF00);nlen |= VerBuf[2] & 0xFF; memcpy(outTemp,VerBuf+3,nlen);if (nlen >0){MBSInformation=cJSON_Parse((char *)outTemp);   cJSON* arrayItem = cJSON_GetObjectItem(MBSInformation,"ID");if (arrayItem >0){strid =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAC_ID");if (arrayItem >0){strFAC_ID =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"MIDDLE_CODE");if (arrayItem >0){strMIDDLE_CODE =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"SERIAL_NO");if (arrayItem >0){strSERIAL_NO =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_CLASS");if (arrayItem >0){strFAULT_CLASS =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_CAUSE");if (arrayItem >0){strFAULT_CAUSE =arrayItem->valuestring;}///arrayItem =cJSON_GetObjectItem (MBSInformation,"RETEST_FAILURE");if (arrayItem >0){strRETEST_FAILURE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_NUM");if (arrayItem >0){strFAULT_NUM =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"FAULT_LOCATION");if (arrayItem >0){strFAULT_LOCATION =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"REWORK_REP_TIMES");if (arrayItem >0){strREWORK_REP_TIMES =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"ABILITY");if (arrayItem >0){strABILITY =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"PROCESSING_METHOD");if (arrayItem >0){strPROCESSING_METHOD =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"TESTER_CODE");if (arrayItem >0){strTESTER_CODE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"MAINTENANCE_PER_CODE");if (arrayItem >0){strMAINTENANCE_PER_CODE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"STATE");if (arrayItem >0){strSTATE =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"INPUT_TIME");if (arrayItem >0){strINPUT_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"COMPLEITION_TIME");if (arrayItem >0){strCOMPLEITION_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"MAINT_DETAILS");if (arrayItem >0){strMAINT_DETAILS =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"CREATE_USER_NAME");if (arrayItem >0){strCREATE_USER_NAME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"CREATE_DATE_TIME");if (arrayItem >0){strCREATE_DATE_TIME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"UPDATE_USER_NAME");if (arrayItem >0){strUPDATE_USER_NAME =arrayItem->valuestring;}arrayItem =cJSON_GetObjectItem (MBSInformation,"UPDATE_DATE_TIME");if (arrayItem >0){strUPDATE_DATE_TIME =arrayItem->valuestring;}//     strTemp =strMIDDLE_CODE+"|"+strSERIAL_NO+"|"+strFAULT_CLASS+"|"+strFAULT_CAUSE+"|"+strRETEST_FAILURE+"|"+strFAULT_NUM+"|"+strFAULT_LOCATION+"|"+strREWORK_REP_TIMES+"|"+strABILITY+"|"+strPROCESSING_METHOD+"|"+strTESTER_CODE+"|"+strMAINTENANCE_PER_CODE+"|"+strINPUT_TIME+"|"+strCOMPLEITION_TIME+"|"+strMAINT_DETAILS+"|"+strCREATE_USER_NAME+"|"+strCREATE_DATE_TIME+"|"+strUPDATE_USER_NAME+"|"+strUPDATE_DATE_TIME;ui.textEditInfor->setText(strTemp);}else{///nlen = ((outValue[1] << 8) & 0xFF00);nlen |= outValue[2] & 0xFF; memcpy(outTemp,outValue+3,nlen);MBSInformation=cJSON_Parse((char *)outTemp);   arrayItem =cJSON_GetObjectItem (MBSInformation,"msg");if (arrayItem >0){strTemp =arrayItem->valuestring;}ui.textEditInfor->setText(strTemp);}  }else { iErrCode =-1;memcpy((char*)outBuf,MySQLConnet,strlen(MySQLConnet));}   cJSON_Delete(MBSInformation);return 0;
}

cjson调用的实例 c++相关推荐

  1. 关于webservice的异步调用简单实例

    于webservice的异步调用简单实例 无论在任何情况下,被调用方的代码无论是被异步调用还是同步调用的情况下,被调用方的代码都是一样的, 下面,我们就以异步调用一个webservice 为例作说明. ...

  2. feign调用多个服务_Spring Cloud多个微服务之间调用代码实例

    这篇文章主要介绍了Spring Cloud多个微服务之间调用代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 现在又一个学生微服务 user ...

  3. java字典写实例,基于JAVA的新华字典接口调用代码实例

    基于JAVA的新华字典接口调用代码实例 接口描述:基于JA V A的新华字典接口调用代码实例 接口平台:聚合数据 import java.io.BufferedReader; import java. ...

  4. java 实现违章_基于JAVA的车辆违章查询数据调用代码实例

    基于JAVA的车辆违章查询数据调用代码实例 代码描述:基于JA V A的车辆违章查询数据调用代码实例 相关平台:聚合数据 import java.io.BufferedReader; import j ...

  5. php 菜谱 源码,基于php的菜谱大全api调用代码实例

    代码描述:基于php的菜谱大全api调用代码实例 接口地址:http://www.juhe.cn/docs/api/id/46 PHP代码 // +-------------------------- ...

  6. 外汇汇率接口 java_基于JAVA的货币汇率api调用代码实例

    代码描述:基于JAVA的货币汇率api调用代码实例 关联数据:货币汇率 接口地址:http://www.juhe.cn/docs/api/id/23 1.[代码][Java]代码 import jav ...

  7. 原生ajax如何执行,原生ajax调用数据实例讲解

    由于jQuery的盛行,现在使用较多的是jQuery封装好了的ajax,因为解决了浏览器兼容性问题,这对程序员来说就等于去掉了一个心头大患,但并非原生ajax就销声匿迹,并且本人感觉还是对原生的aja ...

  8. python的坐标代码_基于Python的地图坐标服务接口调用代码实例

    代码描述:基于Python的地图坐标服务接口调用代码实例 关联数据:地图坐标服务 接口地址:http://www.juhe.cn/docs/api/id/32 #!/usr/bin/python # ...

  9. Android移动APP开发笔记——Cordova(PhoneGap)通过CordovaPlugin插件调用 Activity 实例...

    引言 Cordova(PhoneGap)採用的是HTML5+JavaScript混合模式来开发移动手机APP.因此当页面须要获取手机内部某些信息时(比如:联系人信息,坐标定位.短信等),程序就须要调用 ...

最新文章

  1. OCP读书笔记(10) - 使用闪回技术I
  2. oracle scott用户
  3. 大厂首发!java代码对齐快捷键
  4. cka教程_2020年11月新版CKA考试心得
  5. 【渝粤教育】国家开放大学2018年秋季 1166t汉语通论 参考试题
  6. MySQL系列(一) MySQL体系结构概述
  7. final个人阅读作业
  8. 介绍一种在Xcode中删除一整行代码的快捷键设置,
  9. 使用Telnet客户端测试Exchange邮件收发
  10. 使用docker-compose 大杀器来部署服务 上(转)
  11. 华为电脑管家PcManager多屏协同功能破解
  12. 入职直接给事业编, 90万补贴+50万科启,重庆高校
  13. Spring的三大核心思想
  14. 01. Perl 简介
  15. 搜狗收录之搜狗推送神器
  16. WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version.
  17. Beer-Lambert Law and LAI
  18. UnRaid虚拟机安装Uos家庭版并由Windows远程桌面访问的成功流程
  19. 漂泊者乐园资源分享_有声英语书_BlABook0038_The Night Crew
  20. 技术漫谈|DOE实验设计系列:关键工艺参数的如何识别、定义?

热门文章

  1. java JDBC连接Oracle数据库的方法
  2. 上云实践操作(漫步云端)之上云动力
  3. 如何搭建一个视频直播系统
  4. A-Frame.js 学习文档翻译(一)实体
  5. linux 文件删除恢复
  6. 一些知识点的初步理解_6(核函数,ing...)
  7. Ansi与Unicode及慎用W2A等
  8. Blackberry阻碍因素
  9. Spring Boot req中@NotNull, @NotEmpty和@NotBlank之间的区别是什么?
  10. swoole 异步MYSQL