Пример #1
0
 public IEnumerable <LogRowMismatch> Filter(LogRowMismatch entity, int page, int size)
 {
     return(Context.LogRowMismatches.Include(e => e.Import).Where(e =>
                                                                  (e.ImportId == entity.ImportId || 0 == entity.ImportId) &&
                                                                  (string.IsNullOrEmpty(entity.ThrownException) || e.ThrownException.Contains(entity.ThrownException)) &&
                                                                  (string.IsNullOrEmpty(entity.Row) || e.Row.Contains(entity.Row))
                                                                  ).OrderBy(e => e.OriginalRowNumber).ThenBy(e => e.ImportId).Skip(page * size).Take(size));
 }
Пример #2
0
        public bool TryCorrect(LogRowMismatch entity)
        {
            bool validRow = false;

            if (0 != entity.Id)
            {
                LogRow corrected = entity.TryConvert();
                if (validRow = (null != corrected))
                {
                    new LogRowService(Context).InsertOrUpdate(corrected);
                    entity.Corrected   = true;
                    entity.CorrectedAt = DateTime.Now;
                }
            }
            base.InsertOrUpdate(entity);
            return(validRow);
        }
Пример #3
0
        public Import ProcessFile(ClfContext context)
        {
            ImportService importService = new ImportService(context);

            importService.InsertOrUpdate(Import);

            List <string>         errors          = new List <string>();
            LogRowService         service         = new LogRowService(context);
            LogRowMismatchService mismatchService = new LogRowMismatchService(context);

            using (StreamReader file = new StreamReader(Import.FileName))
            {
                string line;
                while (null != (line = file.ReadLine()))
                {
                    try
                    {
                        Import.RowCount++;
                        service.InsertCollection(Model.LogRow.Parse(line, Import.Id, Import.RowCount));
                        Import.SuccessCount++;
                    }
                    catch (Exception ex)
                    {
                        Import.ErrorCount++;
                        errors.Add(line);
                        mismatchService.InsertCollection(LogRowMismatch.Parse(line, Import.Id, Import.RowCount, Import.ErrorCount, ex));
                    }
                }
            }
            if (Import.ErrorCount > 0)
            {
                Import.MismatchRowsFileName = Import.FileName + ".err";
                context.SaveChanges();
                using (StreamWriter file = File.CreateText(Import.MismatchRowsFileName))
                {
                    foreach (string line in errors)
                    {
                        file.WriteLine(line);
                    }
                    file.Flush();
                }
            }
            return(Import);
        }
Пример #4
0
 public IEnumerable <LogRowMismatch> Filter(LogRowMismatch entity, int page)
 {
     return(Filter(entity, page, ClfAppSettings.Current.PageSize));
 }
Пример #5
0
 public override IEnumerable <LogRowMismatch> Filter(LogRowMismatch entity)
 {
     return(Filter(entity, 0));
 }