Exemple #1
0
/* CRelationMgr::Insert()时调用,用于网关初次上线添加记录或重新上线时更新记录 */
bool CClientInfo::AddWangguan(const char * name)
{
	char sql_line[NORMAL_XG_BUF_LEN];
	char sql_line_exist[NORMAL_XG_BUF_LEN];

	int sql_len_exist = _snprintf_s(sql_line_exist, NORMAL_XG_BUF_LEN-1, _TRUNCATE,
		"SELECT serial FROM %s WHERE serial='%s'", m_wangguan_table, name);
	sql_line_exist[sql_len_exist] = '\0';
	MYSQL_RES * existresults = BeginQuery(sql_line_exist);	// 查询网关名称看是否已存在
	if (NULL == existresults)
	{
		return FALSE;
	}

	if(existresults->row_count == 0)	// 如果不存在,新添加一项网关上线记录
	{	
		EndQuery(existresults);

		int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
			"INSERT INTO %s(serial, onoff) VALUES('%s', 1)",
			m_wangguan_table, name);
		SLOG(4)("AddWangguan = %s", sql_line);

		if(-1 == sql_len)
		{
			return false;
		}
		sql_line[sql_len] = '\0';

		MYSQL_RES * results = BeginQuery(sql_line);
		EndQuery(results);
	}
	else								// 如果存在,说明网关重新上线,则更新记录
	{
		EndQuery(existresults);
		int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
			"UPDATE %s SET onoff=1 WHERE serial='%s'",
			m_wangguan_table, name);
		SLOG(4)("AddWangguan = %s", sql_line);

		if(-1 == sql_len)
		{
			return false;
		}
		sql_line[sql_len] = '\0';

		MYSQL_RES * results = BeginQuery(sql_line);
		EndQuery(results);
	}
	return TRUE;
}
void
WebGL2Context::DeleteQuery(WebGLQuery* query)
{
    if (IsContextLost())
        return;

    if (!query)
        return;

    if (query->IsDeleted())
        return;

    if (query->IsActive())
        EndQuery(query->mType);

    if (mActiveOcclusionQuery && !gl->IsGLES()) {
        /* http://www.opengl.org/registry/specs/ARB/occlusion_query.txt
         *
         * Calling either GenQueriesARB or DeleteQueriesARB while any query of
         * any target is active causes an INVALID_OPERATION error to be
         * generated.
         */
        GenerateWarning("deleteQuery: The WebGL 2 prototype might generate"
                        " INVALID_OPERATION when deleting a query object while"
                        " one other is active.");
    }

    query->RequestDelete();
}
Exemple #3
0
/* CClientContainer::Delete()中调用,即当删除客户端时,更新其对应网关的客户端记录 */
bool CClientInfo::DecreClientRecord(const char * name, int type)
{
	char sql_line[NORMAL_XG_BUF_LEN];
	int sql_len;
	switch(type)
	{
	case RM_PHONE:
		{
			sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
				"UPDATE %s SET android_phone=android_phone-1 WHERE serial='%s'",
				m_client_record_table, name);
			SLOG(4)("DecreClientRecord = %s", sql_line);
			break;
		}
	case RM_PY:
		{
			sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
				"UPDATE %s SET android_pad=android_pad-1 WHERE serial='%s'",
				m_client_record_table, name);
			SLOG(4)("DecreClientRecord = %s", sql_line);
			break;
		}
	case RM_PC:
		{
			sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
				"UPDATE %s SET pc=pc-1 WHERE serial='%s'",
				m_client_record_table, name);
			SLOG(4)("DecreClientRecord = %s", sql_line);
			break;
		}
	case TMP:
		{
			sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
				"UPDATE %s SET tmp=tmp-1 WHERE serial='%s'",
				m_client_record_table, name);
			SLOG(4)("DecreClientRecord = %s", sql_line);
			break;
		}
	case iOS:
		{
			sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
				"UPDATE %s SET iOS=iOS-1 WHERE serial='%s'",
				m_client_record_table, name);
			SLOG(4)("DecreClientRecord = %s", sql_line);
			break;
		}
	default:
		break;
	}
	if(-1 == sql_len) 
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
Exemple #4
0
/* 当网关登录时,初始化客户端记录列表 */
bool CClientInfo::InitClientRecord(const char * name)
{
	char sql_line[NORMAL_XG_BUF_LEN];
	char sql_line_exist[NORMAL_XG_BUF_LEN];

	int sql_len_exist = _snprintf_s(sql_line_exist, NORMAL_XG_BUF_LEN-1, _TRUNCATE,
		"SELECT serial FROM %s WHERE serial='%s'", m_client_record_table, name);
	sql_line_exist[sql_len_exist] = '\0';
	MYSQL_RES * existresults = BeginQuery(sql_line_exist);	// 查询网关名称看是否已存在
	if (NULL == existresults)
	{
		return FALSE;
	}

	if(existresults->row_count == 0)
	{	
		EndQuery(existresults);

		// 如果不存在则初始化client_record表,各项均置为0
		int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
			"INSERT INTO %s(serial,android_phone,android_pad,pc,tmp,iOS)\
			VALUES('%s', 0, 0, 0, 0, 0)",
			m_client_record_table, name);
		if(-1 == sql_len)
		{
			return false;
		}

		SLOG(4)("InitClientRecord = %s", sql_line);

		sql_line[sql_len] = '\0';

		MYSQL_RES * results = BeginQuery(sql_line);
		EndQuery(results);
	}
	else
	{
		EndQuery(existresults);
	}
	return TRUE;
}
Exemple #5
0
bool cConfMySQL::LoadPK()
{
	ostringstream query;
	SelectFields(query);
	WherePKey(query);

	if (StartQuery(query.str()) == -1)
		return false;

	bool found = (Load() >= 0);
	EndQuery();
	return found;
}
Exemple #6
0
/* 转发服务器退出后,清空网关客户端记录 */
bool CClientInfo::ZeroClientRecord()
{
	char sql_line[NORMAL_XG_BUF_LEN];
	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"DELETE FROM %s", m_client_record_table);
	SLOG(4)("ZeroClientRecord = %s", sql_line);

	if(-1 == sql_len)
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);
	EndQuery(results);
	return TRUE;
}
bool QueryResultPostgre::NextRow()
{
    if (!mResult)
        return false;

    if (mTableIndex >= mRowCount)
    {
        EndQuery();
        return false;
    }

    for (int j = 0; j < mFieldCount; j++)
    {
        mCurrentRow[j].SetValue(PQgetvalue(mResult, mTableIndex, j));
    }

    return true;
}
Exemple #8
0
/* 当某个网关下线时,更新网关状态 */
bool CClientInfo::UpdateWangguan(const char * name)
{
	char sql_line[NORMAL_XG_BUF_LEN];
	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"UPDATE %s SET onoff=0 WHERE serial='%s'",
		m_wangguan_table, name);
	SLOG(4)("UpdateWangguan = %s", sql_line);

	if(-1 == sql_len)
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);
	EndQuery(results);
	return TRUE;
}
Exemple #9
0
/* 转发服务器退出后,将所有网关置为下线 */
bool CClientInfo::ZeroWangguan()
{
	char sql_line[NORMAL_XG_BUF_LEN];

	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"UPDATE %s SET onoff=0", m_wangguan_table);
	SLOG(4)("ZeroWangguan = %s", sql_line);

	if(-1 == sql_len) 
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
Exemple #10
0
/* 当网关下线时,删除客户端列表中改网关的记录 */
bool CClientInfo::DelClientRecord(const char * name)
{
	char sql_line[NORMAL_XG_BUF_LEN];

	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"DELETE FROM %s WHERE serial='%s'",m_client_record_table, name);
	if(-1 == sql_len) 
	{
		return false;
	}
	SLOG(4)("DelClientRecord = %s", sql_line);

	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
bool QueryResultMysql::NextRow()
{
    MYSQL_ROW row;

    if (!mResult)
        return false;

    row = mysql_fetch_row(mResult);
    if (!row)
    {
        EndQuery();
        return false;
    }

    for (uint32 i = 0; i < mFieldCount; i++)
        mCurrentRow[i].SetValue(row[i]);

    return true;
}
Exemple #12
0
bool CClientInfo::InsertOnoffRecord(const char * name, char * add, int onoff)
{
	char sql_line[NORMAL_XG_BUF_LEN];
	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"INSERT INTO %s(serial,onoff,ip,time)\
		VALUES('%s', %d, '%s', now())",
		m_onoff_record_table, name, onoff, add);
	SLOG(4)("InsertOnoffRecord = %s", sql_line);

	if(-1 == sql_len) 
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
Exemple #13
0
/* 每次转发服务器重新启动时,添加转发服务器上线时间记录 */
bool CClientInfo::AddStartRecord()
{
	char sql_line[NORMAL_XG_BUF_LEN];

	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"INSERT INTO %s(serial,onoff,ip,time) VALUES(0, 1, '116.255.180.115', now())",
		m_onoff_record_table);
	SLOG(4)("AddStartRecord = %s", sql_line);

	if(-1 == sql_len) 
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
Exemple #14
0
/* 每次转发服务器重新启动时,更新最大连接参数 */
bool CClientInfo::UpdateMaxConn(int size)
{
	char sql_line[NORMAL_XG_BUF_LEN];

	int sql_len = _snprintf_s(sql_line, NORMAL_XG_BUF_LEN - 1, _TRUNCATE, 
		"UPDATE %s SET value=%d WHERE param='max_conn'",
		m_conn_param_table, size);
	SLOG(4)("UpdateMaxConn = %s", sql_line);

	if(-1 == sql_len) 
	{
		return false;
	}
	sql_line[sql_len] = '\0';

	MYSQL_RES * results = BeginQuery(sql_line);

	EndQuery(results);
	return TRUE;
}
Exemple #15
0
void core_test() {
	InitializeIndex();
	char f[32] = "abcd";
//	char f2[32] = "aix";

	StartQuery(5, f, MT_EDIT_DIST, 3);
	MatchDocument(10, "s");
	EndQuery(5);
	puts("====");
	fflush(0);

	DocID did;
	QueryID *qid;
	unsigned int numRes;
	GetNextAvailRes(&did, &numRes, &qid);
	int i;
	for (i = 0; i < numRes; i++)
		printf("---->%d\n", qid[i]);
	printf("did = %d, first qid = %d, numRes = %d\n", did, qid[0], numRes);
}
Exemple #16
0
bool QueryResultMysql::NextRow()
{
    MYSQL_ROW row;

    if (!mResult)
        return false;

    row = mysql_fetch_row(mResult);
    if (!row)
    {
        EndQuery();
        return false;
    }
    long unsigned int * fieldLength = mysql_fetch_lengths(mResult);
    for (uint32 i = 0; i < mFieldCount; i++)
    {
        mCurrentRow[i].SetValue(row[i],fieldLength[i]);
        mCurrentRow[i].SetLength(fieldLength[i]);
    }

    return true;
}
Exemple #17
0
/* CRelationMgr::Insert()和CRelationMgr::Remove()时调用,
   用于添加网关上下线记录。
*/
bool CClientInfo::AddOnoffRecord(const char * name, char * add, int onoff)
{
	char sql_line_exist[NORMAL_XG_BUF_LEN];
	int sql_len_exist = _snprintf_s(sql_line_exist, NORMAL_XG_BUF_LEN-1, _TRUNCATE,
		"SELECT COUNT(*) FROM %s WHERE serial='%s'", m_onoff_record_table, name);
	sql_line_exist[sql_len_exist] = '\0';
	SLOG(4)("AddOnoffRecord = %s", sql_line_exist);
	MYSQL_RES * existresults = BeginQuery(sql_line_exist);
	if (NULL == existresults)
	{
		return FALSE;
	}
	int recordnum = strtoul(*mysql_fetch_row(existresults), NULL, 0);
	EndQuery(existresults);
	if( recordnum == 120)		// 如果已有的该网关上下线记录等于120条
	{
		SLOG(4)("此处应当删除前21条记录");		
		DelOnoffRecord(name);
	}
	InsertOnoffRecord(name, add, onoff);

	return TRUE;
}
bool QueryResultSqlite::NextRow()
{
    int startIndex;
    uint32 i;

    if (!mTableData)
        return false;

    if (mTableIndex >= mRowCount)
    {
        EndQuery();
        return false;
    }

    startIndex = (mTableIndex + 1) * mFieldCount;
    for (i = 0; i < mFieldCount; i++)
    {
        mCurrentRow[i].SetValue(mTableData[startIndex + i]);
    }

    ++mTableIndex;
    return true;
}
bool QueryResultPostgre::NextRow()
{
    if (!mResult)
        return false;

    if (mTableIndex >= mRowCount)
    {
        EndQuery();
        return false;
    }

    char* pPQgetvalue;
    for (int j = 0; j < mFieldCount; j++)
    {
        pPQgetvalue = PQgetvalue(mResult, mTableIndex, j);
        if(pPQgetvalue && !(*pPQgetvalue))
            pPQgetvalue = NULL;

        mCurrentRow[j].SetValue(pPQgetvalue);
    }
    ++mTableIndex;

    return true;
}
QueryResultMysql::~QueryResultMysql()
{
    EndQuery();
}
QueryResultPostgre::~QueryResultPostgre()
{
    EndQuery();
}
Exemple #22
0
QueryResult::~QueryResult()
{
    EndQuery();
}
Exemple #23
0
int cConfMySQL::EndQuery()
{
	return EndQuery(mQuery);
}
QueryResultSqlite::~QueryResultSqlite()
{
    EndQuery();
}