Пример #1
0
        public virtual void AssignDetail(Map map, List <Page> pageDetails, List <Page> pageRemittances)
        {
            var mapDetail     = map.MapDetail;
            var mapRemittance = map.MapRemittance;

            if (mapDetail == null)
            {
                return;
            }
            foreach (var pageDetail in pageDetails)
            {
                var fromRow = mapDetail.FromLine - 1;
                var toRow   = mapDetail.ToLine;
                if (toRow == 0)
                {
                    toRow = pageDetail.Rows.Count;
                }
                var rows = pageDetail.Rows;

                for (var rowIndex = fromRow; rowIndex < toRow; rowIndex++)
                {
                    // omit Empty/Blank Lines
                    if (string.IsNullOrEmpty(rows[rowIndex].Trim()))
                    {
                        continue;
                    }

                    if (mapDetail.BreakDetailLineCondition.Count > 0 &&
                        PsTool.CheckCondition(mapDetail.BreakDetailLineCondition, rows[rowIndex]))
                    {
                        break;
                    }

                    if (mapDetail.RecognizeDetailLineCondition.Count > 0 &&
                        PsTool.CheckCondition(mapDetail.RecognizeDetailLineCondition, rows[rowIndex]))
                    {
                        AssignDetailLine(map, mapDetail, rows[rowIndex]);
                    }


                    if (mapDetail.RecognizeDetailLineCondition.Count == 0)
                    {
                        // for one line one payment with out no condition to recongnize any detail
                        AssignDetailLine(map, mapDetail, rows[rowIndex], "");
                    }
                }
            }
            if (pageDetails.Count > 0 &&
                mapRemittance != null && pageRemittances != null && pageRemittances.Count > 0)
            {
                AssignDetailFromRemitFile(map, pageDetails[0], pageRemittances);
            }
        }
Пример #2
0
        public virtual void AssignDetailFromRemitFile(Map map, Page sourcePage, List <Page> pageRemittances)
        {
            var mapRemittance = map.MapRemittance;
            // Get information of link field between Check file and Remit file
            var linkFieldInfo = map.MapHeader.MapFields.FirstOrDefault(e => e.FieldName == mapRemittance.LinkFieldName);
            var keyFieldValue = sourcePage.Rows[linkFieldInfo.Line - 1].TMid(linkFieldInfo.Start, linkFieldInfo.Length);

            // Get pages of remit(depend) file that exist in check(master) file
            var remitPages = pageRemittances.Where(r => r.Key == keyFieldValue).ToList();

            if (!remitPages.Any())
            {
                return;
            }
            foreach (var remitPage in remitPages)
            {
                int fromRow = mapRemittance.DetailFromLine - 1;
                var toRow   = mapRemittance.DetailToLine;
                if (toRow == 0)
                {
                    toRow = remitPage.Rows.Count;
                }

                var rows = remitPage.Rows;

                for (int rowIndex = fromRow; rowIndex < toRow; rowIndex++)
                {
                    // omit Empty/Blank Lines
                    if (string.IsNullOrEmpty(rows[rowIndex].Trim()))
                    {
                        continue;
                    }

                    // Detail main and comment has same codition
                    if (mapRemittance.BreakDetailLineCondition.Count > 0 &&
                        PsTool.CheckCondition(mapRemittance.BreakDetailLineCondition, rows[rowIndex]))
                    {
                        break;
                    }

                    // Detail main/ Detail Comment
                    if (mapRemittance.RecognizeDetailLineCondition.Count > 0 &&
                        PsTool.CheckCondition(mapRemittance.RecognizeDetailLineCondition, rows[rowIndex]))
                    {
                        AssignDetailLineFromRemitFile(map, rows[rowIndex]);
                    }
                    if (mapRemittance.RecognizeDetailLineCondition.Count == 0)
                    {
                        AssignDetailLineFromRemitFile(map, rows[rowIndex]);
                    }
                }
            }
        }