Make your own free website on Tripod.com
EPolWS
CommandFactory
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
using System; using System.Data; using System.Diagnostics; using System.Configuration; using System.Web; using System.Text; using System.Collections; using EXDb97; using EXCommon; //###2 namespace EPol { public enum ENLanguage { eng =0, fr=1 } public struct SEntityName { public CCommandFactoryBase.P dEntityParent; public CCommandFactoryBase.P dClass; public string[] sHelpArray; public CCommandFactoryBase.P dType; public CCommandFactoryBase.P[] m_oChildArray, m_oIdChildArray, m_oIdParentArray, m_oInstanceArray; public string[] sNameArray; public string[] sAbreviationArray; public CDbEPBase.SProperty[] m_oPropertyArray; public string csDump() { StringBuilder sOutput = new StringBuilder(); sOutput.Append("| dClass = " + dClass); sOutput.Append("| dParent= " + dEntityParent); sOutput.Append("| dType= " + dType + '\n'); sOutput.Append("| ID Parent= " + CDbEPBase.ToString( m_oIdParentArray) + '\n'); sOutput.Append("| Values= " + CDbEPBase.ToString( m_oInstanceArray) + '\n'); sOutput.Append("| Child= " + CDbEPBase.ToString( m_oChildArray) + '\n'); sOutput.Append("| ID Child= " + CDbEPBase.ToString( m_oIdChildArray) + '\n'); sOutput.Append("| Property List= " + CDbEPBase.ToString( m_oPropertyArray) + '\n'); sOutput.Append("| Name= " + CDbEPBase.ToString( sNameArray) + '\n'); sOutput.Append("| Abrevation= " + CDbEPBase.ToString( sAbreviationArray) + '\n'); return sOutput.ToString(); } } /// /// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// public class CEntityNameCommandArray : CDbEPBase { public CEntityNameCommandArray(P dHardCodeCount, P dFirstEntityIndex, int dEntityCount) { m_dFirstEntityIndex = (int)dFirstEntityIndex; m_oHardCodedEntityName = new SEntityName[(int)dHardCodeCount]; m_oDbEntityName = new SEntityName[dEntityCount - m_dFirstEntityIndex]; m_oEntityNameArrayList= new ArrayList(); } SEntityName[] m_oHardCodedEntityName; SEntityName[] m_oDbEntityName; ArrayList m_oEntityNameArrayList; int m_dFirstEntityIndex; public int Length { get { return (int)m_dFirstEntityIndex + m_oDbEntityName.Length + m_oEntityNameArrayList.Count; } } public bool bIsInEntityIndexInTheRange(P i) { return i >= P.NONE && i < P.ENTITY_COUNT || (int)i >= m_dFirstEntityIndex && (int)i < Length; } public SEntityName this [int dIndex] { get { if (dIndex < m_oHardCodedEntityName.Length) { return m_oHardCodedEntityName[dIndex]; } else if (dIndex >= m_dFirstEntityIndex && dIndex < m_dFirstEntityIndex + m_oDbEntityName.Length) { return m_oDbEntityName[dIndex - m_dFirstEntityIndex]; } else if (dIndex >= (m_dFirstEntityIndex + m_oDbEntityName.Length) && (dIndex - m_dFirstEntityIndex - m_oDbEntityName.Length) < m_oEntityNameArrayList.Count) { return (SEntityName)m_oEntityNameArrayList[dIndex - m_dFirstEntityIndex - m_oDbEntityName.Length]; } else { CTrace.i().vWrite(ENMessage.Error, " Can not read " + dIndex + " at " + (int)dIndex); return CEntityManager.m_oNullEntityName; } } set { if (dIndex < m_oHardCodedEntityName.Length) { m_oHardCodedEntityName[dIndex]=value; } else if (dIndex >= m_dFirstEntityIndex && dIndex < m_dFirstEntityIndex + m_oDbEntityName.Length) { m_oDbEntityName[dIndex - m_dFirstEntityIndex] = value; } else if (dIndex >= (m_dFirstEntityIndex + m_oDbEntityName.Length)) { vIncreaseTo(dIndex); m_oEntityNameArrayList[dIndex - m_dFirstEntityIndex - m_oDbEntityName.Length] = value; } else { EPAssert(false, " Failed to insert " + dIndex); } } } void vIncreaseTo(int dName) { if ( dName >= Length) { int dNewItemCount = dName + 1 - Length; for (int i = 0; i < dNewItemCount; i++) { m_oEntityNameArrayList.Add(new SEntityName()); } } } public SProperty[] GetPropertyArray(P dEntity) { if (bIsInEntityIndexInTheRange(dEntity)) { return this[(int)dEntity].m_oPropertyArray; } return null; } public void vSetIdParent(P dName, P dEntityIdParent) { vIncreaseTo((int)dName); SEntityName oEntityName = this[(int)dName]; vAdd(ref oEntityName.m_oIdParentArray, dEntityIdParent); this[(int)dName] = oEntityName; CTrace.i().vWriteLn(ENMessage.Attribute, "this[" + dName + "]= " + this[(int)dName].csDump() ); SEntityName oEntityNameP = this[(int)dEntityIdParent]; vAdd(ref oEntityNameP.m_oChildArray, dName); this[(int)dEntityIdParent] = oEntityNameP; CTrace.i().vWriteLn(ENMessage.Attribute, "this[" + dEntityIdParent + "]= " + this[(int)dEntityIdParent].csDump()); } public void vSetParent(P dName, P dEntityParent) { vIncreaseTo((int)dName); SEntityName oEntityName = this[(int)dName]; oEntityName.dEntityParent = dEntityParent; this[(int)dName] = oEntityName; SEntityName oEntityNameParent = this[(int)dEntityParent]; vAdd(ref oEntityNameParent.m_oChildArray, dName); this[(int)dEntityParent] = oEntityNameParent; } public void vLoadProperty(P dName, SProperty[] oPropertyList) { vIncreaseTo((int)dName); SEntityName oEntityName = this[(int)dName]; oEntityName.m_oPropertyArray = oPropertyList; this[(int)dName] = oEntityName; } public bool bIsADescentOf(P dEntityName, P dEntityIdParent) { CTrace.i().vWrite(ENMessage.Attribute, " bIsADescentOf dEntityIdParent=" + dEntityIdParent + "dEntityName= " + dEntityName); if (bIsInEntityIndexInTheRange(dEntityName) == false || bIsInEntityIndexInTheRange(dEntityIdParent) == false) return false; P[] oIdParentArray = this[(int)dEntityName].m_oIdParentArray; if (Contains(ref oIdParentArray, dEntityIdParent)) return true; CTrace.i().vWriteLn(ENMessage.Attribute, "| oIdParentArray=" + ToString(oIdParentArray)); if (dEntityName == dEntityIdParent) return true; if (oIdParentArray != null) { for (int i = 0; i < oIdParentArray.Length; i++) { if (bIsADescentOf(oIdParentArray[i], dEntityIdParent) == true) { return true; } } } return this[(int)dEntityName].dClass == dEntityIdParent; } public P dFindEntity(P dLanguage, string csEntityName) { if (csEntityName != null ) { csEntityName = csEntityName.ToLower(); for (int i = 0; i < (int)P.ENTITY_COUNT; i++) { //CTrace.i().vWriteLn(ENMessage.Command,"(CCommandArrayFactory.P)i).ToString()= " + ((CCommandArrayFactory.P)i).ToString()); if (bIsInEntityNameCommandArrayRange(dLanguage, i, csEntityName)) { return (CCommandArrayFactory.P)i; } } for (int i = m_dFirstEntityIndex; i < Length; i++) { //CTrace.i().vWriteLn(ENMessage.Command,"(CCommandArrayFactory.P)i).ToString()= " + ((CCommandArrayFactory.P)i).ToString()); if (bIsInEntityNameCommandArrayRange(dLanguage, i, csEntityName)) { return (CCommandArrayFactory.P)i; } } } return P.NOT_USED; } public bool bIsInEntityNameCommandArrayRange(P dLanguage, int i, string csEntityName) { string[] sNameArray = this[i].sNameArray; string[] sAbreviationArray = this[i].sAbreviationArray; CTrace.i().vWriteLn(ENMessage.EntityLoading, "bIsInEntityNameCommandArrayRange csEntityName= " + csEntityName + "sAbreviationArray = " + ToString(sAbreviationArray)); return ((CCommandArrayFactory.P)i).ToString().ToLower() == csEntityName || ((sNameArray != null && sNameArray.Length > dGetLanguage(dLanguage) && csEntityName == sNameArray[dGetLanguage(dLanguage)]) || sAbreviationArray != null && sAbreviationArray.Length > dGetLanguage(dLanguage) && csEntityName == sAbreviationArray[dGetLanguage(dLanguage)]); } public virtual void vSetClass(P dName, P dClass) { vIncreaseTo((int)dName); SEntityName oEntityName = this[(int)dName]; oEntityName.dClass = dClass; this[(int)dName] = oEntityName; SEntityName oEntityNameClass = this[(int)dClass]; vAdd(ref oEntityNameClass.m_oInstanceArray, dName); this[(int)dClass] = oEntityNameClass; } public P dGetClass(P dEntity) { return this[(int)dEntity].dClass; } public void vSetClass(P dName, P dClass, P dLanguage, string sAbreviation) { CTrace.i().vWriteLn(ENMessage.EntityLoading, "vSetClass(" + dName + "," + dClass + "," + sAbreviation); // EPAssert(m_oAbreviasionDictionary.ContainsKey(sAbreviation)== false, " The abreviation " + sAbreviation + " is already used"); EPAssert(IsNotUsed(dFindEntity(dLanguage, sAbreviation)), " The abreviation" + sAbreviation + " is already used as an entity"); vSetClass(dName, dClass); SEntityName oEntityName = this[(int)dName]; vSet(ref oEntityName.sAbreviationArray, dGetLanguage(dLanguage), sAbreviation); this[(int)dName] = oEntityName; // m_oAbreviasionDictionary.Add(sAbreviation, dName); } public void vSetType(P dName, P dType, P dTypeOfTheSet) { SEntityName oEntityName = this[(int)dName]; oEntityName.dType = dType; this[(int)dName] = oEntityName; if (IsUsed(dTypeOfTheSet)) { vSet(dName, CCommandFactoryBase.IS_TYPE_OF_HIS_SET, dTypeOfTheSet); } } public virtual void vSet(P dName, char cRelation, bool bIsTrue) { SEntityName oEntityName = this[(int)dName]; vSet(ref oEntityName.m_oPropertyArray, cRelation, bIsTrue ? P.ALL: P.NONE); this[(int)dName] = oEntityName; } public string sGetName(P dEntityIndex, P dLanguage) { string sName=null; if ((int)dEntityIndex < 0) { sName = P.NOT_USED.ToString(); } else { if ( bIsInEntityIndexInTheRange(dEntityIndex)) { if (this[(int)dEntityIndex].sNameArray != null) { sName = this[(int)dEntityIndex].sNameArray[dGetLanguage(dLanguage)]; } } if (sName == "" || sName == null) { sName = ((P)dEntityIndex).ToString().ToLower(); } } return sName; } public void vSetName(P dName, string sName, P dLanguage) { SEntityName oEntityName = this[(int)dName]; CDbEPBase.vSet(ref oEntityName.sNameArray, dGetLanguage(dLanguage), sName); this[(int)dName] = oEntityName; } public void vSetHelp(P dName, string sHelp, P dLanguage) { SEntityName oEntityName = this[(int)dName]; CDbEPBase.vSet(ref oEntityName.sHelpArray, dGetLanguage(dLanguage), sHelp); this[(int)dName] = oEntityName; } public void vSetAbbreviation(P dName, P dLanguage, string sAbbrevation) { SEntityName oEntityName = this[(int)dName]; CDbEPBase.vSet(ref oEntityName.sAbreviationArray, dGetLanguage(dLanguage), sAbbrevation); this[(int)dName] = oEntityName; } public void vSet(P dName, char cRelation, P dEntityProperty) { SEntityName oEntityName = this[(int)dName]; vSet( ref oEntityName.m_oPropertyArray, cRelation, dEntityProperty); this[(int)dName] = oEntityName; } /* public void vSet(P dName, char cRelation, P dEntityProperty) { SEntityName oEntityName = this[(int)dName]; vSet( oEntityName.m_oPropertiesList, cRelation, dEntityProperty1); this[(int)dName] = oEntityName; }*/ /* public P dGet(SProperty oPropertieArray, P dName, char cRelation) { // string sProperties= m_oEntityNameCommandArray[(int)dName].sPropertiesList; P dEntityProperty = P.NOT_USED; if (sProperties != null && sProperties != "") { CTrace.i().vWriteLn(ENMessage.Entity, dName.ToString() + " " + cRelation + " " + sProperties); int dIndex = sProperties.IndexOf("#" + cRelation); if (dIndex <= -1) { return P.NOT_USED; } else { int dEndIndex = sProperties.IndexOf("#", dIndex + 1); if (dEndIndex <= -1) dEndIndex = sProperties.Length; string sProperty; sProperty = sProperties.Substring(dIndex + 2, dEndIndex - dIndex - 2); // CTrace.i().vWriteLn(ENMessage.Command,"sProperty = " + sProperty); if (sProperty == "") { dEntityProperty = P.NONE; } else { dEntityProperty = (P)Convert.ToInt32(sProperty); } } } return dEntityProperty; } */ } /// /////////////////////////////////////////////////////////////////////////////// /// /// /// /////////////////////////////////////////////////////////////////////////////// /// public struct SEntity { public SEntity(CDbEPBase.P _dClass, object _oInstance) { dClass = _dClass; oInstance = _oInstance; bExact = true; } /* public SEntity() { dClass = CDbEPBase.P.NOT_USED; oInstance = CDbEPBase.P.NOT_USED; bExact = true; }*/ public CDbEPBase.P dClass; object oInstance; public bool bExact; public bool IsUsed { get { return IsNotUsed == false; } } public string sql { get { if (bIsType(CDbEPBase.P.STRING_TYPE) ) { return oInstance.ToString(); } else if (bIsType(CDbEPBase.P.INTEGER_TYPE) || bIsType(CDbEPBase.P.P_TYPE)) { return ((int)oInstance).ToString(); } else { return ((int)CDbEPBase.P.TYPE_ERROR).ToString(); } } } CDbEPBase.P Type { get { return CEntityManager.Instance(CDbEPBase.P.ENGLISH).dGetType(dClass); } } public bool bIsType(CDbEPBase.P dType) { return CEntityManager.Instance(CDbEPBase.P.ENGLISH).bIsA(Type, dType); } public bool IsNotUsed { get { if (oInstance == null) { return true; } else if (bIsType( CDbEPBase.P.STRING_TYPE) ) { return oInstance.ToString() == CDbEPBase.NOT_USED_STR; } else if (bIsType(CDbEPBase.P.INTEGER_TYPE)) { return (int)oInstance == CDbEPBase.NOT_USED; } else if (bIsType(CDbEPBase.P.ENTITY_ARRAY_TYPE)) { return (int)oInstance == CDbEPBase.NOT_USED; } else if (bIsType(CDbEPBase.P.SINDEX_TYPE)) { return CDbEPBase.IsNotUsed((CDbEPBase.SIndex)oInstance); } else { return (CDbEPBase.P)oInstance == CDbEPBase.P.NOT_USED; } } } public bool bEqualTo(CDbEPBase.P dProperty) { if (bIsType(CDbEPBase.P.P_TYPE)) { return (CDbEPBase.P)oInstance == dProperty; } return false; } public object Instance { get { return oInstance; } set { oInstance = value; } } public CEntityArray EntityArrayInstance { get { if (bIsType(CDbEPBase.P.ENTITY_ARRAY_TYPE)) { return (CEntityArray)oInstance; } else { return null; } } } public int dInstance { get { if (bIsType(CDbEPBase.P.INTEGER_TYPE)) { return (int)oInstance; } else { return CDbEPBase.NOT_USED; } } } public void vSetInstanceFromTypeAndIntegerString(string sInstanceKeyword) { try { if (sInstanceKeyword.Length < 2) { oInstance = (CDbEPBase.P)Convert.ToInt32(sInstanceKeyword); } else { string sType = sInstanceKeyword.Substring(0, 2); string sContent = sInstanceKeyword.Substring(2, sInstanceKeyword.Length - 2); if (sType == "i:") { oInstance = Convert.ToInt32(sInstanceKeyword.Substring(2)); } else if (sType == "s:") { oInstance = sInstanceKeyword.Substring(2); } else { oInstance = (CDbEPBase.P)Convert.ToInt32(sInstanceKeyword); } } } catch { oInstance = CDbEPBase.P.CONVERTION_FAILED; } } public string sInstance { get { if (bIsType(CDbEPBase.P.STRING_TYPE)) { return oInstance.ToString(); } else { return CDbEPBase.NOT_USED_STR; } } } public override string ToString() { string sComparator = bExact ? "=" : "*="; string sClass = dClass.ToString().ToLower(); if (bIsType(CDbEPBase.P.STRING_TYPE)) { return sClass + sComparator + "s:" + oInstance.ToString(); } else if (bIsType(CDbEPBase.P.INTEGER_TYPE)) { return sClass + sComparator + "i:" + ((int)oInstance).ToString(); } else if (bIsType(CDbEPBase.P.SINDEX_TYPE)) { return sClass + sComparator + "si:" + ((CDbEPBase.SIndex)oInstance).ToString(); } else if (bIsType(CDbEPBase.P.ENTITY_ARRAY_TYPE)) { return sClass + sComparator + "ea:" + ((CEntityArray)oInstance).ToString(); } else { return sClass + sComparator + "UnknownType" + Type + " for " + oInstance.ToString(); } } public void vSet(CDbEPBase.P dClass, string sInstanceKeyword, CDbEPBase.P dLanguage) { if (sInstanceKeyword.Length < 2) { Instance = CEntityManager.Instance(dLanguage).dFindEntity( sInstanceKeyword); } else { vSetInstanceFromTypeAndIntegerString(sInstanceKeyword); /* string sType = sInstanceKeyword.Substring(0, 2); string sContent = sInstanceKeyword.Substring(2, sInstanceKeyword.Length - 2); if (sType == "i:") { try { oEntity.iInstance = Convert.ToInt32(sInstanceKeyword); } catch { oEntity.Instance = P.CONVERTION_FAILED; } } else if (sType == "s:") { oEntity.sInstance = sContent; } else { oEntity.Instance = dGet(m_dLanguage, sInstanceKeyword); }*/ } } public void vSet(string sClassKeyword, string sInstanceKeyword, CDbEPBase.P dLanguage) { dClass = CEntityManager.Instance(dLanguage).dFindEntity( sClassKeyword); vSet(dClass, sInstanceKeyword, dLanguage); } }; /// /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// public class CEntityManager : CCommandFactoryBase { protected CEntityManager(P dLanguage) { m_dLanguage = dLanguage; m_oEntityNameCommandArray = null; // vLoad(); } static public CEntityManager Instance(P dLanguage) { if (s_oEntityNameArrayFactory == null) { s_oEntityNameArrayFactory = new CEntityManager(dLanguage); } s_oEntityNameArrayFactory.m_dLanguage = dLanguage; return s_oEntityNameArrayFactory; } //Hashtable m_oEntityNameCommandArrayDictionary; P[] m_oOptionEntity, m_oCommandEntity; public CEntityNameCommandArray m_oEntityNameCommandArray; // Hashtable m_oAbreviasionDictionary; public P[] OptionEntityArray { get { return m_oOptionEntity; } } public P[] CommandArray { get { return m_oCommandEntity; } } public P m_dLanguage; public P dFindCommand(string sCommandName) { for (int i = 0; i < m_oCommandEntity.Length; i++) { if (sGetEntityName(m_oCommandEntity[i]) == sCommandName || sGetEntityAbreviation(m_oCommandEntity[i]) == sCommandName) { return m_oCommandEntity[i]; } } return P.NOT_USED; } public string sGetEntityName(P dEntityName) { SEntityName oEntityName = FindEntityName(dEntityName); CTrace.i().vWriteLn(ENMessage.EntityLoading, "FindEntityName(" + dEntityName + ")= " + oEntityName.csDump()); if (oEntityName.sNameArray != null && dGetLanguage( m_dLanguage) < oEntityName.sNameArray.Length) { return oEntityName.sNameArray[dGetLanguage(m_dLanguage)]; } else if (CEntityManager.Instance(P.ENGLISH).bIsInEntityIndexInTheRange(dEntityName)) { return dEntityName.ToString().ToLower(); } else { return "entity:" + ((int)dEntityName).ToString(); } } public string sGetEntityAbreviation(P dEntity) { SEntityName oEntityName = FindEntityName(dEntity); if (oEntityName.sAbreviationArray != null && dGetLanguage(m_dLanguage) < oEntityName.sAbreviationArray.Length) { return oEntityName.sAbreviationArray[dGetLanguage(m_dLanguage)]; } return null; } static CEntityManager s_oEntityNameArrayFactory = null; static public SEntityName m_oNullEntityName; protected P m_dIDChild, m_dIDParent; public bool bIsParentIDHierarchy(P[] dEntityArray) { if (dEntityArray == null) { return true; } m_dIDChild = m_dIDParent = P.NOT_USED; for (int i = dEntityArray.Length - 1; i >= 1; i--) { if ( bIsADescentOf(dEntityArray[i], dEntityArray[i-1])== false) { m_dIDChild = dEntityArray[i]; m_dIDParent = dEntityArray[i - 1]; return false; } } return true; } public SEntityName FindEntityName(P dEntityName) { if (bIsInEntityIndexInTheRange(dEntityName) == false) return m_oNullEntityName; return m_oEntityNameCommandArray[(int)dEntityName]; } public bool bIsInEntityIndexInTheRange(P i) { return i>= P.NONE && i < P.ENTITY_COUNT || i>= P.FIRST_KEYWORD_INDEX && (int)i < m_oEntityNameCommandArray.Length; } public SEntityName FindEntityName(string csEntityName) { return FindEntityName(dFindEntity(csEntityName)); } public P dFindEntity(string csEntityName) { return m_oEntityNameCommandArray.dFindEntity(m_dLanguage, csEntityName); } void vSetOption(P dName) { m_oEntityNameCommandArray.vSetType(dName, P.P_TYPE, P.NOT_USED); m_oEntityNameCommandArray.vSet(dName, IS_OPTION_RELATION, P.P_TYPE); } void vSetCommand(P dCommand, string sAbbreviation, P dCommandSynopsis) { vSetClass(dCommand, P.COMMAND_CLASS, sAbbreviation); vSet(dCommand, IS_SYNOPSIS, dCommandSynopsis); } void vSetOption(P dName, P dType) { m_oEntityNameCommandArray.vSetType(dName, dType, P.NOT_USED); m_oEntityNameCommandArray.vSet(dName, IS_OPTION_RELATION, dType); } void vSetOption(P dName, P dType, P dSetType) { m_oEntityNameCommandArray.vSetType(dName, dType, dSetType); m_oEntityNameCommandArray.vSet(dName, IS_OPTION_RELATION, dType); } public void vSetIdParent(P dName, P dEntityIdParent) { if (IsUsed(dEntityIdParent)) { m_oEntityNameCommandArray.vSetIdParent(dName, dEntityIdParent); } } public void vSetParent(P dName, P dEntityParent) { if (IsUsed(dEntityParent)) { m_oEntityNameCommandArray.vSetParent(dName, dEntityParent); } } public void vLoadProperty(P dName, SProperty[] oPropertyList) { m_oEntityNameCommandArray.vLoadProperty(dName, oPropertyList); } public string sGetChildList( P dEntityParent) { if ( IsNotUsed(dEntityParent)) return null; StringBuilder oChildString = new StringBuilder(); oChildString.Append((int)dEntityParent); if (m_oEntityNameCommandArray[(int)dEntityParent].m_oChildArray != null) { for (int i = 0; i < m_oEntityNameCommandArray[(int)dEntityParent].m_oChildArray.Length; i++) { oChildString.Append(','); oChildString.Append(sGetChildList(m_oEntityNameCommandArray[(int)dEntityParent].m_oChildArray[i])); } } return oChildString.ToString(); } public P dGetBaseFeatureType(P dFeatureEntity) { P dBaseFeatureType = dFeatureEntity; if (bIsA(dFeatureEntity, P.TIMESPAN_FEATURE)) { dBaseFeatureType = P.TIMESPAN_FEATURE; } return dBaseFeatureType; } public bool bIsA(P dEntityName, P dEntityParent) { if (dEntityName == P.NONE || dEntityParent == P.NONE || bIsInEntityIndexInTheRange(dEntityName) == false || bIsInEntityIndexInTheRange(dEntityParent) == false) return false; if (dEntityName == dEntityParent || m_oEntityNameCommandArray[(int)dEntityName].dEntityParent == dEntityParent || m_oEntityNameCommandArray[(int)dEntityName].dClass == dEntityParent) return true; return bIsA(m_oEntityNameCommandArray[(int)dEntityName].dEntityParent, dEntityParent); } public bool bIsADescentOf(P dEntityName, P dEntityIdParent) { return m_oEntityNameCommandArray.bIsADescentOf(dEntityName, dEntityIdParent); } public virtual void vSetClass(P dName, P dClass) { m_oEntityNameCommandArray.vSetClass(dName, dClass); } public void vSetClass(P dName, P dClass, string sAbreviation) { m_oEntityNameCommandArray.vSetClass(dName, dClass, m_dLanguage, sAbreviation); } public P dGetType(P dEntity) { P dClass = dGetClass(dEntity); if (dClass != P.CLASS && dClass != P.ENTITY_ROOT && dClass != P.NONE && dClass != P.NOT_USED) { dEntity = dClass; } P dType = P.P_TYPE; if (bIsInEntityIndexInTheRange(dEntity)) { P dParentEntity = dEntity; do { dType = m_oEntityNameCommandArray[(int)dParentEntity].dType; dParentEntity = m_oEntityNameCommandArray[(int)dParentEntity].dEntityParent; } while (dType <= P.NONE && bIsInEntityIndexInTheRange(dParentEntity) && dParentEntity > P.NONE); } return dType; } public P dGetClass(P dEntity) { P dClass = P.NOT_USED; if (bIsInEntityIndexInTheRange(dEntity)) { P dParentEntity = dEntity; do { CTrace.i().vWrite(ENMessage.EntityLoading, " dGetClass("+ dParentEntity + ")=" + m_oEntityNameCommandArray[(int)dParentEntity].csDump()); dClass = m_oEntityNameCommandArray[(int)dParentEntity].dClass; dParentEntity = m_oEntityNameCommandArray[(int)dParentEntity].dEntityParent; } while (dClass <= P.NONE && bIsInEntityIndexInTheRange(dParentEntity) && dParentEntity > P.NONE); } return dClass; } public SProperty[] GetPropertyArray(P dEntity) { return m_oEntityNameCommandArray.GetPropertyArray(dEntity); } public P dGetSetType(P dEntity) { return dGet(dEntity, IS_TYPE_OF_HIS_SET) ; } public P dGetOptionParameter(P dEntity) { return dGet(dEntity, IS_OPTION_RELATION); } public P dGet(P dEntity, char cRelation) { return CDbEPBase.dGet(m_oEntityNameCommandArray[(int)dEntity].m_oPropertyArray, cRelation); } public int dGetArray(P dEntity, char cRelation, out P[] oProperty) { return CDbEPBase.dGetArray(m_oEntityNameCommandArray[(int)dEntity].m_oPropertyArray, cRelation, out oProperty); } public void vHas(P dName, P dEntityProperty) { m_oEntityNameCommandArray.vSet(dName, HAS_RELATION, dEntityProperty); } public void vHas(P dName, P dEntityProperty1, P dEntityProperty2) { vSet(dName, HAS_RELATION, dEntityProperty2, dEntityProperty1); } public bool bHas(P dName, char cRelation) { return IsUsed(dGet(dName, cRelation)); } void vSetName( P dName, string sName) { m_oEntityNameCommandArray.vSetName(dName, sName, m_dLanguage); } void vSetAbbreviation(P dName, string sText) { m_oEntityNameCommandArray.vSetAbbreviation(dName, m_dLanguage, sText); } public void vSetName(P dName, string sName, P dLanguage) { m_oEntityNameCommandArray.vSetName(dName, sName, dLanguage); } void vSetHelp(P dName, string sHelp) { m_oEntityNameCommandArray.vSetHelp(dName, sHelp, m_dLanguage); } public void vSet(P dName, char cRelation) { m_oEntityNameCommandArray.vSet(dName, cRelation, true); } public virtual void vSet(P dName, char cRelation, P dEntityProperty1 ) { m_oEntityNameCommandArray.vSet(dName, cRelation, dEntityProperty1); } public virtual void vSet(P dName, char cRelation, P dEntityProperty1, P dEntityProperty2) { m_oEntityNameCommandArray.vSet(dName, cRelation, dEntityProperty1); m_oEntityNameCommandArray.vSet(dName, cRelation, dEntityProperty2); } public void vSetType(P dName, P dType, P dTypeOfTheSet) { m_oEntityNameCommandArray.vSetType(dName, dType, dTypeOfTheSet); } public virtual void vLoad(int dEntityTotal) { m_oEntityNameCommandArray = new CEntityNameCommandArray(P.ENTITY_COUNT, P.FIRST_KEYWORD_INDEX, dEntityTotal); m_oEntityNameCommandArray.vSetType(P.AGENT, P.AVATAR_SINDEX_TYPE, P.NOT_USED); vSetParent(P.AVATAR, P.AGENT); m_oEntityNameCommandArray.vSetType(P.AVATAR, P.AVATAR_SINDEX_TYPE, P.AVATAR_SINDEX_TYPE); vSetParent(P.PROFILE, P.AVATAR); vSet(P.AVATAR, HAS_NAME_RELATION, P.AVATAR_NAME); vSetType(P.PROFILE, P.PROFILE_INDEX_TYPE, P.PROFILE_INDEX_TYPE); vSet(P.PROFILE, HAS_NAME_RELATION, P.AVATAR_NAME); vSetType(P.MEME, P.SINDEX_TYPE, P.SINDEX_TYPE ); vSetType(P.MEMBER_PROFILE, P.PROFILE_INDEX_TYPE, P.PROFILE_INDEX_TYPE); vSet(P.AUTHOR, HAS_NAME_RELATION, P.AVATAR_NAME); vSetParent(P.PROSPECT, P.AVATAR); vSetClass(P.AUTHOR, P.AGENT); vSetParent(P.SENDER, P.AVATAR); vSetParent(P.MEMBER, P.AVATAR); vSetParent(P.FRIEND, P.AVATAR); /// NAME vSetType(P.NAME, P.NAME_STRING_TYPE, P.NAME_STRING_TYPE); vSetParent(P.AVATAR_NAME, P.NAME); vSetParent(P.ORGANISATION_NAME, P.NAME); //////////// ORGANISATION vSetType(P.ORGANISATION, P.ORGANISATION_INDEX_TYPE, P.ORGANISATION_INDEX_TYPE); vSet(P.ORGANISATION, HAS_NAME_RELATION, P.ORGANISATION_NAME); vSetParent(P.COMMITTEE, P.ORGANISATION); vSetType(P.COMMITTEE, P.COMMITTEE_SINDEX_TYPE, P.COMMITTEE_SINDEX_TYPE); vSet(P.COMMITTEE, HAS_NAME_RELATION, P.ORGANISATION_NAME); vSetClass(P.MANAGEMENT_TEAM, P.ORGANISATION); vSetParent(P.GOVERMENT_STATE, P.MANAGEMENT_TEAM); vSetParent(P.NOMENCLATURA, P.ORGANISATION); //////////// OBJECTIVE vSet(P.COMMITMENT, HAS_RELATION, P.OBJECTIVE, P.ACTION); //////////// ISSUE vSetClass(P.ISSUE, P.FACT); //////////// POLITICAL CAMPAIGN //////////// RULE /* vSetClass(P.PHYSICAL_RULE, P.RULE); vHas(P.PHYSICAL_RULE, P.CONSEQUENCE); vSetClass(P.ORGANIC_RULE, P.RULE); vSetClass(P.CULTURAL_BELIEF_RULE, P.RULE); vSetParent(P.CASE, P.RULE); * */ vSetParent(P.CULTURAL_BELIEF, P.CONSEQUENCE); vSetParent(P.PROPERTY_DISTRIBUTION, P.CONSEQUENCE); //////////// ACTION vSet(P.ACTION, HAS_MANDATORY_PARAMETER_RELATION, P.LOCATION, P.TIME); vSetClass(P.CREATE_RULE, P.ACTION); vSetClass(P.STRIKE, P.ACTION); vSetClass(P.SELF_TAX_REDUCTION, P.ACTION); //////////// RESPONSABILITY vHas(P.INDIVIDUAL_POSITION, P.ASSIGMENT, P.RIGHT_TO_REACT); //////////// RESSOURCE vSetParent(P.ASSET_LIQUID_SELLABLE, P.RESSOURCE); vSetParent(P.PERSONAL_AVAILABLE_TIME, P.RESSOURCE); vSetParent(P.TAXATION, P.RESSOURCE); vSetParent(P.DIRECT_TAXATION, P.TAXATION); vSetParent(P.INDIRECT_TAXATION, P.TAXATION); vSetParent(P.CIVIL_SERVANT_TIME, P.RESSOURCE); //////////// TIME vSetParent(P.CURRENT_YEAR, P.TIME); vSetParent(P.FUTURE_YEAR, P.TIME); vSetParent(P.PAST_YEAR, P.TIME); //////////// LOCATION vSetParent(P.CYBERSPACE, P.LOCATION); vSetParent(P.WORLD, P.LOCATION); vSetParent(P.COUNTRY, P.WORLD); vSetParent(P.REGION, P.COUNTRY); vSetParent(P.CITY, P.REGION); vSetParent(P.DISTRICT, P.CITY); //////////// PUBLICATION vSet(P.DOCUMENT, HAS_MANDATORY_PARAMETER_RELATION, P.AUTHOR); vSet(P.DOCUMENT, HAS_MANDATORY_PARAMETER_RELATION, P.LANGUAGE); vSetParent(P.PUBLICATION, P.DOCUMENT); vSetParent(P.URL, P.DOCUMENT); vSetParent(P.GUIDANCE, P.DOCUMENT); vSetParent(P.BILL, P.GUIDANCE); vSetParent(P.SECTION, P.CHAPTER); vSetParent(P.SUB_SECTION, P.CHAPTER); vSetParent(P.RESOLUTION, P.GUIDANCE); vSetParent(P.EXPERITMENT_RESOLUTION, P.RESOLUTION); vSetParent(P.ACT_RESOLUTION, P.RESOLUTION); vSetParent(P.INFORMATIVE_RESOLUTION, P.RESOLUTION); vSetParent(P.POLL, P.INFORMATIVE_RESOLUTION); //////////// Document vSetIdParent(P.PARAGRAPH, P.DOCUMENT); vSetType(P.BIBLE_LINE, P.SINDEX_TYPE, P.SINDEX_TYPE); vSet(P.DOCUMENT, HAS_MANDATORY_PARAMETER_RELATION, P.DOCUMENT_REFERENCE); vSetType(P.DOCUMENT_REFERENCE, P.IDENTIFIER, P.IDENTIFIER); vSetClass(P.GOSPEL, P.DOCUMENT_REFERENCE); vSetParent(P.EVANGELIST, P.AGENT); vSet(P.GOSPEL, HAS_MANDATORY_PARAMETER_RELATION, P.EVANGELIST); vSetClass(P.MARK, P.EVANGELIST); vSetClass(P.JOHN, P.EVANGELIST); vSetClass(P.MATTHEW, P.EVANGELIST); vSetClass(P.LUKE, P.EVANGELIST); vSetParent(P.GOSPEL_TRANSLATION, P.TRANSLATION); vSet(P.GOSPEL, HAS_MANDATORY_PARAMETER_RELATION, P.GOSPEL_TRANSLATION); // vSet(P.GOSPEL_TRANSLATION, HAS_MANDATORY_PARAMETER_RELATION, P.DATE); //vSetType(P.DATE, P.DATE_TYPE); vSet(P.GOSPEL_TRANSLATION, HAS_MANDATORY_PARAMETER_RELATION, P.LANGUAGE); vSetClass(P.YOUNG_LITERAL_TRANSLATION, P.GOSPEL_TRANSLATION); //////// keyword vSetClass(P.CONSULTATION, P.ACTION); //////////// ARGUMENT vSetClass(P.STUDY_RESULT, P.ACTION); vSetParent(P.BELIEF, P.ARGUMENT); vSetParent(P.BELIEF, P.ARGUMENT); vSetParent(P.CONSENSUS, P.BELIEF); vSetParent(P.FACT, P.ARGUMENT); //ATTRIBUTE vSetClass(P.BIRTHDATE, P.TIME); vSetType(P.BIRTHDATE, P.DATE_TYPE, P.NOT_USED); // TYPE vSetClass(P.STRING_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.INTEGER_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.P_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.TIMESPAN_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.DATE_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.SINDEX_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.ENTITY_ARRAY_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.EXECUTED_ENTITY_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.ENTITY_ITEM_ARRAY_TYPE, P.ATTRIBUTE_TYPE); vSetClass(P.COMMAND_LINE_TYPE, P.ATTRIBUTE_TYPE); vSetParent(P.STRING_255_TYPE, P.STRING_TYPE); vSetParent(P.STRING_10_TYPE, P.STRING_TYPE); vSetParent(P.STRING_20_TYPE, P.STRING_TYPE); vSetParent(P.STRING_4000_TYPE, P.STRING_TYPE); vSetParent(P.TITLE_AND_TEXT_TYPE, P.STRING_4000_TYPE); vSetParent(P.TEXT_TYPE, P.STRING_4000_TYPE); // vSetParent(RULE_TYPE, STRING_4000_ATTRIBUTE_TYPE); vSetParent( P.AVATAR_SINDEX_TYPE, P.SINDEX_TYPE); vSetParent(P.COMMITTEE_SINDEX_TYPE,P.SINDEX_TYPE); vSetParent(P.ORGANISATION_INDEX_TYPE, P.INDEX_TYPE); vSetParent(P.PROFILE_INDEX_TYPE, P.INDEX_TYPE); // Feature vSetClass(P.ELECTION_SPAN_FEATURE, P.ORGANISATION_PROPERTY_CLASS); vSetParent(P.TIMESPAN_FEATURE, P.FEATURE); vSetParent(P.ELECTION_SPAN_FEATURE, P.TIMESPAN_FEATURE); vSetClass(P.ELECTION_CHANGE_FREEZE_PERCENTAGE_FEATURE, P.ORGANISATION_PROPERTY_CLASS); vSetParent(P.PERCENTAGE_FEATURE, P.FEATURE); vSetParent(P.ELECTION_CHANGE_FREEZE_PERCENTAGE_FEATURE, P.PERCENTAGE_FEATURE); //Function vSetClass(P.ATTRIBUTE, P.ENTITY_ROOT); vSetParent(P.PROFILE_ATTRIBUTE, P.ATTRIBUTE); vSet(P.PROFILE_ATTRIBUTE, HAS_MANDATORY_PARAMETER_RELATION, P.PROFILE); vSetParent(P.MEMBER_ATTRIBUTE, P.ATTRIBUTE); vSet(P.MEMBER_ATTRIBUTE, HAS_MANDATORY_PARAMETER_RELATION, P.MEMBER); vSetParent(P.ORGANISATION_ATTRIBUTE, P.ATTRIBUTE); vSet(P.ORGANISATION_ATTRIBUTE, HAS_MANDATORY_PARAMETER_RELATION, P.ORGANISATION); vSetParent(P.MEMBER_IN_ORGANISATION_ATTRIBUTE, P.ATTRIBUTE); vSet(P.MEMBER_IN_ORGANISATION_ATTRIBUTE, HAS_MANDATORY_PARAMETER_RELATION, P.MEMBER_PROFILE, P.ORGANISATION); vSetParent(P.MEMBER_IN_COMMITTEE_ATTRIBUTE, P.MEMBER_IN_ORGANISATION_ATTRIBUTE); vSet(P.MEMBER_IN_COMMITTEE_ATTRIBUTE, HAS_MANDATORY_PARAMETER_RELATION, P.MEMBER_PROFILE, P.COMMITTEE); vSetClass(P.GRADE_CLASS, P.ENTITY_ROOT); vSetClass(P.ATTRIBUTE_ORGANISATION_CLASS, P.ENTITY_ROOT); vSetClass(P.DOCUMENT_CLASS, P.ENTITY_ROOT); vSetClass(P.CURRENCY_CLASS, P.ENTITY_ROOT); vSetClass(P.CATEGORY, P.ENTITY_ROOT); vSetType(P.CATEGORY, P.ENTITY_ITEM_ARRAY_TYPE, P.ENTITY_ITEM_ARRAY_TYPE); // vSetClass(P.RULE_CLASS, P.ENTITY_ROOT); vSetClass(P.BILL_PROPOSAL_CLASS, P.ENTITY_ROOT); //vSetClass(P.TRADUCTION_CLASS, P.ENTITY_ROOT); vSetClass(P.VOTE_TYPE_CLASS, P.ENTITY_ROOT); vSetClass(P.ATTRIBUTE_TYPE, P.ENTITY_ROOT); vSetParent(P.INDEX_TYPE, P.INTEGER_TYPE); // vSetType(P.INDEX_TYPE, P.INTEGER_TYPE, P.INTEGER_ARRAY_TYPE); //vSetClass(P.SUB_INDEX, P.SUB_INDEX_CLASS); vSetParent(P.PROFILE_INDEX_TYPE, P.INDEX_TYPE); vSetParent(P.AVATAR_SINDEX_TYPE, P.SINDEX_TYPE); // vSetParent(P.MEME_INDEX, P.INDEX); // vSetParent(P.MEME_SUB_INDEX, P.SUB_INDEX); vSetParent(P.BILL_PROPOSAL_CLASS, P.DOCUMENT_CLASS); vSetParent(P.ANNOTATION_CLASS, P.ENTITY_ROOT); //vSetClass(P.IDENTIFIER, P.ENTITY); vSetType(P.IDENTIFIER, P.IDENTIFIER_TYPE, P.IDENTIFIER_TYPE); // Index //vSetClass(P.INDEX_CLASS, P.ENTITY_ROOT); //vSetClass(P.SUB_INDEX_CLASS, P.ENTITY_ROOT); //Critics vSetParent(P.ANNOTATION, P.PRINCIPLE); // vSetParent(P.RULE, P.ENTITY); vSetParent(P.PRINCIPLE, P.RULE); /* vSetParent(P.CRITIC, P.PRINCIPLE); vSetParent(P.CRITIC_REDACTION, P.CRITIC); vSetParent(P.CRITIC_PROPAGANDA, P.CRITIC); vSetParent(P.CRITIC_VOCABULARY, P.CRITIC); // vSetClass(P.CRITIC, P.RULE_CLASS); */ // vSetClass(P.CRITIC_OF_CRITIC, P.RULE_CLASS); /* vSetClass(P.RULE, P.RULE_CLASS); vSetClass(P.RULE_FUNDAMENTAL, P.RULE_CLASS); * */ // Principle /* vSetClass(P.FUTURE_VERSUS_PRESENT_CRITERIA, P.CRITERIA); vSetClass(P.HUMANITY_VERSUS_INDIVIDUAL_CRITERIA, P.CRITERIA); vSetClass(P.READIBILITY_CRITERIA, P.CRITERIA); vSetClass(P.COST_CRITERIA, P.CRITERIA); vSetClass(P.RESEARCH_CRITERIA, P.CRITERIA); vSetClass(P.URGENCE_CRITERIA, P.CRITERIA); vSetClass(P.IMPORTANCE_CRITERIA, P.CRITERIA); vSetClass(P.ORIGINALITY_CRITERIA, P.CRITERIA); * */ // Command vSetClass(P.COMMAND_CLASS, P.ENTITY_ROOT); vSetCommand(P.CREATE, "c", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.LIST, "l", P.COMMAND_ENTITY_COMMAND_SYNOPSIS); vSetCommand(P.MOVE, "m", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.REMOVE, "r", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.REVOKE, "rev", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.DELETE, "del", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.HELP, "h", P.COMMAND_ENTITY_COMMAND_SYNOPSIS); vSetCommand(P.SUPPORT, "yes", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.OPPOSE, "no", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.ADD, "a", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.UPDATE, "u", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.SET, "se", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.GRANT, "gr", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.STATUS, "st", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.DISPLAY, "d", P.COMMAND_ENTITY_COMMAND_SYNOPSIS); vSetCommand(P.HIDE, "hi", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetCommand(P.SHOW, "sh", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS ); vSetCommand(P.VOTE_COUNT, "vc", P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS); vSetClass(P.IDENTIFIER, P.ENTITY_ROOT, "id"); vSetParent(P.IDENTIFIER_RESULT, P.IDENTIFIER); vSetParent(P.LIST, P.DISPLAY); vSetParent(P.GRANT, P.CREATE); vSetParent(P.ADD, P.CREATE); vSetParent(P.REVOKE, P.DELETE); vSetParent(P.REMOVE, P.DELETE); vSetParent(P.SET, P.UPDATE); vSetParent(P.SUPPORT, P.VOTE); vSetParent(P.OPPOSE, P.VOTE); // Execution vSetParent(P.EXECUTIVE_FEATURE, P.FEATURE); vSetParent(P.EXCLUSIVE_EXECUTION, P.EXECUTIVE_CONDITION); vSetParent(P.DEPENDANT_EXECUTION, P.EXECUTIVE_CONDITION); vSetParent(P.INDEPENDANT_EXECUTION, P.EXECUTIVE_CONDITION); //vSetParent(P.EXCLUSIVE_EXECUTION, P.EXECUTION_RESTRICTION); /* // Excution vSetClass(P.EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetClass(P.PURPOSE_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetClass(P.TIME_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetClass(P.FINANCIAL_ONLY_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetClass(P.LEGAL_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetClass(P.PHYSICAL_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetParent(P.PURPOSE_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXCLUSIVE_EXECUTIVE_RESTRICTION); vSetParent(P.LEGAL_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXCLUSIVE_EXECUTIVE_RESTRICTION); vSetParent(P.PHYSICAL_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXCLUSIVE_EXECUTIVE_RESTRICTION); vSetParent(P.EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetParent(P.TIME_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); vSetParent(P.PURPOSE_EXCLUSIVE_EXECUTIVE_RESTRICTION, P.EXECUTIVE_RESTRICTION); */ //LANGUAGE vSetClass(P.ENGLISH, P.LANGUAGE, "eng"); vSetClass(P.FRENCH, P.LANGUAGE, "fr"); /////////// Option vSetOption(P.COMMENT, P.TEXT_TYPE); vSetOption(P.LANGUAGE, P.P_TYPE); vSetOption( P.NAME, P.STRING_TYPE); vSetOption(P.AVATAR, P.AVATAR_SINDEX_TYPE, P.AVATAR_SINDEX_TYPE); vSetOption( P.VIRTUAL); vSetOption(P.PARENT, P.EXECUTED_ENTITY_TYPE); vSetOption( P.RECURSIVE); vSetOption(P.TYPE); vSetOption(P.MEMBER, P.PROFILE_INDEX_TYPE, P.COMMITTEE_SINDEX_TYPE); vSetOption(P.MEMBER, P.AVATAR_SINDEX_TYPE, P.COMMITTEE_SINDEX_TYPE); vSet(P.MEMBER, HAS_NAME_RELATION, P.MEMBER_NAME); vSetParent(P.MEMBER_NAME, P.NAME); vSetOption(P.AUTHOR, P.AVATAR_SINDEX_TYPE, P.COMMITTEE_SINDEX_TYPE); vSet(P.AUTHOR, HAS_NAME_RELATION, P.AUTHOR_NAME); vSetParent(P.AUTHOR_NAME, P.NAME); vSetOption(P.ORGANISATION, P.ORGANISATION_INDEX_TYPE); vSetOption(P.COMMITTEE, P.COMMITTEE_SINDEX_TYPE); vSetOption( P.CATEGORY, P.IDENTIFIER_TYPE); vSetOption(P.THEME, P.P_TYPE); vSetOption(P.TO, P.IDENTIFIER_TYPE); vSetOption(P.PRINCIPLE, P.EXECUTED_ENTITY_TYPE); vSetOption(P.COMPARATOR, P.P_TYPE); vSetOption(P.TRACE, P.P_TYPE); vSetOption( P.ENCRYPT); vSetOption(P.ACCESS, P.AVATAR_SINDEX_TYPE, P.AVATAR_SINDEX_TYPE); vSetOption(P.AGAINST, P.EXECUTED_ENTITY_TYPE); vSetOption(P.VARIABLE, P.STRING_TYPE); vSetClass(P.COMMAND_ENTITY_COMMAND_SYNOPSIS, P.COMMAND_SYNOPSIS_CLASS); vSetClass(P.COMMAND_ENTITY_NAME_COMMAND_SYNOPSIS, P.COMMAND_SYNOPSIS_CLASS); vSetClass(P.COMMAND_ENTITY_NAME_TEXT_COMMAND_SYNOPSIS, P.COMMAND_SYNOPSIS_CLASS); /////// MESSAGE m_oNullEntityName = FindEntityName(P.NOT_USED); if (m_dLanguage == P.ENGLISH) { vSetEnglishLanguageComment(); vConstructEnglishFeatures(); } m_oOptionEntity = dGetEntityByRelationFilter(IS_OPTION_RELATION); m_oCommandEntity = dGetEntityByClassFilter(P.COMMAND_CLASS); } public P[] dGetEntityByClassFilter(P dClassFilter) { ArrayList oOptionArrayList = new ArrayList(); for (int i = 0; i < m_oEntityNameCommandArray.Length; i++) { if (bIsA(m_oEntityNameCommandArray[i].dClass, dClassFilter)) { oOptionArrayList.Add((P)i); } } return (P[])oOptionArrayList.ToArray(typeof(P)); } public P[] dGetEntityByRelationFilter(char cRelation) { ArrayList oOptionArrayList = new ArrayList(); for (int i = 0; i < m_oEntityNameCommandArray.Length; i++) { if (bHas((P)i, cRelation) ) { oOptionArrayList.Add((P)i); } } return (P[])oOptionArrayList.ToArray(typeof(P)); } void vSetEnglishLanguageComment() { vSetName(P.SUB_SECTION, "subsection"); vSetName(P.FRENCH, "french"); vSetAbbreviation(P.FRENCH, "fr"); vSetName(P.ENGLISH, "english"); vSetAbbreviation(P.ENGLISH, "eng"); //vSetName(P.MEMBER_ORGANISATION, "member"); vSetName(P.ADMINISTRATOR_ORGANISATION, "administrator"); vSetAbbreviation(P.IDENTIFIER, "id"); vSetAbbreviation(P.AVATAR, "av"); vSetAbbreviation(P.ORGANISATION, "org"); //vSetAbbreviation(P.VARIABLE, "var"); // vSetClass(P.VARIABLE, P.ENTITY_ROOT, "var"); // vSetType(P.VARIABLE, P.IDENTIFIER_TYPE, P.IDENTIFIER_TYPE); // vSetName(P.IDENTIFIER, "id"); vSetClass(P.FUNCTION, P.ENTITY_ROOT, "var"); vSetType(P.FUNCTION, P.COMMAND_LINE_TYPE, P.COMMAND_LINE_TYPE); // vSetName(P.IDENTIFIER, "id"); //vSetName(P.AVATAR, "av"); //vSetName(P.ORGANISATION, "org"); vSetName(P.BIRTHDATE, "birthdate"); vSetName(P.STRING_255_TYPE, "string255"); vSetName(P.INTEGER_TYPE, "integer"); vSetName(P.STRING_50_TYPE, "string50"); vSetName(P.STRING_10_TYPE, "string10"); vSetName(P.STRING_20_TYPE, "string20"); vSetName(P.STRING_4000_TYPE, "text"); vSetName(P.STRING_TYPE, "string"); vSetName(P.BOOLEAN_TYPE, "boolean"); vSetName(P.DOUBLE_TYPE, "double"); vSetName(P.DATE_TYPE, "date"); //vSetName(P.ATTRIBUTE_CLASS, "attribute"); vSetName(P.GRADE_CLASS, "grade"); vSetName(P.DOCUMENT_CLASS, "document"); vSetName(P.TIMESPAN_TYPE, "timespan"); // vSetName(P.CRITERIA, "principle"); vSetName(P.EXCLUSIVE_EXECUTION, "exclusive"); vSetName(P.INDEPENDANT_EXECUTION, "independant"); vSetName(P.DEPENDANT_EXECUTION, "dependant"); //////// keyword vSetHelp(P.AVATAR, "An avatar has restricted access to the information of your profile.\nThe avatar can have a restricted display right of his father avatar. A normal avatar is created by the user."); vSetHelp(P.PROFILE, "The profile is the root avatar and it has all accesses. The connection to a profile should be done witha password."); vSetHelp(P.PROSPECT, "A prospect is a non register avatar. A prospect is created by a friend in order to join a cause."); } public void vConstructEnglishFeatures() { if (CFeatureTypeFactory.Instance().Count == 0) { CFeatureTypeFactory.Instance().vAdd("INSTANT", TimeSpan.FromDays(0)); CFeatureTypeFactory.Instance().vAdd("1WK", TimeSpan.FromDays(7)); CFeatureTypeFactory.Instance().vAdd("1M", TimeSpan.FromDays(30)); CFeatureTypeFactory.Instance().vAdd("3M", TimeSpan.FromDays(365 / 4)); CFeatureTypeFactory.Instance().vAdd("1Y", TimeSpan.FromDays(365)); CFeatureTypeFactory.Instance().vAdd("3Y", TimeSpan.FromDays(365 * 3)); CFeatureTypeFactory.Instance().vAdd("5Y", TimeSpan.FromDays(365 * 5)); CFeatureTypeFactory.Instance().Create(P.ELECTION_SPAN_FEATURE); CFeatureTypeFactory.Instance().vAdd("0%", 0); CFeatureTypeFactory.Instance().vAdd("5%", 5); CFeatureTypeFactory.Instance().vAdd("10%", 10); CFeatureTypeFactory.Instance().vAdd("25%", 25); CFeatureTypeFactory.Instance().vAdd("50%", 50); CFeatureTypeFactory.Instance().vAdd("75%", 75); CFeatureTypeFactory.Instance().vAdd("90%", 90); CFeatureTypeFactory.Instance().vAdd("95%", 95); CFeatureTypeFactory.Instance().vAdd("100%", 100); CFeatureTypeFactory.Instance().Create(P.ELECTION_CHANGE_FREEZE_PERCENTAGE_FEATURE); CFeatureTypeFactory.Instance().vAdd(ENExecution.Independant.ToString(), (int)ENExecution.Independant); CFeatureTypeFactory.Instance().vAdd(ENExecution.DoneOnlyIfOtherDone.ToString(), (int)ENExecution.DoneOnlyIfOtherDone); CFeatureTypeFactory.Instance().vAdd(ENExecution.Exclusive.ToString(), (int)ENExecution.Exclusive); CFeatureTypeFactory.Instance().Create(P.EXECUTIVE_FEATURE); } } static public void vAdd(ref SEntity[] eArray, SEntity oEntity) { if (eArray == null) { eArray = new SEntity[1]; eArray[0] = oEntity; } else { SEntity[] eNewArray = new SEntity[eArray.Length + 1]; for (int i = 0; i < eArray.Length; i++) { eNewArray[i] = eArray[i]; } eNewArray[eArray.Length] = oEntity; eArray = eNewArray; } } public static SEntity NOT_USED_SENTITY = new SEntity(P.NOT_USED, NOT_USED); static public string ToString(SEntity[] dArray) { if (dArray == null || dArray.Length == 0) return null; StringBuilder sResult = new StringBuilder(dArray[0].ToString()); for (int i = 1; i < dArray.Length; i++) { sResult.Append(','); sResult.Append(dArray[i].ToString()); } return sResult.ToString(); } static public bool IsNotUsed(SEntity oEntity) { return oEntity.dClass == P.NOT_USED || oEntity.IsNotUsed; } static public bool IsUsed(SEntity oEntity) { return oEntity.dClass != P.NOT_USED && oEntity.IsUsed; } } public class CEntityHelp { public CEntityHelp() { m_oHelpArray = new ArrayList(); } public CDbEPBase.P dEntity; ArrayList m_oHelpArray; public void vAdd(CDbEPBase.P dCommand, CDbEPBase.P dOption, string sHelp) { SHelp oHelp = new SHelp(); oHelp.dOption= dOption; oHelp.dCommand= dCommand; oHelp.sHelp= sHelp; } public string[] sGetHelp(CDbEPBase.P dCommand) { ArrayList oOutputArray = new ArrayList(); for(int i=0; i < m_oHelpArray.Count; i++) { if ( ((SHelp)m_oHelpArray[i]).dCommand == dCommand) { oOutputArray.Add( ((SHelp)m_oHelpArray[i]).sHelp); } } return (string[])oOutputArray.ToArray(typeof(string)); } } public struct SHelp { public CDbEPBase.P dCommand; public CDbEPBase.P dOption; public string sHelp; } /// /// Summary description for CEPolCommandArrayFactory /// public class CCommandArrayFactory : CCommandFactoryBase { public CCommandArrayFactory() { m_oCommandArrayDictionary = new SortedList(); } SortedList m_oCommandArrayDictionary; public string sKey(P dLanguage, P dEntity) { string sKey = ((int)dLanguage).ToString(); if (CDbEPBase.IsUsed(dEntity)) { sKey += 'e' + ((int)dEntity).ToString(); } return sKey; } /* public string sKey(P dLanguage, P dCommand, P dEntity, P dOption) { string sKey = ((int)dLanguage).ToString(); if (CDbEPBase.IsUsed(dCommand)) { sKey += 'c' + ((int)dCommand).Tostring() } if (CDbEPBase.IsUsed(dEntity)) { sKey += 'e'+ ((int)dEntity).Tostring(); } if (CDbEPBase.IsUsed(dOption)) { sKey += 'o'+ ((int)dOption).Tostring(); } return sKey; } * * */ public string[] sHelp(P dLanguage, P dCommand, P dEntity) { CEntityHelp oEntityHelp = null; string sKey1 = sKey(dLanguage, dEntity); if (m_oCommandArrayDictionary.ContainsKey(sKey1)) { oEntityHelp = ((CEntityHelp)m_oCommandArrayDictionary[sKey1]); } else if (P.ENGLISH != dLanguage) { string sKey2 = sKey(P.ENGLISH, dEntity); if (m_oCommandArrayDictionary.ContainsKey(sKey2)) { oEntityHelp = ((CEntityHelp)m_oCommandArrayDictionary[sKey2]); } if (oEntityHelp == null) { string[] sReturn = new string[1]; sReturn[0] = "There is no help for " + dEntity.ToString().ToLower() + " in " + dLanguage.ToString().ToLower(); if (dLanguage != P.ENGLISH) { sReturn[0] += " or english"; } return sReturn; } } return oEntityHelp == null ? null : oEntityHelp.sGetHelp(dCommand); } // public SCommand m_oNullCommand; static CCommandArrayFactory s_oCommandArrayFactory = null; public static CCommandArrayFactory Instance() { if (s_oCommandArrayFactory == null) { s_oCommandArrayFactory = new CCommandArrayFactory(); } return s_oCommandArrayFactory; } public void vSetHelp(P dLanguage, P dCommand, P dEntityName, P dOption, string sHelp) { SHelp oHelp = new SHelp(); oHelp.dCommand = dCommand; oHelp.dOption = dOption; oHelp.sHelp = sHelp; m_oCommandArrayDictionary.Add(sKey(dLanguage, dEntityName), oHelp); } } ///------------------------------------------------------------------------------------------------------------------------- /// /// Summary description for CDbEntityNameTable /// ///------------------------------------------------------------------------------------------------------------------------- public class CIdentifier : CDbEPBase { public CIdentifier() { vClear(); } public CIdentifier(SBIndex iIndex) { vClear(); m_iIndex = iIndex; } public CIdentifier(int dIndex) { vClear(); m_iIndex.dReferenceIndex= NOT_USED; m_iIndex.dMainSIndex.dIndex = dIndex; m_iIndex.dMainSIndex.dSubIndex = NOT_USED; } public CIdentifier(P dEntity, CIdentifier oIdentifierParent) { vClear(); m_dEntity = dEntity; m_oIdentifierParent = oIdentifierParent; } public CIdentifier(P dEntity, CIdentifier oIdentifierParent, CEntityArray oEntityArray) { vClear(); m_dEntity = dEntity; m_oIdentifierParent = oIdentifierParent; m_eaFilter = oEntityArray; } public CIdentifier( SBIndex iIndex, P dEntity, CEntityArray oEntityArray) { vClear(); m_dEntity = dEntity; m_oIdentifierParent = null; m_eaFilter = oEntityArray; m_iIndex = iIndex; } public override string ToString() { string sOutput = ""; if (m_oIdentifierParent != null) { sOutput = m_oIdentifierParent.ToString(); } else { sOutput = ""; } if (sOutput != "") sOutput += IDENTIFIER_CHILD_SEPARATOR; if (IsUsed(m_dEntity)) { sOutput += FromNoodToString(); } else { sOutput += "id:" + m_iIndex.ToString(); } if (IsUsed(m_iIndex.dMainSIndex.dSubIndex)) { sOutput += IDENTIFIER_MEME_SEPARATOR + m_iIndex.dMainSIndex.dSubIndex; } return sOutput; } public bool bIsEmpty { get { return IsNotUsed(m_dEntity); } } public void vSetSubMeme(int dSubMeme) { m_iIndex.dMainSIndex.dSubIndex = dSubMeme; } public CIdentifier(P dEntity) { vClear(); m_dEntity = dEntity; } void vClear() { m_dEntity = P.NOT_USED; m_oIdentifierParent = null; m_eaFilter = null; m_dDepth = NOT_USED; m_iIndex = NOT_USED_SBINDEX; } P m_dEntity; protected SBIndex m_iIndex; CIdentifier m_oIdentifierParent; CEntityArray m_eaFilter; int m_dDepth; public P Language { get { int dInstance= dFind(P.LANGUAGE); if (IsUsed(dInstance)) { return (P)dInstance; } return P.ENGLISH; } } public int dFind(P dClass) { if (m_eaFilter != null) { int dInstance = m_eaFilter.dFind(dClass); if (IsUsed(dInstance)) { return dInstance; } else if (m_oIdentifierParent != null) { return m_oIdentifierParent.dFind(dClass); } } return NOT_USED; } public CEntityArray ParentEntityArray { get { if (this.m_oIdentifierParent != null) { return m_oIdentifierParent.m_eaFilter; } return null; } } public CEntityArray dGetEntityArray(bool bIsExactMatch) { if (m_eaFilter != null) { return m_eaFilter.toExactMatch(bIsExactMatch); } return null; } public void vSetEntityArray(CEntityArray ea) { m_eaFilter = ea; } public bool bIsA(P dEntity) { CIdentifier oIdentifier = this; if (oIdentifier.m_dEntity == dEntity) { return true; } else { if (oIdentifier.ParentIdentifier == null) { return false; } else { return oIdentifier.ParentIdentifier.bIsA( dEntity); } } } public int AuthorIndex { get { CIdentifier oIdentifier = oGetRoot(P.PROFILE_ATTRIBUTE); if (oIdentifier != null) { CEntityArray oEntityArray = oIdentifier.dGetEntityArray(false); if (oEntityArray != null) { return (int)oEntityArray.pFind(P.PROFILE_INDEX_TYPE); } } return NOT_USED; } } public CIdentifier oGetRoot(P dEntity) { CIdentifier oIdentifier = this; if (oIdentifier.m_dEntity == dEntity) { return oIdentifier; } else { if (oIdentifier.ParentIdentifier == null) { return null; } else { return oIdentifier.ParentIdentifier.oGetRoot(dEntity); } } } public CIdentifier ParentIdentifier { get { return m_oIdentifierParent; } set { m_oIdentifierParent = value; } } public int dReferenceIndex { get { return m_iIndex.dReferenceIndex; } set { m_iIndex.dReferenceIndex= value; } } public SIndex Index { get { return m_iIndex.dMainSIndex; } set { m_iIndex.dReferenceIndex = NOT_USED; m_iIndex.dMainSIndex = value; } } public SBIndex iIndex { get { return m_iIndex; } set { m_iIndex = value; } } public void vSetParentIndentifierIndex(SBIndex iIndex) { m_oIdentifierParent = new CIdentifier(iIndex); } public void vSetParentIndentifierPrincipalIndex(SIndex dIndex) { m_oIdentifierParent = new CIdentifier(new SBIndex( dIndex)); } public P Entity { get { return m_dEntity; } set { m_dEntity = value; } } public void vAddTail(CIdentifier oIdentifierAncestor) { if (m_oIdentifierParent == null) { m_oIdentifierParent = oIdentifierAncestor; } else { m_oIdentifierParent.vAddTail(oIdentifierAncestor); } } bool bSet(SEntity oEntity) { if (m_eaFilter != null && IsUsed(m_eaFilter.pFind(oEntity.dClass)) ) { m_eaFilter.vAdd(oEntity); return true; } else if ( this.ParentIdentifier != null) { return ParentIdentifier.bSet(oEntity); } return false; } public void vAdd(P dClass, int dInstance) { vAdd(new SEntity(dClass, dInstance)); } public void vAdd(SEntity oEntity) { if (bSet(oEntity) == false) { vAddAttribute(oEntity); } } void vAddAttribute(SEntity oEntity) { m_iIndex = NOT_USED_SBINDEX; if (m_eaFilter == null) { m_eaFilter = new CEntityArray(oEntity); } else { m_eaFilter.vAdd(oEntity); } } public bool bAdd(P dEntity, SEntity oEntity) { if (dEntity == m_dEntity) { vAddAttribute(oEntity); } else { if (m_oIdentifierParent != null) { return m_oIdentifierParent.bAdd(dEntity, oEntity); } } return false; } public string ToString(P dEntity) { return CEntityManager.Instance(Language).sGetEntityName(dEntity); } string FromNoodToString() { if (IsUsed(m_dEntity)) { string sOutput = ToString(m_dEntity); if (m_eaFilter != null && m_eaFilter.ToString() != "") { sOutput += IDENTIFIER_PROPERTY_SEPARATOR + m_eaFilter.ToString(); } return sOutput; } return null; } public int Depth { get { if (IsUsed(m_dDepth)) { return m_dDepth; } else { if (m_oIdentifierParent == null) { m_dDepth = 1; } else { m_dDepth = m_oIdentifierParent.Depth + 1; } } return m_dDepth; } } public P[] GetEntityList { get { P[] oArray = new P[Depth]; CIdentifier oIdentifierParent = ParentIdentifier; oArray[0] = m_dEntity; for (int i = 1; i < Depth; i++) { if (oIdentifierParent != null) { oArray[i] = oIdentifierParent.m_dEntity; oIdentifierParent = oIdentifierParent.ParentIdentifier; } } return oArray; } } public CIdentifier GetParent(int dDepth) { CIdentifier oIdentifierParent = ParentIdentifier; for (int i = 1; i < dDepth; i++) { if (oIdentifierParent == null) { return null; } else { oIdentifierParent = oIdentifierParent.ParentIdentifier; } } return oIdentifierParent; } public string csDump() { string sOutput = ""; if (m_oIdentifierParent != null) { sOutput = m_oIdentifierParent.csDump(); } else { sOutput = ""; } if (sOutput != "") sOutput += IDENTIFIER_CHILD_SEPARATOR; if (IsUsed(this.m_iIndex)) { sOutput += m_iIndex.ToString() + ':'; } sOutput += FromNoodToString(); if ( IsUsed(m_iIndex.dMainSIndex.dSubIndex) ) { sOutput += IDENTIFIER_MEME_SEPARATOR + m_iIndex.dMainSIndex.dSubIndex; } return sOutput; } } ///------------------------------------------------------------------------------------------------------------------------ public class CEntityArray : CDbEPBase { public CEntityArray(SEntity[] oEntityArray) { vClear(); m_oEntityArray = oEntityArray; } public CEntityArray() { vClear(); } public CEntityArray(SEntity[] oEntityArray, SEntity oEntity) { vClear(); vAppend(oEntityArray); vAppend(oEntity); } public CEntityArray(SEntity oEntity) { vClear(); vAppend(oEntity); } public CEntityArray(P dClass, P dInstance) { vClear(); SEntity[] oEntityArray = new SEntity[1]; oEntityArray[0].dClass = dClass; oEntityArray[0].Instance = dInstance; vAppend(oEntityArray); } public CEntityArray(P dClass, int dInstance) { vClear(); SEntity[] oEntityArray = new SEntity[1]; oEntityArray[0].dClass = dClass; oEntityArray[0].Instance = dInstance; vAppend(oEntityArray); } public CEntityArray(CEntityArray oEntityArray, SEntity oEntity) { vClear(); m_oEntityArray = oEntityArray.EntityExtraArray; vAppend(oEntity); } public CEntityArray(params CEntityArray[] oEntityArrayOfArray) { vClear(); for(int i=0; i < oEntityArrayOfArray.Length; i++) { if (oEntityArrayOfArray[i] != null) { vAppend(oEntityArrayOfArray[i].EntityExtraArray); } } } public CEntityArray(SEntity[] oEntityArray, SEntity[] oEntityArray2) { vClear(); vAppend(oEntityArray); vAppend(oEntityArray2); } /* public CEntityArray(ArrayList oEntityArrayList) { vClear(); vAppend(ToSEntityArray(oEntityArrayList)); }*/ public bool bIsEmpty { get { return m_oEntityArray.Length == 0; } } SEntity[] m_oEntityArray; public void vClear() { m_bNormalForm = true; m_oEntityArray = new SEntity[0]; } public SEntity[] EntityExtraArray { get { if (m_bNormalForm == false) dSort(); return m_oEntityArray; } } public SEntity[] EntityArray { get { if (m_bNormalForm == false) dSort(); SEntity[] oEntityArray = new SEntity[m_oEntityArray.Length]; for (int i = 0; i < m_oEntityArray.Length; i++) { oEntityArray[i] = m_oEntityArray[i]; } return oEntityArray; } } public void vTrim() { if (m_oEntityArray != null) { SEntity[] oEntityArrayOld = m_oEntityArray; m_oEntityArray = new SEntity[0]; for (int i = 0; i < oEntityArrayOld.Length; i++) { if (IsUsed(oEntityArrayOld[i])) { vAdd(oEntityArrayOld[i]); } } } } static new public bool IsUsed(object oValue) { if (oValue is SEntity) { return ((SEntity)oValue).IsUsed; } else { return CDbEPBase.IsUsed(oValue); } } /*static new public bool IsUsed(object oValue) { return CFeatureType.IsUsed(oValue); } */ public static CEntityArray FromClassAndPTypeToEntityArray(ArrayList oArrayList) { if (oArrayList == null) { return null; } SEntity[] oEntityArray = new SEntity[oArrayList.Count]; for (int i = 0; i < oArrayList.Count; i++) { object[] oObjects = (object[])oArrayList[i]; oEntityArray[i].dClass = (P)oObjects[0]; oEntityArray[i].Instance = oObjects[1]; } return new CEntityArray(oEntityArray); } public static CEntityArray FromClassAndSIndexToEntityArray(ArrayList oArrayList) { if (oArrayList == null) { return null; } SEntity[] oEntityArray = new SEntity[oArrayList.Count]; for (int i = 0; i < oArrayList.Count; i++) { object[] oObjects = (object[])oArrayList[i]; oEntityArray[i].dClass = (P)oObjects[0]; SIndex oSIndex = new SIndex((int)oObjects[1], (int)oObjects[2]); oEntityArray[i].Instance = oSIndex; } return new CEntityArray(oEntityArray); } public CEntityArray toExactMatch(bool bIsExactMatch) { if (bIsExactMatch) { SEntity[] oNewEntity = new SEntity[m_oEntityArray.Length]; for (int i = 0; i < m_oEntityArray.Length; i++) { oNewEntity[i] = m_oEntityArray[i]; oNewEntity[i].bExact = bIsExactMatch; } return new CEntityArray(oNewEntity); } return this; } public virtual void vInitializedWithContext(CEntityArray oEntityArray) { vClear(); } bool m_bNormalForm; public SEntity this[int i] { get { if (m_bNormalForm == false) dSort(); return m_oEntityArray[i]; } } public int Length { get { if (m_oEntityArray == null) return 0; if (m_bNormalForm == false) dSort(); return m_oEntityArray.Length; } } public override string ToString() { if (m_bNormalForm == false) dSort(); StringBuilder sEntityKey = new StringBuilder(); //sEntityKey.Append(dMetaClass + "," + dClass + "," + dName + "," + dLanguage); for (int i = 0; i < m_oEntityArray.Length; i++) { if ( sEntityKey.Length > 0 ) sEntityKey.Append(','); sEntityKey.Append(m_oEntityArray[i].ToString()); } return sEntityKey.ToString(); } public ec dSort() { vTrim(); ec dRC = ec.ST_SUCCEED; if (m_oEntityArray != null) { SEntity[] oOutPutArray = new SEntity[m_oEntityArray.Length]; ArrayList oInputList = new ArrayList(); oInputList.AddRange(m_oEntityArray); for (int i = 0; i < oOutPutArray.Length; i++) { P dMinEntity = (P)9999999; int dCurrentIndex = 0; for (int j = 0; j < oInputList.Count; j++) { if (((SEntity)oInputList[j]).dClass < (P)dMinEntity) { if (((SEntity)oInputList[j]).dClass < (P)dMinEntity) { dMinEntity = ((SEntity)oInputList[j]).dClass; dCurrentIndex = j; } else if (((SEntity)oInputList[j]).dClass == (P)dMinEntity) { dRC = ec.ST_ATTRIBUTE_ENTITY_DUPLICATE; dCurrentIndex = j; } } } oOutPutArray[i] = ((SEntity)oInputList[dCurrentIndex]); oInputList.RemoveAt(dCurrentIndex); } m_oEntityArray = oOutPutArray; m_bNormalForm = true; } return dRC; } static public SEntity oCreateEntity(P dEntityClass, object oInstance) { SEntity oAttribute = new SEntity(); oAttribute.dClass = dEntityClass; oAttribute.Instance = oInstance; return oAttribute; } static public SEntity[] oGetEntityArray( P dEntityClass, object oInstance) { return oGetEntityArray(new SEntity(dEntityClass, oInstance)); } static public SEntity[] oGetEntityArray(SEntity oEntity) { SEntity[] oAttributeArray = new SEntity[1]; oAttributeArray[0] = oEntity; return oAttributeArray; } public void vAppend(SEntity oEntity) { SEntity[] oSecondEntityArray; oSecondEntityArray = new SEntity[1]; oSecondEntityArray[0] = oEntity; vAppend(oSecondEntityArray); } public void vAdd(P dClass, P dInstance) { SEntity oSecondEntity = new SEntity(dClass, dInstance); vAdd(oSecondEntity); } public void vAdd(P dClass, int dInstance) { SEntity oSecondEntity = new SEntity(dClass, dInstance); vAdd(oSecondEntity); } public void vAppend(SEntity[] oSecondEntityArray) { if (oSecondEntityArray != null) { ArrayList oSecondEntityArrayList = new ArrayList(); for (int i = 0; i < oSecondEntityArray.Length; i++) { oSecondEntityArrayList.Add(oSecondEntityArray[i]); } oSecondEntityArray = (SEntity[])oSecondEntityArrayList.ToArray(typeof(SEntity)); SEntity[] oAttributeArray; if (m_oEntityArray != null) { oAttributeArray = new SEntity[m_oEntityArray.Length + oSecondEntityArray.Length]; for (int i = 0; i < m_oEntityArray.Length; i++) { oAttributeArray[i] = m_oEntityArray[i]; } for (int i = 0; i < oSecondEntityArray.Length; i++) { oAttributeArray[m_oEntityArray.Length + i] = oSecondEntityArray[i]; } } else { oAttributeArray = oSecondEntityArray; } m_oEntityArray = oAttributeArray; } if (m_oEntityArray == null) m_oEntityArray = new SEntity[0]; m_bNormalForm = false; } protected int dFindIndex(P dEntityClass) { for (int i = 0; i < m_oEntityArray.Length; i++) { if (m_oEntityArray[i].dClass == dEntityClass) { return i; } } return NOT_USED; } public object oExtract(P dClassName) { int dIndex = dFindIndex(dClassName); object oInstance = P.NOT_USED; if (dIndex >= 0) { oInstance = m_oEntityArray[dIndex].Instance; vRemoveAt(dIndex); } return oInstance; } protected void vRemoveAt(int dIndex) { SEntity[] oOldArray = m_oEntityArray; m_oEntityArray = new SEntity[oOldArray.Length - 1]; int j = 0; for (int i = 0; i < oOldArray.Length; i++) { if (i != dIndex) { m_oEntityArray[j] = oOldArray[i]; j++; } } } public int dFind(P dEntityClass) { int dIndex = Convert.ToInt32(oFind(dEntityClass)); return dIndex; } public P pFind(P dEntityClass) { P dIndex = (P)oFind(dEntityClass); return dIndex; } public object oFind(P dEntityClass) { if (m_bNormalForm == false) dSort(); int dIndex = dFindIndex(dEntityClass); if (IsUsed(dIndex)) { return m_oEntityArray[dIndex].Instance; } // } return P.NOT_USED; } public void vAdd(SEntity oEntity) { for (int i = 0; m_oEntityArray != null && i < m_oEntityArray.Length; i++) { if (m_oEntityArray[i].dClass == oEntity.dClass) { m_oEntityArray[i].Instance = oEntity.Instance; return; } } vAppend(oEntity); } public void vAdd(SEntity[] oEntityArray2) { for (int i = 0; oEntityArray2 != null && i < oEntityArray2.Length; i++) { vAdd(oEntityArray2[i]); } } public void vAdd(string sAddress) { ArrayList dEntityArrayList = new ArrayList(); string sKeyword = ""; string sClass = ""; for (int i = 0; i < sAddress.Length; i++) { char cChar = sAddress[i]; if (cChar.ToString() == IDENTIFIER_PROPERTY_SEPARATOR || i == sAddress.Length - 1) { if (i == sAddress.Length - 1) sKeyword += cChar; SEntity oEntity = new SEntity(); try { oEntity.vSetInstanceFromTypeAndIntegerString(sKeyword); if (sClass == "") { oEntity.dClass = P.IDENTIFIER; } else { oEntity.dClass = (P)Convert.ToInt32(sClass); } dEntityArrayList.Add(oEntity); } catch { oEntity.Instance = P.CONVERTION_FAILED; } sClass = sKeyword = ""; } else if (cChar == '=') { sClass = sKeyword; sKeyword = ""; } else { sKeyword += cChar; } } vAppend((SEntity[])dEntityArrayList.ToArray(typeof(SEntity))); } } ///------------------------------------------------------------------------------------------------------------------------ public class CCommandContext : CDbEPBase { public CCommandContext() { m_oVariableMap = new SortedList(); vClear(); } public void vClear() { m_iSender = m_iMember = m_iOrganisation = NOT_USED_SINDEX; dLanguage = P.ENGLISH; m_oVariableMap.Clear(); } SortedList m_oVariableMap; SIndex m_iSender; SIndex m_iMember; public SIndex m_iOrganisation; public P dLanguage; public SIndex SenderIndex { get { return m_iSender; } set { if (IsNotUsed(value.dSubIndex)) { if (IsUsed(m_iSender)) { m_iSender.dSubIndex = PUBLIC_PROFILE_SUB_INDEX; } } else { m_iSender = value; } } } public SIndex MemberIndex { get { return m_iMember; } set { m_iMember = value; } } /* public SIndex AvatarIndex { get { return m_iSender; } set { if (m_iSender.dIndex == value.dIndex) { m_iSender = value; } } }*/ public void vSet(CCommandLine oCommandLine) { m_iMember = oCommandLine.MemberIndex; m_iSender = oCommandLine.SenderIndex; m_iOrganisation = oCommandLine.OrganisationIndex; dLanguage = oCommandLine.Language; } public void vAdd(string sVariableName, CIdentifier oIdentifier) { if ( sVariableName.Substring(0,1) == "$" ) { sVariableName = sVariableName.Substring(1); } m_oVariableMap.Remove(sVariableName); m_oVariableMap.Add(sVariableName, oIdentifier); } public void vAdd(string sVariableName, CCommandLine oCommandLine) { if ( sVariableName.Substring(0,1) == "$" ) { sVariableName = sVariableName.Substring(1); } m_oVariableMap.Add(sVariableName, oCommandLine); } public void vAdd(string sVariableName, CMemeArray oMemeArray) { if ( sVariableName.Substring(0,1) == "$" ) { sVariableName = sVariableName.Substring(1); } m_oVariableMap.Add(sVariableName,oMemeArray); } public CMemeArray maGetVariable(string sVariableName) { return (CMemeArray)oGetVariable( sVariableName, typeof(CMemeArray)); } public CIdentifier idGetVariable(string sVariableName) { return (CIdentifier)oGetVariable( sVariableName, typeof(CIdentifier)); } public string sGetVariable(string sVariableName) { return (string)oGetVariable( sVariableName, typeof(string)); } public object oGetVariable(string sVariableName, Type oCastType) { if ( sVariableName != null && sVariableName.Substring(0,1) == "$" ) { sVariableName = sVariableName.Substring(1); if (m_oVariableMap.Contains(sVariableName) == false || m_oVariableMap[sVariableName].GetType() != oCastType) { return null; } if ( m_oVariableMap[sVariableName].GetType() == oCastType) { return m_oVariableMap[sVariableName]; } } return null; } public CCommandLine clGetVariable(string sVariableName) { return (CCommandLine)oGetVariable( sVariableName, typeof(CCommandLine)); } public string csDump() { string sOutput = "Sender:" + m_iSender.ToString() + " Member:" + m_iMember.ToString() + " Organisation:" + m_iOrganisation.ToString() + " Language:" + dLanguage + "\nDict: "; foreach(DictionaryEntry oVariableEntry in m_oVariableMap) { sOutput += oVariableEntry.Key.ToString() + ":"; if ( oVariableEntry.Value.GetType() == typeof(CCommandLine)) { sOutput += ((CCommandLine)oVariableEntry.Value).csDump() + "\n"; } else if ( oVariableEntry.Value.GetType() == typeof(CIdentifier)) { sOutput += ((CIdentifier)oVariableEntry.Value).csDump()+ "\n"; } else { sOutput += oVariableEntry.Value.ToString() + "\n"; } } return sOutput; } } ///------------------------------------------------------------------------------------------------------------------------ public class CEmailCommand { public CEmailCommand(CDbEPBase.P dLanguage, CDbEPBase.P dCommand, string sEntityName, string csEntityContent, string csOption) { m_dLanguage = dLanguage; m_dCommand = dCommand; m_sEntityName = sEntityName; m_csEntityContent = csEntityContent; m_csOptionString = csOption; } CDbEPBase.P m_dLanguage; public CDbEPBase.P m_dCommand; public string m_csOptionString, m_csEntityContent, m_sEntityName; /* public bool bHasOption(string csOptionName) { return CCommandManager.bHasOption(csOptionName, m_csOptionString); } */ public string Synopsis { get { return m_dCommand.ToString() + ' ' + m_sEntityName + " " + m_csEntityContent + " " + m_csOptionString; } } public string csDump() { string csDump = "command:" + m_dCommand.ToString() + " entity:" + m_sEntityName; csDump += " m_csOptionString: " + m_csOptionString + " m_csEntityContent:" + m_csEntityContent; return csDump; } } ///------------------------------------------------------------------------------------------------------------------- public class CCommandLine : CDbEPBase { public CCommandLine(P dCommand, P dExecutedEntity, ref CCommandContext oCommandContext) { vClear(); m_dCommand = dCommand; ExecutedEntity = dExecutedEntity; m_oCommandContext = oCommandContext; } public CCommandLine(ref CCommandContext oCommandContext) { vClear(); m_oCommandContext = oCommandContext; } CCommandContext m_oCommandContext; ArrayList m_oErrorCode; public CCommandContext CommandContext { get { return m_oCommandContext; } } public void vClear() { m_dCommand = P.NOT_USED; ExecutedEntity = P.NOT_USED; m_oOptionList = new SortedList(); m_sContentText= m_sContentName = null; m_oErrorCode = new ArrayList(); } P m_dCommand; P m_dExecutedEntity; string m_sContentName, m_sContentText; public bool bIsAVariable { get { return m_sContentName != null && m_sContentName.Substring(0,1)== "$"; } } public CIdentifier ContentIdentifier { get { CIdentifier idContentIdentifier=null; if ( bIsAVariable ) { idContentIdentifier= m_oCommandContext.idGetVariable(m_sContentName); /*if ( idContentIdentifier== null && ContentCommandLine != null) { CTrace.i().vWriteLn(ENMessage.Trace, "ContentCommandLine = " + ContentCommandLine.csDump() ); idContentIdentifier= ContentCommandLine.ContentIdentifier; }*/ } if ( idContentIdentifier == null) idContentIdentifier = idFind(m_dExecutedEntity); return idContentIdentifier; } set { EPAssert(m_sContentName == null, "m_sContentName should be null"); // EPAssert(IsNotUsed(m_oContentIndex), "m_oContentIndex should be not be used"); if (value.GetType() == typeof(CIdentifier)) { this.vAdd(m_dExecutedEntity, (CIdentifier)value); } else { } } } public SIndex ContentIndex { get { if (IsNotUsed(m_dExecutedEntity) || m_dExecutedEntity== P.FUNCTION) { return NOT_USED_SINDEX; } SIndex oIndex = iFind(m_dExecutedEntity); return oIndex; } set { EPAssert(ContentIdentifier == null || ContentIdentifier.bIsEmpty, "ContentIdentifier should not be used"); EPAssert(m_sContentName == null, "m_sContentName should be null"); vAdd(m_dExecutedEntity, value); } } public CCommandLine ContentCommandLine { get { if (IsNotUsed(m_dExecutedEntity)) { return null; } if (bIsAVariable) { return m_oCommandContext.clGetVariable(m_sContentName); } return null; } /*set { EPAssert(ContentIdentifier == null || ContentIdentifier.bIsEmpty, "ContentIdentifier should not be used"); EPAssert(m_sContentName != null, "m_sContentName should not be null " + m_sContentName); vAdd(PFUNCTION, value); } */ } public void vAddFunctionAndCommandLine(string sVariableEntityName, CCommandLine oVariableCommandLine) { CTrace.i().vWriteLn(ENMessage.Function, " vAddFunctionAndCommandLine sVariableEntityName= " + sVariableEntityName + " oVariableCommandLine = " + oVariableCommandLine.csDump() ); if (sVariableEntityName.Substring(0,1) != "$" ) { m_sContentName = "$" + sVariableEntityName; } else { m_sContentName = sVariableEntityName; } CommandContext.vAdd(m_sContentName, oVariableCommandLine); CTrace.i().vWriteLn(ENMessage.Function, "CommandContext = " + CommandContext.csDump() ); } public string ContentName { get { CIdentifier idContentIdentifier = ContentIdentifier; if (idContentIdentifier != null && idContentIdentifier.bIsEmpty == false ) { return ContentIdentifier.ToString(); } else { return m_sContentName; } } set { EPAssert(ContentIdentifier == null || ContentIdentifier.bIsEmpty, "ContentIdentifier should be null"); // EPAssert(IsNotUsed(m_oContentIndex), "m_oContentIndex should be not be used"); CDbEPBase.dGetEquation(value, out m_sContentName, out m_sContentText); } } public string ContentText { get { if (m_sContentText == "") { m_sContentText = null; } return m_sContentText; } set { m_sContentText = value; } } public SIndex NoodIndex { get { SIndex oIndex = iFind(P.PARENT); if (IsNotUsed(oIndex)) { if (bIsA(ExecutedEntity, P.AVATAR)) { oIndex = SenderIndex; oIndex.dSubIndex = CDbEPBase.PUBLIC_PROFILE_SUB_INDEX; if (oIndex.dSubIndex == CDbEPBase.PRIVATE_PROFILE_SUB_INDEX) { oIndex.dSubIndex = CDbEPBase.PUBLIC_PROFILE_SUB_INDEX; } } } return oIndex; } } public P AttributeClass { get { P dAttributeClass; if (IsUsed( OrganisationIndex)) { if (IsUsed( MemberIndex) && IsMemberEqualSender == false) { if ( OrganisationIndex.dSubIndex == ORGANISATION_ROOT_SUB_INDEX) { dAttributeClass = P.MEMBER_IN_ORGANISATION_ATTRIBUTE; } else { dAttributeClass = P.MEMBER_IN_COMMITTEE_ATTRIBUTE; } } else { if ( OrganisationIndex.dSubIndex == ORGANISATION_ROOT_SUB_INDEX) { dAttributeClass = P.ORGANISATION_ATTRIBUTE; } else { dAttributeClass = P.COMMITTEE_ATTRIBUTE; } } } else if ( ExecutedEntity == P.MEMBER_ATTRIBUTE) { dAttributeClass = P.MEMBER_ATTRIBUTE; } else if (bIsA(ExecutedEntity, P.ATTRIBUTE)) { dAttributeClass = P.PROFILE_ATTRIBUTE; } else { dAttributeClass = P.NOT_USED; } return dAttributeClass; } } public string Comment { get { return sFind(P.COMMENT); } set { // EPAssert(m_sContentName != null || idFind(P.IDENTIFIER_NEW_OBJECT) != null, "m_sContentName should be filled up"); vAdd(P.COMMENT, value); } } SortedList m_oOptionList; public SortedList GetSortedList() { return m_oOptionList; } public void vClear(P dOption) { m_oOptionList.Remove(dOption); } public void vAdd(P dOption, SIndex oIndex) { /* if (dOption == P.MEMBER) { Debug.Write(" P.MEMBER"); }*/ if (IsUsed(dOption) && IsUsed(oIndex)) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, oIndex); } } public void vAdd(P dOption, int dIndex) { if (IsUsed(dOption) && IsUsed(dIndex)) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, dIndex); } } public void vAdd(P dOption, string sText) { if (IsUsed(dOption) && sText != null && sText != "") { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, sText); } } public void vAdd(P dOption, P dEntity) { if (IsUsed(dOption) && IsUsed(dEntity)) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, dEntity); } } public void vAdd(P dOption, CEntityArray oEntityArray) { if (IsUsed(dOption) && oEntityArray != null) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, oEntityArray); } } public void vAdd(P dOption, CIdentifier oIdentifier) { if (IsUsed(dOption) && oIdentifier != null) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, oIdentifier); } } public void vAdd(P dOption, CCommandLine oCommandLine) { if (IsUsed(dOption) && oCommandLine != null) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, oCommandLine); } } public void vAppend(P dOption, CEntityArray oEntityArray) { CEntityArray oCurrentEntityArray = eaFind(dOption); if (IsUsed(dOption) && oCurrentEntityArray != null) { oCurrentEntityArray.vAppend(oEntityArray.EntityExtraArray); m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, oCurrentEntityArray); } else { m_oOptionList.Add(dOption, oEntityArray); } } public void vAppend(P dOption, SEntity oEntity) { CEntityArray oCurrentEntityArray = eaFind(dOption); if (IsUsed(dOption) && oCurrentEntityArray != null) { m_oOptionList.Remove(dOption); oCurrentEntityArray.vAppend(oEntity); } else { m_oOptionList.Add(dOption, new CEntityArray(oEntity)); } } public void vAdd(P dOption, bool bBoolean) { if (IsUsed(dOption)) { m_oOptionList.Remove(dOption); m_oOptionList.Add(dOption, bBoolean); } } public bool bIsA(P dEntity, P dEntityBase) { return CEntityManager.Instance(P.ENGLISH).bIsA(dEntity, dEntityBase); } public object oFind(P dOption, out P dType) { dType = P.NOT_USED; object oIndex = null; if (IsNotUsed(dOption)) { return null; } else if (m_oOptionList.ContainsKey(dOption)) { dType = CEntityManager.Instance(P.ENGLISH).dGetType(dOption); if (dType == P.EXECUTED_ENTITY_TYPE) { dType = CEntityManager.Instance(P.ENGLISH).dGetType(m_dExecutedEntity); } if (bIsA(dType, P.SINDEX_TYPE)) { oIndex = ((SIndex)m_oOptionList[dOption]); } else if (bIsA(dType, P.INTEGER_TYPE)) { oIndex = ((int)m_oOptionList[dOption]); } else if (bIsA(dType, P.ENTITY_ITEM_ARRAY_TYPE)) { oIndex = ((P[])m_oOptionList[dOption]); } else if (bIsA(dType, P.COMMAND_LINE_TYPE)) { oIndex = (CCommandLine)m_oOptionList[dOption]; } else if (bIsA(dType, P.P_TYPE)) { oIndex = ((P)m_oOptionList[dOption]); } else if (bIsA(dType, P.STRING_TYPE)) { oIndex = m_oOptionList[dOption].ToString(); } else if (bIsA(dType, P.IDENTIFIER_TYPE)) { oIndex = ((CIdentifier)m_oOptionList[dOption]); } else if ( bIsA(dType, P.ENTITY_ARRAY_TYPE)) { oIndex = ((CEntityArray)m_oOptionList[dOption]); } } else if (dOption == P.MEMBER_PROFILE) { oIndex = (int)MemberIndex.dIndex; dType = CEntityManager.Instance(P.ENGLISH).dGetType(dOption); } else if (dOption == P.PROFILE) { oIndex = (int)MemberIndex.dIndex; dType = CEntityManager.Instance(P.ENGLISH).dGetType(dOption); } /* else if (dOption == P.AUTHOR) { oIndex = AuthorIndex.dIndex; dType = P.PROFILE_INDEX_TYPE; }*/ else if (oIndex == null) { if (dOption == P.SENDER) { oIndex = m_oCommandContext.SenderIndex; } else if (dOption == P.ORGANISATION) { oIndex = m_oCommandContext.m_iOrganisation.dIndex; } else if (dOption == P.COMMITTEE) { oIndex = m_oCommandContext.m_iOrganisation; } else if (dOption == P.MEMBER) { oIndex = m_oCommandContext.MemberIndex; } else if (dOption == P.MEMBER_PROFILE) { oIndex = m_oCommandContext.MemberIndex.dIndex; } else if (dOption == P.PROFILE) { oIndex = m_oCommandContext.SenderIndex.dIndex; } else if (dOption == P.LANGUAGE ) { oIndex = m_oCommandContext.dLanguage; } if (oIndex != null) { dType = CEntityManager.Instance(P.ENGLISH).dGetType(dOption); CTrace.i().vWriteLn(ENMessage.CommandParsing, " oFind dType = " + dType); } } return oIndex; } public P[] peFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssert(oInstance == null || IsNotUsed(dType) || bIsA(dType, P.ENTITY_ITEM_ARRAY_TYPE), " xxFind The type is not a ENTITY_ITEM_ARRAY_TYPE dType= " + dType); if (bIsA(dType, P.ENTITY_ITEM_ARRAY_TYPE)) { return (P[])oInstance; } return null; } public CCommandLine clFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssert(oInstance == null || IsNotUsed(dType) || bIsA(dType, P.COMMAND_LINE_TYPE), " xxFind The type is not a CComandLineType dType= " + dType); if (bIsA(dType, P.COMMAND_LINE_TYPE)) { return (CCommandLine)oInstance; } return null; } public SIndex iFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssert(oInstance == null || IsNotUsed(dType) || bIsA(dType, P.SINDEX_TYPE) || bIsA(dType, P.ORGANISATION_INDEX_TYPE), " xxFind The type is not a ENTITY_ITEM_ARRAY_TYPE dType= " + dType); if (bIsA(dType, P.SINDEX_TYPE)) { return (SIndex)oInstance; } else if (bIsA(dType, P.ORGANISATION_INDEX_TYPE)) { return new SIndex((int)oInstance, ORGANISATION_ROOT_SUB_INDEX); } return NOT_USED_SINDEX; } public P pFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssertMessage(oInstance == null || bIsA(dType, P.P_TYPE), " xxFind The type is not a P_TYPE dType= " + dType); if (bIsA(dType, P.P_TYPE)) { return (P)oInstance; } return P.NOT_USED; } public string sFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssert(oInstance == null || bIsA(dType, P.STRING_TYPE), " xxFind The type is not a STRING_TYPE dType= " + dType); if (bIsA(dType, P.STRING_TYPE)) { return oInstance.ToString(); } return null; } public CIdentifier idFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); if (bIsA(dType, P.IDENTIFIER_TYPE)) { return (CIdentifier)oInstance; } return null; } public CEntityArray eaFind(P dOption) { P dType; object oInstance = oFind(dOption, out dType); EPAssert(IsNotUsed(dType) || bIsA(dType, P.ENTITY_ARRAY_TYPE), " xxFind The type is not a ENTITY_ARRAY_TYPE dType= " + dType); if (bIsA(dType, P.ENTITY_ARRAY_TYPE)) { return (CEntityArray)oInstance; } return null; } P m_dEntityParameterNotExisting; public ec dExtract(P[] oParameter, out CEntityArray ea) { ec dRet= ec.ST_SUCCEED; ea = new CEntityArray(); if (oParameter != null) { for (int i = 0; i < oParameter.Length; i++) { P dType; object oInstance; /* if (oParameter[i] == P.AUTHOR ) { oInstance = AuthorIndex.dIndex; dType = P.PROFILE_INDEX_TYPE; } else { */ oInstance = oFind(oParameter[i], out dType); //} if (oInstance != null) { ea.vAppend(new SEntity(oParameter[i], oInstance)); } else { m_dEntityParameterNotExisting = oParameter[i]; dRet = ec.ST_ATTRIBUTE_THE_PARAMETER_IS_MISSING_FROM_THE_COMMAND_LINE; CTrace.i().vWriteLn(ENMessage.Error, " Missing parameter from command line " + m_dEntityParameterNotExisting.ToString() + " in " + csDump()); } } } if (ea.Length == 0) { ea = null; } return dRet; } public bool bHasOption(P dOption) { if (m_oOptionList.ContainsKey(dOption)) { P dType = CEntityManager.Instance(P.ENGLISH).dGetType(dOption); if (dType == P.EXECUTED_ENTITY_TYPE) { dType = CEntityManager.Instance(P.ENGLISH).dGetType(m_dExecutedEntity); } if (dType == P.BOOLEAN_TYPE) { return (bool)m_oOptionList[dOption]; } else { return true; } } return false; } public SIndex SenderIndex { get { SIndex iIndex = iFind(P.SENDER); if (IsNotUsed(iIndex)) { iIndex = this.m_oCommandContext.SenderIndex; } CTrace.i().vWriteLn(ENMessage.CommandManagerDetail, "Get SenderIndex = " + iIndex); return iIndex; } set { if (IsNotUsed(value.dSubIndex)) { SenderProfileSubIndex = PUBLIC_PROFILE_SUB_INDEX; } else { vAdd(P.SENDER, value); } CTrace.i().vWriteLn(ENMessage.CommandManager, "Set SenderIndex = " + value); } } public SIndex AuthorIndex { get { SIndex iIndex = iFind(P.AUTHOR); if (IsNotUsed(iIndex)) { if (IsNotUsed(iIndex)) { CIdentifier oIdentifier = idFind(P.IDENTIFIER); if (oIdentifier != null) { iIndex.dIndex = oIdentifier.AuthorIndex; iIndex.dSubIndex = PUBLIC_PROFILE_SUB_INDEX; } } } /* if (IsNotUsed(iIndex)) { iIndex = SenderIndex; }*/ return iIndex; } set { vAdd(P.AUTHOR, value); } } public SIndex OrganisationIndex { get { SIndex oCommitteeIndex = iFind(P.COMMITTEE); if (IsNotUsed(oCommitteeIndex)) { P dType; object oIndex = oFind(P.ORGANISATION, out dType); if ( bIsA(dType, P.ORGANISATION_INDEX_TYPE)) { oCommitteeIndex.dIndex = (int)oIndex; oCommitteeIndex.dSubIndex = ORGANISATION_ROOT_SUB_INDEX; } } if (IsNotUsed(oCommitteeIndex)) { oCommitteeIndex=this.m_oCommandContext.m_iOrganisation; } return oCommitteeIndex; } set { if (value.dSubIndex == ORGANISATION_ROOT_SUB_INDEX) { vAdd(P.ORGANISATION, value.dIndex); } else { vAdd(P.COMMITTEE, value); } } } public bool IsMemberEqualSender { get { return MemberIndex.dIndex == SenderIndex.dIndex; } } public SIndex MemberIndex { get { SIndex iIndex = iFind(P.MEMBER); if (IsNotUsed(iIndex)) { iIndex=this.m_oCommandContext.MemberIndex; } return iIndex; } set { vAdd(P.MEMBER, value); } } /* public SIndex AvatarIndex { get { return iFind(P.AVATAR); } set { SIndex oAvatarIndex = value; if (oAvatarIndex.dIndex == SenderIndex.dIndex) { SenderIndex = value; vAdd(P.AVATAR, value); } else { vAdd(P.MEMBER, value); } } } * */ public int SenderProfileSubIndex { get { return iFind(P.SENDER).dSubIndex; } set { SIndex oSenderIndex = SenderIndex; if (IsUsed(value) && IsUsed(oSenderIndex)) { oSenderIndex.dSubIndex = value; vAdd(P.SENDER, oSenderIndex); } } } public P ExecutedEntity { get { if (IsUsed(m_dExecutedEntity)) { return m_dExecutedEntity; } return P.IDENTIFIER; } set { m_dExecutedEntity = value; } } public P Command { get { return m_dCommand; } set { m_dCommand = value; } } public P AttributeType { get { P dAttributeType = pFind(P.TYPE); if (IsNotUsed(dAttributeType)) { dAttributeType = CEntityManager.Instance(P.ENGLISH).dGetType(m_dExecutedEntity); if (dAttributeType == P.ATTRIBUTE_TYPE || bIsA(m_dExecutedEntity, P.ATTRIBUTE) ) { dAttributeType = P.STRING_TYPE; } } return dAttributeType; } set { vAdd(P.TYPE, (P)value); } } public P Language { get { return pFind(P.LANGUAGE); } set { vAdd(P.LANGUAGE, (P)value); } } public Type ContentType { get { if (ContentIdentifier != null && ContentIdentifier.bIsEmpty== false) { return typeof(CIdentifier); } else if (IsUsed(ContentIndex)) { return typeof(SIndex); } else if (ContentCommandLine != null) { return typeof(CCommandLine); } else { return typeof(string); } } } public void vAdd(object oEvent, ec ecErrorCode) { if (ecErrorCode != ec.ST_SUCCEED && ecErrorCode != ec.ST_NOT_USED) { m_oErrorCode.Add(new ENErrorEvent(oEvent, ecErrorCode)); } } public void vAdd(ENErrorEvent oErrorEvent) { if (oErrorEvent.bIsError) { m_oErrorCode.Add(oErrorEvent); } } public ENErrorEvent[] GetErrors { get { return (ENErrorEvent[])m_oErrorCode.ToArray(typeof(ENErrorEvent)); } } public string csDump() { string sOutput = Command.ToString().ToLower() + " " + ExecutedEntity.ToString().ToLower(); if (ContentType == typeof(string) && ContentName != null) { sOutput += " name_str:" + ContentName.ToLower(); } else if (ContentType == typeof(SIndex)) { sOutput += " name_si:" + ContentIndex.ToString().ToLower(); } else if (ContentType == typeof(CEntityArray) && ContentIdentifier != null) { sOutput += " name_ea:" + ContentIdentifier.ToString().ToLower(); } if (ContentText != null) { sOutput += " content_str:" + ContentText; } sOutput += " Sender:" + SenderIndex; if (IsUsed(MemberIndex)) { sOutput += " Member: " + MemberIndex; } if (IsUsed(OrganisationIndex)) { sOutput += " Organisation:" + OrganisationIndex; } sOutput += "\n"; foreach (DictionaryEntry oOption in m_oOptionList) { if (oOption.Value is CEntityArray ) { if (((CEntityArray)oOption.Value).bIsEmpty == false) { sOutput += " " + oOption.Key.ToString().ToLower() + "=" + oOption.Value.ToString().ToLower(); } } else if (oOption.Value is CIdentifier) { sOutput += " " + oOption.Key.ToString().ToLower() + "=" + ((CIdentifier)oOption.Value).csDump(); } else if (oOption.Value is CCommandLine) { sOutput += " " + oOption.Key.ToString().ToLower() + "=" + ((CCommandLine)oOption.Value).csDump(); } else { if (IsUsed(oOption.Value)) { sOutput += " " + oOption.Key.ToString().ToLower() + "=" + oOption.Value.ToString().ToLower(); } } } return sOutput + ToString(GetErrors); } } }

Enter supporting content here