コード例 #1
0
ファイル: LogView.cs プロジェクト: ihvrooman/LogViewer_New
 /// <summary>
 /// Creates a new <see cref="LogView"/>.
 /// </summary>
 /// <param name="database">The <see cref="LogFile"/> being opened in the <see cref="LogView"/>.</param>
 public LogView(LogFile logFile)
 {
     IsNew    = true;
     IsEdited = true;
     SetName(logFile.NetworkFile.FullName);
     SubscribeToEvents();
     LogFilePaths.Add(logFile.NetworkFile?.FullName);
 }
コード例 #2
0
ファイル: LogView.cs プロジェクト: ihvrooman/LogViewer_New
 public void AddLogFile(LogFile logFile)
 {
     LogFilePaths.Add(logFile.NetworkFile.FullName);
 }
コード例 #3
0
ファイル: LogView.cs プロジェクト: ihvrooman/LogViewer_New
        public void UpdateFromXml(string xmlLogView)
        {
            try
            {
                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(xmlLogView);

                //Set the log view name and last opened date
                Name           = xmlDocument.DocumentElement.Attributes[0].Value;
                DateLastOpened = DateTime.ParseExact(xmlDocument.DocumentElement.Attributes[1].Value, AppInfo.LastOpenedTimeFormatString, CultureInfo.InvariantCulture);
                IsPinned       = Convert.ToBoolean(xmlDocument.DocumentElement.Attributes[2].Value);

                // Add the log files
                XmlNode logFilesNode = xmlDocument.GetElementsByTagName(logFilesXmlNodeName)[0];
                LogFilePaths.Clear();
                foreach (XmlNode logFileNode in logFilesNode.ChildNodes)
                {
                    var networkFilePath = logFileNode.Attributes[0].Value.ToString();
                    LogFilePaths.Add(networkFilePath);
                }

                // Add the databases
                XmlNode databasesNode = xmlDocument.GetElementsByTagName(databasesXmlNodeName)[0];
                DatabaseNames.Clear();
                foreach (XmlNode databaseNode in databasesNode.ChildNodes)
                {
                    var name = databaseNode.Attributes[0].Value.ToString();
                    DatabaseNames.Add(name);
                }

                //Add the filter options
                XmlNode filterOptionsNode = xmlDocument.GetElementsByTagName(filterOptionsXmlNodeName)[0];
                foreach (XmlAttribute attribute in filterOptionsNode.Attributes)
                {
                    switch (attribute.Name)
                    {
                    case filterOptionsXmlIncludeErrorsAttrName:
                        FilterOptions.IncludeErrors = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeWarningsAttrName:
                        FilterOptions.IncludeWarnings = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeInformationAttrName:
                        FilterOptions.IncludeInformation = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeVerboseAttrName:
                        FilterOptions.IncludeVerbose = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeDebugAttrName:
                        FilterOptions.IncludeDebug = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeDebugErrorsAttrName:
                        FilterOptions.IncludeDebugErrors = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeDebugWarningsAttrName:
                        FilterOptions.IncludeDebugWarnings = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeDebugInformationAttrName:
                        FilterOptions.IncludeDebugInformation = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeDebugVerboseAttrName:
                        FilterOptions.IncludeDebugVerbose = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlIncludeUnknownAttrName:
                        FilterOptions.IncludeUnknown = Convert.ToBoolean(attribute.Value);
                        break;

                    case filterOptionsXmlUseQuickDateRangeAtrrName:
                        FilterOptions.UseQuickDateRange = Convert.ToBoolean(attribute.Value);
                        FilterOptions.SpecifyDateRange  = !FilterOptions.UseQuickDateRange;
                        break;

                    case filterOptionsXmlSelectedQuickDateRangeNameAttrName:
                        FilterOptions.SelectedQuickDateRange = FilterOptions.QuickDateRanges.FirstOrDefault(qdr => qdr.Name == attribute.Value);
                        break;

                    case filterOptionsXmlMinDayAttrName:
                        FilterOptions.MinDay = Convert.ToDateTime(attribute.Value);
                        break;

                    case filterOptionsXmlMinHourAttrName:
                        FilterOptions.MinHour = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMinMinuteAttrName:
                        FilterOptions.MinMinute = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMinSecondAttrName:
                        FilterOptions.MinSecond = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMinMilliSecondAttrName:
                        FilterOptions.MinMillisecond = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMaxDayAttrName:
                        FilterOptions.MaxDay = Convert.ToDateTime(attribute.Value);
                        break;

                    case filterOptionsXmlMaxHourAttrName:
                        FilterOptions.MaxHour = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMaxMinuteAttrName:
                        FilterOptions.MaxMinute = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMaxSecondAttrName:
                        FilterOptions.MaxSecond = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlMaxMilliSecondAttrName:
                        FilterOptions.MaxMillisecond = Convert.ToInt32(attribute.Value);
                        break;

                    case filterOptionsXmlUsernameAttrName:
                        FilterOptions.FilterUsername = attribute.Value;
                        break;

                    case filterOptionsXmlComputernameAttrName:
                        FilterOptions.FilterComputername = attribute.Value;
                        break;

                    case filterOptionsXmlSearchTermAttrName:
                        FilterOptions.SearchTerm = attribute.Value;
                        break;

                    case filterOptionsXmlExclusionTermAttrName:
                        FilterOptions.ExclusionTerm = attribute.Value;
                        break;

                    default:
                        break;
                    }
                }

                if (FilterOptions.UseQuickDateRange)
                {
                    FilterOptions.LoadQuickDateRange(FilterOptions.SelectedQuickDateRange);
                }

                //Add the settings
                XmlNode settingsNode = xmlDocument.GetElementsByTagName(settingsXmlNodeName)[0];
                foreach (XmlAttribute attribute in settingsNode.Attributes)
                {
                    switch (attribute.Name)
                    {
                    case settingsAutoRefreshAttrName:
                        Settings.AutoRefresh = Convert.ToBoolean(attribute.Value);
                        break;

                    case settingsHighlightNewLogEntriesAttrName:
                        Settings.HighlightNewLogEntries = Convert.ToBoolean(attribute.Value);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to update {GetType().Name} from xml. Xml parameter: \"{xmlLogView}\" | Inner exception message: {ex.Message}");
            }
        }