protected void SetError(string sErr) { _errMsg = sErr; if (!string.IsNullOrEmpty(_errMsg)) { if (ShowErrorMessage) { FormLog.ShowMessage(_errMsg); } if (ExecuteError != null) { ExecuteError(this, EventArgs.Empty); } } }
public void Log(string message, params object[] values) { if (LoggingEnabled) { if (!string.IsNullOrEmpty(this.LogFilePath)) { string msg; try { if (values != null && values.Length > 0) { msg = string.Format(message, values); } else { msg = message; } } catch (Exception e) { msg = ExceptionLimnorDatabase.FormExceptionText(e) + " " + message; } if (!string.IsNullOrEmpty(msg)) { StreamWriter sw = null; try { sw = new StreamWriter(LogFilePath, true, Encoding.ASCII); sw.Write(DateTime.Now.ToString("u")); sw.Write(" - "); sw.WriteLine(msg); } catch (Exception er) { FormLog.ShowMessage(ExceptionLimnorDatabase.FormExceptionText(er)); } finally { if (sw != null) { sw.Close(); } } } } } }