public static void TraceLog(string message, string logFileName) { string tmppath = AppDomain.CurrentDomain.BaseDirectory + "\Log\"; if (!Directory.Exists(tmppath)) { Directory.CreateDirectory(tmppath); } lock (s_lock) { StreamWriter myFile = null; try { myFile = new StreamWriter(tmppath + DateTime.Now.ToString("yyyyMMdd") + logFileName + ".log", true, Encoding.Default); var textL = new TextWriterTraceListener(myFile); var defL = new DefaultTraceListener(); if (Trace.Listeners.IndexOf(textL) == -1) { Trace.Listeners.Clear(); Trace.Listeners.Add(textL); Trace.Listeners.Add(defL); } Trace.AutoFlush = true; Trace.WriteLine(string.Empty); Trace.WriteLine(message); } catch (Exception ioe) { Console.WriteLine(ioe.Message); } finally { if (myFile != null) { myFile.Close(); myFile.Dispose(); } } } } public static List<T> BuildEntityList<T>(DataTable table) where T : class, new() { if (table == null) { return new List<T>(0); } var list = new List<T>(table.Rows.Count); foreach (DataRow row in table.Rows) { list.Add(EntityBuilder.BuildEntity<T>(row)); } return list; } public static string ConvertObject<T>(T o) { StringBuilder sb = new StringBuilder(); using (TextWriter reader = new StringWriter(sb)) { var serializer = new XmlSerializer(typeof(T)); serializer.Serialize(reader, o); reader.WriteLine(); return sb.ToString(); } }