コード例 #1
0
        public static void ToLog(string message, SimpleLogEventType entryType)
        {
            if (!IsInitialized)
            {
                return;
            }

            if (entryType > _maxLoggingVerbosity)
            {
                return;
            }

            string fqPath = _fqLogFilePath + (_withThreading ? "." + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() : string.Empty);

            using (StreamWriter sw = File.AppendText(fqPath))
            {
                sw.WriteLine(
                    string.Format(LogFormat,
                                  DateTime.UtcNow.ToString("o"),
                                  entryType,
                                  message)
                    );

                sw.Flush();
            }
        }
コード例 #2
0
ファイル: SimpleLogTest.cs プロジェクト: sermel66/EzEtl
        public void ToLogTest()
        {
            string             message   = "Test message";
            SimpleLogEventType entryType = SimpleLogEventType.Error;

            SimpleLog.ToLog(message, entryType);
            Assert.Inconclusive("Verify the actual log file and .bak file");
        }
コード例 #3
0
ファイル: SimpleLogTest.cs プロジェクト: sermel66/EzEtl
        public void SetUpLogTest()
        {
            string             fqLogFilePath       = @"C:\Temp\SetUpLogTest.log";
            SimpleLogEventType maxLoggingVerbosity = SimpleLogEventType.Error;

            SimpleLog.SetUpLog(fqLogFilePath, maxLoggingVerbosity, true);
            Assert.IsTrue(SimpleLog.IsInitialized);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            string connectionString = @"Server=MELIKHOV-THINK\sqlexpress; Initial Catalog=TestAssignment; Integrated Security = True";
            string query            = @"

   SELECT TOP 10000
       [year]
      ,[StatePostalCode]
      ,[StateFipsCode]
      ,[CountyFipsCode]
      ,[Registry]
      ,[RaceId]
      ,[OriginId]
      ,[SexId]
      ,[AgeGroupId]
      ,[Population]
FROM [dbo].[Census]";


            try
            {
                string logFileTimeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd_HH_mm_ss");

                string             fqLogFilePath       = String.Format(@"C:\Temp\EzEtl\ExEtl_{0}.log", logFileTimeStamp);
                SimpleLogEventType maxLoggingVerbosity = SimpleLogEventType.Debug;
                SimpleLog.SetUpLog(fqLogFilePath, maxLoggingVerbosity, true);

                PipeIn.SqlClientInput rdr = new PipeIn.SqlClientInput(1024, connectionString, query, 500);

                PipeOut.FileCsvOutput wrt = new PipeOut.FileCsvOutput(rdr, @"C:\Temp\EzEtl\PipeOut.csv", @",", @"""");

                Task task = Task.Run(() => wrt.ExecuteAsync());
                Task.WaitAll(task);
                wrt.Close();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                SimpleLog.ToLog(ex.Message, SimpleLogEventType.Error);
                SimpleLog.ToLog(ex.StackTrace, SimpleLogEventType.Error);

                if (ex.InnerException != null && ex.InnerException != ex)
                {
                    System.Console.WriteLine(ex.InnerException.Message);
                    SimpleLog.ToLog(ex.InnerException.Message, SimpleLogEventType.Error);
                    SimpleLog.ToLog(ex.InnerException.StackTrace, SimpleLogEventType.Error);
                }
            }


            //DataTable bt = rdr.ReadBatch();
            //int gotCount = bt.Rows.Count;
            //bt = rdr.ReadBatch();
            //gotCount = bt.Rows.Count;
        }
コード例 #5
0
ファイル: SimpleLog.cs プロジェクト: sermel66/EzEtl
        public static void SetUpLog(string fqLogFilePath, SimpleLogEventType maxLoggingVerbosity, bool withThreading)
        {
            if (string.IsNullOrWhiteSpace(fqLogFilePath))
                throw new ArgumentNullException("fqLogFilePath");

            _fqLogFilePath = fqLogFilePath;
            _maxLoggingVerbosity = maxLoggingVerbosity;
            _withThreading = withThreading;

            if (File.Exists(_fqLogFilePath))
            {
                string backFilePath = _fqLogFilePath + BackupExtension;
                if (File.Exists(backFilePath))
                {
                    File.Delete(backFilePath);
                }
                File.Move(_fqLogFilePath, backFilePath);
            }
        }
コード例 #6
0
        static SimpleLogEventType _maxLoggingVerbosity = SimpleLogEventType.Information; // also the default verbosity if one is not provided

        public static void SetUpLog(string fqLogFilePath, SimpleLogEventType maxLoggingVerbosity, bool withThreading)
        {
            if (string.IsNullOrWhiteSpace(fqLogFilePath))
            {
                throw new ArgumentNullException("fqLogFilePath");
            }

            _fqLogFilePath       = fqLogFilePath;
            _maxLoggingVerbosity = maxLoggingVerbosity;
            _withThreading       = withThreading;

            if (File.Exists(_fqLogFilePath))
            {
                string backFilePath = _fqLogFilePath + BackupExtension;
                if (File.Exists(backFilePath))
                {
                    File.Delete(backFilePath);
                }
                File.Move(_fqLogFilePath, backFilePath);
            }
        }
コード例 #7
0
ファイル: SimpleLog.cs プロジェクト: sermel66/EzEtl
        public static void ToLog(string message, SimpleLogEventType entryType)
        {
            if (!IsInitialized)
                return;

            if (entryType > _maxLoggingVerbosity)
                return;

            string fqPath = _fqLogFilePath + (_withThreading ? "." + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() : string.Empty);

            using (StreamWriter sw = File.AppendText(fqPath))
            {
                sw.WriteLine(
                    string.Format(LogFormat,
                     DateTime.UtcNow.ToString("o"),
                     entryType,
                     message)
                );

                sw.Flush();

            }
        }