Example #1
0
        /// <summary>
        /// Gets a list of components from a single message by ID
        /// </summary>
        /// <param name="m">The message to search</param>
        /// <param name="ID">The ID of the component to pull</param>
        /// <returns>Returns the list of components</returns>
        public static List <Component> GetByID(this Message m, string ID)
        {
            if (!String.IsNullOrEmpty(ID))
            {
                ComponentID      cid         = ID.ConvertID();
                List <Component> returnValue = new List <Component>();
                var items = from com in m.Segments.Get(cid.SegmentName) where com.GetByID(ID) != null select com.GetByID(ID);

                foreach (Component c in items)
                {
                    returnValue.Add(c);
                }
                return(returnValue);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// Gets a single component from a single message by ID and with the specified value
        /// </summary>
        /// <param name="m">The message to search</param>
        /// <param name="ID">The ID of the component to pull</param>
        /// <param name="ValueString">The value of the component to search for</param>
        /// <returns>The component returned</returns>
        public static Component GetByID(this Message m, string ID, string ValueString)
        {
            Component returnValue = new Component();

            if (!String.IsNullOrEmpty(ID))
            {
                ComponentID    cid      = ID.ConvertID();
                List <Segment> segments = m.Segments.Get(cid.SegmentName);
                foreach (Segment s in segments)
                {
                    Component c = s.GetByID(ID);
                    if (ValueString.ToUpper() == "NULL")
                    {
                        if (c != null && String.IsNullOrEmpty(c.Value))
                        {
                            returnValue = c;
                        }
                    }
                    else if (ValueString.ToUpper() == "!NULL")
                    {
                        if (c != null && !String.IsNullOrEmpty(c.Value))
                        {
                            returnValue = c;
                        }
                    }
                    else
                    {
                        if (c != null && c.Value != null)
                        {
                            if (c.Value.ToUpper() == ValueString.ToUpper())
                            {
                                returnValue = c;
                            }
                        }
                    }
                }
            }
            return(returnValue);
        }