예제 #1
0
        public string FormatRecord(D900CdrElement record)
        {
            IList<D900CdrElement> childs = record.GetAllChilds();
            if ((childs == null) || (childs.Count == 0)) return String.Empty;

            StringBuilder builder = new StringBuilder();
            FormatterColumn column;
            string fieldValue;

            for (int i = 0; i < _settings.ColumnCount; i++)
            {
                column = _settings.GetColumnAt(i);
                fieldValue = String.Empty;
                foreach (D900CdrElement element in childs)
                {
                    if (String.Equals(element.Path, column.Definition.Path))
                    {
                        if (!String.IsNullOrEmpty(fieldValue))
                        {
                            fieldValue = String.Format("{0} | {1}", fieldValue, element.Parselet.Value(column.Definition.ValueType, element));
                        }
                        else
                        {
                            fieldValue = element.Parselet.Value(column.Definition.ValueType, element);
                        }
                    }
                }

                builder.AppendFormat(_settings.Format, fieldValue);
            }
            return builder.ToString();
        }
예제 #2
0
        public static D900CdrElement CreateFromTlv(TlvObject tlv)
        {
            D900CdrElement element = new D900CdrElement();

            element._offset        = tlv.Offset;
            element._path          = tlv.Path;
            element._name          = tlv.Path;
            element._isConstructed = tlv.IsConstructed;
            if (!tlv.IsEmpty)
            {
                if (tlv.IsConstructed)
                {
                    List <D900CdrElement> val = new List <D900CdrElement>((tlv.Value as List <TlvObject>).Count);
                    foreach (TlvObject ch in (tlv.Value as List <TlvObject>))
                    {
                        val.Add(D900CdrElement.CreateFromTlv(ch));
                    }
                    ;
                    element._value = val;
                }
                else
                {
                    byte[] src = (tlv.Value as byte[]);
                    byte[] dst = new byte[src.Length];
                    Array.Copy(src, dst, src.Length);
                    element._value = dst;
                }
            }

            return(element);
        }
예제 #3
0
        private void ParseElement(D900CdrElement element)
        {
            ID900CdrElementDefinition elementDef = DefinitionProvider.FindDefinition(element.Path);
            if (elementDef != null)
            {
                if (elementDef.Name.Length != 0)
                {
                    element.Name = elementDef.Name;
                }

                if (elementDef.Parselet.Length > 0)
                {
                    ID900Parselet parselet = ParseletProvider.FindParselet(elementDef.Parselet);
                    if (parselet != null)
                    {
                        element.Parselet = parselet;
                        element.DefaultValueType = elementDef.ValueType;
                    }
                }
            }

            if (element.Parselet == null && !element.IsConstructed)
            {
                element.Parselet = D900ParseletProvider.Instance.FindParselet("GenericParselet");
            }

            if ((element.IsConstructed) && (!element.IsEmpty))
            {
                foreach (D900CdrElement e in (element.Value as List<D900CdrElement>))
                {
                    this.ParseElement(e);
                }
            }
        }
예제 #4
0
        protected void CheckElement(D900CdrElement element, ElementsStatTable tablePresent, ElementsStatTable tableNone)
        {
            if (element.Path.Equals(element.Name) || (element.Name.Length == 0))
            {
                if (tableNone.ContainsKey(element.Path))
                {
                    tableNone[element.Path]++;
                }
                else
                {
                    tableNone.Add(element.Path, 1);
                }
            }
            else
            {
                if (tablePresent.ContainsKey(element.Path))
                {
                    tablePresent[element.Path]++;
                }
                else
                {
                    tablePresent.Add(element.Path, 1);
                }
            }

            if (element.IsConstructed && !element.IsEmpty)
            {
                foreach (D900CdrElement child in (element.Value as List <D900CdrElement>))
                {
                    CheckElement(child, tablePresent, tableNone);
                }
            }
        }
예제 #5
0
        private void ParseElement(D900CdrElement element)
        {
            ID900CdrElementDefinition elementDef = DefinitionProvider.FindDefinition(element.Path);

            if (elementDef != null)
            {
                if (elementDef.Name.Length != 0)
                {
                    element.Name = elementDef.Name;
                }

                if (elementDef.Parselet.Length > 0)
                {
                    ID900Parselet parselet = ParseletProvider.FindParselet(elementDef.Parselet);
                    if (parselet != null)
                    {
                        element.Parselet         = parselet;
                        element.DefaultValueType = elementDef.ValueType;
                    }
                }
            }

            if (element.Parselet == null && !element.IsConstructed)
            {
                element.Parselet = D900ParseletProvider.Instance.FindParselet("GenericParselet");
            }

            if ((element.IsConstructed) && (!element.IsEmpty))
            {
                foreach (D900CdrElement e in (element.Value as List <D900CdrElement>))
                {
                    this.ParseElement(e);
                }
            }
        }
예제 #6
0
        public D900CdrElement DecodeRecord(Stream asnStream, bool skipFillers)
        {
            TlvObject tlv;
            long      offset = asnStream.Position;

            // Verify that the next byte - Billing Record Tag (0xE1)
            if (!skipFillers)
            {
                int b = asnStream.ReadByte();
                if (b != 0xE1)
                {
                    return(null);
                }
                asnStream.Seek(-1, SeekOrigin.Current);
            }

            BerDecoderResult pr = DecodeTlv(asnStream, out tlv, ref offset, 0, byte.MaxValue);

            D900CdrElement record = null;

            if (pr == BerDecoderResult.Finished)
            {
                record = _tlvParser.ParseTlvObject(tlv);;
            }

            return(record);
        }
예제 #7
0
        public D900CdrElement ParseTlvObject(TlvObject tlv)
        {
            D900CdrElement element = D900CdrElement.CreateFromTlv(tlv);

            this.ParseElement(element);

            return(element);
        }
예제 #8
0
        public string FormatRecord(D900CdrElement record)
        {
            IList <D900CdrElement> childs = record.GetAllChilds();

            if ((childs == null) || (childs.Count == 0))
            {
                return(String.Empty);
            }

            StringBuilder   builder = new StringBuilder();
            FormatterColumn column;
            string          fieldValue;

            for (int i = 0; i < _settings.ColumnCount; i++)
            {
                column     = _settings.GetColumnAt(i);
                fieldValue = String.Empty;
                foreach (D900CdrElement element in childs)
                {
                    if (String.Equals(element.Path, column.Definition.Path))
                    {
                        if (!String.IsNullOrEmpty(fieldValue))
                        {
                            fieldValue = String.Format("{0} | {1}", fieldValue, element.Parselet.Value(column.Definition.ValueType, element));
                        }
                        else
                        {
                            fieldValue = element.Parselet.Value(column.Definition.ValueType, element);
                        }
                    }
                }

                builder.AppendFormat(_settings.Format, fieldValue);
            }
            return(builder.ToString());
        }
        protected void CheckElement(D900CdrElement element, ElementsStatTable tablePresent, ElementsStatTable tableNone)
        {
            if (element.Path.Equals(element.Name) || (element.Name.Length == 0))
            {
                if (tableNone.ContainsKey(element.Path))
                {
                    tableNone[element.Path]++;
                }
                else
                {
                    tableNone.Add(element.Path, 1);
                }
            }
            else
            {
                if (tablePresent.ContainsKey(element.Path))
                {
                    tablePresent[element.Path]++;
                }
                else
                {
                    tablePresent.Add(element.Path, 1);
                }
            }

            if (element.IsConstructed && !element.IsEmpty)
            {
                foreach (D900CdrElement child in (element.Value as List<D900CdrElement>))
                    CheckElement(child, tablePresent, tableNone);
            }
        }
예제 #10
0
        public static D900CdrElement CreateFromTlv(TlvObject tlv)
        {
            D900CdrElement element = new D900CdrElement();
            element._offset = tlv.Offset;
            element._path = tlv.Path;
            element._name = tlv.Path;
            element._isConstructed = tlv.IsConstructed;
            if (!tlv.IsEmpty)
            {
                if (tlv.IsConstructed)
                {
                    List<D900CdrElement> val = new List<D900CdrElement>((tlv.Value as List<TlvObject>).Count);
                    foreach (TlvObject ch in (tlv.Value as List<TlvObject>))
                    {
                        val.Add(D900CdrElement.CreateFromTlv(ch));
                    };
                    element._value = val;
                }
                else
                {
                    byte[] src = (tlv.Value as byte[]);
                    byte[] dst = new byte[src.Length];
                    Array.Copy(src, dst, src.Length);
                    element._value = dst;
                }
            }

            return element;
        }