Make your own free website on Tripod.com
EPolWS
SerializableBase
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.Diagnostics; using System.Text; using System.IO; using System.Collections; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Threading; //###2 namespace EXCommon { ///

/// Description résumée de BaseSerializable. /// /// [Serializable] abstract public class CSerializableBase { public CSerializableBase() { } public const int NOT_IN_STRING = -1; static public bool PORTFOLIO_PERSISTENCE = true; public static bool Contains( string strContenant, string strObject) { return strContenant.IndexOf( strObject ) != NOT_IN_STRING; } public static bool ContainsNoCase( string strContenant, string strObject) { return strContenant.ToUpper().IndexOf( strObject.ToUpper() ) != NOT_IN_STRING; } public bool IsSameDay(DateTime oLastDate, DateTime oTodayDate) { return oLastDate.Year == oTodayDate.Year && oLastDate.Month == oTodayDate.Month && oLastDate.Day == oTodayDate.Day; } public const bool MORE_THAN = true; public const bool LESS_THAN = false; static public bool IsUsed( int nValue) { return nValue != NOT_USED && nValue != END_OF_SERIAL && nValue != NO_INFORMATION ; } static public bool IsUsed( double dValue) { return dValue != NOT_USED && dValue != END_OF_SERIAL && dValue != NO_INFORMATION && Double.IsNaN(dValue) == false && Double.IsInfinity(dValue) == false; } static string GetDownloadedUrlPath(string strDirectoryPath, string strTicker) { string strFilePath = strDirectoryPath + "\\" + strTicker.ToUpper() + ".html"; if (!File.Exists(strFilePath)) { strFilePath = strDirectoryPath + "\\" + strTicker.ToUpper() + ".htm"; if (!File.Exists(strFilePath)) { return null; } } if (!IsFileFilledUp(strFilePath)) { return null; } return strFilePath; } static public bool IsFileFilledUp(string strPath) { Debug.WriteLine("IsFileFilledUp = " + strPath); if (File.Exists(strPath)) { FileInfo oFileInfo = new FileInfo(strPath); return oFileInfo.Exists && oFileInfo.Length > 0; } return false; } static public string ConvertToTableName(string strTicker) { string strTableName = strTicker; strTableName = strTableName.Replace('.', '_'); strTableName = strTableName.Replace('^', '_'); if (strTableName[0] != '[') strTableName = "[" + strTableName + "]"; return strTableName; } static public string RemoveBracket(string strName) { if (strName[0] == '[') strName = strName.Substring(1); if (strName[strName.Length - 1] == ']') strName = strName.Substring(0, strName.Length - 1); return strName; } public enum ENBoolean { True, False, Unknown } static public bool IsNotUsed( object oValue) { return ! IsUsed( oValue); } static public bool IsUsed( object oValue) { if ( oValue == null) { return false; } if ( oValue is int || oValue is double ) { int nValue; try { nValue = Convert.ToInt32(oValue); } catch (OverflowException e) { CTrace.i().vWriteLn(ENMessage.Trace, "oValue = " + oValue); CTrace.i().vWriteLn(ENMessage.Trace, e.ToString() + " Source = " + e.Source + " Msg = " + e.Message); nValue = NOT_USED; } return nValue != NOT_USED && nValue != END_OF_SERIAL && nValue != NO_INFORMATION; ; } else if ( oValue is string ) { string strValue = oValue.ToString(); return strValue != null && strValue.Length > 0 && strValue != NOT_USED_STR && strValue != NO_DATA && strValue != NO_INFORMATION_STR && strValue != "%" && strValue != "null"; } else if ( oValue is DateTime ) { DateTime oDate = Convert.ToDateTime(oValue); return oDate != NOT_USED_DATE;; } Debug.Assert( false, oValue.GetType() + " is not known "); return false; } public static DateTime YAHOO_DAILY_FIRST_DATE = new DateTime( 1950, 1,1); static public void EPAssert(bool bAssert, string sMessage) { CTrace.i().vAssert(bAssert, "Assert failed = " + sMessage); } static public void EPAssert(bool bAssert) { CTrace.i().vAssert(bAssert); } public const string CURRENCY_REFERENCE = "USD"; public enum ENCurrency { AUD, CAD, CHF, EUR, GBP, HKD, JPY, USD, NONE, Count } static public bool IsNotUsed( double dValue) { return dValue == -888 || dValue == NOT_USED || dValue == END_OF_SERIAL || Double.IsNaN(dValue) || Double.IsInfinity(dValue); } static public bool IsNotUsed( string strValue) { return strValue == null || strValue.Length == 0 || strValue == "-888" || strValue == NOT_USED_STR || strValue == NO_DATA || strValue == NO_INFORMATION_STR ||strValue == NON_APPLICABLE_STRING_ZACKS || strValue == "%" || strValue == "null" ; } static public bool IsNotUsed( DateTime oDate) { return oDate == NOT_USED_DATE; } public const string NO_DATA = "-666"; public const int NOT_USED = -999; public const string NOT_USED_STR = "-999"; public const int NO_INFORMATION = -888; public const string NO_INFORMATION_STR = "-888"; public const double END_OF_SERIAL = -666; public static DateTime NOT_USED_DATE = new DateTime( 1800,12,31); public const string NON_APPLICABLE_STRING_ZACKS = "n/a"; public static string ToString(int nPad, object obj) { string str; if ( obj == null) return str = "null"; else str = obj.ToString(); return str.Length < nPad ? string.Format("{0:-" + nPad.ToString() + "}",str) : str.Substring(0,nPad); } public const string FILE_PATH = "D:\\tmp"; } public enum ENMessage { sqlError, sqlWarning, sqlNotExistingTableWarning, sqlDuplicateIndexWarning, sqlTrace, Trace, assert, Report, Organisation, Feature, Parser, Lesson, ParseLesson, Thread, Access, Convert, Error, Warning, Avatar, TraceManager, CommandParsing, DbS, DbMultiJoin, DbView, CommandManager, CommandManagerDetail, EmailManager, Entity, DbTrace, EntityLoading, Attribute, Identifier, DbMultiSlaveView, Function } /// /// Description résumée de BaseSerializable. /// /// public class CTrace : CSerializableBase { protected CTrace() { m_oAllStream = File.CreateText(FILE_PATH + "\\trace\\" + "all.rtf"); m_oAllStream.AutoFlush = true; m_oTraceStream = File.CreateText(FILE_PATH + "\\trace\\" + "traces.rtf"); m_oTraceStream.AutoFlush = true; m_oPriorityStream = File.CreateText(FILE_PATH + "\\trace\\" + "reduce.rtf"); m_oPriorityStream.AutoFlush = true; } ENMessage[] enPriorityMessageList = { ENMessage.DbMultiSlaveView, ENMessage.Access, ENMessage.Convert, ENMessage.sqlTrace, ENMessage.sqlError, ENMessage.DbView, ENMessage.Organisation, ENMessage.Avatar, ENMessage.CommandManager, ENMessage.Function, ENMessage.Identifier, ENMessage.Parser}; public bool bIsPriority(ENMessage enMessage) { foreach (ENMessage enIdxMessage in enPriorityMessageList) { if (enMessage == enIdxMessage) { return true; } } return false; } public void vWriteLn(ENMessage enMessage, string sMessage) { vWrite(enMessage, sMessage + "\n"); } public void vWrite(ENMessage enMessage, string sMessage) { m_oAllStream.Write(sMessage + " "); if (enMessage == ENMessage.sqlTrace || enMessage == ENMessage.Trace || bIsPriority(enMessage)) { m_oTraceStream.Write(enMessage + ": " + sMessage + " " ); } if (bIsPriority(enMessage)) { m_oPriorityStream.Write(enMessage + ": " + sMessage + " "); Debug.Write(enMessage + ": " + sMessage + " "); } } StreamWriter m_oAllStream, m_oTraceStream, m_oPriorityStream; static CTrace m_oTrace = null; public static CTrace i() { if (m_oTrace == null) { m_oTrace = new CTrace(); } return m_oTrace; } public void vWriteSqlLn( string sMessage) { vWriteSql(sMessage + "\n"); } public void vWriteSql(string sMessage) { vWrite(ENMessage.DbTrace, sMessage); } public void vWriteSqlLn( int dError, string sMessage) { vWriteSql(dError, sMessage + "\n"); } public void vWriteSql(int dError, string sMessage) { if (dError != 208 && dError != 2067 && dError != 3022 && dError != 911 && dError != 1913) { vWrite(ENMessage.sqlError, "|error:" + dError + "|" + sMessage); } else { vWrite(ENMessage.sqlWarning, "|error:" + dError + "|" + sMessage); } } public void vAssert(bool bExecuted) { vAssert(bExecuted, null); } public void vAssertMessage(bool bExecuted, string sMessage) { if (bExecuted == false) { vWrite(ENMessage.assert, "Assert Failed:" + sMessage); } } public void vAssert(bool bExecuted, string sMessage) { if (bExecuted == false) { vWrite(ENMessage.assert, "Assert Failed:" + sMessage); Debug.Assert(bExecuted, sMessage); return; } } } }

Enter supporting content here