示例#1
0
void processWindowMessage(LONG_PTR source, LONG_PTR hwnd, WPARAM wParam, LPARAM lParam)
{
    char							procVar[30] = ST_TRAYNOTIFICATION;
    LONG_PTR							procNbr = 0;
    PA_Variable						fourDVar;
    BOOL							bFuncReturn;


    bFuncReturn = SetForegroundWindow(windowHandles.fourDhWnd);
    switch (source)
    {
    case TRAY_ICON_FUNCTION :
        if( ( PA_Get4DVersion() & 0x0000FFFF ) < 0x00001100 ) {
            // REB #17503 8/8/08 in v11 we can no longer call PA_GetVariable from this subclass.
            //   Instead of setting the ST_TRAYNOTIFICATION variable, we will just do a call
            //   back to the monitoring process in 4D on double clicks.
            strcpy(procVar, ST_TRAYNOTIFICATION);
            fourDVar = PA_GetVariable(procVar);
            if (PA_GetVariableKind(fourDVar) == eVK_Longint) {
                PA_SetLongintVariable(&fourDVar, lParam);
                PA_SetVariable(procVar, fourDVar, 1);
                findIconID( &startPtr, (LONG_PTR)wParam, &procNbr); // find icon id and get process number
                PA_UpdateProcessVariable(procNbr);
            }
        } else {
            if((lParam==515)|(lParam==518)) {
                findIconID( &startPtr, (LONG_PTR)wParam, &procNbr); // find icon id and get process number
                PA_UpdateProcessVariable(procNbr);
            };
        };
        break;

    case RESPECT_TOOL_BAR_FUNCTION :
        // REB #16207 1/7/09 In v11 we can no longer call PA_GetVariable from this subclass.
        // Unfortunately we won't be able to support use of <>TB_NOTIFICATION anymore.
        if( ( PA_Get4DVersion() & 0x0000FFFF ) < 0x00001100 ) {
            strcpy(procVar, TB_NOTIFICATION);
            fourDVar = PA_GetVariable(procVar);
            if (PA_GetVariableKind(fourDVar) == eVK_ArrayLongint) {
                if (PA_GetArrayNbElements(fourDVar) == 4) {
                    if (toolBarRestrictions.leftProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 1, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.leftProcessNbr);
                    }
                    if (toolBarRestrictions.topProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 2, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.topProcessNbr);
                    }
                    if (toolBarRestrictions.rightProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 3, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.rightProcessNbr);
                    }
                    if (toolBarRestrictions.bottomProcessNbr > 0) {
                        PA_SetLongintInArray(fourDVar, 4, hwnd);
                        PA_SetVariable(procVar, fourDVar, 0);
                        PA_UpdateProcessVariable(toolBarRestrictions.bottomProcessNbr);
                    }
                }
            }
        } else {
            // REB 3/29/10 #22878 Since we can't update the TB_NOTIFICATION array, just do a call to the toolbar processes.
            if (toolBarRestrictions.leftProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.leftProcessNbr);
            }
            if (toolBarRestrictions.topProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.topProcessNbr);
            }
            if (toolBarRestrictions.rightProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.rightProcessNbr);
            }
            if (toolBarRestrictions.bottomProcessNbr > 0) {
                PA_UpdateProcessVariable(toolBarRestrictions.bottomProcessNbr);
            }
        }

        break;

    }
}
void OD_Set_SQL_in_cursor(sLONG_PTR *pResult, PackagePtr pParams)
{
	C_LONGINT Param1;
	C_TEXT Param2;
	C_LONGINT Param3;	
	C_LONGINT returnValue;
	
	Param1.fromParamAtIndex(pParams, 1);
	Param2.fromParamAtIndex(pParams, 2);
	Param3.fromParamAtIndex(pParams, 3);
	
	uint32_t cursorId = Param1.getIntValue();
	
	sword err = 0;
	
	ORACLE_SQL_CURSOR *cursor = _cursorGetAndCheckInactive(cursorId);
	
	if(cursor)
	{
		sessionInfo *session = _sessionGet(cursor->sessionId);
		
		if(session)
		{
			_cursorClearBind(session, cursor);
			
			//convert 4D bindings to oracle bindings
			CUTF8String sql, substr;
			Param2.copyUTF8String(&sql);
			
			size_t start, end, pos; 
			end = 0;
			pos = 0;
			
			C_TEXT variableName;
			PA_Variable variable;
			
			CUTF8String parsedSql;
			
			ORACLE_SQL_SUBSTITUTION_LIST substitutions;
			//ORACLE_SQL_BIND_TYPE_LIST isByName;
			ORACLE_SQL_BIND_NAME_LIST names;
			
			C_TEXT temp;
			CUTF16String u16;
			
			for(start = sql.find((const uint8_t *)"<<"); start != CUTF8String::npos; start = sql.find((const uint8_t *)"<<", end))
			{
				end = sql.find((const uint8_t *)">>", start);
				if(end != CUTF8String::npos)
				{
					start += 2;//length of "<<"
					substr = sql.substr(start, end-start);
					
					variableName.setUTF8String(&substr);
					variable = PA_GetVariable((PA_Unichar *)variableName.getUTF16StringPtr());
					
					parsedSql += sql.substr(pos, start - pos - 2);
					parsedSql += (const uint8_t *)":";
					
					if(substr.length()){
						
						parsedSql += substr;
						//isByName.push_back(true);
						temp.setUTF8String(&substr);
						temp.copyUTF16String(&u16);
						
					}else{
						
						char buf[10];
						size_t len;
						
						len = sprintf(buf,"%d", (int)substitutions.size() + 1);
						parsedSql += CUTF8String((const uint8_t *)buf, len);
						//isByName.push_back(false);
						u16.clear();
						
					}
					
					pos = end + 2;//length of ">>"
					
					names.push_back(u16);
					substitutions.push_back(variable);	
					
				}
				
			}
			
			//remaining text
			parsedSql += sql.substr(pos);			

			temp.setUTF8String(&parsedSql);
			temp.copyUTF16String(&cursor->sql);
			
			cursor->substitutions = substitutions;
//			cursor->isByName = isByName;
			cursor->names = names;
			
			size_t count = substitutions.size();
			
			_cursorResize(session, cursor, count);

			unsigned int sql_type = 0;
			
			ub4 language = OCI_NTV_SYNTAX;
			
			switch (Param3.getIntValue())
			{
				case 2:
					language = OCI_V7_SYNTAX;
					break;

				case 3:
					language = OCI_V8_SYNTAX;
					break;					
			}
			
			err = OCIStmtPrepare(cursor->stmtp, cursor->errhp, 
						   (CONST text *)cursor->sql.c_str(), 
						   (ub4)cursor->sql.length() * sizeof(PA_Unichar),								 
						   language,
						   OCI_DEFAULT);
			
			//in characters or in number of bytes, depending on the encoding
			//http://docs.oracle.com/cd/B10500_01/appdev.920/a96584/oci16ms6.htm
			
			if(!err)
			{
				err = OCIAttrGet(cursor->stmtp, OCI_HTYPE_STMT, (dvoid *)&sql_type, 0, OCI_ATTR_STMT_TYPE, cursor->errhp);
				//http://docs.oracle.com/cd/B10500_01/appdev.920/a96584/oci15r20.htm#443771
				
				if(!err)
				{
					cursor->sql_type = sql_type;
					//http://docs.oracle.com/cd/E14072_01/appdev.112/e10646/oci04sql.htm#CIHEHCEJ	
					
					switch (sql_type)
					{
						case OCI_STMT_SELECT:
							cursor->isTowardsSQL.assign(count, false);//SELECT is towards 4D
							break;					
						default:
							cursor->isTowardsSQL.assign(count, true);//INSERT is towards SQL
							break;
					}
					
					returnValue.setIntValue(1);

				}

			}
			
			if(err)
			{
				_errorInfoSet(0, cursor->errhp, cursor->sessionId, cursorId, false, PA_GetCurrentProcessNumber(), 0);	
				returnValue.setIntValue(err);
			}
			
		}

	}
		
	returnValue.setReturn(pResult);	
	
}