Beispiel #1
0
        //===============================================================
        // Function: ErrorLog()
        //===============================================================
        public void WriteLog(string moduleName, string functionName, string logText,
            logMessageLevel logLevel)
        {
            DateTime now = DateTime.Now;
            string strDate = now.Year + "/" + now.Month + "/" + now.Day + " ";
            if (now.Minute > 9)
            {
                strDate += now.Hour + ":" + now.Minute;
            }
            else
            {
                strDate += now.Hour + ":0" + now.Minute;
            }

            string logContents = strDate + " - " + moduleName + ":" + functionName + " - " + logText;
            // All error messages are written to the event log
            if (logLevel == logMessageLevel.errorMessage)
            {
                System.Diagnostics.EventLog appLog = new System.Diagnostics.EventLog();
                appLog.Source = "Sedogo";
                appLog.WriteEntry(logContents);
            }
            StreamWriter sw;
            if (logLevel <= GlobalSettings.errorLogLevel)
            {
                sw = new StreamWriter(GlobalSettings.errorLogFile, true);
                sw.WriteLine(logContents);
                sw.Flush();
                sw.Close();
            }
        }
Beispiel #2
0
        //===============================================================
        // Function: mainForm (Constructor)
        //===============================================================
        public mainForm()
        {
            InitializeComponent();

            // Load configuration info
            connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionInfo"].ToString();
            errorLogFile = System.Configuration.ConfigurationManager.AppSettings["ErrorLogFile"].ToString();
            errorLogLevel = (logMessageLevel)int.Parse(System.Configuration.ConfigurationManager.AppSettings["ErrorLogLevel"].ToString());

            GlobalSettings.connectionString = connectionString;
            GlobalSettings.errorLogFile = errorLogFile;
            GlobalSettings.errorLogLevel = errorLogLevel;

            string[] args = Environment.GetCommandLineArgs();
            foreach (string arg in args)
            {
                if (arg == "-sendAlerts")
                {
                    EventAlert.SendAlertEmails();
                    Environment.Exit(0);
                }
                if (arg == "-sendBroadcast")
                {
                    MiscUtils.SendBroadcastEmail();
                    Environment.Exit(0);
                }
            }
        }