EPolWS
CommandFactoryBase
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.Data; using System.Configuration; using System.Web; using System.Diagnostics; using System.Collections; using EXDb97; using EXCommon; //###2 namespace EPol { /// /// Summary description for EPolCommandManagerBase /// public class CCommandFactoryBase : CDbEPBase { public const string NO_PARAMETER = "none"; static new public bool IsUsed(object oValue) { return CFeatureType.IsUsed(oValue); } public static string csGetParameter(string csRadical, string csText) { CTrace.i().vWriteLn(ENMessage.Parser," csGetParameter csRadical=" + csRadical + " csText=" + csText); if (csRadical== null || csText == null || csText == "") return null; string csParameterValue = null; //if (csRadical.Contains(":") == false) csRadical += ':'; int dCurrentOptionStartIndex = csText.IndexOf(csRadical); int dRadicalLength = csRadical.Length; if (dCurrentOptionStartIndex >= 0) { if (dRadicalLength + dCurrentOptionStartIndex == csText.Length) { csParameterValue = NO_PARAMETER; } else if (csText[dRadicalLength + dCurrentOptionStartIndex] == ':') { dRadicalLength++; if (csText[dCurrentOptionStartIndex + csRadical.Length] == '\'' || csText[dCurrentOptionStartIndex + csRadical.Length] == '"') { dRadicalLength++; for (int i = dCurrentOptionStartIndex + dRadicalLength; i < csText.Length; i++) { char cCurrentChar = csText[i]; if (cCurrentChar == '\'' || csText[dCurrentOptionStartIndex] == '"') break; csParameterValue += cCurrentChar; } } else { for (int i = dCurrentOptionStartIndex + dRadicalLength; i < csText.Length; i++) { char cCurrentChar = csText[i]; if (cCurrentChar == ' ' || cCurrentChar == '-') break; csParameterValue += cCurrentChar; } } if (csParameterValue == null || csParameterValue == "") { csParameterValue = NO_PARAMETER; } } else if (csText[dRadicalLength + dCurrentOptionStartIndex] == ' ' || csText[dRadicalLength + dCurrentOptionStartIndex] == '-') { csParameterValue = NO_PARAMETER; } } else { csParameterValue = null; } CTrace.i().vWriteLn(ENMessage.Parser," csParameterValue =" + csParameterValue); return csParameterValue; } public static string csUsedIDFromEmailAdress(string sEmailAdress) { int dStartIndex = sEmailAdress.IndexOf("@"); if (dStartIndex < sEmailAdress.Length) { return sEmailAdress.Substring(0, dStartIndex).ToLower(); } return null; } static public int dGetDefaultValueOfProperty( P dPropertyType) { switch (dPropertyType) { case P.ELECTION_SPAN_FEATURE: return CFeatureTypeFactory.Instance().oGet(dPropertyType).dFind("1M"); } return NOT_USED; } public class CFeatureTypeFactory : CDbEPBase { public CFeatureTypeFactory() { m_oValueList = new ArrayList(); m_oFeatureDictionary = new Hashtable(); } ArrayList m_oValueList; Hashtable m_oFeatureDictionary; static CFeatureTypeFactory m_oFeatureFactory = null; static public CFeatureTypeFactory Instance() { if (m_oFeatureFactory == null) { m_oFeatureFactory = new CFeatureTypeFactory(); } return m_oFeatureFactory; } public int Count { get { return m_oFeatureDictionary.Count; } } public CFeatureType oGet(P dEntityType) { dEntityType = CEntityManager.Instance(P.ENGLISH).dGetBaseFeatureType(dEntityType); CFeatureType oFeatureType = (CFeatureType)m_oFeatureDictionary[dEntityType]; if (oFeatureType == null) { oFeatureType = Create(dEntityType); } return oFeatureType; } public void vAdd(string sName, object oObj) { CFeatureType.SObject oObject; oObject.sName = sName; oObject.oObject = oObj; m_oValueList.Add(oObject); } public CFeatureType Create(P dEntityType) { // dEntityType = CEntityNamerrayFactory.Instance(P.ENGLISH).dGetBaseFeatureType(dEntityType); CFeatureType oFeature = new CFeatureType( dEntityType, m_oValueList); m_oValueList.Clear(); m_oFeatureDictionary.Add(dEntityType , oFeature); return oFeature; } } public class CFeatureType { public CFeatureType( P dEntityType, ArrayList oArray) { m_dEntityType = dEntityType; m_oValueArray = new SObject[oArray.Count]; for (int i = 0; i < oArray.Count; i++) { m_oValueArray[i] = (SObject)oArray[i]; } // m_dEntityBaseType = CEntityManager.Instance(P.ENGLISH).dGetBaseFeatureType(m_dEntityType); } protected SObject[] m_oValueArray; P m_dEntityType; public int Count { get { return m_oValueArray.Length; } } public struct SObject { public string sName; public object oObject; } public string ToString(int i) { return m_oValueArray[i].sName; } public object To(int i) { return m_oValueArray[i].oObject; } public int FromIndexToValueInteger(int i) { return ToValueInteger(m_oValueArray[i].oObject); } public int ToValueInteger(object oObj) { int dInteger = NOT_USED; try { if (CEntityManager.Instance(P.ENGLISH).dGetBaseFeatureType(m_dEntityType) == P.TIMESPAN_FEATURE) { dInteger = ((TimeSpan)oObj).Seconds; } } catch { dInteger = (int)P.CONVERTION_FAILED; } return dInteger; } public int dFind(string sValue) { for (int i = 0; i < m_oValueArray.Length; i++) { if (m_oValueArray[i].sName == sValue) { return i; } } return NOT_USED; } public int dGetRoundOnValue(object oValue) { int dInteger = NOT_USED; int dCompareValue = ToValueInteger(oValue); if (IsUsed(dCompareValue)) { for (int i = 0; i < m_oValueArray.Length; i++) { if (dCompareValue >= FromIndexToValueInteger(i)) { if (i >= 1) { if ((FromIndexToValueInteger(i) - dCompareValue) > (dCompareValue - FromIndexToValueInteger(i - 1))) { return i - 1; } } return i; } } } return dInteger; } public int dGetRoundOnIndex(double dbIndex) { CTrace.i().vWriteLn(ENMessage.Feature, "dGetRoundOnIndex dbIndex=" + dbIndex); int dIndexFloor = (int)dbIndex; int dIndexCeil = (int)dbIndex + 1; int dIndexRound = (dIndexCeil - dbIndex) > (dbIndex - dIndexFloor) ? dIndexFloor : dIndexCeil; if (dIndexRound >= Count) { dIndexRound = Count - 1; } if (dIndexRound < 0) { dIndexRound = 0; } CTrace.i().vWriteLn(ENMessage.Parser,"dIndexRound =" + dIndexRound); return dIndexRound; } static public bool IsUsed(object oValue) { if (oValue == null) { return false; } else if ( oValue is CEntityArray) { return ((CEntityArray)oValue).bIsEmpty == false; } else if (oValue is SEntity) { return ((SEntity)oValue).IsUsed; } else { return CDbEPBase.IsUsed(oValue); } } } } ///------------------------------------------------------------------------------------------------------------------------ }

Enter supporting content here