///<summary>Executes the GetLockedObjects command, returning an FdoILockedObjectReader.</summary> /// <returns>Returns FdoILockedObjectReade.r</returns> FdoILockedObjectReader* ArcSDEGetLockedObjectsCommand::Execute () { FdoPtr<ArcSDEConnection> connection; CHAR user_name[SE_MAX_OWNER_LEN]; FdoStringP user_str; CHAR* user; LONG result; SE_REGINFO *registrations; LONG count; CHAR table_name[SE_QUALIFIED_TABLE_NAME]; LONG number; LONG *ids; FdoPtr<ArcSDELockedObjectReader> ret; // verify the connection connection = static_cast<ArcSDEConnection*>(GetConnection ()); if (connection == NULL) throw FdoException::Create (NlsMsgGet (ARCSDE_CONNECTION_NOT_ESTABLISHED, "Connection not established.")); // establish an empty locked object reader ret = new ArcSDELockedObjectReader (connection); // get the user name if (NULL == GetLockOwner () || (0 == wcscmp (L"", GetLockOwner ()))) { result = SE_connection_get_user_name (connection->GetConnection (), user_name); handle_sde_err<FdoCommandException> (connection->GetConnection (), result, __FILE__, __LINE__, ARCSDE_USER_UNKNOWN, "Cannot determine current user."); user = user_name; } else { user_str = mLockOwner.Upper(); #ifdef SDE_UNICODE user = (CHAR*)sde_cstwc(user_str); #else sde_wide_to_multibyte (user, (FdoString*)user_str); #endif } // process the list of registered arcsde tables, checking for locks by user (or not) // Read all registered arcsde tables, adding user locks on the rows to the FdoILockedObjectReader connection->GetArcSDERegistrationList(®istrations, &count); for (int i = 0; i < count; i++) { if (SE_reginfo_allow_rowlocks (registrations[i])) { result = SE_reginfo_get_table_name (registrations[i], table_name); handle_sde_err<FdoCommandException> (connection->GetConnection(), result, __FILE__, __LINE__, ARCSDE_REGISTRATION_INFO_ITEM, "Table registration info item '%1$ls' could not be retrieved.", L"table_name"); result = SE_table_get_rowlocks_by_user (connection->GetConnection(), table_name, user, &number, &ids); handle_sde_err<FdoCommandException>(connection->GetConnection(), result, __FILE__, __LINE__, ARCSDE_GET_ROW_LOCK_LIST_FAILED, "Failed to get the row lock list."); for (int j = 0; j < number; j++) ret->AddIdentity (table_name, ids[j]); SE_table_free_rowlocks_list (number, ids, NULL); } } return (FDO_SAFE_ADDREF (ret.p)); }
/// <summary>Executes the GetLockOwners command, returning an FdoILockOwnersReader.</summary> /// <returns>Returns the lock info reader.</returns> FdoILockOwnersReader* ArcSDEGetLockOwnersCommand::Execute () { FdoPtr<ArcSDEConnection> connection; CHAR user_name[SE_MAX_OWNER_LEN]; LONG result; SE_REGINFO *registrations; LONG count; CHAR table_name[SE_QUALIFIED_TABLE_NAME]; LONG number; LONG *ids; CHAR **users; FdoPtr<ArcSDELockOwnersReader> ret; // verify the connection connection = static_cast<ArcSDEConnection*>(GetConnection ()); if (connection == NULL) throw FdoException::Create (NlsMsgGet (ARCSDE_CONNECTION_NOT_ESTABLISHED, "Connection not established.")); // establish an empty lock owners reader ret = new ArcSDELockOwnersReader (); // process the list of registered arcsde tables, checking for locks by user (or not) // Read all registered arcsde tables, adding them into their schema: connection->GetArcSDERegistrationList(®istrations, &count); user_name[0] = '\0'; // cache to speed up processing for (int i = 0; i < count; i++) { if (SE_reginfo_allow_rowlocks (registrations[i])) { result = SE_reginfo_get_table_name (registrations[i], table_name); handle_sde_err<FdoCommandException> (connection->GetConnection (), result, __FILE__, __LINE__, ARCSDE_REGISTRATION_INFO_ITEM, "Table registration info item '%1$ls' could not be retrieved.", L"table_name"); result = SE_table_get_rowlocks (connection->GetConnection (), table_name, &number, &ids, &users); handle_sde_err<FdoCommandException>(connection->GetConnection(), result, __FILE__, __LINE__, ARCSDE_GET_ROW_LOCK_LIST_FAILED, "Failed to get the row lock list."); for (int j = 0; j < number; j++) { if (0 != sde_strcmp (sde_pcus2wc(user_name), sde_pcus2wc(users[j]))) { wchar_t* owner; sde_strcpy (sde_pus2wc(user_name), sde_pcus2wc(users[j])); sde_multibyte_to_wide (owner, user_name); ret->AddOwner (owner); } } SE_table_free_rowlocks_list (number, ids, users); } } return (FDO_SAFE_ADDREF (ret.p)); }