/// <summary> /// <strong> only release mode will ignore other will throw exception </strong> /// </summary> private Pdf1099K ExtractFile(KeyValuePair <string, string> file, Extract1099KEntities ctx) { Pdf1099K file1099k = null; #if (!DEBUG) try { #endif string content = FileUtil.GetPdfContent(file.Value); // file1099k = File1099KParser.Parse(content); file1099k = _parser.Parse <Pdf1099K>(content); file1099k.FileName = file.Key; file1099k.FileLocation = file.Value; file1099k.PDFContent = File.ReadAllBytes(file.Value); file1099k.Save(ctx, "Steven Wu"); logger.Info($"File {file.Key} extract succeed! ID: {file1099k.ID}"); #if (!DEBUG) } catch (Exception ex) { logger.Info($"Extract file {file.Key} failed check log file for more detail!"); logger.Error(ex, $"=========== Extract *{file.Key}* failed exception==========="); ctx.SaveChanges(); } #endif return(file1099k); }
public void NewInMemoryObjctUpdateTest() { var x = Pdf1099K.GetByTaxYearAndID(2012, "113019324").FirstOrDefault(); var newObj = new Pdf1099K { TaxYear = x.TaxYear, FileName = x.FileName, TaxID = x.TaxID, AccountNum = x.AccountNum, FederalID = x.FederalID, FileLocation = x.FileLocation, PDFContent = x.PDFContent }; newObj.Save(); Assert.AreEqual(x.ID, newObj.ID); Assert.IsTrue(DateTime.Now.Subtract(newObj.UpdateAt.Value) < TimeSpan.FromSeconds(3)); }