Ejemplo n.º 1
0
        public virtual bool DoParsingOfIncomingPage(string bookName, Page incomPage, ParsingArgs args)
        {
            Dictionary <string, int> columnNumbers = null;
            Book resultBook = CreateBookForResultData(args.TemplateFile);

            while (GetFirstOrNextColumns(incomPage, ref columnNumbers))
            {
                if (PositionToFirstRow(incomPage))
                {
                    do
                    {
                        if (args.WorkerArgs.Cancel)
                        {
                            return(false);
                        }
                        Dictionary <string, List <Dictionary <int, string> > > values = GatherValuesFromPage(incomPage, columnNumbers);
                        if (values != null)
                        {
                            WriteDataToBook(resultBook, values);
                        }
                        this.OnSetProgressValue(incomPage);
                        incomPage.CurrentRow++;
                    }while (!incomPage.IsEndPosition());
                }
            }
            if (!args.WorkerArgs.Cancel)
            {
                SaveCurrentBook(resultBook, args.ResultPath, bookName, incomPage.Name);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public virtual bool DoParsingWithDivisionVolumesOfIncomingPage(string bookName, Page incomPage, ParsingArgs args)
        {
            int tovarPos  = 1;
            int volumeNum = 1;
            Dictionary <string, int> columnNumbers = null;
            Book resultBook = CreateBookForResultData(args.TemplateFile);

            while (GetFirstOrNextColumns(incomPage, ref columnNumbers))
            {
                if (PositionToFirstRow(incomPage))
                {
                    do
                    {
                        if (args.WorkerArgs.Cancel)
                        {
                            return(false);
                        }
                        Dictionary <string, List <Dictionary <int, string> > > values = GatherValuesFromPage(incomPage, columnNumbers);
                        if (values != null)
                        {
                            WriteDataToBook(resultBook, values);
                        }
                        this.OnSetProgressValue(incomPage);
                        incomPage.CurrentRow++;

                        if (tovarPos == args.VolumeSize)
                        {
                            SaveCurrentBook(resultBook, args.ResultPath, bookName, incomPage.Name, volumeNum++, args.DigitNum);
                            resultBook = CreateBookForResultData(args.TemplateFile);
                            tovarPos   = 1;
                        }
                        else
                        {
                            tovarPos++;
                        }
                    }while (!incomPage.IsEndPosition());
                }
            }
            if (!args.WorkerArgs.Cancel)
            {
                if (tovarPos > 1)
                {
                    SaveCurrentBook(resultBook, args.ResultPath, bookName, incomPage.Name, volumeNum, args.DigitNum);
                }
                else
                {
                    resultBook.Close();
                }
            }

            return(true);
        }