예제 #1
0
        public async Task <Result <bool> > ProcessList(string file)
        {
            Result <bool> result = new Result <bool>();
            var           str    = _serviceFile.ReadFile(file).Skip(1);
            var           t      = await _serviceFile.GetTypeData(file).ConfigureAwait(false);

            return(await Task.Run(() =>
            {
                try
                {
                    if (t.Title == "Поиск по ИФНС")
                    {
                        FoundIfns(str);
                    }
                    else if (t.Title == "Поиск по мун. образованию")
                    {
                        FoundMun(str);
                    }
                    else
                    {
                        throw new Exception("Неверный тип данных");
                    }
                }
                catch (FormatException fex)
                {
                    result.ErrorResult = new ErrorResult(fex.Message, EnumTypeError.ErrorFileFormat);
                }
                catch (Exception ex)
                {
                    result.ErrorResult = new ErrorResult(ex.Message, EnumTypeError.ErrorSite);
                }

                return result;
            }));
        }
예제 #2
0
        public async Task <Result <RequestFound> > ProcessingList(string file)
        {
            Result <RequestFound> result = new Result <RequestFound>();

            return(await Task.Run(async() =>
            {
                try
                {
                    var str = _serviceFile.ReadFile(file).Skip(1);

                    var t = await _serviceFile.GetTypeData(file).ConfigureAwait(false);
                    var fileName = CreateFileOffice.GetUniqueOnlyFileName(file);

                    if (t.Title == "Физические лица")
                    {
                        await FoundGroopPerson(fileName, str).ConfigureAwait(false);
                    }
                    else if (t.Title == "Юридические лица")
                    {
                        await FoundGroopCompany(fileName, str).ConfigureAwait(false);
                    }
                    else if (t.Title == "Номера исполнительных производств")
                    {
                        await FoundGroopNumber(fileName, str).ConfigureAwait(false);
                    }
                    else
                    {
                        throw new Exception("Неверный тип данных");
                    }
                }
                catch (FormatException fex)
                {
                    result.ErrorResult = new ErrorResult(fex.Message, EnumTypeError.ErrorFileFormat);
                }
                catch (Exception ex)
                {
                    result.ErrorResult = new ErrorResult(ex.Message, EnumTypeError.ErrorSite);
                }

                return result;
            }).ConfigureAwait(false));
        }