/// -----------------------------------------------------------------------------
        /// <summary>
        ///   Retrieves the Google Analytics config file, "SiteAnalytics.config".
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private StreamReader GetConfigFile()
        {
            StreamReader fileReader = null;
            string       filePath   = "";

            try
            {
                filePath = Globals.ApplicationMapPath + "\\SiteAnalytics.config";

                if (File.Exists(filePath))
                {
                    fileReader = new StreamReader(filePath);
                }
            }
            catch (Exception ex)
            {
                //log it
                var log = new LogInfo {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                };
                log.AddProperty("GoogleAnalytics.UpgradeModule", "GetConfigFile Failed");
                log.AddProperty("FilePath", filePath);
                log.AddProperty("ExceptionMessage", ex.Message);
                LogController.Instance.AddLog(log);
                if (fileReader != null)
                {
                    fileReader.Close();
                }
                Logger.Error(ex);
            }

            return(fileReader);
        }
Exemplo n.º 2
0
        public static void UpdateServerActivity(ServerInfo server)
        {
            var existServer = GetServers().FirstOrDefault(s => s.ServerName == server.ServerName && s.IISAppName == server.IISAppName);
            var serverId = DataProvider.Instance().UpdateServerActivity(server.ServerName, server.IISAppName, server.CreatedDate, server.LastActivityDate, server.PingFailureCount, server.Enabled);
            
            server.ServerID = serverId;
            if (existServer == null
                || string.IsNullOrEmpty(existServer.Url)
                || (string.IsNullOrEmpty(existServer.UniqueId) && !string.IsNullOrEmpty(GetServerUniqueId())))
            {
                //try to detect the server url from url adapter.
                server.Url = existServer == null || string.IsNullOrEmpty(existServer.Url) ? GetServerUrl() : existServer.Url;
                //try to detect the server unique id from url adapter.
                server.UniqueId = existServer == null || string.IsNullOrEmpty(existServer.UniqueId) ? GetServerUniqueId() : existServer.UniqueId;

                UpdateServer(server);
            }

            
            //log the server info
            var log = new LogInfo();
            log.AddProperty(existServer != null ? "Server Updated" : "Add New Server", server.ServerName);
            log.AddProperty("IISAppName", server.IISAppName);
            log.AddProperty("Last Activity Date", server.LastActivityDate.ToString());
            log.LogTypeKey = existServer != null ? EventLogController.EventLogType.WEBSERVER_UPDATED.ToString() 
                                        : EventLogController.EventLogType.WEBSERVER_CREATED.ToString();
            LogController.Instance.AddLog(log);

            ClearCachedServers();
        }
Exemplo n.º 3
0
        private void UpgradeModule(EventMessage message)
        {
            string             BusinessController = message.Attributes["BusinessControllerClass"].ToString();
            object             oObject            = Reflection.CreateObject(BusinessController, BusinessController);
            EventLogController objEventLog        = new EventLogController();
            LogInfo            objEventLogInfo;

            if (oObject is IUpgradeable)
            {
                // get the list of applicable versions
                string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].ToString().Split(",".ToCharArray());
                foreach (string Version in UpgradeVersions)
                {
                    //call the IUpgradeable interface for the module/version
                    string upgradeResults = ((IUpgradeable)oObject).UpgradeModule(Version);
                    //log the upgrade results
                    objEventLogInfo = new LogInfo();
                    objEventLogInfo.AddProperty("Module Upgraded", BusinessController);
                    objEventLogInfo.AddProperty("Version", Version);
                    objEventLogInfo.AddProperty("Results", upgradeResults);
                    objEventLogInfo.LogTypeKey = EventLogController.EventLogType.MODULE_UPDATED.ToString();
                    objEventLog.AddLog(objEventLogInfo);
                }
            }
            UpdateSupportedFeatures(oObject, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
        }
        public static RewriterConfiguration GetConfig()
        {
            var config = new RewriterConfiguration {
                Rules = new RewriterRuleCollection()
            };
            FileStream fileReader = null;
            string     filePath   = "";

            try
            {
                config = (RewriterConfiguration)DataCache.GetCache("RewriterConfig");
                if ((config == null))
                {
                    filePath = Common.Utilities.Config.GetPathToFile(Common.Utilities.Config.ConfigFileType.SiteUrls);

                    //Create a FileStream for the Config file
                    fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    var doc = new XPathDocument(fileReader);
                    config = new RewriterConfiguration {
                        Rules = new RewriterRuleCollection()
                    };
                    foreach (XPathNavigator nav in doc.CreateNavigator().Select("RewriterConfig/Rules/RewriterRule"))
                    {
                        var rule = new RewriterRule {
                            LookFor = nav.SelectSingleNode("LookFor").Value, SendTo = nav.SelectSingleNode("SendTo").Value
                        };
                        config.Rules.Add(rule);
                    }
                    if (File.Exists(filePath))
                    {
                        //Set back into Cache
                        DataCache.SetCache("RewriterConfig", config, new DNNCacheDependency(filePath));
                    }
                }
            }
            catch (Exception ex)
            {
                //log it
                var log = new LogInfo {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                };
                log.AddProperty("UrlRewriter.RewriterConfiguration", "GetConfig Failed");
                log.AddProperty("FilePath", filePath);
                log.AddProperty("ExceptionMessage", ex.Message);
                LogController.Instance.AddLog(log);
                Logger.Error(log);
            }
            finally
            {
                if (fileReader != null)
                {
                    //Close the Reader
                    fileReader.Close();
                }
            }
            return(config);
        }
Exemplo n.º 5
0
        void LogException(Exception ex)
        {
            var logEntry = new LogInfo();

            logEntry.AddProperty("Source", GetType().BaseType.FullName);
            logEntry.AddProperty("Message", "Cannot load '~/admin/Skins/banner.ascx' skinobject, please check project readme for details.");
            logEntry.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
            logEntry.Exception  = new ExceptionInfo(ex);
            EventLogController.Instance.AddLog(logEntry);
        }
        public override void OnException(HttpActionExecutedContext context)
        {
            //face logging in DNN in Admin logs
            DotNetNuke.Services.Exceptions.Exceptions.LogException(context.Exception);


            //face logging in DNN in Admin logs
            DotNetNuke.Services.Exceptions.Exceptions.LogException(context.Exception);

            EventLogController eventLog = new EventLogController();

            DotNetNuke.Services.Log.EventLog.LogInfo logInfo = new LogInfo();
            logInfo.LogTypeKey = EventLogController.EventLogType.ADMIN_ALERT.ToString();
            logInfo.AddProperty("exceptionMessage:", context.Exception.Message);
            logInfo.AddProperty("exception:", context.Exception.ToString());
            eventLog.AddLog(logInfo);


            //pentru exceptiile de validare aruncate de fluent validation
            if (context.Exception is ValidationException)
            {
                throw new HttpResponseException(context.Request.CreateErrorResponse(HttpStatusCode.BadRequest, context.Exception.Message));
            }

            string exceptionMessage = context.Exception.Message;

            var statusCode = HttpStatusCode.InternalServerError;

            if (context.Exception is ArgumentException)
            {
                statusCode = HttpStatusCode.BadRequest;
            }
            else if (context.Exception is UnauthorizedAccessException)
            {
                statusCode = HttpStatusCode.Unauthorized;
            }
            else if (context.Exception is InvalidOperationException)
            {
                statusCode = HttpStatusCode.Forbidden;
            }
            else if (context.Exception is ArgumentNullException || context.Exception is ValidationException)
            {
                statusCode = HttpStatusCode.BadRequest;
            }
            else if (context.Exception is SqlException)
            {
                exceptionMessage = "SQL exception: " + context.Exception.Message;
            }


            throw new HttpResponseException(new HttpResponseMessage(statusCode)
            {
                Content = new StringContent(exceptionMessage),
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// This method stores a list of tabIds for the specific portal in the cache
        /// This is used to lookup and see if there are any providers to load for a tab,
        /// without having to store individual tabid/portaldId provider lists for every tab
        /// If a tab doesn't appear on this cached list, then the cache isn't checked
        /// for that particular tabid/portalId combination.
        /// </summary>
        /// <param name="providers"></param>
        /// <param name="portalId"></param>
        /// <param name="settings"></param>
        internal static void StoreListOfTabsWithProviders(List <ExtensionUrlProvider> providers, int portalId, FriendlyUrlSettings settings)
        {
            // go through the list of providers and store all the tabs that they are configured for
            var providersWithTabs    = new List <int>();
            var providersWithTabsStr = new List <string>();

            foreach (ExtensionUrlProvider provider in providers)
            {
                if (provider.ProviderConfig.AllTabs)
                {
                    if (providersWithTabs.Contains(RewriteController.AllTabsRewrite) == false)
                    {
                        providersWithTabs.Add(RewriteController.AllTabsRewrite);
                        providersWithTabsStr.Add("AllTabs");
                    }
                }

                if (provider.AlwaysUsesDnnPagePath(portalId) == false)
                {
                    if (providersWithTabs.Contains(RewriteController.SiteRootRewrite) == false)
                    {
                        providersWithTabs.Add(RewriteController.SiteRootRewrite);
                        providersWithTabsStr.Add("NoPath");
                    }
                }

                foreach (int providerTabId in provider.ProviderConfig.TabIds)
                {
                    if (providersWithTabs.Contains(providerTabId) == false)
                    {
                        providersWithTabs.Add(providerTabId);
                        providersWithTabsStr.Add(providerTabId.ToString());
                    }
                }
            }

            // store list as array in cache
            string key = string.Format(PortalModuleProviderTabsKey, portalId);

            SetPageCache(key, providersWithTabs.ToArray(), settings);
            if (settings.LogCacheMessages)
            {
                var log = new LogInfo {
                    LogTypeKey = "HOST_ALERT"
                };
                log.AddProperty("Url Rewriting Caching Message", "Portal Module Providers Tab List stored in cache");
                log.AddProperty("Cache Item Key", key);
                log.AddProperty("PortalId", portalId.ToString());
                log.AddProperty("Provider With Tabs", string.Join(",", providersWithTabsStr.ToArray()));
                log.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString());
                LogController.Instance.AddLog(log);
            }
        }
Exemplo n.º 8
0
    public static void LogMessage(string source, string mess)
    {
        DotNetNuke.Services.Log.EventLog.EventLogController eventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
        LogInfo logInfo = new LogInfo();

        logInfo.LogUserID   = -1;
        logInfo.LogPortalID = Globals.GetPortalSettings().PortalId;
        logInfo.LogTypeKey  = EventLogController.EventLogType.HOST_ALERT.ToString();
        logInfo.AddProperty("Source ", source);
        logInfo.AddProperty("Message ", mess);

        eventLog.AddLog(logInfo);
    }
Exemplo n.º 9
0
        public void writeLog(string type, string log)
        {
            EventLogController eventLog = new EventLogController();

            DotNetNuke.Services.Log.EventLog.LogInfo logInfo = new LogInfo();
            logInfo.LogUserID = UserId;

            logInfo.LogPortalID = PortalSettings.PortalId;
            logInfo.LogTypeKey  = EventLogController.EventLogType.ADMIN_ALERT.ToString();
            logInfo.AddProperty("tabid=", this.TabId.ToString());
            logInfo.AddProperty("moduleid=", this.ModuleId.ToString());
            logInfo.AddProperty("Loai=", type);
            logInfo.AddProperty("ThongTin=", log);
            eventLog.AddLog(logInfo);
        }
Exemplo n.º 10
0
        private void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            try
            {
                //First check if we are upgrading/installing or if it is a non-page request
                var         app     = (HttpApplication)sender;
                HttpRequest request = app.Request;

                //First check if we are upgrading/installing
                if (request.Url.LocalPath.ToLower().EndsWith("install.aspx") ||
                    request.Url.LocalPath.ToLower().Contains("upgradewizard.aspx") ||
                    request.Url.LocalPath.ToLower().Contains("installwizard.aspx"))
                {
                    return;
                }

                //exit if a request for a .net mapping that isn't a content page is made i.e. axd
                if (request.Url.LocalPath.ToLower().EndsWith(".aspx") == false && request.Url.LocalPath.ToLower().EndsWith(".asmx") == false &&
                    request.Url.LocalPath.ToLower().EndsWith(".ashx") == false)
                {
                    return;
                }
                if (HttpContext.Current != null)
                {
                    HttpContext context = HttpContext.Current;
                    if ((context == null))
                    {
                        return;
                    }
                    var page = context.Handler as CDefault;
                    if ((page == null))
                    {
                        return;
                    }
                    page.Load += OnPageLoad;
                }
            }
            catch (Exception ex)
            {
                var objEventLog     = new EventLogController();
                var objEventLogInfo = new LogInfo();
                objEventLogInfo.AddProperty("Analytics.AnalyticsModule", "OnPreRequestHandlerExecute");
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
                Logger.Error(objEventLogInfo);
            }
        }
Exemplo n.º 11
0
        private void LogResult(string message)
        {
            var portalSecurity = new PortalSecurity();

            var log = new LogInfo
            {
                LogPortalID   = PortalSettings.PortalId,
                LogPortalName = PortalSettings.PortalName,
                LogUserID     = UserId,
                LogUserName   = portalSecurity.InputFilter(txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup)
            };

            if (string.IsNullOrEmpty(message))
            {
                log.LogTypeKey = "PASSWORD_SENT_SUCCESS";
            }
            else
            {
                log.LogTypeKey = "PASSWORD_SENT_FAILURE";
                log.LogProperties.Add(new LogDetailInfo("Cause", message));
            }

            log.AddProperty("IP", _ipAddress);

            LogController.Instance.AddLog(log);
        }
Exemplo n.º 12
0
        private void LogResult(string message)
        {
            var portalSecurity = new PortalSecurity();

            var objEventLog     = new EventLogController();
            var objEventLogInfo = new LogInfo();

            objEventLogInfo.AddProperty("IP", _ipAddress);
            objEventLogInfo.LogPortalID   = PortalSettings.PortalId;
            objEventLogInfo.LogPortalName = PortalSettings.PortalName;
            objEventLogInfo.LogUserID     = UserId;
            //    objEventLogInfo.LogUserName = portalSecurity.InputFilter(txtUsername.Text,
            //                                                           PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
            if (string.IsNullOrEmpty(message))
            {
                objEventLogInfo.LogTypeKey = "PASSWORD_SENT_SUCCESS";
            }
            else
            {
                objEventLogInfo.LogTypeKey = "PASSWORD_SENT_FAILURE";
                objEventLogInfo.LogProperties.Add(new LogDetailInfo("Cause", message));
            }

            objEventLog.AddLog(objEventLogInfo);
        }
Exemplo n.º 13
0
        public void ExecuteAction(NewsEntryAction action, int portalId, int tabId, int?userId = null)
        {
            try {
                switch (action.Action)
                {
                case NewsEntryActions.Duplicate:
                    Duplicate(action.EntryId, portalId, tabId, action.ModuleId);
                    break;

                case NewsEntryActions.SyncTab:
                    SyncTab(action.EntryId, portalId, tabId);
                    break;

                case NewsEntryActions.StartDiscussion:
                    StartDiscussion(action.EntryId, portalId, userId.Value, action.Params [0]);
                    break;

                case NewsEntryActions.JoinDiscussion:
                    JoinDiscussion(action.EntryId, portalId);
                    break;
                }
            }
            catch (Exception ex) {
                var log = new LogInfo();
                log.Exception   = new ExceptionInfo(ex);
                log.LogTypeKey  = EventLogController.EventLogType.HOST_ALERT.ToString();
                log.LogPortalID = portalId;
                log.AddProperty("Message", $"Cannot execute {action.Action} action");
                EventLogController.Instance.AddLog(log);
            }
        }
        private void ChangeScheduledTasksServerAffinity()
        {
            try
            {
                var firstEnabledServer = ServerController.GetEnabledServers().OrderBy(x => x.KeyID).FirstOrDefault();
                var serverName         = ServerController.GetServerName(firstEnabledServer);

                // Move all the tasks to the first enagbled server
                var scheduleItems  = SchedulingController.GetSchedule();
                var movedSchedules = new List <string>();

                foreach (var item in scheduleItems)
                {
                    if (item.TypeFullName == "DotNetNuke.Azure.AppService.AppServiceServerChecker, DotNetNuke.Azure.AppService")
                    {
                        if (item.Servers != Null.NullString)
                        {
                            item.Servers = Null.NullString;
                            SchedulingProvider.Instance().UpdateSchedule(item);
                            movedSchedules.Add(item.FriendlyName);
                        }
                    }
                    else if (item.Servers != $",{serverName},")
                    {
                        item.Servers = $",{serverName},";
                        SchedulingProvider.Instance().UpdateSchedule(item);
                        movedSchedules.Add(item.FriendlyName);
                    }
                }
                if (movedSchedules.Count() > 0)
                {
                    Logger.Info($"Changed schedules '{string.Join(",", movedSchedules)}' to '{serverName}'");
                    var log = new LogInfo {
                        LogTypeKey = EventLogController.EventLogType.SCHEDULE_UPDATED.ToString()
                    };
                    log.AddProperty("Updated schedules", string.Join(",", movedSchedules));
                    log.AddProperty("Changed to server", serverName);
                    LogController.Instance.AddLog(log);
                }
            }
            catch (Exception ex)
            {
                var message = $"Error changing server affinity: {ex.Message}";
                ScheduleHistoryItem.AddLogNote(message);
                Exceptions.LogException(ex);
            }
        }
Exemplo n.º 15
0
        private static void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            try
            {
                // First check if we are upgrading/installing or if it is a non-page request
                var app     = (HttpApplication)sender;
                var request = app.Request;

                if (!Initialize.ProcessHttpModule(request, false, false))
                {
                    return;
                }

                if (HttpContext.Current == null)
                {
                    return;
                }

                var context = HttpContext.Current;

                if (context == null)
                {
                    return;
                }

                var page = context.Handler as CDefault;
                if (page == null)
                {
                    return;
                }

                page.InitComplete += OnPageInitComplete;
                page.PreRender    += OnPagePreRender;
            }
            catch (Exception ex)
            {
                var log = new LogInfo {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                };
                log.AddProperty("Analytics.AnalyticsModule", "OnPreRequestHandlerExecute");
                log.AddProperty("ExceptionMessage", ex.Message);
                LogController.Instance.AddLog(log);
                Logger.Error(log);
            }
        }
        private static void AddEventLog(string path)
        {
            try
            {
                var log = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(),
                };
                log.AddProperty("Summary", Localization.GetString("PotentialDangerousFile.Text", ResourceFile));
                log.AddProperty("File Name", path);

                new LogController().AddLog(log);
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Exemplo n.º 17
0
        protected void LogAdminAlert(string message, int portalId)
        {
            var log = new LogInfo();

            log.LogTypeKey  = EventLogController.EventLogType.ADMIN_ALERT.ToString();
            log.LogPortalID = portalId;
            log.AddProperty("Message", message);
            EventLogController.Instance.AddLog(log);
        }
Exemplo n.º 18
0
        protected virtual void RestartApplication()
        {
            var log = new LogInfo {
                BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
            };

            log.AddProperty("Message", this.GetString("UserRestart"));
            LogController.Instance.AddLog(log);
            Config.Touch();
        }
        protected void RestartApplication(object sender, EventArgs e)
        {
            var log = new LogInfo {
                BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
            };

            log.AddProperty("Message", Localization.GetString("UserRestart", LocalResourceFile));
            LogController.Instance.AddLog(log);
            Config.Touch();
            Response.Redirect(Globals.NavigateURL(), true);
        }
Exemplo n.º 20
0
        protected virtual void RestartApplication()
        {
            var objEv           = new EventLogController();
            var objEventLogInfo = new LogInfo {
                BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
            };

            objEventLogInfo.AddProperty("Message", GetString("UserRestart"));
            objEv.AddLog(objEventLogInfo);
            Config.Touch();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Ghi nhật ký
        /// </summary>
        /// <param name="logType">Được khai báo trong enum LogType</param>
        /// <param name="logAction">Thao tác: thêm, sửa, xóa, duyệt,...</param>
        /// <param name="value"></param>
        public static void saveLog(LogType logType, LogAction logAction, string value)
        {
            String PortalName = PortalController.Instance.GetCurrentPortalSettings().PortalName;
            int    PortalID   = PortalController.Instance.GetCurrentPortalSettings().PortalId;
            String UserName   = UserController.Instance.GetCurrentUserInfo().Username;
            int    UserID     = UserController.Instance.GetCurrentUserInfo().UserID;

            EventLogController elc     = new EventLogController();
            LogInfo            loginfo = new LogInfo();

            loginfo.LogCreateDate = DateTime.Now;                                        //Ngày tạo Log
            loginfo.LogPortalName = PortalName;                                          //Tên Portal Thao tác
            loginfo.LogPortalID   = PortalID;                                            //ID Portal Thao tác
            loginfo.LogTypeKey    = logType.ToString();                                  //Khóa nhật ký
            loginfo.LogUserName   = UserName;                                            //Người dùng thao tác
            loginfo.LogUserID     = UserID;                                              //ID người dùng thao tác
            loginfo.AddProperty("Hành động", ClassCommon.GetEnumDescription(logAction)); //Thuộc tính nhật ký
            loginfo.AddProperty("Nội dung", value);                                      //Thuộc tính nhật ký
            elc.AddLog(loginfo);
        }
Exemplo n.º 22
0
        internal void StorePageIndexInCache(
            SharedDictionary <string, string> tabDictionary,
            SharedDictionary <int, PathSizes> portalDepthInfo,
            FriendlyUrlSettings settings,
            string reason)
        {
            this.onRemovePageIndex = settings.LogCacheMessages ? (CacheItemRemovedCallback)this.RemovedPageIndexCallBack : null;

            // get list of portal ids for the portals we are storing in the page index
            var portalIds = new List <int>();

            using (portalDepthInfo.GetReadLock())
            {
                portalIds.AddRange(portalDepthInfo.Keys);
            }

            // 783 : use cache dependency to manage page index instead of triggerDictionaryRebuild regex.
            SetPageCache(PageIndexKey, tabDictionary, new DNNCacheDependency(this.GetTabsCacheDependency(portalIds)), settings, this.onRemovePageIndex);

            SetPageCache(PageIndexDepthKey, portalDepthInfo, settings);

            LogRemovedReason = settings.LogCacheMessages;

            if (settings.LogCacheMessages)
            {
                var log = new LogInfo {
                    LogTypeKey = "HOST_ALERT"
                };

                log.AddProperty("Url Rewriting Caching Message", "Page Index built and Stored in Cache");
                log.AddProperty("Reason", reason);
                log.AddProperty("Cache Item Key", PageIndexKey);
                using (tabDictionary.GetReadLock())
                {
                    log.AddProperty("Item Count", tabDictionary.Count.ToString());
                }

                log.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString());
                LogController.Instance.AddLog(log);
            }
        }
Exemplo n.º 23
0
        public void AddEventLog(string username, int userId, string portalName, string ip, EventLogType logType, string message)
        {
            //initialize log record
            var objSecurity = new PortalSecurity();
            var log         = new LogInfo
            {
                LogTypeKey    = logType.ToString(),
                LogPortalID   = PortalId,
                LogPortalName = portalName,
                LogUserName   = objSecurity.InputFilter(username, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup),
                LogUserID     = userId
            };

            log.AddProperty("IP", ip);
            log.AddProperty("Message", message);

            //create log record
            var logctr = new LogController();

            logctr.AddLog(log);
        }
Exemplo n.º 24
0
 public static string[] GetCacheKeys(int PortalId)
 {
     string[] CacheKeys = new string[] { };
     try
     {
         var builder = new UrlBuilder();
         CacheKeys = builder.BuildCacheKeys(PortalId);
     }
     catch (Exception ex)
     {
         //log it
         var objEventLog     = new EventLogController();
         var objEventLogInfo = new LogInfo();
         objEventLogInfo.AddProperty("UrlRewriter.RewriterConfiguration", "GetCacheKeys Failed");
         objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
         objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
         objEventLog.AddLog(objEventLogInfo);
         Logger.Error(ex);
     }
     return(CacheKeys);
 }
Exemplo n.º 25
0
        private static void UpgradeModule(EventMessage message)
        {
            try
            {
                int desktopModuleId = Convert.ToInt32(message.Attributes["DesktopModuleId"]);
                var desktopModule   = DesktopModuleController.GetDesktopModule(desktopModuleId, Null.NullInteger);

                string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
                object controller = Reflection.CreateObject(BusinessControllerClass, string.Empty);
                if (controller is IUpgradeable)
                {
                    // get the list of applicable versions
                    string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].Split(',');
                    foreach (string Version in UpgradeVersions)
                    {
                        // call the IUpgradeable interface for the module/version
                        string Results = ((IUpgradeable)controller).UpgradeModule(Version);

                        // log the upgrade results
                        var log = new LogInfo {
                            LogTypeKey = EventLogController.EventLogType.MODULE_UPDATED.ToString()
                        };
                        log.AddProperty("Module Upgraded", BusinessControllerClass);
                        log.AddProperty("Version", Version);
                        if (!string.IsNullOrEmpty(Results))
                        {
                            log.AddProperty("Results", Results);
                        }

                        LogController.Instance.AddLog(log);
                    }
                }

                UpdateSupportedFeatures(controller, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
        }
            private static void AddEventLog(int userId, string username, int portalId, string propertyName, string propertyValue)
            {
                LogInfo log = new LogInfo
                {
                    LogUserID   = userId,
                    LogUserName = username,
                    LogPortalID = portalId,
                    LogTypeKey  = EventLogController.EventLogType.ADMIN_ALERT.ToString()
                };

                log.AddProperty(propertyName, propertyValue);
                LogController.Instance.AddLog(log);
            }
Exemplo n.º 27
0
 private static void AttachDnnStateIfPossible(DnnContextOld dnn, LogInfo logInfo)
 {
     try
     {
         if (dnn != null)
         {
             logInfo.LogUserName = dnn.User?.DisplayName ?? "unknown";
             logInfo.LogUserID   = dnn.User?.UserID ?? -1;
             logInfo.LogPortalID = dnn.Portal.PortalId;
             logInfo.AddProperty("ModuleId", dnn.Module?.ModuleID.ToString() ?? "unknown");
         }
     }
     catch { /* ignore */ }
 }
Exemplo n.º 28
0
        public static void LogToDnn(string key, string message, ILog log = null, DnnContextOld dnnContext = null, bool force = false)
        {
            if (!force)
            {
                if (!EnableLogging(GlobalConfiguration.Configuration.Properties))
                {
                    return;
                }
            }


            // note: this code has a lot of try/catch, to ensure that most of it works and that
            // it doesn't interfere with other functionality
            try
            {
                var logInfo = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.ADMIN_ALERT.ToString()
                };

                // the initial message should come first, as it's visible in the summary
                if (!string.IsNullOrEmpty(message))
                {
                    logInfo.AddProperty(key, message);
                }

                AttachDnnStateIfPossible(dnnContext, logInfo);

                log?.Entries.ForEach(e => logInfo.AddProperty(e.Source, e.Message));

                new EventLogController().AddLog(logInfo);
            }
            catch
            {
                TryToReportLoggingFailure("logging");
            }
        }
Exemplo n.º 29
0
        public HttpResponseMessage RecycleApplicationPool()
        {
            if (UserController.Instance.GetCurrentUserInfo().IsSuperUser)
            {
                var log = new LogInfo {
                    BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                };
                log.AddProperty("Message", "UserRestart");
                LogController.Instance.AddLog(log);
                Config.Touch();
                return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true }));
            }

            return(Request.CreateResponse(HttpStatusCode.InternalServerError));
        }
Exemplo n.º 30
0
        public void Log(ServicesAction action)
        {
            EventLogController eventLog = new EventLogController();

            DotNetNuke.Services.Log.EventLog.LogInfo logInfo = default(DotNetNuke.Services.Log.EventLog.LogInfo);
            logInfo               = new LogInfo();
            logInfo.LogUserName   = action.Username;
            logInfo.LogPortalID   = PortalId;
            logInfo.LogTypeKey    = action.LogTypeKey;
            logInfo.LogServerName = action.LogServerName;
            logInfo.AddProperty("Requested By", action.AppName);
            //logInfo.AddProperty("PropertyName2", propertyValue2);

            eventLog.AddLog(logInfo);
        }