/**************************************************************************************************
功能:添加记录
参数:pStaion,待插入的记录
返回:-2,数据库尚未连接
	  -3,添加到列表失败
	  -4,数据库添加操作失败
	  0,添加成功
作者:张林颢 2014-10-11
**************************************************************************************************/
int CPrintParamConfig::add( TPrintParam *pInputParam )
{
	if(!m_isInit)	return -2;

    if( checkDBConnect() < 0 )      return -4;

    TPrintParam temp = {0};
    temp.ID = pInputParam->ID;
    temp.stationID = pInputParam->stationID;
    strcpy(temp.bodyFontFamily, pInputParam->bodyFontFamily);
    temp.fontSize = pInputParam->fontSize;
    temp.indexCol = pInputParam->indexCol;
    temp.contentsCol = pInputParam->contentsCol;
    temp.isFixedTicketName = pInputParam->isFixedTicketName;
    strcpy(temp.fixedTicketName, pInputParam->fixedTicketName);
    temp.isfirstLineGetUp = pInputParam->isfirstLineGetUp;
    strcpy(temp.getUpText, pInputParam->getUpText);
    temp.isLastLineGetDown = pInputParam->isLastLineGetDown;
    strcpy(temp.getDownText, pInputParam->getDownText);
    temp.isFirstLineIndex = pInputParam->isFirstLineIndex;
    temp.isFirstLineFlag = pInputParam->isFirstLineFlag;
    strcpy(temp.firstLineText, pInputParam->firstLineText);
    temp.isLastLineIndex = pInputParam->isLastLineIndex;
    temp.isLastLineFlag = pInputParam->isLastLineFlag;
    strcpy(temp.lastLineText, pInputParam->lastLineText);
    temp.isEndFlag = pInputParam->isEndFlag;
    temp.endType = pInputParam->endType;
    strcpy(temp.endText, pInputParam->endText);
    strcpy(temp.dateTimeFaram, pInputParam->dateTimeFaram);
    strcpy(temp.currentPageFaram, pInputParam->currentPageFaram);
    strcpy(temp.pagesCountFaram, pInputParam->pagesCountFaram);
    temp.isPrintTicketName = pInputParam->isPrintTicketName;
    strcpy(temp.endPicPath, pInputParam->endPicPath);

	int lastAddID;
	char sql[10240] = {0};
    strcat(sql, "insert into t_printparam values(NULL,:f1<unsigned int>,:f2<char[64]>,:f3<unsigned int>,");
    strcat(sql, ":f4<unsigned int>,:f5<unsigned int>,:f6<unsigned int>,:f7<char[64]>,:f8<unsigned int>,:f9<char[64]>,");
    strcat(sql, ":f10<unsigned int>,:f11<char[64]>,:f12<unsigned int>,:f13<unsigned int>,:f14<char[64]>,");
    strcat(sql, ":f15<unsigned int>,:f16<unsigned int>,:f17<char[64]>,:f18<unsigned int>,:f19<unsigned int>,");
	strcat(sql, ":f20<char[64]>,:f21<char[32]>,:f22<char[32]>,:f23<char[32]>,:f24<unsigned int>,:f25<char[255]>)");

	try
	{
		otl_stream insertStream(1, sql, m_db);
		insertStream.set_commit(0);
        insertStream << temp.stationID;
        insertStream << temp.bodyFontFamily;
        insertStream << temp.fontSize;
        insertStream << temp.indexCol;
        insertStream << temp.contentsCol;
        insertStream << temp.isFixedTicketName;
        insertStream << temp.fixedTicketName;
        insertStream << temp.isfirstLineGetUp;
        insertStream << temp.getUpText;
        insertStream << temp.isLastLineGetDown;
        insertStream << temp.getDownText;
        insertStream << temp.isFirstLineIndex;
        insertStream << temp.isFirstLineFlag;
        insertStream << temp.firstLineText;
        insertStream << temp.isLastLineIndex;
        insertStream << temp.isLastLineFlag;
        insertStream << temp.lastLineText;
        insertStream << temp.isEndFlag;
        insertStream << DWORD32(temp.endType);
        insertStream << temp.endText;
        insertStream << temp.dateTimeFaram;
        insertStream << temp.currentPageFaram;
        insertStream << temp.pagesCountFaram;
        insertStream << temp.isPrintTicketName;
        insertStream << temp.endPicPath;

        if(1 == m_dbType)//SQLite数据库
        {
            char strLastAddID[20] = {0};
            otl_stream selectStream(1, "select last_insert_rowid()", m_db);
            selectStream.set_commit(0);
            selectStream >> strLastAddID;
            temp.ID = atoi(strLastAddID);
        }
        else
        {
            otl_stream selectStream(1, "SELECT LAST_INSERT_ID()", m_db);
            selectStream.set_commit(0);
            selectStream >> lastAddID;
            temp.ID = lastAddID;
        }

		m_db.commit();

		int ret = add2List(&temp);
		if(ret < 0)		return -3;
	}
//lixh 2011-09-19 新增红绿灯灯组输出信息
HRESULT CTrafficLightImpl::PrintLightStatus(const LIGHT_TEAM_STATUS& ltsInfo , char* pLightStatus,int iLightStatusLen)
{

	int iPos = 0;
	DWORD32 dwStatus = 0;


	if(NULL == pLightStatus || iLightStatusLen<=0)
	{
		return S_FALSE;
	}
	for(DWORD32 i = 0; i < ltsInfo.nTeamCount; ++i)
	{
		dwStatus = ltsInfo.pdwStatus[i];
		for(int k = ltsInfo.pnLightCount[i] - 1; k >= 0 ; --k)
		{
			if(iPos + k >= iLightStatusLen)
			{
				return S_FALSE;	
			}
			DWORD32 dwLightStatus = dwStatus & 0x0F;
			//外接红绿灯需要跟设置场景对应上20120525
			if (m_tlpTrafficLightParam.iCheckType == 1 && dwLightStatus == 1)
			{
				switch(m_rgIOLight[k].tlsStatus)
				{
				case TLS_RED:
					dwLightStatus = TS_RED;
					break;
				case TLS_YELLOW:
					dwLightStatus = TS_YELLOW;
					break;
				case TLS_GREEN:
					dwLightStatus = TS_GREEN;
					break;
				case TLS_UNSURE:
					dwLightStatus = TS_UNSURE;
					break;
				default:
					break;
				}
			}
			//end
			switch (dwLightStatus)
			{
			case TS_RED:
				pLightStatus[iPos + k] = '1';
				break;
			case TS_YELLOW:
				pLightStatus[iPos + k] = '2';
				break;
			case TS_GREEN:
				pLightStatus[iPos + k] = '3';
				break;
			case TS_UNSURE:
				pLightStatus[iPos + k] = '0';
				break;
			default:
				pLightStatus[iPos + k] = '?';
				break;
			}
			dwStatus >>= 4;
		}
		iPos += ltsInfo.pnLightCount[i];
		if(  DWORD32(i+1) < ltsInfo.nTeamCount )
		{
			if(iPos+1>= iLightStatusLen)
			{
				return S_FALSE;
			}
			pLightStatus[iPos++] = '_';
		}
		//
	}
	return S_OK;
}
//如果是灯组状态与场景是邦定的
int CTrafficLightImpl::GetSceneNumber(const LIGHT_TEAM_STATUS& ltsInfo, const int& iSceneCount)
{
	int iRet = -1;
	char szSceneInfo[64];
	memset(szSceneInfo, 0, 64);
	int iPos = 0;
	DWORD32 dwStatus = 0;
	for(DWORD32 i = 0; i < ltsInfo.nTeamCount; ++i)
	{
		dwStatus = ltsInfo.pdwStatus[i];
		for(int k = ltsInfo.pnLightCount[i] - 1; k >= 0 ; --k)
		{
			switch (dwStatus & 0x0F)
			{
			case TS_RED:
				szSceneInfo[iPos + k] = '1';
				break;
			case TS_YELLOW:
				szSceneInfo[iPos + k] = '2';
				break;
			case TS_GREEN:
				szSceneInfo[iPos + k] = '3';
				break;
			case TS_UNSURE:
				szSceneInfo[iPos + k] = '0';
				break;
			default:
				szSceneInfo[iPos + k] = '?';
				break;
			}
			dwStatus >>= 4;
		}
		iPos += ltsInfo.pnLightCount[i];
		if(  DWORD32(i+1) < ltsInfo.nTeamCount )
		{
			szSceneInfo[iPos++] = '_';
		}
	}

	SCENE_INFO stInfo;
	int iLen = 0;
	for( int i = 0; i < iSceneCount; ++i )
	{
		if( GetSceneInfo(i, &stInfo) )
		{
			iLen = (int)strlen(stInfo.pszInfo);
			if( strlen(szSceneInfo) != iLen ) continue;
			
			int k = 0;
			for(k = 0; k < iLen; ++k)
			{
				if( stInfo.pszInfo[k] == '?' ) continue;
				if( stInfo.pszInfo[k] == '*' &&  szSceneInfo[k] > '0' ) continue;
				if( stInfo.pszInfo[k] != szSceneInfo[k] ) break; 
			}
			if( k >= iLen ) 
			{
				iRet = i;
				break;
			}
		}
	}
	return iRet;
}
Exemple #4
0
ULONG FASTCALL WU32DialogBoxParam(PVDMFRAME pFrame)
{
    ULONG    ul;
    DLGDATA  DlgData;
    PVOID    pDlg;
    DWORD    cb, cb16;
    register PDIALOGBOXPARAM16 parg16;
    BYTE     abT[1024];

    GETARGPTR(pFrame, sizeof(DIALOGBOXPARAM16), parg16);

    DlgData.vpfnDlgProc     = DWORD32(parg16->f4);
    DlgData.dwUserInitParam = DWORD32(parg16->f5);

    if (!(cb16 = parg16->f6)) {
        cb = ConvertDialog16(NULL, DWORD32(parg16->f2), 0, cb16);
    }
    else {
        // The idea is eliminate a call to ConverDialog16
        //
        // the maximum size that 32bit dlgtemplate would be is twice
        // the 16bit dlgtemplate.
        //
        // this assumption is true cause - we convert most words to dwords
        // and ansi strings to unicode strings - since we know that a
        // DWORD is twice the sizeof a WORD a unicode character is 2bytes
        // therefore maxsize of dlgtemplate cannot exceed cb * 2.
        //
        //                                                      - nanduri

        cb = cb16 * max(sizeof(DWORD) / sizeof(WORD), sizeof(WCHAR)/sizeof(BYTE));
        WOW32ASSERT(cb >= ConvertDialog16(NULL, DWORD32(parg16->f2), 0, cb16));
    }

    pDlg = (cb > sizeof(abT)) ? malloc_w(cb) : (PVOID)abT;
    if (cb && pDlg) {
        cb = ConvertDialog16(pDlg, DWORD32(parg16->f2), cb, cb16);

        if (parg16->f7) {
            ul = GETINT16(DialogBoxIndirectParamAorW(HMODINST32(parg16->f1),
                            pDlg, HWND32(parg16->f3),
                            (DLGPROC)(DlgData.vpfnDlgProc ? W32DialogFunc: 0),
                            (LPARAM) &DlgData, SCDLG_ANSI));
        }
        else {
            ul = GETHWND16((pfnOut.pfnServerCreateDialog)(HMODINST32(parg16->f1), (LPDLGTEMPLATE)pDlg,
                            cb,  HWND32(parg16->f3),
                            (DLGPROC)(DlgData.vpfnDlgProc ? W32DialogFunc: 0),
                            (LPARAM) &DlgData,  SCDLG_CLIENT | SCDLG_ANSI | SCDLG_NOREVALIDATE));
        }

        if (pDlg != (PVOID)abT) {
            free_w (pDlg);
        }

    }

    // Invalidate SendDlgItemMessage cache
    hdlgSDIMCached = NULL ;

    FREEARGPTR(parg16);
    RETURN(ul);
}