Example #1
0
        // ============================================================================================================================
        // EVENT HANDLERS
        //

        // ----------------------------------------------------------------------------------------------------------------------------
        // EVENTCLASS EVENT
        //
        void EventLog(DateTime dateTime, EventLogArgs eventLogArgs, string fileName = null)
        {
            try
            {
                string dateTimeString = string.Format("{0:MM/dd/yy hh:mm:ss.fff tt}", dateTime);
                //format:  Date, Job, Message
                string jobName = "                ";

                string messageString;
                if (eventLogArgs.isException)
                {
                    messageString = String.Format("{0}\t\t{1}\t{2}\t\tEXCEPTION: {3}:{4} - [{5}] {6}", dateTimeString, eventLogArgs.propertyLogEntryType.ToString(), jobName, eventLogArgs.propertyClassName, eventLogArgs.propertyMethodName, eventLogArgs.propertyExceptionKey, eventLogArgs.propertyException.Message);
                    string errorMessageString = String.Format("{0}\t\t{1}\t\t{2} --> {3}", dateTimeString, eventLogArgs.propertyExceptionKey, eventLogArgs.propertyException.Message, eventLogArgs.propertyException.StackTrace);
                    LogWriteStack(dateTime, errorMessageString);
                }
                else
                {
                    messageString = String.Format("{0}\t\t{1}\t{2}\t\t{3}", dateTimeString, eventLogArgs.propertyLogEntryType.ToString(), jobName, eventLogArgs.propertyMessage);
                }


                LogWriteTextBox(dateTime, messageString);
                LogWriteFile(dateTime, messageString, fileName);
            }

            catch (Exception ex)
            {
                LogWriteTextBox(DateTime.Now, DateTime.Now.ToString("0:MM/dd/yy hh:mm:ss.fff tt") + "     EXCEPTION: " + ex.Message);
                LogWriteFile(DateTime.Now, DateTime.Now.ToString("0:MM/dd/yy hh:mm:ss.fff tt") + "     EXCEPTION: " + ex.Message);
            }
        }
Example #2
0
        public static void LogEvent(EventLogArgs eventLogArgs)
        {
            DateTime currentTime = DateTime.Now;

            // RAISE EVENT
            if (eventLog2 != null)
            {
                eventLog2(currentTime, eventLogArgs);
            }
        }