public void Load() { DirectoryInfo d = new DirectoryInfo(ConfigurationManager.AppSettings["ProcessPath"]); foreach (FileInfo f in d.GetFiles()) { try { ClaimFile c = new ClaimFile(); c.Parsed = false; c.Filename = f.Name; c.FileSize = f.Length.ToString(); c.ts = DateTime.Now; db.ClaimFiles.Add(c); db.SaveChanges(); c = db.ClaimFiles.Where(x => x.Filename == f.Name).Single(); if (Parse(c.FileID, f.FullName)) { f.Delete(); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public async Task Delete(ClaimFile file) { var fileDb = file.Adapt <ClaimFileDB>(); applicationDbContext.Remove(fileDb); applicationDbContext.SaveChanges(); }
public ActionResult Create(Claim claim) { if (ModelState.IsValid) { List <ClaimFile> claimfiles = new List <ClaimFile>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); ClaimFile claimFile = new ClaimFile() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid() }; claimfiles.Add(claimFile); var path = Path.Combine(Server.MapPath("~/App_Data/Upload/"), claimFile.Id + claimFile.Extension); file.SaveAs(path); } } claim.ClaimFiles = claimfiles; _context.Claims.Add(claim); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(claim)); }
// ClaimInfo: ClaimFiles/ClaimInfo public ActionResult ClaimInfo(int FileID, int recordsequence, string FileVersion, ClaimLayoutType ClaimLayout, string DCN) { try { ParsedViewModel pvm = new ParsedViewModel(); ClaimFile claimFile = db.ClaimFiles.Find(FileID); if (claimFile == null) { return(HttpNotFound()); } int iFileID = FileID; pvm.cf = claimFile; pvm.cf.fh = new FileHeader(iFileID); pvm.cf.fh.lsdch = new List <ClaimHeader>(); pvm.lsCHTVM = new List <ClaimHeaderTableViewModel>(); ClaimHeader ch = new ClaimHeader(FileID, recordsequence, FileVersion, DCN); PaperHeader ph = new PaperHeader(FileID, recordsequence + 1, FileVersion, ClaimLayout); ch.ph = ph; ch.lscd = new List <ClaimDetail>(); for (int x = 0; x < ch.NumberofDetails; x++) { int iCDRecordSeq = recordsequence + 2 + (x * 2); ClaimDetail cd = new ClaimDetail(FileID, iCDRecordSeq, FileVersion, ClaimLayout); ch.lscd.Add(cd); } pvm.cf.fh.lsdch.Add(ch); return(View(pvm)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "ClaimFiles", "Index"))); } }
// Details: ClaimFiles/Details/5 public ActionResult Details(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()); } int iFileID = (int)id; pvm.cf = claimFile; pvm.cf.fh = new FileHeader(iFileID); pvm.cf.fh.lsdch = new List <ClaimHeader>(); pvm.lsCHTVM = new List <ClaimHeaderTableViewModel>(); List <FileFieldValue> lsClaims = db.FileFieldValues.Where(x => x.FileID == id && x.recordType == RecordType.ClaimHeader).ToList(); for (int i = 0; i < pvm.cf.fh.NumberofClaims; i++) { int iMinRecordSequence = lsClaims.Min(x => x.recordSequence); List <FileFieldValue> lsClaim = lsClaims.Where(x => x.recordSequence == iMinRecordSequence).ToList(); var ffvct = (from c in db.FileFieldValues join f in db.Fields on c.FieldID equals f.FieldID where f.Name == "STD_BATCH_TYPE_CODE" && c.FileID == iFileID && c.recordType == RecordType.ClaimHeader && c.recordSequence == iMinRecordSequence select new { value = c.value }); string sClaimTypeCode = ffvct.First().value; ClaimLayoutType clt = Utility.GetCLT(sClaimTypeCode); Field fDCN = db.Fields.Where(x => x.RecordType == RecordType.PaperHeader && x.ClaimType == clt && x.FileVersion == pvm.cf.fh.FileVersion && x.Name.Trim().ToUpper() == "ENDORSEMENT NUMBER").Single(); FileFieldValue ffvDCN = db.FileFieldValues.Where(x => x.FieldID == fDCN.FieldID && x.FileID == id && x.recordSequence == iMinRecordSequence + 1).Single(); ClaimHeaderTableViewModel chtvm = new ClaimHeaderTableViewModel(iFileID, pvm.cf.fh.FileVersion, ffvDCN.value, sClaimTypeCode, iMinRecordSequence); pvm.lsCHTVM.Add(chtvm); foreach (FileFieldValue ffv in lsClaim) { lsClaims.Remove(ffv); } } return(View(pvm)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "ClaimFiles", "Index"))); } }
// GET: ClaimFiles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClaimFile claimFile = db.ClaimFiles.Find(id); if (claimFile == null) { return(HttpNotFound()); } return(View(claimFile)); }
// 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"))); } }
public async Task <long> Upload(ClaimFile file) { try { var fileDb = file.Adapt <ClaimFileDB>(); applicationDbContext.Add(fileDb); applicationDbContext.SaveChanges(); return(fileDb.Id); } catch (Exception ex) { throw; } }
public ActionResult DeleteConfirmed(int id) { try { ClaimFile claimFile = db.ClaimFiles.Find(id); //string _FileName = claimFile.Filename; //string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); //System.IO.File.Delete(_path); db.Database.ExecuteSqlCommand("Delete FileFieldValues where FileID =" + claimFile.FileID.ToString()); db.Database.ExecuteSqlCommand("Delete ClaimFiles where FileID =" + claimFile.FileID.ToString()); return(RedirectToAction("Index")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "ClaimFiles", "Index"))); } }
public JsonResult CreatePost() { ClaimFile claimFile = new ClaimFile(); if (Request.Files.Count == 1) { HttpFileCollectionBase files = Request.Files; HttpPostedFileBase file = files[0]; try { if (file.ContentLength > 0) { Utility.SendProgress("Uploading File " + Path.GetFileName(file.FileName), 1, 2); string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); Utility.SendProgress("Uploading File " + Path.GetFileName(file.FileName), 2, 2); FileInfo f = new FileInfo(_path); ClaimFile c = new ClaimFile(); c.Parsed = false; c.Filename = f.Name; c.FileSize = f.Length.ToString(); c.ts = DateTime.Now; db.ClaimFiles.Add(c); db.SaveChanges(); c = db.ClaimFiles.Where(x => x.Filename == f.Name).Single(); Thread.Sleep(1000); Parse(c.FileID); f.Delete(); } return(Json(Url.Action("Index", "ClaimFiles"))); } catch (Exception e) { Utility.SendProgress("Uploading File " + Path.GetFileName(file.FileName), 2, 2); throw e; } } else { return(Json("You must select 1 file.")); } }
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); } }
public async Task <long> Upload(ClaimFile file) { return(await claimFileRepository.Upload(file)); }
public async Task Delete(ClaimFile claimFile) { await claimFileRepository.Delete(claimFile); }