Make your own free website on Tripod.com
EPolWS
ProfileView
Home
Account
ep_test.txt
SerializableBase
DbConnectionBase
EPolESForm
DbSTable
EmailFactory.cs
epmain
EPolES
DbVariableView.cs
ProfileView
EPolLOcal Main
Page Main Example
EPolWS EPolWS.asmx
EPolWS EPolWS.cs
CommandManager
CommandFactory
CommandFactoryBase
OrganisationView
EPolConsole Main
DbEPBase.cs
DbRecordArray
DbTable

Enter subhead content here

using System; using System.Diagnostics; using System.Collections; using EXDb97; using EXCommon; //###2 namespace EPol { ///--------------------------------------------------------------------------------------------------------------------------------------------------- ///

/// Summary description for Class1. /// ///--------------------------------------------------------------------------------------------------------------------------------------------------- public class CProfileView : CDbVariableSubProfileTable { public CProfileView(P dLanguage, string strDatabaseName) : base(dLanguage, PROFILE_LIST_TABLE_NAME, strDatabaseName) { m_oMasterTable.vAddColumn(LANGUAGE_FIELD, ENTITY_TYPE, false); m_oAvatarRelationAuthorisationTable = new CAvatarGrantRelation(strDatabaseName); m_oAvatarRelationView = new CDbJoinView(new CDbTableView(PROFILE_PREFIXE, m_oMasterTable), new CDbTableView(RELATION_PREFIXE, m_oAvatarRelationAuthorisationTable)); m_oAvatarRelationView.vAddLinkIndex(PROFILE_PREFIXE, MASTER_INDEX_FIELD, RELATION_PREFIXE, MASTER_INDEX_FIELD); m_oAvatarRelationView.vAddLinkIndex(PROFILE_PREFIXE, MASTER_SUB_INDEX_FIELD, RELATION_PREFIXE, MASTER_SUB_INDEX_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView = new CDbJoinView(new CDbTableView(FRIEND_PREFIXE, m_oMasterTable), m_oAvatarRelationView); m_oAvatarRelationWithMyAvatarAccessNameView.vAddLinkIndex(FRIEND_PREFIXE, MASTER_INDEX_FIELD, RELATION_PREFIXE, BENEFICIARY_INDEX_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.vAddLinkIndex(FRIEND_PREFIXE, MASTER_SUB_INDEX_FIELD, RELATION_PREFIXE, BENEFICIARY_SUB_INDEX_FIELD); } CAvatarGrantRelation m_oAvatarRelationAuthorisationTable; CDbJoinView m_oAvatarRelationView, m_oAvatarRelationWithMyAvatarAccessNameView; public override void vCleanAllData() { base.vCleanAllData(); m_oAvatarRelationWithMyAvatarAccessNameView.vCleanAllData(); m_oAvatarRelationAuthorisationTable.dDropTable(); m_oAvatarRelationView.vCleanAllData(); } public EPol.SEntity oGetEntity(P dLanguage, P dClass, string sName) { return CDbEntityManager.Instance(m_sDatabaseName, m_dLanguage).oGetEntity(dLanguage, dClass, sName); } public const string FRIEND_PREFIXE = "fr"; public const string PROFILE_PREFIXE = "prof"; public const string RELATION_PREFIXE = "rel"; public CAvatarGrantRelation GetFriendTable { get { return m_oAvatarRelationAuthorisationTable; } } public ec dGetSelectFriendAvatarAccess(SIndex oClaimingProfile, out ArrayList oTargetProfileArrayList) { m_oAvatarRelationWithMyAvatarAccessNameView.vResetSelect(); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(PROFILE_PREFIXE, MASTER_NAME_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(FRIEND_PREFIXE, MASTER_NAME_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(RELATION_PREFIXE, DATE_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddWhere(RELATION_PREFIXE, BENEFICIARY_INDEX_FIELD, oClaimingProfile.dIndex); CTrace.i().vWriteLn(ENMessage.Avatar, "m_oAvatarRelationView = " + m_oAvatarRelationWithMyAvatarAccessNameView.csDumpTable()); ec dRC = m_oAvatarRelationWithMyAvatarAccessNameView.dGetSelect(out oTargetProfileArrayList); return dRC; } public ec dGetSelectFriend(SIndex oMyProfile, out ArrayList oTargetProfileArrayList) { m_oAvatarRelationWithMyAvatarAccessNameView.vResetSelect(); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(FRIEND_PREFIXE, MASTER_NAME_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(PROFILE_PREFIXE, MASTER_NAME_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddDisplayColumn(RELATION_PREFIXE, DATE_FIELD); m_oAvatarRelationWithMyAvatarAccessNameView.bAddWhere(RELATION_PREFIXE, MASTER_INDEX_FIELD, oMyProfile.dIndex); CTrace.i().vWriteLn(ENMessage.Avatar, "m_oAvatarRelationWithMyAvatarAccessNameView = " + m_oAvatarRelationWithMyAvatarAccessNameView.csDumpTable()); ec dRC = m_oAvatarRelationWithMyAvatarAccessNameView.dGetSelect(out oTargetProfileArrayList); if (dRC == ec.ST_SQL_THE_RETURN_ROW_SET_IS_EMPTY) { dRC = ec.ST_PROFILE_NO_FRIEND_REGISTERED; } return dRC; } public ec dGetSelectFriendAvatarAccess(int dReaderClaimingProfile, int dAuthorTargetProfile, out SIndex[] oTargetAvatar) { m_oAvatarRelationView.vResetSelect(); m_oAvatarRelationView.bAddDisplayColumn(PROFILE_PREFIXE, MASTER_INDEX_FIELD); m_oAvatarRelationView.bAddDisplayColumn(PROFILE_PREFIXE, MASTER_SUB_INDEX_FIELD); m_oAvatarRelationView.bAddWhere(RELATION_PREFIXE, BENEFICIARY_INDEX_FIELD, dReaderClaimingProfile); m_oAvatarRelationView.bAddWhere(RELATION_PREFIXE, MASTER_INDEX_FIELD, dAuthorTargetProfile); ArrayList oTargetProfileArrayList = new ArrayList(); CTrace.i().vWriteLn(ENMessage.Avatar, "m_oAvatarRelationView = " + m_oAvatarRelationView.csDumpTable()); ec dRC = m_oAvatarRelationView.dGetSelect(out oTargetProfileArrayList); dRC = dConvert(oTargetProfileArrayList, out oTargetAvatar); CTrace.i().vWriteLn(ENMessage.Access, " dGetSelectFriendAvatarAccess(" + dReaderClaimingProfile + ")=" + ToString(oTargetAvatar)); return dRC; } public ec dUpdateLanguage(SIndex oProfileIndex, P dDefaultLanguage) { ec dRet = m_oMasterTable.dUpdate(LANGUAGE_FIELD, ((int)dDefaultLanguage).ToString(), m_oMasterTable.sqlIsIndex(oProfileIndex)); return dRet == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_PROFILE_CAN_NOT_CHANGE_AVATAR_LANGUAGE; } public ec dRename(SIndex oProfileIndex, string sNewName) { return m_oMasterTable.dRename(oProfileIndex, sNewName) == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_PROFILE_CAN_NOT_RENAME_THE_AVATAR; } public ec dAddPublicProfile(SIndex oPrivateIndex, string sProfileID, P dLanguage) { ec dRC = ec.ST_SUCCEED; if (IsNotUsed(dLanguage)) dLanguage = P.ENGLISH; if ( IsUsed(CEntityManager.Instance(dLanguage).dFindEntity(sProfileID))) { dRC = ec.ST_PROFILE_SHOULD_NOT_USED_A_RESERVE_KEYWORD; } else if (bHasOnlyAuthorizeCharacter(sProfileID) == false) { dRC = ec.ST_PROFILE_HAS_AN_INVALID_CHARACTER; } else { oPrivateIndex.dSubIndex = NOT_USED; m_oMasterTable.dAddNewSubProfileIndexValues(oPrivateIndex); m_oMasterTable.vAddValue(sProfileID); m_oMasterTable.vAddValue(dLanguage); if (m_oMasterTable.dInsertIntoTable() != ec.ST_SUCCEED) { // oIndex = NOT_USED_SINDEX; dRC = ec.ST_PROFILE_AVATAR_NOT_CREATED; } } return dRC; } public ec dAddAvatar(string strUserID, SIndex oParentIdx, P dDefaultLanguage, out SIndex oNewProfileIndex) { ec dRC = ec.ST_SUCCEED; if (IsNotUsed(dDefaultLanguage)) dDefaultLanguage = P.ENGLISH; if ( IsUsed(CEntityManager.Instance(dDefaultLanguage).dFindEntity(strUserID)) ) { oNewProfileIndex = NOT_USED_SINDEX; dRC = ec.ST_PROFILE_SHOULD_NOT_USED_A_RESERVE_KEYWORD; } else { oNewProfileIndex = m_oMasterTable.dGetIndex(strUserID); if (IsNotUsed(oNewProfileIndex) && IsUsed(oParentIdx)) { oNewProfileIndex = m_oMasterTable.dAddNewSubProfile(strUserID, oParentIdx); m_oMasterTable.vAddValue(dDefaultLanguage); if (m_oMasterTable.dInsertIntoTable() != ec.ST_SUCCEED) { oNewProfileIndex = NOT_USED_SINDEX; dRC = ec.ST_PROFILE_AVATAR_NOT_CREATED; } } } return dRC; } public P dGetLanguage(SIndex oIndex) { return (P)GetMasterTable.dGetInteger(LANGUAGE_FIELD, oIndex); } public bool bIsUserExist(string strProfileId) { SIndex oProfileIndex = m_oMasterTable.dGetIndex(strProfileId); return IsUsed(oProfileIndex); } public ec dCheckIfAvatarOfEmail(string csAvatar, string sEmailAdresss, out SIndex oAvatarProfileIndex) { SIndex oRootProfileIndex = m_oMasterTable.dGetIndex(sEmailAdresss); oAvatarProfileIndex = m_oMasterTable.dGetIndex(csAvatar); return dCheckIfAvatarOfEmail(oAvatarProfileIndex, oRootProfileIndex); } public ec dCheckIfAvatarOfEmail(SIndex oAvatarProfileIndex, SIndex oRootProfileIndex) { if (oRootProfileIndex.dIndex != oAvatarProfileIndex.dIndex) { return ec.ST_PROFILE_THE_AVATAR_DOES_NOT_BELONG_TO_THIS_PROFILE; } return ec.ST_SUCCEED; } public SIndex dGetProfileIndex(string sAvatarName, SIndex oSenderProfile) { SIndex oIndex; if (sAvatarName == null) { oIndex = oSenderProfile; } else if (sAvatarName.ToLower() == "public") { oIndex = new SIndex(oSenderProfile.dIndex, CDbEPBase.PUBLIC_PROFILE_SUB_INDEX); } else if (sAvatarName.ToLower() == "private") { oIndex = new SIndex(oSenderProfile.dIndex, CDbEPBase.PRIVATE_PROFILE_SUB_INDEX); } else if (sAvatarName.ToLower() == "myself") { oIndex = oSenderProfile; } else { oIndex = dGetProfileIndex(sAvatarName); if (IsNotUsed(oIndex)) { oIndex = oSenderProfile; } else if (oIndex.dIndex != oSenderProfile.dIndex) { oIndex = NOT_USED_SINDEX; } } return oIndex; } public SIndex dGetProfileIndex(string sAvatarName) { if (sAvatarName == CEntityManager.Instance(P.ENGLISH).sGetEntityName(P.MYSELF)) { return NOT_USED_SINDEX; } else { SIndex oIndex = m_oMasterTable.dGetIndex(sAvatarName); if (IsNotUsed(oIndex.dIndex)) return NOT_USED_SINDEX; return oIndex; } } public SIndex dAddFirstProfile(string sProfileID) { SIndex oMainIndex; if (bHasOnlyAuthorizeCharacter(sProfileID) == false) { return NOT_USED_SINDEX; } oMainIndex = m_oMasterTable.dAddProfileIndexValues(CDbEPBase.PRIVATE_PROFILE_SUB_INDEX, NOT_USED); m_oMasterTable.vAddValue(sProfileID); return oMainIndex; } public SIndex dAddProfileFromEmail(string sEmailAdress, P dDefaultLanguage) { SIndex oProfileIndex = dGetProfileIndex(sEmailAdress); if (IsNotUsed(oProfileIndex.dIndex)) { oProfileIndex = dAddFirstProfile(sEmailAdress); if (IsUsed(oProfileIndex)) { m_oMasterTable.vAddValue(dDefaultLanguage); m_oMasterTable.dInsertIntoTable(); } } return oProfileIndex; } public SIndex dAddProfile(string strUserID, string strPassword, P dDefaultLanguage) { if (IsNotUsed(dDefaultLanguage)) dDefaultLanguage = P.ENGLISH; if (bHasOnlyAuthorizeCharacter(strUserID) == false) { return NOT_USED_SINDEX; } SIndex oProfileIndex = dGetProfileIndex(strUserID); if (IsNotUsed(oProfileIndex)) { oProfileIndex = dAddFirstProfile(strUserID); m_oMasterTable.vAddValue(dDefaultLanguage); m_oMasterTable.dInsertIntoTable(); } return oProfileIndex; } /* public ec dAddAttributeIdentifier(P dParentIDIndex, P dLanguage, string sAttributeNameInEnglish, out P dIndex) { return CDbEntityManager.Instance(m_sDatabaseName, m_dLanguage).GetKeywordView. dAdd(P.ATTRIBUTE, dParentIDIndex, dParentIDIndex, dLanguage, sAttributeNameInEnglish, null, out dIndex); } */ public ec dLink(CIdentifier oNewIdenfier, CIdentifier oToIdenfier) { ec dRC = ec.ST_SUCCEED; SIndex[] oToIdentifierIndexArray; dRC = m_oIdentifierView.dGet(2, true, oToIdenfier, out oToIdentifierIndexArray); if (oToIdentifierIndexArray.Length > 1) { dRC = ec.ST_ATTRIBUTE_LINK_AMBIGUOUS_RETURN_TO_THIS_LINK; } else if (oToIdentifierIndexArray.Length == 0 || IsNotUsed(oToIdentifierIndexArray[0])) { dRC = ec.ST_ATTRIBUTE_LINK_NOTHINK_TO_THIS_LINK; } else { dRC = m_oIdentifierView.dAddKeyWordsToExistingIdentifier(oNewIdenfier, oToIdentifierIndexArray[0].dIndex); } return dRC; } public P LastComputeEntity { get { return m_oIdentifierView.m_dLastEntityComputed; } } public ec dAddLinkTraduction(CCommandLine oCommandLine, CIdentifier oFromIdenfier, P dAttributeType, string sValue) { ec dRC = ec.ST_SUCCEED; SIndex[] oToOriginalIndexArray; if (oFromIdenfier.Language == oCommandLine.Language) { dRC = ec.ST_ATTRIBUTE_TRADUCTION_THE_TRADUCTION_LANGUAGE_SHOULD_BE_DIFFERENT_TO_THE_ORIGINAL_LANGUAGE; } else { dRC = m_oIdentifierView.dGet(2, true, oFromIdenfier, out oToOriginalIndexArray); if (oToOriginalIndexArray.Length > 1) { dRC = ec.ST_ATTRIBUTE_LINK_AMBIGUOUS_RETURN_TO_THIS_LINK; } else if (oToOriginalIndexArray.Length == 0 || IsNotUsed(oToOriginalIndexArray[0])) { dRC = ec.ST_ATTRIBUTE_LINK_NOTHINK_TO_THIS_LINK; } else { oFromIdenfier.Index = oToOriginalIndexArray[0]; CIdentifier oIdentifierTraduction = new CIdentifier(P.TRADUCTION, oFromIdenfier, new CEntityArray(P.LANGUAGE, oCommandLine.Language)); CMemeArray oMemeArray; int dCount; dRC = dGetMeme(oCommandLine, oIdentifierTraduction, out oMemeArray, out dCount); if (dRC == ec.ST_SUCCEED) { if (oMemeArray != null && oMemeArray.Length > 0 && oMemeArray[0].dType != dAttributeType) { dRC = ec.ST_ATTRIBUTE_NOT_MATCHING_TYPE; } else { dRC = dUpdateMeme(oCommandLine, oIdentifierTraduction, sValue); } } if (dRC != ec.ST_SUCCEED) { dRC = dAddMeme(oCommandLine, oIdentifierTraduction, dAttributeType, sValue); } } } return dRC; } public CDbEntityManager EntityManager { get { return CDbEntityManager.Instance(m_sDatabaseName, m_dLanguage); } } public ec dCreateAttributeIdentifier(P dAttributeClass, CCommandLine oCommandLine, out CIdentifier oIdentifier) { string sAttributeNameInEnglish = oCommandLine.ContentName; CIdentifier oIdentifierParent=null; ec dRC = ec.ST_SUCCEED; dRC = m_oIdentifierView.dCreateAttributeIdentifier(dAttributeClass, oCommandLine, out oIdentifierParent); if (dRC != ec.ST_SUCCEED && dRC != ec.ST_ENTITY_IDENTIFIER_ALREADY_INSERTED) { /*if ( dRC != ec.ST_ENTITY_IDENTIFIER_ALREADY_INSERTED) { oIdentifier = null; } else { oIdentifier = oIdentifierParent; }*/ oIdentifier = null; CTrace.i().vWriteLn(ENMessage.Error, "Can not create attribute id for " + oCommandLine); } else { dRC = m_oIdentifierView.dCreateIdentifier(dAttributeClass, oCommandLine.peFind(P.CATEGORY), sAttributeNameInEnglish, oIdentifierParent, P.ENGLISH, out oIdentifier); } return dRC; } public ec dAddAttribute(P dAttributeClass, CCommandLine oCommandLine, string sValue, out CIdentifier oIdentifier) { // string sAttributeNameInEnglish = oCommandLine.ContentName; m_oLastMemeVersion = NOT_USED_SINDEX; ec dRC = dCreateAttributeIdentifier(dAttributeClass, oCommandLine, out oIdentifier); if (oIdentifier == null) { return dRC; } else { dRC = dStoreValueToIdentifier(oCommandLine, oIdentifier, oCommandLine.AttributeType, sValue); } return dRC; } public ec dStoreValueToIdentifier(CCommandLine oCommandLine, CIdentifier oIdentifier, P dAttributeType, string sValue) { m_oLastMemeVersion = NOT_USED_SINDEX; CMemeArray oMemeArray; int dCount; ec dRC = dGetMeme(oCommandLine, oIdentifier, out oMemeArray, out dCount); if (dRC == ec.ST_SUCCEED) { if (oMemeArray != null) { oMemeArray = oMemeArray.dFilterOnAuthorShip(oCommandLine.SenderIndex.dIndex); } if (oMemeArray != null) { if (oMemeArray.Length > 0 && CEntityManager.Instance(P.ENGLISH).bIsA(oMemeArray[0].dType, dAttributeType) == false) { dRC = ec.ST_ATTRIBUTE_NOT_MATCHING_TYPE; } else { dRC = dUpdateMeme(oCommandLine, oIdentifier, sValue); } } else { dRC = ec.ST_ATTRIBUTE_MEME_NONE_FOR_THIS_AUTHOR; } } // } if (dRC != ec.ST_SUCCEED) { // oEntity = EntityManager.oAddAttributeIdentifier(dClass, sAttributeNameInEnglish); // oIdentifier.bAdd(dMetaClass, oEntity); dRC = dAddMeme(oCommandLine, oIdentifier, dAttributeType, sValue); } return dRC; } public ec dGetRule(CIdentifier oIdentifier, string sAttributeNameInEnglish, out int oRuleIdentifier) { ec dRC = ec.ST_SUCCEED; SEntity oEntity = EntityManager.oGetEntity(P.ENGLISH, P.NAME, sAttributeNameInEnglish); if (IsUsed(oEntity)) { oIdentifier.bAdd(P.PRINCIPLE, oEntity); } oRuleIdentifier = NOT_USED; SIndex[] dIdentifierIndexArray; dRC = m_oIdentifierView.dGet(2, true, oIdentifier, out dIdentifierIndexArray); if (dRC == ec.ST_SUCCEED && dIdentifierIndexArray != null && dIdentifierIndexArray.Length > 0) { oRuleIdentifier = dIdentifierIndexArray[0].dIndex; } else { dRC = ec.ST_RULE_NO_RULE_OF_THIS_NAME; } return dRC; } public ec dAddRule(CCommandLine oCommandLine, P dClass, string sAttributeNameInEnglish, CIdentifier oIdentifier, string sRuleDescription) { ec dRC = m_oIdentifierView.dCreateIdentifier(P.RULE_CLASS, dGetArray(dClass), sAttributeNameInEnglish, null, P.ENGLISH, out oIdentifier); dRC = dStoreValueToIdentifier(oCommandLine, oIdentifier, P.STRING_4000_TYPE, sRuleDescription); // ec dRC = dGetRule(oEntityArray, sAttributeNameInEnglish, out oRuleIdentifier); if (dRC == ec.ST_SUCCEED) { dRC = dUpdateMeme(oCommandLine, oIdentifier, sRuleDescription); } else { dRC = dAddMeme(oCommandLine, oIdentifier, P.STRING_4000_TYPE, sRuleDescription); } return dRC; } /* public ec dGetMeme(CCommandLine oCommandLine, CIdentifier oIdentifierSet, out CMemeArray oMemeArray, out int dCount) { SIndex[] dIdentifierIndexArray; oMemeArray = null; dCount = 0; ec dRC = m_oIdentifierView.dGet(MAX_MEME_IDENTIFIER_RETURN_COUNT, false, oIdentifierSet, out dIdentifierIndexArray); if (dRC == ec.ST_SUCCEED) { if (dIdentifierIndexArray == null || dIdentifierIndexArray.Length == 0) { dRC = ec.ST_ATTRIBUTE_NO_FIND_ANY_ENTITY_FOR_KEYWORD; } else { ArrayList oMemeArrayList = new ArrayList(); for (int i = 0; i < dIdentifierIndexArray.Length; i++) { CMeme oMeme; SBIndex oIdentifierIndex = m_oIdentifierView.ToReferenceIndex(dIdentifierIndexArray[i]); dRC = dGetMeme(oCommandLine, oIdentifierIndex.dIndex, out oMeme); if (oMeme != null && oMeme.bIsValid) { CIdentifier oExactIdentifier; m_oIdentifierView.dGetSelect(dIdentifierIndexArray[i], out oExactIdentifier); oExactIdentifier.iIndex = oIdentifierIndex; oMeme.vSet(oExactIdentifier, true); oMemeArrayList.Add(oMeme); } } oMemeArray = (CMeme[])oMemeArrayList.ToArray(typeof(CMeme)); } } if (oMemeArray == null) { dCount = 0; } else if (oMemeArray.Length >= MAX_MEME_IDENTIFIER_RETURN_COUNT) { int dItemCount; for (int i = 0; i < oMemeArray.Length; i++) { m_oIdentifierView.dGetRecordCount(new SIndex(oMemeArray[i].oGetAddress.dReferenceIndex, NOT_USED), oMemeArray[i].oGetAddress.Entity, oMemeArray[i].oGetAddress.dGetEntityArray(false), out dItemCount); dCount += dItemCount; } } else { dCount = oMemeArray.Length; } return dRC; } */ public ec dGetMeme(CCommandLine oCommandLine, CIdentifier oIdentifier, out CMemeArray oMemeArray, out int dCount) { SIndex[] dIdentifierIndexArray; ArrayList oMemeArrayList = new ArrayList(); oMemeArrayList.Clear(); ec dRC = m_oIdentifierView.dGet(MAX_MEME_IDENTIFIER_RETURN_COUNT, true, oIdentifier, out dIdentifierIndexArray); if (dRC == ec.ST_SUCCEED) { if (dIdentifierIndexArray == null || dIdentifierIndexArray.Length == 0) { dRC = ec.ST_ATTRIBUTE_NO_FIND_ANY_ENTITY_FOR_KEYWORD; } for (int i = 0; i < dIdentifierIndexArray.Length; i++) { CMemeArray oSameMemeWithDifferentAuthorArray; SBIndex oIdentifierIndex = m_oIdentifierView.ToReferenceIndex(dIdentifierIndexArray[i]); SIndex oMemeIndex; oMemeIndex.dIndex = dIdentifierIndexArray[i].dIndex; oMemeIndex.dSubIndex = NOT_USED; dRC = dGetMeme(oCommandLine, oIdentifierIndex.dIndex, out oSameMemeWithDifferentAuthorArray); if (dRC == ec.ST_SUCCEED) { for (int j = 0; j < oSameMemeWithDifferentAuthorArray.Length; j++) { // SIndex oAuthorAccessProfile = m_oAvatarRelationAuthorisationTable.iGetMyFriendAvatarGrantedBy(oCommandLine.AuthorIndex, // oCommandLine.SenderIndex); if (oSameMemeWithDifferentAuthorArray[j].bIsValid) { CIdentifier oIdentifier2; m_oIdentifierView.dGetSelect(dIdentifierIndexArray[i], out oIdentifier2); oSameMemeWithDifferentAuthorArray[j].vSet(oIdentifier2); oMemeArrayList.Add(oSameMemeWithDifferentAuthorArray[j]); } else { dRC = ec.ST_PROFILE_THE_ATTRIBUTE_DOES_NOT_HAVE_ACCESS_AUTHORISATION; } } } } } oMemeArray = new CMemeArray(oMemeArrayList); if (oMemeArray == null) { dCount = 0; } else if (oMemeArray.Length >= MAX_MEME_IDENTIFIER_RETURN_COUNT) { dCount = 0; int dItemCount; for (int i = 0; i < oMemeArray.Length; i++) { m_oIdentifierView.dGetRecordCount(new SIndex(oMemeArray[i].oGetAddress.dReferenceIndex, NOT_USED), oMemeArray[i].oGetAddress.Entity, oMemeArray[i].oGetAddress.dGetEntityArray(false), out dItemCount); dCount += dItemCount; } } else { dCount = oMemeArray.Length; } return dRC; } public ec dShowToAvatar(CCommandLine oCommandLine, CIdentifier oIdentifier) { SIndex[] dIdentifierIndexArray; ec dRC = m_oIdentifierView.dGet(2, true, oIdentifier, out dIdentifierIndexArray); if (dRC == ec.ST_SUCCEED) { if (dIdentifierIndexArray.Length == 0) { return ec.ST_ATTRIBUTE_CONTENT_IS_MISSING; } SIndex oMeme; oMeme.dIndex = dIdentifierIndexArray[0].dIndex; oMeme.dSubIndex = NOT_USED; SIndex[] iAuthorizedProfileIndexArray; dRC = dGetAuthorshipAvatarAccess(oCommandLine.SenderIndex.dIndex, ref oMeme, out iAuthorizedProfileIndexArray); if (dRC == ec.ST_SUCCEED) { if (m_oMasterTable.bIsChildOf(oCommandLine.SenderIndex, iAuthorizedProfileIndexArray)) { dRC = ec.ST_PROFILE_ALREADY_HAVE_ACCESS_AUTHORISATION; } } if (dRC != ec.ST_SUCCEED) { dRC = dAddAuthorisation(oCommandLine.SenderIndex, oMeme); } } return dRC; } public ec dHideToAvatar(CCommandLine oCommandLine, CIdentifier oIdentifier, out SIndex oParent) { /* if (oCommandLine.OrganisationIndex) { return ec.ST_AVATAR_HIDE_SHOW_FAILED_AS_THE_ORGANISATION_IS_UNKNOWN; } * */ CTrace.i().vWriteLn(ENMessage.Avatar, "m_oProfileView.GetMasterTable=" + GetMasterTable.csDumpTable()); CTrace.i().vWriteLn(ENMessage.Avatar, "oCommandLine=" + oCommandLine.csDump()); SIndex[] dIdentifierIndexArray; oParent = NOT_USED_SINDEX; ec dRC = m_oIdentifierView.dGet(2, true, oIdentifier, out dIdentifierIndexArray); if (dRC == ec.ST_SUCCEED) { if (dIdentifierIndexArray.Length == 0) { return ec.ST_ATTRIBUTE_CONTENT_IS_MISSING; } SIndex oMeme; oMeme.dIndex = dIdentifierIndexArray[0].dIndex; oMeme.dSubIndex = NOT_USED; SIndex[] iAuthorizedProfileIndexArray; dRC = dGetAuthorshipAvatarAccess(oCommandLine.SenderIndex.dIndex, ref oMeme, out iAuthorizedProfileIndexArray); if (dRC == ec.ST_SUCCEED) { if (m_oMasterTable.bIsChildOf(oCommandLine.SenderIndex, iAuthorizedProfileIndexArray, out oParent)) { dRC = dDeleteAuthorisation(oParent, oMeme); } else { dRC = ec.ST_PROFILE_THE_ATTRIBUTE_DOES_NOT_HAVE_ACCESS_AUTHORISATION; } } } return dRC; } } //---------------------------------------------------------------------------------------------------------------------------------------------- /// /// Summary description for DbVariableTable. /// /// //---------------------------------------------------------------------------------------------------------------------------------------------- public class CDbVariableSubProfileTable : CCommandFactoryBase { public CDbVariableSubProfileTable(P dLanguage, string sMasterTableName, string sDatabaseName) { m_dLanguage = dLanguage; m_sDatabaseName = sDatabaseName; m_oMasterTable = new CDbMasterTable(sMasterTableName, sDatabaseName); m_oIdentifierView = new CDbIdentifierView(dLanguage, sDatabaseName); m_oMemeView = new CDbMemeView(sDatabaseName); m_oAuthorshipLink = new CDbSIndexTable(AUTHORSHIP_NAME, sDatabaseName); m_oAuthorshipLink.vAddColumn(PROFILE_INDEX_FIELD, INTEGER_TYPE, false); m_oAvatarAccessMeme = new CDbSTable(AUTHORSHIP_ACCESS_NAME, sDatabaseName); m_oAvatarAccessMeme.vAddColumn(MEME_INDEX_FIELD, INTEGER_TYPE, true); m_oAvatarAccessMeme.vAddColumn(MEME_SUB_INDEX_FIELD, INTEGER_TYPE, true); m_oAvatarAccessMeme.vAddColumn(PROFILE_SUB_INDEX_FIELD, INTEGER_TYPE, false); m_oAuthorshipView = new CDbJoinView(new CDbTableView(AUTHORSHIP_PREFIXE, m_oAuthorshipLink), new CDbTableView(AVATAR_ACCESS_PREFIXE, m_oAvatarAccessMeme)); m_oAuthorshipView.vAddLinkIndex(AUTHORSHIP_PREFIXE, MASTER_INDEX_FIELD, AVATAR_ACCESS_PREFIXE, MEME_INDEX_FIELD); m_oAuthorshipView.vAddLinkIndex(AUTHORSHIP_PREFIXE, MASTER_SUB_INDEX_FIELD, AVATAR_ACCESS_PREFIXE, MEME_SUB_INDEX_FIELD); } public string sDatabaseName { get { return m_sDatabaseName; } } public virtual void vRegister() { m_oIdentifierView.vRegister(); } string sqlIsAuthorshipIndex(int dAuthorIndex ) { return m_oAuthorshipLink.sFieldEqual(PROFILE_INDEX_FIELD, dAuthorIndex); } string sqlIsAuthorshipIndex(int dAuthorIndex, int dMemeIndex) { string sSql = sqlIsAuthorshipIndex(dAuthorIndex); if (IsUsed(dMemeIndex)) { sSql += AND + m_oAuthorshipLink.sFieldEqual(MASTER_INDEX_FIELD, dMemeIndex); } return sSql; } string sqlIsAuthorshipIndex(int dAuthorIndex, SIndex oMemeIndex) { return sqlIsAuthorshipIndex(dAuthorIndex, oMemeIndex.dIndex) + AND + m_oAuthorshipLink.sFieldEqual(MASTER_SUB_INDEX_FIELD, oMemeIndex.dSubIndex); } protected string m_sDatabaseName; protected P m_dLanguage; CDbSIndexTable m_oAuthorshipLink; CDbSTable m_oAvatarAccessMeme; protected CDbMemeView m_oMemeView; public CDbIdentifierView GetIdentifierView { get { return m_oIdentifierView; } } protected CDbIdentifierView m_oIdentifierView; public const string AUTHORSHIP_NAME = "Authorship", AUTHORSHIP_ACCESS_NAME = "AuthorshipAccess"; public const string AUTHORSHIP_PREFIXE = "aut", AVATAR_ACCESS_PREFIXE = "acc"; CDbJoinView m_oAuthorshipView; protected CDbMasterTable m_oMasterTable; /* public CDbEntityManager.CDbEntityNameView GetKeywordView { get { return m_oIdentifierView.GetKeywordView; } } * */ public virtual void vCleanAllData() { m_oIdentifierView.vCleanAllData(); m_oMemeView.vCleanAllData(); m_oAuthorshipView.vCleanAllData(); m_oMasterTable.dDropTable(); } protected ec dAddAuthorship(CCommandLine oCommandLine, SIndex oMeme) { m_oAuthorshipLink.dAddIndexValues(oMeme); m_oAuthorshipLink.vAddValue(oCommandLine.SenderIndex.dIndex); ec dRC = m_oAuthorshipLink.dInsertIntoTable(); if (oCommandLine.SenderIndex.dSubIndex > PRIVATE_PROFILE_SUB_INDEX) { dRC = dAddAuthorisation(oCommandLine.SenderIndex, oMeme); } return dRC; } protected ec dAddAuthorisation(SIndex oAuthor, SIndex oMeme) { m_oAvatarAccessMeme.vAddValue(oMeme); m_oAvatarAccessMeme.vAddValue(oAuthor.dSubIndex); ec dRC = m_oAvatarAccessMeme.dInsertIntoTable(); return dRC; } protected ec dDeleteAuthorisation(SIndex oAuthor, SIndex oMeme) { m_oAvatarAccessMeme.vAddValue(oMeme); m_oAvatarAccessMeme.vAddValue(oAuthor.dSubIndex); ec dRC = m_oAvatarAccessMeme.dDelete(m_oAvatarAccessMeme.sFieldEqual(MEME_INDEX_FIELD, oMeme.dIndex) + AND + m_oAvatarAccessMeme.sFieldEqual(MEME_SUB_INDEX_FIELD, oMeme.dSubIndex) + AND + m_oAvatarAccessMeme.sFieldEqual(PROFILE_SUB_INDEX_FIELD, oAuthor.dSubIndex)); return dRC; } protected ec dGetAuthorshipAvatarAccess(int dAuthorIndex, ref SIndex oMemeIndex, out SIndex[] oAuthorAccess) { SIndex[] oMemeArray; oMemeIndex.dSubIndex = NOT_USED; oAuthorAccess = null; ec dRC = dGetActiveVersion(dAuthorIndex, oMemeIndex.dIndex, out oMemeArray); if (oMemeArray == null || oMemeArray.Length == 0) { dRC = ec.ST_ATTRIBUTE_MEME_HAVE_NO_ACTIVE_VERSION_WITH_AN_AUTHORIZE_ACCESS; } else if (oMemeArray.Length == 1) { oMemeIndex = oMemeArray[0]; dRC = dGetMemeAccess(oMemeIndex, out oAuthorAccess); } else { dRC = ec.ST_ATTRIBUTE_MEME_MORE_THAN_ONE_ACTIVE_VERSION; } return dRC; } protected ec dGetMemeAccess(SIndex oMeme, out SIndex[] oAuthorAccess) { oAuthorAccess = null; int dAuthorIndex; ec dRC = dGetAuthorship(oMeme, out dAuthorIndex); if (dRC == ec.ST_SUCCEED && m_oAuthorshipView.bIsTableExist()) { m_oAuthorshipView.vResetSelect(); m_oAuthorshipView.bAddDisplayColumn(AUTHORSHIP_PREFIXE, PROFILE_INDEX_FIELD); m_oAuthorshipView.bAddDisplayColumn(AVATAR_ACCESS_PREFIXE, PROFILE_SUB_INDEX_FIELD); m_oAuthorshipView.bAddWhere(AUTHORSHIP_PREFIXE, oMeme); ArrayList oOutputArray; dRC = m_oAuthorshipView.dGetSelect(out oOutputArray); if (dRC == ec.ST_SUCCEED) { dRC = dConvert(oOutputArray, out oAuthorAccess); } } if (oAuthorAccess == null && IsUsed(dAuthorIndex)) { oAuthorAccess = new SIndex[1]; oAuthorAccess[0].dIndex = dAuthorIndex; oAuthorAccess[0].dSubIndex = PRIVATE_PROFILE_SUB_INDEX; } return dRC; } protected ec dGetAuthorship(int dMemeIndex, out int[] dAuthorIndex) { ArrayList oOutputArray; ec dRC = m_oAuthorshipLink.dGetSelect(m_oAuthorshipLink.sqlIsIndex(dMemeIndex), out oOutputArray, PROFILE_INDEX_FIELD); if (oOutputArray != null && oOutputArray.Count > 0) { dAuthorIndex = ToIntegerArray(oOutputArray); // dAuthorIndex = (int)((object[])oOutputArray[0])[0]; } else { dAuthorIndex = null; dRC = ec.ST_ATTRIBUTE_MEME_NO_OWNER_REFERENCE; } return dRC; } protected ec dGetAuthorship(SIndex oMemeIndex, out int dAuthorIndex) { ArrayList oOutputArray; ec dRC = m_oAuthorshipLink.dGetSelect(m_oAuthorshipLink.sqlIsIndex(oMemeIndex), out oOutputArray, PROFILE_INDEX_FIELD); if (oOutputArray != null && oOutputArray.Count > 0) { dAuthorIndex = (int)((object[])oOutputArray[0])[0]; } else { dAuthorIndex = NOT_USED; dRC = ec.ST_ATTRIBUTE_MEME_NO_OWNER_REFERENCE; } return dRC; } protected ec dGetActiveVersion(int dAuthorIndex, int dMemeIndex, out SIndex[] oMemeArray) { ArrayList oOutputArray; string sWhere; sWhere = sqlIsAuthorshipIndex(dAuthorIndex, dMemeIndex); ec dRC = m_oAuthorshipLink.dGetSelect(sWhere, out oOutputArray, MASTER_INDEX_FIELD, MASTER_SUB_INDEX_FIELD); if (oOutputArray == null) { oMemeArray = null; dRC = ec.ST_PROFILE_NO_ACTIVE_MEMBERSHIP_FOR_THE_MEME; } else { dRC = dConvert(oOutputArray, out oMemeArray); } return dRC; } public CDbMasterTable GetMasterTable { get { return m_oMasterTable; } } protected virtual string sqlIsIndex(int dProfileIndex) { return m_oMasterTable.sFieldEqual(PROFILE_INDEX_FIELD, dProfileIndex); } protected SBIndex m_oLastIdentifierIndex; protected SIndex m_oLastMemeVersion; public SBIndex LastIdentifierIndex { get { return m_oLastIdentifierIndex; } } public SIndex LastMemeVersion { get { return LastMemeVersion; } } public ec dUpdateMeme(CCommandLine oCommandLine, CIdentifier oIdentifierAdress, string sValue) { m_oLastIdentifierIndex = NOT_USED_SBINDEX; SIndex[] oIdentifierSIndexArray; ec dRC = m_oIdentifierView.dGet(2, true, oIdentifierAdress, out oIdentifierSIndexArray); if (oIdentifierSIndexArray == null || oIdentifierSIndexArray.Length == 0) { return ec.ST_ENTITY_ONE_OF_KEYWORD_USED_IS_UNKNOWN; } if (oIdentifierSIndexArray != null) { if (oIdentifierSIndexArray.Length == 1) { m_oLastIdentifierIndex = m_oIdentifierView.ToReferenceIndex(oIdentifierSIndexArray[0]); dRC = dUpdateMeme(oCommandLine, m_oLastIdentifierIndex, sValue); } else { dRC = ec.ST_ATTRIBUTE_ENTITY_DUPLICATE; } } return dRC; } public ec dAddMeme(CCommandLine oCommandLine, CIdentifier oIdentifierAdress, P dAttributeType, string sValue) { m_oLastMemeVersion = NOT_USED_SINDEX; SIndex[] oIdentifierSIndexArray; ec dRC = m_oIdentifierView.dGet(2, true, oIdentifierAdress, out oIdentifierSIndexArray); if (oIdentifierSIndexArray == null || oIdentifierSIndexArray.Length == 0) { /* dRC = m_oIdentifierView.dAddKeyWords(oEntityArray); if (dRC == ec.ST_SUCCEED) { dRC = m_oIdentifierView.dGet(1, oEntityArray, out oIdentifierArray); }*/ return ec.ST_ENTITY_ONE_OF_KEYWORD_USED_IS_UNKNOWN; } if (oIdentifierSIndexArray != null && oIdentifierSIndexArray.Length > 0) { m_oLastIdentifierIndex = m_oIdentifierView.ToReferenceIndex(oIdentifierSIndexArray[0]); dRC = dAddMeme( oCommandLine, m_oLastIdentifierIndex, dAttributeType, sValue, out m_oLastMemeVersion); if (IsUsed(m_oLastMemeVersion)) { dRC = dAddAuthorship(oCommandLine, m_oLastMemeVersion); } else { return ec.ST_ATTRIBUTE_SHOULD_HAVE_ONLY_ONE_MEME; } } return dRC; } public ec dUpdateMeme(CCommandLine oCommandLine, SBIndex oIdentifierIndex, string sValue) { CMemeArray oExistingMemeArray; ec dRC = dGetMeme(oCommandLine, oIdentifierIndex.dMainSIndex.dIndex, out oExistingMemeArray); if (oExistingMemeArray.Length==1 && oExistingMemeArray[0].bHasAuthorRight(oCommandLine.SenderIndex) == false) { return ec.ST_PROFILE_THE_ATTRIBUTE_DOES_NOT_HAVE_ACCESS_AUTHORISATION; } if (oExistingMemeArray == null || oExistingMemeArray[0].bIsValid == false) { return ec.ST_ATTRIBUTE_THIS_ATTRIBUTE_NAME_IS_UNKNOWN; } else { dRC = m_oMemeView.dUpdateAttribute(oExistingMemeArray[0].m_iMemeIndex, sValue); } return dRC; } public ec dAddMeme(CCommandLine oCommandLine, SBIndex oIdentifierIndex, P dAttributeType, string sValue, out SIndex iMemeIndex) { iMemeIndex = NOT_USED_SINDEX; CMemeArray oExistingMemeArray; ec dRC = dGetMeme(oCommandLine, oIdentifierIndex.dIndex, out oExistingMemeArray); if (oExistingMemeArray != null) { oExistingMemeArray = oExistingMemeArray.dFilterOnAuthorShip(oCommandLine.SenderIndex.dIndex); } if (oExistingMemeArray != null) { iMemeIndex = oExistingMemeArray[0].m_iMemeIndex; if (dRC != ec.ST_ATTRIBUTE_MEME_HAVE_NO_ACTIVE_VERSION && oExistingMemeArray[0].bHasAuthorRight(oCommandLine.SenderIndex) == false) { dRC = ec.ST_PROFILE_THE_ATTRIBUTE_DOES_NOT_HAVE_ACCESS_AUTHORISATION; } } else if (oExistingMemeArray == null || oExistingMemeArray[0].bIsValid == false) { if (IsNotUsed(dAttributeType)) { dRC = ec.ST_ATTRIBUTE_THIS_ATTRIBUTE_TYPE_IS_UNKNOWN; } else { dRC = m_oMemeView.dAddNewAttributeVersion(oIdentifierIndex.dIndex, dAttributeType, sValue, out iMemeIndex); } } else { dRC = ec.ST_ATTRIBUTE_SHOULD_HAVE_ONLY_ONE_MEME; } return dRC; } /* string sqlIsIndex(int dAuthorIndex ) { string sSql= m_oAuthorshipLink.sFieldEqual(PROFILE_INDEX_FIELD, dAuthorIndex); return sSql; }*/ protected ec dGetMeme(CCommandLine oCommandLine, int dIdentifierIndex, out CMemeArray oMemeArray) { ec dRC = ec.ST_SUCCEED; if (IsUsed(oCommandLine.AuthorIndex)) { CMeme oMeme; dRC = dGetMeme(oCommandLine.AuthorIndex.dIndex, dIdentifierIndex, out oMeme); oMemeArray = new CMemeArray(oMeme); } else { int[] dAuthorIndexArray; dRC = dGetAuthorship(dIdentifierIndex, out dAuthorIndexArray); ArrayList oMemeArrayList = new ArrayList(); if (dAuthorIndexArray != null) { for (int i = 0; i < dAuthorIndexArray.Length; i++) { CMeme oMeme; dRC = dGetMeme(dAuthorIndexArray[i], dIdentifierIndex, out oMeme); if ( oMeme.bIsValid ) { oMemeArrayList.Add(oMeme); } } } if (oMemeArrayList.Count==0) { oMemeArray = null; dRC = ec. ST_ATTRIBUTE_MEME_NO_MEME; } else { oMemeArray = new CMemeArray(oMemeArrayList); } } return dRC; } protected ec dGetMeme(int dAuthorIndex, int dIdentifierIndex, out CMeme oMeme) { SIndex oMemeIndex; oMemeIndex.dIndex = dIdentifierIndex; oMemeIndex.dSubIndex = NOT_USED; oMeme = null; SIndex[] iAuthorizedProfileIndexArray = null; ec dRC = dGetAuthorshipAvatarAccess(dAuthorIndex, ref oMemeIndex, out iAuthorizedProfileIndexArray); if (dRC == ec.ST_SUCCEED) { dRC = m_oMemeView.dGetAttribute(oMemeIndex, out oMeme); if (dRC == ec.ST_SUCCEED) { dRC = dGetAuthorship(oMemeIndex, out oMeme.m_dAuthorProfileIndex); } oMeme.m_iAvatarAuthorAccessArray = iAuthorizedProfileIndexArray; } return dRC; } public ec dDelete(SIndex oProfileIndex) { CSubIndexArray oSubIndexArray = new CSubIndexWithNameArray(); ec dRet = m_oMasterTable.dGetSubIndex(oProfileIndex, false, ref oSubIndexArray); if (dRet != ec.ST_SUCCEED) return dRet; if (oSubIndexArray.Count > 0) { return ec.ST_PROFILE_CAN_NOT_DELETE_IF_THERE_IS_SUB_AVATAR; } dRet = m_oMasterTable.dDelete(m_oMasterTable.sqlIsIndex(oProfileIndex)); return dRet == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_PROFILE_CAN_NOT_DELETE_THE_AVATAR; } } ///--------------------------------------------------------------------------------------------------------------------------------------------------- /// /// Summary description for Class1. /// ///--------------------------------------------------------------------------------------------------------------------------------------------------- public class CAvatarGrantRelation : CDbSTable { public CAvatarGrantRelation(string strDatabaseName) : base("AvatarRelationTable", strDatabaseName) { vAddColumn(MASTER_INDEX_FIELD, INTEGER_TYPE, true); vAddColumn(MASTER_SUB_INDEX_FIELD, INTEGER_TYPE, true); vAddColumn(BENEFICIARY_INDEX_FIELD, INTEGER_TYPE, true); vAddColumn(BENEFICIARY_SUB_INDEX_FIELD, INTEGER_TYPE, false); vAddColumn(DATE_FIELD, DATE_TYPE, false); } public SIndex iGetMyFriendAvatarGrantedBy(int dAuthorTargetProfileIndex, int dReaderClaimingProfileIndex) { SIndex oAuthorTargetProfile = new SIndex(dAuthorTargetProfileIndex); if (oAuthorTargetProfile.dIndex != dReaderClaimingProfileIndex) { oAuthorTargetProfile.dSubIndex = base.GetInteger(MASTER_SUB_INDEX_FIELD, sqlIsIndex(dAuthorTargetProfileIndex, dReaderClaimingProfileIndex)); } if (IsNotUsed(oAuthorTargetProfile.dSubIndex)) { oAuthorTargetProfile.dSubIndex = PUBLIC_PROFILE_SUB_INDEX; } return oAuthorTargetProfile; } public ec dGetSelect(SIndex oClaimingProfile, out SIndex[] oTargetProfileArray) { return dGetSelect(sFieldEqual(BENEFICIARY_INDEX_FIELD, oClaimingProfile.dIndex), out oTargetProfileArray); } public ec dGetSelect(SIndex oClaimingProfile, SIndex oTargetProfileProfile, out SIndex[] oTargetProfileArray) { return dGetSelect(sFieldEqual(BENEFICIARY_INDEX_FIELD, oClaimingProfile.dIndex) + AND + sFieldEqual(MASTER_INDEX_FIELD, oTargetProfileProfile.dIndex), out oTargetProfileArray); } protected ec dGetSelect(string sWhere, out SIndex[] oTargetProfileArray) { ArrayList oTargetProfileArrayList; ec dRC = dGetSelect(sWhere, out oTargetProfileArrayList, BENEFICIARY_INDEX_FIELD) == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_AVATAR_PROFILE_SELECTION_FAILED; oTargetProfileArray = new SIndex[oTargetProfileArrayList.Count]; for (int i = 0; i < oTargetProfileArrayList.Count; i++) { oTargetProfileArray[i].dIndex = (int)((object[])oTargetProfileArrayList[i])[0]; oTargetProfileArray[i].dSubIndex = (int)((object[])oTargetProfileArrayList[i])[1]; } return dRC; } public string sqlIsIndex(int dTargetProfile, int dClaimingProfile) { return sFieldEqual(MASTER_INDEX_FIELD, dTargetProfile) + AND + sFieldEqual(BENEFICIARY_INDEX_FIELD, dClaimingProfile); } public string sqlIsIndex(SIndex iTargetProfile, int dClaimingProfile) { return sFieldEqual(MASTER_INDEX_FIELD, iTargetProfile.dIndex) + AND + sFieldEqual(MASTER_SUB_INDEX_FIELD, iTargetProfile.dSubIndex) + AND + sFieldEqual(BENEFICIARY_INDEX_FIELD, dClaimingProfile); } public ec dGrantAccess(SIndex oProfileToAcceed, SIndex oClaimingProfile) { if (oProfileToAcceed.dSubIndex == PRIVATE_PROFILE_SUB_INDEX) { return ec.ST_PROFILE_FRIEND_PRIVATE_PROFILE_CAN_NOT_HAVE_FRIEND; } else { vAddValue(oProfileToAcceed.dIndex); vAddValue(oProfileToAcceed.dSubIndex); vAddValue(oClaimingProfile.dIndex); vAddValue(oClaimingProfile.dSubIndex); vAddValue(DateTime.UtcNow); ec dRC = base.dInsertIntoTable(); return dRC == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_AVATAR_RELATION_CAN_NOT_ADD; } } /* public ec dUpdateAccess(SIndex oProfileToAcceed, SIndex oClaimingProfile) { if (oProfileToAcceed.dSubIndex == PRIVATE_PROFILE_SUB_INDEX) { return ec.ST_PROFILE_FRIEND_PRIVATE_PROFILE_CAN_NOT_HAVE_FRIEND; } else { ec dRC = this.dUpdate(MASTER_SUB_INDEX_FIELD, oProfileToAcceed.dSubIndex.ToString(), sqlIsIndex(oProfileToAcceed.dIndex, oClaimingProfile.dIndex)); return dRC == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_AVATAR_RELATION_CAN_NOT_ADD; } }*/ public ec dRevokeAccess(SIndex oProfileToAcceed, SIndex oClaimingProfile) { ec dRet = this.dDelete(sqlIsIndex(oProfileToAcceed, oClaimingProfile.dIndex)); return dRet == ec.ST_SUCCEED ? ec.ST_SUCCEED : ec.ST_AVATAR_RELATION_CAN_NOT_ADD; } } ///--------------------------------------------------------------------------------------------------------------------------------------------------- /// /// Summary description for Class1. /// ///--------------------------------------------------------------------------------------------------------------------------------------------------- public class CSubIndexWithNameArray : CSubIndexArray { public CSubIndexWithNameArray(params string[] sComplementParameterArray) : base(sComplementParameterArray) { m_sParentName = "root"; } public CSubIndexWithNameArray() : base(sGetParameters(MASTER_NAME_FIELD)) { m_sParentName = "root"; } public CSubIndexWithNameArray(string sComplement) : base(sGetParameters(MASTER_NAME_FIELD, sComplement)) { m_sParentName = "root"; } string m_sParentName; public const int NAME_POSITION = 3; public const int COMPLEMENT_POSITION = 4; public string sGetNameFromSubIndex(int dSubIndex) { int i = dGetIndexFromSubIndex(dSubIndex); if (IsNotUsed(i)) return null; return sGetName(i); } public string sGetName(int i) { return oGetParameter(i, NAME_POSITION).ToString(); } public string sGetParentName(int i) { if (dGetSubIndex(i) == 0) { return "root"; } string sParentName = sGetNameFromSubIndex(dGetParentSubIndex(i)); if (sParentName == null) { return m_sParentName; } return sParentName; } public override CSubIndexArray Create() { return new CSubIndexWithNameArray(ParameterArray); } public object oGetComplement(int i) { return oGetParameter(i, COMPLEMENT_POSITION); } } }

Enter supporting content here