Ejemplo n.º 1
0
 // Parse: ClaimFiles/Parse/5
 public ActionResult Parse(int?id)
 {
     try
     {
         ParsedViewModel pvm = new ParsedViewModel();
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         ClaimFile claimFile = db.ClaimFiles.Find(id);
         if (claimFile == null)
         {
             return(HttpNotFound());
         }
         string _FileName = claimFile.Filename;
         string _path     = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
         string sSource   = System.IO.File.ReadAllText(_path);
         pvm.cf    = claimFile;
         pvm.cf.fh = claimFile.Parse(sSource);
         Thread.Sleep(1000);
         SavePVMToDB(pvm);
         db                = new FESContext();
         claimFile         = db.ClaimFiles.Find(id);
         claimFile.Parsed  = true;
         claimFile.DocType = pvm.cf.fh.lsdch[0].ClaimType;
         if (claimFile != null)
         {
             try
             {
                 db.ClaimFiles.Attach(claimFile);
                 db.Entry(claimFile).State = EntityState.Modified;
                 db.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw;
             }
         }
         return(Request.IsAjaxRequest()
             ? (ActionResult)PartialView("FileList", db.ClaimFiles.ToList())
             : RedirectToAction("index"));
         //return View(pvm);
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "ClaimFiles", "Index")));
     }
 }
Ejemplo n.º 2
0
 private Boolean Parse(int?id, string sPath)
 {
     try
     {
         ParsedViewModel pvm = new ParsedViewModel();
         if (id == null)
         {
             return(false);
         }
         ClaimFile claimFile = db.ClaimFiles.Find(id);
         if (claimFile == null)
         {
             return(false);
         }
         string sSource = System.IO.File.ReadAllText(sPath);
         pvm.cf    = claimFile;
         pvm.cf.fh = claimFile.Parse(sSource);
         SavePVMToDB(pvm);
         db                = new FESContext();
         claimFile         = db.ClaimFiles.Find(id);
         claimFile.Parsed  = true;
         claimFile.DocType = pvm.cf.fh.lsdch[0].ClaimType;
         if (claimFile != null)
         {
             try
             {
                 db.ClaimFiles.Attach(claimFile);
                 db.Entry(claimFile).State = EntityState.Modified;
                 db.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }