Make your own free website on Tripod.com
EPolWS
DbRecordArray
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 EXCommon; using System.Data; using System.Data.SqlClient; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; //###5 namespace EXDb97 { ///

/// Description résumée de DbPersistenceTable. /// abstract public class CDbPersistenceTable : CDbTable { public CDbPersistenceTable() : base("FEATURE_DISTRIBUTION") { AddColumnKey(); vAddColumn(DATE_FIELD, "Date", false); vAddColumn("[Comment]", "String 255", false); vAddColumn(VALUE_FIELD, "Binary", false); } protected virtual void AddColumnKey() { vAddColumn(INDEX_FIELD, "Date", false); } // public const string VALUE_FIELD = "[Value]"; public override bool PrepareLine() { return dDeleteCurrent() == ST_SUCCEED; } public object Retrieve(string strKey) { string strSqlWhere = strKey; object binValue = GetValue(VALUE_FIELD, strSqlWhere); if (binValue == null) { return null; } else { return Deserialize(binValue); } } /* public byte[] GetSerializedValue(CSerializableBase oPersistentObject) { MemoryStream msStream = new MemoryStream(); IFormatter formatter = new BinaryFormatter(); // serialize shapes try { formatter.Serialize(msStream , oPersistentObject); Debug.WriteLine("\nmsStream Stream Length = " + msStream.Length); } catch (SerializationException e) { Console.WriteLine("Failed to serialize. Reason: " + e.Message); throw; } finally { msStream.Close(); } // msStream.Seek(0,0); return msStream.GetBuffer(); } public object Deserialize(object binValue) { MemoryStream msStream = new MemoryStream((byte [])binValue); Debug.WriteLine("\nmsStream Retrieved Length = " + msStream.Length); IFormatter formatter = new BinaryFormatter(); object oSerializedValue; try { oSerializedValue= formatter.Deserialize(msStream); } catch (SerializationException e) { Console.WriteLine("Failed to deserialize. Reason: " + e.Message); throw; } finally { msStream.Close(); } return oSerializedValue; }*/ } /// /// Description résumée de DbRecord. /// public class CDbRecordArray { public CDbRecordArray(int nRecordSize) { m_nRecordSize = nRecordSize; m_oRecordArray = new ArrayList(100); m_nReaderIndex = -1; m_oFieldArray = null; } int m_nRecordSize; int m_nReaderIndex; string[] m_oFieldArray; ArrayList m_oRecordArray; public void InitRead() { m_nReaderIndex = -1; } public bool Read() { m_nReaderIndex++; return m_nReaderIndex < Count; } public bool Contains(int nField, object oValue) { for(int i=0; i < m_oRecordArray.Count; i++) { object[] oRecordArray = (object[])m_oRecordArray[i]; // Debug.WriteLine("oRecordArray[nField] = " + oRecordArray[nField]); if ( oRecordArray[nField].Equals( oValue) ) { return true; } } return false; } public void Fill(CDbConnection oDbConnection) { //Retrieve column schema into a DataTable. DataTable schemaTable = oDbConnection.Reader.GetSchemaTable(); m_oFieldArray = new string[schemaTable.Columns.Count]; int i = 0; foreach (DataColumn myProperty in schemaTable.Columns) { m_oFieldArray[i] = myProperty.ColumnName; i++; } m_oRecordArray = new ArrayList(100); m_nReaderIndex = -1; while ( oDbConnection.Read() ) { object[] oRecordArray = new object[m_nRecordSize]; oDbConnection.Reader.GetValues(oRecordArray); m_oRecordArray.Add(oRecordArray); Debug.Write("\n" + oRecordArray[0].ToString() + " " + m_oRecordArray.Count + " "); } m_oRecordArray.TrimToSize(); } public int Count { get { return m_oRecordArray.Count; } } public int Length { get { return m_nRecordSize; } } public object this[int nIndex] { get { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; return oRecord[nIndex]; } } public string GetString(int nIndex) { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; return (oRecord[nIndex]).ToString(); } public int GetInt32(int nIndex) { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; return Convert.ToInt32(oRecord[nIndex]); } public bool GetBoolean(int nIndex) { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; return Convert.ToBoolean(oRecord[nIndex]); } public string sGetAllField() { return sConvert((object[])m_oRecordArray[m_nReaderIndex]); } int dIndexOf(string sFieldName) { if (m_oFieldArray != null) { for (int i = 0; i < m_oFieldArray.Length; i++) { if (m_oFieldArray[i] == sFieldName) { return i; } } } return CBase.NOT_USED; } public bool bIsEqual(string sFieldName, object oValue) { int dIdx = dIndexOf(sFieldName); if (CBase.IsUsed(dIdx)) { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; return oRecord[dIdx] == oValue; } return false; } public bool bUpdate(string sFieldName, object oValue) { int dIdx = dIndexOf(sFieldName); if ( CBase.IsUsed(dIdx)) { object[] oRecord = (object[])m_oRecordArray[m_nReaderIndex]; oRecord[dIdx] = oValue; m_oRecordArray[m_nReaderIndex] = oRecord; } return false; } static public string sConvert(object[] oArray) { if (oArray == null || oArray.Length == 0) return null; string sOutput = oArray[0].ToString(); for (int i = 1; i < oArray.Length; i++) { sOutput += ',' + oArray[i].ToString(); } return sOutput; } } }

Enter supporting content here