예제 #1
0
        public override void AddLog(LogInfo logInfo)
        {
            string configPortalID = logInfo.LogPortalID != Null.NullInteger
                                        ? logInfo.LogPortalID.ToString()
                                        : "*";
            var logTypeConfigInfo = GetLogTypeConfigInfoByKey(logInfo.LogTypeKey, configPortalID);

            if (logTypeConfigInfo == null || logTypeConfigInfo.LoggingIsActive == false)
            {
                return;
            }
            logInfo.LogConfigID = logTypeConfigInfo.ID;
            var logQueueItem = new LogQueueItem {
                LogInfo = logInfo, LogTypeConfigInfo = logTypeConfigInfo
            };
            SchedulingProvider scheduler = SchedulingProvider.Instance();

            if (scheduler == null || logInfo.BypassBuffering || SchedulingProvider.Enabled == false ||
                scheduler.GetScheduleStatus() == ScheduleStatus.STOPPED || !Host.EventLogBuffer)
            {
                WriteLog(logQueueItem);
            }
            else
            {
                LogQueue.Add(logQueueItem);
            }
        }
예제 #2
0
        public override void AddLog(LogInfo objLogInfo)
        {
            string ConfigPortalID;

            if (objLogInfo.LogPortalID != Null.NullInteger)
            {
                ConfigPortalID = objLogInfo.LogPortalID.ToString();
            }
            else
            {
                ConfigPortalID = "*";
            }

            LogTypeConfigInfo objLogTypeConfigInfo;

            objLogTypeConfigInfo = GetLogTypeConfigInfoByKey(objLogInfo.LogTypeKey, ConfigPortalID);

            if (objLogTypeConfigInfo.LoggingIsActive == false)
            {
                return;
            }

            bool UseEventLogBuffer = true;

            if (Globals.HostSettings.ContainsKey("EventLogBuffer"))
            {
                if (Convert.ToString(Globals.HostSettings["EventLogBuffer"]) != "Y")
                {
                    UseEventLogBuffer = false;
                }
            }
            else
            {
                UseEventLogBuffer = false;
            }

            objLogInfo.LogConfigID = objLogTypeConfigInfo.ID;

            LogQueueItem objLogQueueItem = new LogQueueItem();

            objLogQueueItem.LogInfo           = objLogInfo;
            objLogQueueItem.LogTypeConfigInfo = objLogTypeConfigInfo;

            SchedulingProvider scheduler = SchedulingProvider.Instance();

            if (objLogInfo.BypassBuffering || SchedulingProvider.Enabled == false || scheduler.GetScheduleStatus() == ScheduleStatus.STOPPED || UseEventLogBuffer == false)
            {
                WriteLog(objLogQueueItem);
            }
            else
            {
                LogQueue.Add(objLogQueueItem);
            }
        }
예제 #3
0
 public override void PurgeLogBuffer()
 {
     LockQueueLog.AcquireWriterLock(WriterLockTimeout);
     try
     {
         for (int i = LogQueue.Count - 1; i >= 0; i += -1)
         {
             LogQueueItem logQueueItem = LogQueue[i];
             //in case the log was removed
             //by another thread simultaneously
             if (logQueueItem != null)
             {
                 WriteLog(logQueueItem);
                 LogQueue.Remove(logQueueItem);
             }
         }
     }
     finally
     {
         LockQueueLog.ReleaseWriterLock();
     }
     DataProvider.Instance().PurgeLog();
 }
예제 #4
0
 public override void AddLog(LogInfo logInfo)
 {
     string configPortalID = logInfo.LogPortalID != Null.NullInteger 
                                 ? logInfo.LogPortalID.ToString() 
                                 : "*";
     var logTypeConfigInfo = GetLogTypeConfigInfoByKey(logInfo.LogTypeKey, configPortalID);
     if (logTypeConfigInfo == null || logTypeConfigInfo.LoggingIsActive == false)
     {
         return;
     }
     logInfo.LogConfigID = logTypeConfigInfo.ID;
     var logQueueItem = new LogQueueItem {LogInfo = logInfo, LogTypeConfigInfo = logTypeConfigInfo};
     SchedulingProvider scheduler = SchedulingProvider.Instance();
     if (scheduler == null || logInfo.BypassBuffering || SchedulingProvider.Enabled == false 
         || scheduler.GetScheduleStatus() == ScheduleStatus.STOPPED || !Host.EventLogBuffer)
     {
         WriteLog(logQueueItem);
     }
     else
     {
         LogQueue.Add(logQueueItem);
     }
 }
예제 #5
0
        private static void WriteLog(LogQueueItem logQueueItem)
        {
            LogTypeConfigInfo logTypeConfigInfo = null;
            try
            {
                logTypeConfigInfo = logQueueItem.LogTypeConfigInfo;
                if (logTypeConfigInfo != null)
                {
                    LogInfo objLogInfo = logQueueItem.LogInfo;
                    string logProperties = objLogInfo.LogProperties.Serialize();
                    DataProvider.Instance().AddLog(objLogInfo.LogGUID,
                                                   objLogInfo.LogTypeKey,
                                                   objLogInfo.LogUserID,
                                                   objLogInfo.LogUserName,
                                                   objLogInfo.LogPortalID,
                                                   objLogInfo.LogPortalName,
                                                   objLogInfo.LogCreateDate,
                                                   objLogInfo.LogServerName,
                                                   logProperties,
                                                   Convert.ToInt32(objLogInfo.LogConfigID));
                    if (logTypeConfigInfo.EmailNotificationIsActive)
                    {
                        LockNotif.AcquireWriterLock(ReaderLockTimeout);
                        try
                        {
                            if (logTypeConfigInfo.NotificationThreshold == 0)
                            {
                                string str = logQueueItem.LogInfo.Serialize();
    
                                Mail.Mail.SendEmail(logTypeConfigInfo.MailFromAddress, logTypeConfigInfo.MailToAddress, "Event Notification", str);
                            }
                        }
                        finally
                        {
                            LockNotif.ReleaseWriterLock();
                        }
                    }
                }
            }
            catch (SqlException exc)
            {
                DnnLog.Error(exc);
                if ((HttpContext.Current != null))
                {
                    if (HttpContext.Current.IsCustomErrorEnabled)
                    {
                        HttpContext.Current.AddError(exc);
                    }
                    else
                    {
                        HttpResponse response = HttpContext.Current.Response;
                        response.StatusCode = 500;
                        HtmlUtils.WriteHeader(response, "SQL Exception");

                        string strMessage = SqlUtils.TranslateSQLException(exc);
                        if (logTypeConfigInfo != null)
                        {
                            HtmlUtils.WriteError(response, logTypeConfigInfo.LogFileNameWithPath, strMessage);
                        }

                        HtmlUtils.WriteFooter(response);
                        response.End();
                    }
                }
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);

                if (HttpContext.Current != null)
                {
                    HttpResponse response = HttpContext.Current.Response;
                    HtmlUtils.WriteHeader(response, "Unhandled Error");
                    string strMessage = exc.Message;
                    if (logTypeConfigInfo != null)
                    {
                        HtmlUtils.WriteError(response, logTypeConfigInfo.LogFileNameWithPath, strMessage);
                    }
                    HtmlUtils.WriteFooter(response);
                    response.End();
                }
            }
        }
예제 #6
0
        private static void WriteLog(LogQueueItem logQueueItem)
        {
            LogTypeConfigInfo logTypeConfigInfo = null;

            try
            {
                logTypeConfigInfo = logQueueItem.LogTypeConfigInfo;
                if (logTypeConfigInfo != null)
                {
                    LogInfo objLogInfo    = logQueueItem.LogInfo;
                    string  logProperties = objLogInfo.LogProperties.Serialize();
                    DataProvider.Instance().AddLog(objLogInfo.LogGUID,
                                                   objLogInfo.LogTypeKey,
                                                   objLogInfo.LogUserID,
                                                   objLogInfo.LogUserName,
                                                   objLogInfo.LogPortalID,
                                                   objLogInfo.LogPortalName,
                                                   objLogInfo.LogCreateDate,
                                                   objLogInfo.LogServerName,
                                                   logProperties,
                                                   Convert.ToInt32(objLogInfo.LogConfigID));
                    if (logTypeConfigInfo.EmailNotificationIsActive)
                    {
                        LockNotif.AcquireWriterLock(ReaderLockTimeout);
                        try
                        {
                            if (logTypeConfigInfo.NotificationThreshold == 0)
                            {
                                string str = logQueueItem.LogInfo.Serialize();

                                Mail.Mail.SendEmail(logTypeConfigInfo.MailFromAddress, logTypeConfigInfo.MailToAddress, "Event Notification", str);
                            }
                        }
                        finally
                        {
                            LockNotif.ReleaseWriterLock();
                        }
                    }
                }
            }
            catch (SqlException exc)
            {
                DnnLog.Error(exc);
                if ((HttpContext.Current != null))
                {
                    if (HttpContext.Current.IsCustomErrorEnabled)
                    {
                        HttpContext.Current.AddError(exc);
                    }
                    else
                    {
                        HttpResponse response = HttpContext.Current.Response;
                        response.StatusCode = 500;
                        HtmlUtils.WriteHeader(response, "SQL Exception");

                        string strMessage = SqlUtils.TranslateSQLException(exc);
                        if (logTypeConfigInfo != null)
                        {
                            HtmlUtils.WriteError(response, logTypeConfigInfo.LogFileNameWithPath, strMessage);
                        }

                        HtmlUtils.WriteFooter(response);
                        response.End();
                    }
                }
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);

                if (HttpContext.Current != null)
                {
                    HttpResponse response = HttpContext.Current.Response;
                    HtmlUtils.WriteHeader(response, "Unhandled Error");
                    string strMessage = exc.Message;
                    if (logTypeConfigInfo != null)
                    {
                        HtmlUtils.WriteError(response, logTypeConfigInfo.LogFileNameWithPath, strMessage);
                    }
                    HtmlUtils.WriteFooter(response);
                    response.End();
                }
            }
        }
예제 #7
0
        private static void WriteLog(LogQueueItem objLogQueueItem)
        {
            LogTypeConfigInfo objLogTypeConfigInfo = null;

            try
            {
                objLogTypeConfigInfo = objLogQueueItem.LogTypeConfigInfo;
                if (objLogTypeConfigInfo != null)
                {
                    LogInfo objLogInfo    = objLogQueueItem.LogInfo;
                    string  LogProperties = objLogInfo.LogProperties.Serialize();

                    DataProvider.Instance().AddLog(objLogInfo.LogGUID, objLogInfo.LogTypeKey, objLogInfo.LogUserID, objLogInfo.LogUserName, objLogInfo.LogPortalID, objLogInfo.LogPortalName, objLogInfo.LogCreateDate, objLogInfo.LogServerName, LogProperties, Convert.ToInt32(objLogInfo.LogConfigID));

                    if (objLogTypeConfigInfo.EmailNotificationIsActive)
                    {
                        try
                        {
                            lockNotif.AcquireWriterLock(ReaderLockTimeout);
                            if (objLogTypeConfigInfo.NotificationThreshold == 0)
                            {
                                string str = objLogQueueItem.LogInfo.Serialize();
                                Mail.Mail.SendMail(objLogTypeConfigInfo.MailFromAddress, objLogTypeConfigInfo.MailToAddress, "", "Event Notification", str, "", "", "", "", "", "");
                            }
                            else if (objLogTypeConfigInfo.LogTypeKey != "LOG_NOTIFICATION_FAILURE")
                            {
                                //pending log notifications go here
                            }
                        }
                        finally
                        {
                            lockNotif.ReleaseWriterLock();
                        }
                    }
                }

                if (objLogTypeConfigInfo.EmailNotificationIsActive)
                {
                    if (objLogTypeConfigInfo.NotificationThreshold == 0)
                    {
                        //SendNotification(objLogTypeConfigInfo.MailFromAddress, objLogTypeConfigInfo.MailToAddress, "", "Event Notification", xmlDoc.InnerXml)
                    }
                    else if (objLogTypeConfigInfo.LogTypeKey != "LOG_NOTIFICATION_FAILURE")
                    {
                    }
                }
            }
            catch (Exception exc)
            {
                if (HttpContext.Current != null)
                {
                    HttpResponse response = HttpContext.Current.Response;
                    HtmlUtils.WriteHeader(response, "Unhandled Error");

                    string strMessage = exc.Message;
                    HtmlUtils.WriteError(response, objLogTypeConfigInfo.LogFileNameWithPath, strMessage);

                    HtmlUtils.WriteFooter(response);
                    response.End();
                }
            }
        }
예제 #8
0
        private static void WriteLog(LogQueueItem objLogQueueItem)
        {

            LogTypeConfigInfo objLogTypeConfigInfo = null;
            try
            {
                objLogTypeConfigInfo = objLogQueueItem.LogTypeConfigInfo;
                if (objLogTypeConfigInfo != null)
                {
                    LogInfo objLogInfo = objLogQueueItem.LogInfo;
                    string LogProperties = objLogInfo.LogProperties.Serialize();

                    DataProvider.Instance().AddLog(objLogInfo.LogGUID, objLogInfo.LogTypeKey, objLogInfo.LogUserID, objLogInfo.LogUserName, objLogInfo.LogPortalID, objLogInfo.LogPortalName, objLogInfo.LogCreateDate, objLogInfo.LogServerName, LogProperties, Convert.ToInt32(objLogInfo.LogConfigID));

                    if (objLogTypeConfigInfo.EmailNotificationIsActive)
                    {
                        try
                        {
                            lockNotif.AcquireWriterLock(ReaderLockTimeout);
                            if (objLogTypeConfigInfo.NotificationThreshold == 0)
                            {
                                string str = objLogQueueItem.LogInfo.Serialize();
                                Mail.Mail.SendMail(objLogTypeConfigInfo.MailFromAddress, objLogTypeConfigInfo.MailToAddress, "", "Event Notification", str, "", "", "", "", "", "");
                            }
                            else if (objLogTypeConfigInfo.LogTypeKey != "LOG_NOTIFICATION_FAILURE")
                            {
                                //pending log notifications go here
                            }
                        }
                        finally
                        {
                            lockNotif.ReleaseWriterLock();
                        }
                    }
                }

                if (objLogTypeConfigInfo.EmailNotificationIsActive)
                {
                    if (objLogTypeConfigInfo.NotificationThreshold == 0)
                    {
                        //SendNotification(objLogTypeConfigInfo.MailFromAddress, objLogTypeConfigInfo.MailToAddress, "", "Event Notification", xmlDoc.InnerXml)
                    }
                    else if (objLogTypeConfigInfo.LogTypeKey != "LOG_NOTIFICATION_FAILURE")
                    {

                    }
                }

            }
            catch (Exception exc)
            {
                if (HttpContext.Current != null)
                {
                    HttpResponse response = HttpContext.Current.Response;
                    HtmlUtils.WriteHeader(response, "Unhandled Error");

                    string strMessage = exc.Message;
                    HtmlUtils.WriteError(response, objLogTypeConfigInfo.LogFileNameWithPath, strMessage);

                    HtmlUtils.WriteFooter(response);
                    response.End();
                }
            }

        }
예제 #9
0
        public override void AddLog( LogInfo objLogInfo )
        {
            string ConfigPortalID;
            if( objLogInfo.LogPortalID != Null.NullInteger )
            {
                ConfigPortalID = objLogInfo.LogPortalID.ToString();
            }
            else
            {
                ConfigPortalID = "*";
            }

            LogTypeConfigInfo objLogTypeConfigInfo;
            objLogTypeConfigInfo = GetLogTypeConfigInfoByKey( objLogInfo.LogTypeKey, ConfigPortalID );

            if( objLogTypeConfigInfo.LoggingIsActive == false )
            {
                return;
            }

            bool UseEventLogBuffer = true;
            if( Globals.HostSettings.ContainsKey( "EventLogBuffer" ) )
            {
                if( Convert.ToString( Globals.HostSettings["EventLogBuffer"] ) != "Y" )
                {
                    UseEventLogBuffer = false;
                }
            }
            else
            {
                UseEventLogBuffer = false;
            }

            objLogInfo.LogConfigID = objLogTypeConfigInfo.ID;

            LogQueueItem objLogQueueItem = new LogQueueItem();
            objLogQueueItem.LogInfo = objLogInfo;
            objLogQueueItem.LogTypeConfigInfo = objLogTypeConfigInfo;

            SchedulingProvider scheduler = SchedulingProvider.Instance();
            if( objLogInfo.BypassBuffering || SchedulingProvider.Enabled == false || scheduler.GetScheduleStatus() == ScheduleStatus.STOPPED || UseEventLogBuffer == false )
            {
                WriteLog( objLogQueueItem );
            }
            else
            {
                LogQueue.Add( objLogQueueItem );
            }
        }