예제 #1
0
 public void DeleteLogType(LogTypeInfo logType)
 {
     LogController.Instance.DeleteLogType(logType);
 }
예제 #2
0
 public void UpdateLogType(LogTypeInfo logType)
 {
     LogController.Instance.UpdateLogType(logType);
 }
예제 #3
0
 public void AddLogType(LogTypeInfo logType)
 {
     LogController.Instance.AddLogType(logType);
 }
예제 #4
0
 public virtual void UpdateLogType(LogTypeInfo logType)
 {
     LoggingProvider.Instance().UpdateLogType(logType.LogTypeKey, logType.LogTypeFriendlyName, logType.LogTypeDescription, logType.LogTypeCSSClass, logType.LogTypeOwner);
 }
예제 #5
0
 public virtual void DeleteLogType(LogTypeInfo logType)
 {
     LoggingProvider.Instance().DeleteLogType(logType.LogTypeKey);
 }
예제 #6
0
        public void AddLogType(string configFile, string fallbackConfigFile)
        {
            var xmlDoc = new XmlDocument {
                XmlResolver = null
            };

            try
            {
                xmlDoc.Load(configFile);
            }
            catch (FileNotFoundException exc)
            {
                Logger.Debug(exc);
                xmlDoc.Load(fallbackConfigFile);
            }

            var logType = xmlDoc.SelectNodes("/LogConfig/LogTypes/LogType");

            if (logType != null)
            {
                foreach (XmlNode typeInfo in logType)
                {
                    if (typeInfo.Attributes != null)
                    {
                        var objLogTypeInfo = new LogTypeInfo
                        {
                            LogTypeKey          = typeInfo.Attributes["LogTypeKey"].Value,
                            LogTypeFriendlyName = typeInfo.Attributes["LogTypeFriendlyName"].Value,
                            LogTypeDescription  = typeInfo.Attributes["LogTypeDescription"].Value,
                            LogTypeCSSClass     = typeInfo.Attributes["LogTypeCSSClass"].Value,
                            LogTypeOwner        = typeInfo.Attributes["LogTypeOwner"].Value
                        };
                        AddLogType(objLogTypeInfo);
                    }
                }
            }

            var logTypeConfig = xmlDoc.SelectNodes("/LogConfig/LogTypeConfig");

            if (logTypeConfig != null)
            {
                foreach (XmlNode typeConfigInfo in logTypeConfig)
                {
                    if (typeConfigInfo.Attributes != null)
                    {
                        var logTypeConfigInfo = new LogTypeConfigInfo
                        {
                            EmailNotificationIsActive = typeConfigInfo.Attributes["EmailNotificationStatus"].Value == "On",
                            KeepMostRecent            = typeConfigInfo.Attributes["KeepMostRecent"].Value,
                            LoggingIsActive           = typeConfigInfo.Attributes["LoggingStatus"].Value == "On",
                            LogTypeKey                    = typeConfigInfo.Attributes["LogTypeKey"].Value,
                            LogTypePortalID               = typeConfigInfo.Attributes["LogTypePortalID"].Value,
                            MailFromAddress               = typeConfigInfo.Attributes["MailFromAddress"].Value,
                            MailToAddress                 = typeConfigInfo.Attributes["MailToAddress"].Value,
                            NotificationThreshold         = Convert.ToInt32(typeConfigInfo.Attributes["NotificationThreshold"].Value),
                            NotificationThresholdTime     = Convert.ToInt32(typeConfigInfo.Attributes["NotificationThresholdTime"].Value),
                            NotificationThresholdTimeType =
                                (LogTypeConfigInfo.NotificationThresholdTimeTypes)
                                Enum.Parse(typeof(LogTypeConfigInfo.NotificationThresholdTimeTypes), typeConfigInfo.Attributes["NotificationThresholdTimeType"].Value)
                        };
                        AddLogTypeConfigInfo(logTypeConfigInfo);
                    }
                }
            }
        }
예제 #7
0
        public void AddLog(LogInfo logInfo)
        {
            //if (Globals.Status == Globals.UpgradeStatus.Install)
            //{
            //    Logger.Info(logInfo);
            //}
            //else
            //{
            try
            {
                logInfo.LogCreateDate = DateTime.Now;
                logInfo.LogServerName = Globals.ServerName;
                if (string.IsNullOrEmpty(logInfo.LogServerName))
                {
                    logInfo.LogServerName = "NA";
                }
                if (String.IsNullOrEmpty(logInfo.LogUserName))
                {
                    logInfo.LogUserName = "";

                    //if (HttpContext.Current != null)
                    //{
                    //    if (HttpContext.Current.Request.IsAuthenticated)
                    //    {
                    //        logInfo.LogUserName = UserController.Instance.GetCurrentUserInfo().Username;
                    //    }
                    //}
                }

                //Get portal name if name isn't set
                if (logInfo.LogPortalID != Null.NullInteger && String.IsNullOrEmpty(logInfo.LogPortalName))
                {
                    //logInfo.LogPortalName = PortalController.Instance.GetPortal(logInfo.LogPortalID).PortalName;
                    logInfo.LogPortalName = "";
                }

                //Check if Log Type exists
                if (!GetLogTypeInfoDictionary().ContainsKey(logInfo.LogTypeKey))
                {
                    //Add new Log Type
                    var logType = new LogTypeInfo()
                    {
                        LogTypeKey          = logInfo.LogTypeKey,
                        LogTypeFriendlyName = logInfo.LogTypeKey,
                        LogTypeOwner        = "DotNetNuke.Logging.EventLogType",
                        LogTypeCSSClass     = "GeneralAdminOperation",
                        LogTypeDescription  = string.Empty
                    };
                    AddLogType(logType);

                    var logTypeConfigInfo = new LogTypeConfigInfo()
                    {
                        LogTypeKey                    = logInfo.LogTypeKey,
                        LogTypePortalID               = "*",
                        LoggingIsActive               = false,
                        KeepMostRecent                = "-1",
                        EmailNotificationIsActive     = false,
                        NotificationThreshold         = 1,
                        NotificationThresholdTime     = 1,
                        NotificationThresholdTimeType = LogTypeConfigInfo.NotificationThresholdTimeTypes.Seconds,
                        MailFromAddress               = String.Empty,
                        MailToAddress                 = String.Empty
                    };
                    AddLogTypeConfigInfo(logTypeConfigInfo);
                }

                if (LoggingProvider.Instance() != null)
                {
                    try
                    {
                        LoggingProvider.Instance().AddLog(logInfo);
                    }
                    catch (Exception)
                    {
                        if (Globals.Status != Globals.UpgradeStatus.Upgrade)     //this may caught exception during upgrade because old logging provider has problem in it.
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

                AddLogToFile(logInfo);
            }
            //}
        }