Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fd"></param>
        /// <returns></returns>
        private string GetFilterDisplayValue(FilterDefinition fd)
        {
            switch (fd.Type)
            {
                case Global.FilterType.Ip:
                    return ipValue.Text;
                case Global.FilterType.Numeric:
                    return txtValue.Text;
                case Global.FilterType.AcknowledgementClass:
                case Global.FilterType.Sensor:
                case Global.FilterType.Classification:
                case Global.FilterType.Protocol:

                    if (cboValue.SelectedIndex == -1)
                    {
                        return string.Empty;
                    }

                    NameValue nameValueSeverity = (NameValue)cboValue.Items[cboValue.SelectedIndex];
                    return nameValueSeverity.Name;
                case Global.FilterType.Text:
                    return txtValue.Text;
                case Global.FilterType.Timestamp:
                    return txtValue.Text;
                case Global.FilterType.PayloadAscii:
                    return txtValue.Text;
                case Global.FilterType.PayloadHex:
                    return txtValue.Text;
                default:
                    return string.Empty;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fd"></param>
        /// <returns></returns>
        private string GetFilterValue(FilterDefinition fd)
        {
            switch (fd.Type)
            {
                case Global.FilterType.AcknowledgementClass:
                case Global.FilterType.Classification:
                case Global.FilterType.Sensor:
                case Global.FilterType.Protocol:
                    if (cboValue.SelectedIndex == -1)
                    {
                        return string.Empty;
                    }

                    NameValue nameValueClass = (NameValue)cboValue.Items[cboValue.SelectedIndex];
                    return nameValueClass.Value;
                case Global.FilterType.Ip:
                    long ip = Misc.ConvertIpAddress(ipValue.Text);
                    if (ip == 0)
                    {
                        throw new Exception("Invalid IP address");
                    }
                    return ip.ToString();
                case Global.FilterType.Numeric:
                case Global.FilterType.Text:
                case Global.FilterType.Timestamp:
                    return txtValue.Text;
                case Global.FilterType.PayloadAscii:
                    // Convert to HEX
                    string payloadAscii = txtValue.Text;
                    bool wildcardStart = payloadAscii.StartsWith("%");
                    bool wildcardEnd = payloadAscii.EndsWith("%");
                    if (wildcardStart == true)
                    {
                        payloadAscii = payloadAscii.Substring(1);
                    }

                    if (wildcardEnd == true)
                    {
                        payloadAscii = payloadAscii.Remove(payloadAscii.Length - 1);
                    }

                    payloadAscii = woanware.Text.ConvertTextToHex(payloadAscii);
                    if (wildcardStart == true)
                    {
                        payloadAscii = "%" + payloadAscii;
                    }

                    if (wildcardEnd == true)
                    {
                        payloadAscii =  payloadAscii + "%";
                    }

                    return payloadAscii;
                case Global.FilterType.PayloadHex:
                    string payloadHex = txtValue.Text;
                    bool wildcardStartHex = payloadHex.StartsWith("%");
                    bool wildcardEndHex = payloadHex.EndsWith("%");
                    if (wildcardStartHex == true)
                    {
                        payloadHex = payloadHex.Substring(1);
                    }

                    if (wildcardEndHex == true)
                    {
                        payloadHex = payloadHex.Remove(payloadHex.Length - 1);
                    }

                    if (woanware.Text.IsHex(payloadHex) == false)
                    {
                        throw new Exception("Invalid HEX value");
                    }

                    if (wildcardStartHex == true)
                    {
                        payloadHex = "%" + payloadHex;
                    }

                    if (wildcardEndHex == true)
                    {
                        payloadHex = payloadHex + "%";
                    }

                    return payloadHex; // Test if hex?
                case Global.FilterType.Initials:
                    return txtValue.Text.ToUpper();
                case Global.FilterType.AcknowledgementNotes:
                    string notes = txtValue.Text;
                    notes = notes.Replace("%", string.Empty);
                    return "%" + notes + "%";
                default:
                    return string.Empty;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="field"></param>
 /// <param name="columnName"></param>
 /// <param name="type"></param>
 private void AddFilterDefinition(string field, 
     string columnName,
     snorbert.Global.FilterType type)
 {
     FilterDefinition fd = new FilterDefinition();
     fd.Field = field;
     fd.ColumnName = columnName;
     fd.Type = type;
     _filterDefinitions.Add(fd);
 }