Пример #1
0
        /// <inheritdoc/>
        public override void Remove(int tabId)
        {
            try
            {
                Dictionary <int, int> portals = PortalController.GetPortalDictionary();
                if (portals.ContainsKey(tabId) && portals[tabId] > Null.NullInteger)
                {
                    var    filesNotDeleted = new StringBuilder();
                    int    i           = 0;
                    string cacheFolder = GetCacheFolder(portals[tabId]);

                    if (!string.IsNullOrEmpty(cacheFolder))
                    {
                        foreach (string file in Directory.GetFiles(cacheFolder, string.Concat(tabId, "_*.*")))
                        {
                            if (!FileSystemUtils.DeleteFileWithWait(file, 100, 200))
                            {
                                filesNotDeleted.Append(string.Concat(file, ";"));
                            }
                            else
                            {
                                i += 1;
                            }
                        }

                        if (filesNotDeleted.Length > 0)
                        {
                            var log = new LogInfo {
                                LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString()
                            };

                            var logDetail = new LogDetailInfo
                            {
                                PropertyName  = "FileOutputCacheProvider",
                                PropertyValue =
                                    string.Format(
                                        "Deleted {0} files, however, some files are locked.  Could not delete the following files: {1}",
                                        i, filesNotDeleted),
                            };
                            var properties = new LogProperties {
                                logDetail
                            };
                            log.LogProperties = properties;

                            LogController.Instance.AddLog(log);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }
        }
Пример #2
0
    /*
     * 获取所有用户名下的log信息
     * @return  List<LogListInfo>
     * **/
    public static List <LogListInfo> readXMLListFileAllUser(string xmlRootPath)
    {
        List <LogListInfo> plist  = new List <LogListInfo>();
        DirectoryInfo      drInfo = new DirectoryInfo(xmlRootPath);

        DirectoryInfo[] subDr = drInfo.GetDirectories();
        foreach (DirectoryInfo subDir in drInfo.GetDirectories())
        {
            string        subFile   = subDir.FullName + @"\";
            DirectoryInfo subDrInfo = new DirectoryInfo(subFile);
            FileInfo[]    fileInfo  = subDrInfo.GetFiles();
            foreach (FileInfo f in fileInfo)
            {
                List <LogDetailInfo> ldlist = new List <LogDetailInfo>();
                if (f.Extension == ".xml" || f.Extension == ".XML")
                {
                    XElement xlm      = XElement.Load(f.FullName);
                    var      elements = from e in xlm.Elements("logDetails") select e;
                    foreach (var element in elements)
                    {
                        LogListInfo logListinfo = new LogListInfo();
                        logListinfo.Id        = element.Attribute("id").Value;
                        logListinfo.Name      = element.Element("name").Value;
                        logListinfo.CaseName  = element.Element("caseName").Value;
                        logListinfo.StudentId = element.Element("studentId").Value;
                        logListinfo.Path      = element.Element("path").Value;
                        logListinfo.Duration  = int.Parse(element.Element("duration").Value);
                        logListinfo.DateTime  = Convert.ToDateTime(element.Element("beginTime").Value);
                        logListinfo.Username  = element.Element("username").Value;

                        var logs        = from e in xlm.Elements("Logs") select e;
                        var logelements = from e in logs.First().Elements("Log") select e;
                        foreach (var logelement in logelements)
                        {
                            LogDetailInfo logDetailInfo = new LogDetailInfo();
                            logDetailInfo.Type    = int.Parse(logelement.Element("type").Value);
                            logDetailInfo.Time    = logelement.Element("time").Value;
                            logDetailInfo.Content = logelement.Element("content").Value;
                            ldlist.Add(logDetailInfo);
                        }
                        logListinfo.LogOptlist = ldlist;
                        plist.Add(logListinfo);
                    }
                }
            }
        }
        return(plist);
    }
Пример #3
0
        public static void LogToEventLog(string methodName, string message)
        {
            DotNetNuke.Services.Log.EventLog.ExceptionLogController objEventLog = new DotNetNuke.Services.Log.EventLog.ExceptionLogController();
            DotNetNuke.Services.Log.EventLog.LogInfo objEventLogInfo            = new DotNetNuke.Services.Log.EventLog.LogInfo();
            objEventLogInfo.BypassBuffering = true;
            objEventLogInfo.LogTypeKey      = "ADMIN_ALERT";
            objEventLogInfo.LogPortalID     = staticPortalSettings.PortalId;

            LogDetailInfo logInfo1 = new LogDetailInfo("methodName: ", methodName);
            LogDetailInfo logInfo2 = new LogDetailInfo("Message: ", message);

            objEventLogInfo.LogProperties.Add(logInfo1);
            objEventLogInfo.LogProperties.Add(logInfo2);
            objEventLog.AddLog(objEventLogInfo);

            //eventLog.AddLog("DNN.Authentication.SAML." + methodName + " : " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss:fff"), message, staticPortalSettings, -1, EventLogController.EventLogType.ADMIN_ALERT);
        }
Пример #4
0
    /*
     * 模糊查询日志操作内容
     * @Param: 操作内容
     * **/
    public static List <LogDetailInfo> selectLogDetailInfoWithFuzzyQuery(string operation)
    {
        List <LogDetailInfo> plist = new List <LogDetailInfo>();
        XElement             xml   = XElement.Load(currentLogFile);
        var Logs = from e in xml.Elements("Logs") select e;
        var Log  = from e in Logs.First().Elements("Log") where (e.Element("content").Value.Contains(operation)) select e;

        foreach (var element in Log)
        {
            LogDetailInfo logDetailInfo = new LogDetailInfo();
            logDetailInfo.Type    = int.Parse(element.Element("type").Value);
            logDetailInfo.Time    = element.Element("time").Value;
            logDetailInfo.Content = element.Element("content").Value;
            plist.Add(logDetailInfo);
        }
        return(plist);
    }
Пример #5
0
        public string GetPropertiesText(object obj)
        {
            LogInfo objLogInfo = (LogInfo)obj;

            LogProperties objLogProperties = objLogInfo.LogProperties;
            StringBuilder str = new StringBuilder();

            int i;

            for (i = 0; i <= objLogProperties.Count - 1; i++)
            {
                // display the values in the Panel child controls.
                LogDetailInfo ldi = (LogDetailInfo)objLogProperties[i];
                str.Append("<b>" + ldi.PropertyName + "</b>: " + Server.HtmlEncode(ldi.PropertyValue) + "<br>");
            }
            str.Append(Localization.GetString("ServerName", this.LocalResourceFile) + Server.HtmlEncode(objLogInfo.LogServerName) + "<br>");
            return(str.ToString());
        }
Пример #6
0
    /*
     * 查看单个当前Log日志全部信息
     * @Param 如果当前log路径为NULL的话 ,可以采用手动传参路径,默认为""
     * **/
    public static LogListInfo getCurrentSingleLogDetailInfo(string currentFullPath = "")
    {
        XElement xlm;

        if (currentLogFile == null || currentLogFile == "")
        {
            xlm = XElement.Load(currentFullPath);
        }
        else
        {
            xlm = XElement.Load(currentLogFile);
            Debug.Log(currentLogFile);
        }
        var                  elements    = from e in xlm.Elements("logDetails") select e;
        LogListInfo          logListinfo = new LogListInfo();
        List <LogDetailInfo> ldlist      = new List <LogDetailInfo>();

        foreach (var element in elements)
        {
            logListinfo.Id        = element.Attribute("id").Value;
            logListinfo.Name      = element.Element("name").Value;
            logListinfo.CaseName  = element.Element("caseName").Value;
            logListinfo.StudentId = element.Element("studentId").Value;
            logListinfo.Path      = element.Element("path").Value;
            logListinfo.Duration  = int.Parse(element.Element("duration").Value);
            logListinfo.DateTime  = Convert.ToDateTime(element.Element("beginTime").Value);
            logListinfo.Username  = element.Element("username").Value;

            var logs        = from e in xlm.Elements("Logs") select e;
            var logelements = from e in logs.First().Elements("Log") select e;
            foreach (var logelement in logelements)
            {
                LogDetailInfo logDetailInfo = new LogDetailInfo();
                logDetailInfo.Type    = int.Parse(logelement.Element("type").Value);
                logDetailInfo.Time    = logelement.Element("time").Value;
                logDetailInfo.Content = logelement.Element("content").Value;
                ldlist.Add(logDetailInfo);
            }
            logListinfo.LogOptlist = ldlist;
        }
        return(logListinfo);
    }