Exemplo n.º 1
0
        /// <summary>
        /// Process the FILTERS Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadFilters(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_FILTERS_SHOWBASIC:
                    _showBasicInformation = childElement.TextAsBoolean;
                    break;

                case V_FILTERS_SHOWDATE:
                    _showDateInformation = childElement.TextAsBoolean;
                    break;

                case V_FILTERS_SHOWVERSION:
                    _showVersionInformation = childElement.TextAsBoolean;
                    break;

                case V_FILTERS_FILE:
                    _filterFile = childElement.Text;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// We have parsed the 'General' element so now parse the items
        /// within this section noting that we terminate parsing when we reach the end
        /// of the section.
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ReadGeneral(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_GENERAL_AUTHOR:
                    _author = childElement.Text;
                    break;

                case V_GENERAL_TYPE:
                    _reportType = (eReportType)childElement.TextAsInt;
                    break;

                case V_GENERAL_NAME:
                    _name = childElement.Text;
                    break;

                case V_GENERAL_DESCRIPTION:
                    _description = childElement.Text;
                    break;

                case V_GENERAL_VERSION:
                    _currentVersion = childElement.Text;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Read the Audit Data File into our internal buffer
        /// </summary>
        /// <returns></returns>
        public bool Read(string fileName)
        {
            XmlTextReader    textReader;
            XmlSimpleElement xmlSimpleElement = new XmlSimpleElement("junk");
            XmlParser        xmlParser;

            // First of all parse the file
            try
            {
                textReader       = new XmlTextReader(fileName);
                xmlParser        = new XmlParser();
                xmlSimpleElement = xmlParser.Parse(textReader);
                textReader.Close();
            }

            catch (Exception)
            {
                return(false);
            }

            // Now iterate through the data recovered
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                ProcessElementRead(childElement);
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Read an audit data file (from an existing XML stream in an XmlTextReader)
        /// </summary>
        /// <param name="xmlDocument"></param>
        /// <returns></returns>
        public bool Read(XmlTextReader textReader)
        {
            XmlSimpleElement xmlSimpleElement = new XmlSimpleElement("junk");
            XmlParser        xmlParser;

            // First of all parse the file
            try
            {
                xmlParser        = new XmlParser();
                xmlSimpleElement = xmlParser.Parse(textReader);
                textReader.Close();
            }

            catch (Exception)
            {
                return(false);
            }

            // If we can't find the 'Alert Notification' element then this is NOT a valid file
            if (xmlSimpleElement.TagName != S_ALERTNOTIFICATION_FILE)
            {
                return(false);
            }

            // Now iterate through the data recovered
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                ProcessElementRead(childElement);
            }

            return(true);
        }
        /// <summary>
        /// Called as we parse a top level element from the configuration file
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ProcessElementRead(XmlSimpleElement xmlSimpleElement)
        {
            string elementName = xmlSimpleElement.TagName;

            // OK what sort of element is it?
            switch (elementName)
            {
            case S_REPORT_DEFINITION:
                break;

            case S_GENERAL:
                ReadGeneral(xmlSimpleElement);
                break;

            case S_REPORT_SECTIONS:
                ReadReportSections(xmlSimpleElement);
                break;

            case S_REPORT_LABELS:
                ReadReportLabels(xmlSimpleElement);
                break;

            case S_SCOPE:
                ReadScope(xmlSimpleElement);
                break;

            case S_FILTERS:
                ReadFilters(xmlSimpleElement);
                break;

            default:
                break;
            }
            return;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Process the FILTERS Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadFilters(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_FILTERS_STARTDATE:
                    _startDate = Convert.ToDateTime(childElement.Text);
                    break;

                case V_FILTERS_ENDDATE:
                    _endDate = Convert.ToDateTime(childElement.Text);
                    break;

                case V_FILTER_TYPE:
                    _subtype = (eHistoryType)childElement.TextAsInt;
                    break;

                case V_FILTERS_DAYS:
                    _days = childElement.TextAsInt;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Process the FILTERS Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadFilters(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_FILTERS_APPLICATIONS:
                    _selectedApplications = childElement.Text;
                    break;

                case V_FILTERS_PUBLISHERS:
                    _selectedPublishers = childElement.Text;
                    break;

                case V_FILTERS_SHOWINSTANCES:
                    _showInstanceDetails = childElement.TextAsBoolean;
                    break;

                case V_FILTERS_SHOWKEYSONLY:
                    _showWithKeysOnly = childElement.TextAsBoolean;
                    break;

                case V_FILTERS_SHOWLICENSES:
                    _showLicenses = childElement.TextAsBoolean;
                    break;

                default:
                    break;
                }
            }
        }
 /// <summary>
 /// The 'SelectedFields' section should consist of 1 or mnore field definitions
 /// </summary>
 /// <param name="xmlSimpleElement"></param>
 protected void ReadSelectedFields(XmlSimpleElement reader)
 {
     // We should only be able to find a 'SELECTEDFIELDS' section here
     foreach (XmlSimpleElement childElement in reader.ChildElements)
     {
         switch (childElement.TagName)
         {
         case V_FILTERS_SELECTEDFIELD:
             _listSelectedFields.Add(childElement.Text);
             break;
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Read the Audit Scanner Configuration File into our internal buffer
        /// </summary>
        /// <returns></returns>
        public virtual bool ReadReport()
        {
            // Create a log file
            LogFile ourLog = LogFile.Instance;

            ourLog.Write("Reading Report Definition from " + _filename, true);

            // Erase the default sections
            _listReportSections.Clear();

            //
            XmlTextReader    textReader;
            XmlSimpleElement xmlSimpleElement = new XmlSimpleElement("junk");
            XmlParser        xmlParser;

            // First of all parse the file
            try
            {
                textReader       = new XmlTextReader(_filename);
                xmlParser        = new XmlParser();
                xmlSimpleElement = xmlParser.Parse(textReader);
                textReader.Close();
            }

            catch (Exception ex)
            {
                ourLog.Write("Exception occurred while report definition file, the error was " + ex.Message, true);
                return(false);
            }

            // If we can't find the 'Report Defintion' element then this is NOT a valid file
            _isValidFile = (xmlSimpleElement.TagName == S_REPORT_DEFINITION);
            if (!_isValidFile)
            {
                ourLog.Write("The [" + S_REPORT_DEFINITION + "] section was not found and therefore the file is invalid", true);
                return(false);
            }

            // Now iterate through the data recovered
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                ProcessElementRead(childElement);
            }

            // Flag that we read this definition from a file
            ReadFromFile = true;

            return(true);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Load this object from XML
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public int LoadFromXml(XmlSimpleElement reader)
        {
            foreach (XmlSimpleElement childElement in reader.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_SECTION_TEXT:
                    _rawText = childElement.Text;
                    break;

                case V_SECTION_HALIGN:
                    _hAlignment = (HAlign)childElement.TextAsInt;
                    break;

                case V_SECTION_VALIGN:
                    _vAlignment = (VAlign)childElement.TextAsInt;
                    break;

                case V_SECTION_FORECOLOR:
                    _foreColor = Color.FromName(childElement.Text);
                    break;

                //case V_SECTION_BACKCOLOR:
                //    _backColor = Color.FromName(childElement.Text);
                //    break;

                case V_SECTION_FONTDATA_SIZE:
                    _fontData.SizeInPoints = childElement.TextAsInt;
                    break;

                case V_SECTION_FONTDATA_NAME:
                    _fontData.Name = childElement.Text;
                    break;

                case V_SECTION_FONTDATA_UNDERLINE:
                    _fontData.Underline = (childElement.TextAsBoolean) ? DefaultableBoolean.True : DefaultableBoolean.False;
                    break;

                case V_SECTION_FONTDATA_BOLD:
                    _fontData.Bold = (childElement.TextAsBoolean) ? DefaultableBoolean.True : DefaultableBoolean.False;
                    break;

                default:
                    break;
                }
            }
            return(0);
        }
Exemplo n.º 11
0
 /// <summary>
 /// We have parsed the an individual label element so now parse its attributes
 /// </summary>
 /// <param name="xmlElement"></param>
 protected void ReadReportLabel(XmlSimpleElement xmlSimpleElement)
 {
     foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
     {
         if (childElement.TagName == V_LABEL_MAPPING)
         {
             string value = childElement.Text;
             int    index = value.LastIndexOf("###");
             if (index != -1)
             {
                 string field = value.Substring(0, index);
                 string label = value.Substring(index + 3);
                 _dictionaryLabels.Add(field, label);
             }
         }
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// We have parsed the 'Report Sections' element so now parse the items
        /// within this section noting that we terminate parsing when we reach the end
        /// of the section.
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ReadReportSections(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                // For each section we create a new section and ask it to populate itself
                case S_REPORT_SECTION:
                    ExportSection reportSection = new ExportSection();
                    reportSection.LoadFromXml(childElement);
                    _listReportSections.Add(reportSection);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// We have parsed the 'Labels' element so now parse the items
        /// within this section noting that we terminate parsing when we reach the end
        /// of the section.
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ReadReportLabels(XmlSimpleElement xmlSimpleElement)
        {
            // Create a new dictionary
            _dictionaryLabels = new Dictionary <string, string>();

            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                // For each section we create a new section and ask it to populate itself
                case S_REPORT_LABEL:
                    ReadReportLabel(childElement);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// We have parsed the 'Alert' element so now parse the alert notification itself
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ProcessAlertRead(XmlSimpleElement xmlSimpleElement)
        {
            // Create an alert notification object
            AlertNotification alertNotification = new AlertNotification();

            // ...then loop through the fields in this section
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_ALERT_NAME:
                    alertNotification.AlertName = childElement.Text;
                    break;

                case V_ALERT_TYPE:
                    alertNotification.Type = childElement.Text;
                    break;

                case V_ALERT_CATEGORY:
                    alertNotification.Category = childElement.Text;
                    break;

                case V_ALERT_KEY:
                    alertNotification.Key = childElement.Text;
                    break;

                case V_ALERT_OLDVALUE:
                    alertNotification.OldValue = childElement.Text;
                    break;

                case V_ALERT_NEWVALUE:
                    alertNotification.NewValue = childElement.Text;
                    break;

                default:
                    break;
                }
            }

            // Add the Alert Notification to our internal list
            _listAlertNotifications.Add(alertNotification);
        }
        /// <summary>
        /// Process the FILTERS Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadFilters(XmlSimpleElement reader)
        {
            // Clear the existing list of selected fields
            _listSelectedFields.Clear();

            // We should only be able to find a 'SELECTEDFIELDS' section here
            foreach (XmlSimpleElement childElement in reader.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_FILTERS_SELECTEDFIELDS:
                    ReadSelectedFields(childElement);
                    break;

                case V_FILTERS_SHOWASSETREGISTER:
                    _showAssetRegister = childElement.TextAsBoolean;
                    break;
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Called as we parse a top level element from the Alert Notification file
        /// </summary>
        /// <param name="xmlElement"></param>
        protected void ProcessElementRead(XmlSimpleElement xmlSimpleElement)
        {
            string elementName = xmlSimpleElement.TagName;

            // OK what sort of element is it?
            switch (elementName)
            {
            case V_ASSET_NAME:
                _assetName = xmlSimpleElement.Text;
                break;

            case S_ALERT:
                ProcessAlertRead(xmlSimpleElement);
                break;

            default:
                break;
            }
            return;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Load this object definition from XML
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public int LoadFromXml(XmlSimpleElement reader)
        {
            foreach (XmlSimpleElement childElement in reader.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_SECTION_TYPE:
                    _sectionType = (eSectionType)childElement.TextAsInt;
                    break;

                // If we find the FormattedText section then let that object load itself
                case S_REPORT_SECTION_FORMAT:
                    _formattedText.LoadFromXml(childElement);
                    break;

                default:
                    break;
                }
            }

            return(0);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Process the SCOPE Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadScope(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_SCOPE_LOCATIONS:
                    SelectedGroups = childElement.Text;
                    break;

                case V_SCOPE_ASSETS:
                    SelectedAssets = childElement.Text;
                    break;

                case V_SCOPE_IGNORECHILDASSETS:
                    IgnoreChildAssets = childElement.TextAsBoolean;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Process the FILTERS Section
        /// </summary>
        /// <param name="xmlSimpleElement"></param>
        protected void ReadFilters(XmlSimpleElement xmlSimpleElement)
        {
            foreach (XmlSimpleElement childElement in xmlSimpleElement.ChildElements)
            {
                switch (childElement.TagName)
                {
                case V_FILTERS_STARTDATE:
                    _startDate = Convert.ToDateTime(childElement.Text);
                    break;

                case V_FILTERS_ENDDATE:
                    _endDate = Convert.ToDateTime(childElement.Text);
                    break;

                case V_FILTERS_URL:
                    _filterURL = childElement.Text;
                    break;

                default:
                    break;
                }
            }
        }