Пример #1
0
 private static void build_list_list(Segment seg, SegmentLabel looplabel, ref List <Segment> subList, List <List <Segment> > listList)
 {
     if (seg.Label == looplabel && subList.Count > 0)
     {
         listList.Add(subList);
         subList = new List <Segment>();
     }
     subList.Add(seg);
 }
Пример #2
0
        /// <summary>
        /// When click on a segment, refresh color of other segments (Request tab)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnReqLabelSelectChanged(object sender, System.EventArgs e)
        {
            SegmentLabel lbl = (SegmentLabel)sender;

            foreach (var c in ctlPanelRequest.Controls)
            {
                SegmentLabel l = (SegmentLabel)c;
                if (l.IsSelected && !l.ID.Equals(lbl.ID))
                {
                    l.IsSelected = false;
                }
            }
        }
Пример #3
0
        private IEnumerable <IEdiInContainer> split(EdiSegmentCollection segments, SegmentLabel labelType,
                                                    SegmentLabel closeType, IEdiInContainer parentContainer)
        {
            IList <IEdiInContainer> returnList = new List <IEdiInContainer>();
            IList <Segment>         segs       = parentContainer.InnerSegments.ToList();

            segs = RemoveNullSegments(segs);
            var ctxtCount = segs.Where(s => s != null).ToList().Count(s => s.Label == labelType);

            for (int i = 0; i < ctxtCount; i++)
            {
                returnList.Add(parentContainer.CreateChild(extract(new EdiSegmentCollection(segs, segments.ElementDelimiter), labelType, closeType, i)));
            }
            return(returnList);
        }
Пример #4
0
        private CustomerOrderLine build_line(List <Segment> lst, SegmentLabel terminator)
        {
            var nextSeg      = lst.FirstOrDefault();
            var segmentCount = 0;

            if (nextSeg == null)
            {
                return(null);
            }
            if (nextSeg.Label.Text == terminator.Text)
            {
                return(null);
            }
            CustomerOrderLine lineItem = _poParser.CreateLine(nextSeg);

            if (lineItem == null)
            {
                return(null);
            }
            lst.Remove(nextSeg);

            lineItem.ItemId = "";

            IEnumerable <Segment> remainingSegments = lst.TakeWhile(seg => seg.Label == SegmentLabel.ReferenceLabel ||
                                                                    seg.Label == SegmentLabel.ScheduleLabel);

            var line = remainingSegments.BuildInnerResponse(lineItem.LineNumber);

            segmentCount += line.ResponseElements.Count();

            line.ResponseElements.Add(new LineResponseElementEntity {
                ElementName = "PO1", Qualifier = "IN", Value = lineItem.CustomerPartNumber.SafeTrim()
            });

            _lines.Add(line);

            segmentCount += process_schedules(remainingSegments);

            lst.RemoveRange(0, segmentCount);

            _poParser.SegmentCount += segmentCount;

            return(lineItem);
        }
Пример #5
0
        private static EdiSegmentCollection extract(EdiSegmentCollection segments, SegmentLabel labelType, SegmentLabel closeType, int ndx)
        {
            IList <Segment> lst;
            var             segs = segments.SegmentList.ToList();

            lst = getPreviousSegmentsToStrip(segments, closeType, ndx, labelType);


            lst.ToList().ForEach(segment => segs.Remove(segment));


            if (segs.Count == 0)
            {
                throw new Exception(string.Format("{0} label was missing!", labelType));
            }

            var close_seg = segs.First();

            if (ndx > 0)
            {
                segs.Remove(close_seg);
            }

            lst = segs.TakeWhile(s => s.Label.Value != closeType.Value).ToList();

            lst.ToList().ForEach(segment => segs.Remove(segment));

            if (segs.Count == 0)
            {
                throw new Exception(string.Format("{0} label was missing!", labelType));
            }

            close_seg = segs.First();

            if (close_seg.Label != closeType)
            {
                throw new Exception("This should never happen!");
            }


            lst.Add(close_seg);
            return(new EdiSegmentCollection(lst, segments.ElementDelimiter));
        }
Пример #6
0
        /// <summary>
        /// Add new segment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ctlBtnAdd_Click(object sender, System.EventArgs e)
        {
            SegmentLabel lbl = new SegmentLabel();

            if (ctlTabProtocol.SelectedIndex == 0)
            {
                lbl.DataSegment.Name = "Request dat " + mEditingProtocol.ReqSegments.Count;
                lbl.OnSelected      += new EventHandler(OnReqLabelSelectChanged);

                ctlPanelRequest.Controls.Add(lbl);
                mEditingProtocol.ReqSegments.Add(lbl.DataSegment);
            }
            else
            {
                lbl.DataSegment.Name = "Response dat " + mEditingProtocol.RepSegments.Count;
                lbl.OnSelected      += new EventHandler(OnRepLabelSelectChanged);

                ctlPanelResponse.Controls.Add(lbl);
                mEditingProtocol.RepSegments.Add(lbl.DataSegment);
            }
        }
Пример #7
0
 public static Segment FindSegmentByLabel(this IEnumerable <Segment> segs,
                                          SegmentLabel labelValue)
 {
     return(segs.Find(seg => seg.Label == labelValue));
 }
Пример #8
0
 public static IEnumerable <Segment> FindSegmentsByLabel(this IEnumerable <Segment> segs,
                                                         SegmentLabel labelValue)
 {
     return(segs.Where(seg => seg.Label == labelValue));
 }
Пример #9
0
        public static bool MoveSegmentByLabel(List <Segment> source, List <Segment> dest, SegmentLabel lbl)
        {
            Segment temp_seg = source.FindSegmentByLabel(lbl);

            if (temp_seg == null)
            {
                return(false);
            }
            dest.Add(temp_seg);
            source.Remove(temp_seg);
            return(true);
        }
Пример #10
0
        private static IList <Segment> getPreviousSegmentsToStrip(EdiSegmentCollection segments, SegmentLabel closeType, int ndx, SegmentLabel labelType)
        {
            IList <Segment> lst;

            try
            {
                int counter = 0;
                lst = segments.SegmentList.TakeWhile(s =>
                {
                    if (s.Label == closeType)
                    {
                        counter++;
                    }
                    return(counter < ndx);
                }).ToList();
            }
            catch
            {
                throw new Exception(string.Format("{0} label was missing!", labelType));
            }
            return(lst);
        }
Пример #11
0
 public Segment FirstWith(SegmentLabel label)
 {
     return(SegmentList.FindSegmentByLabel(label));
 }
Пример #12
0
 public static SegmentLabel GetSegmentLabel(this string str)
 {
     return(SegmentLabel.FromText <SegmentLabel>(str));
 }