public ActionResult Delete(string id) { CheckManager manager = new CheckManager(User.Identity.Name); try { string fileName = manager.GetFilePath(id); System.IO.File.Delete(fileName); } catch (Exception ex) { Infrastructure.Logger.Error(ex.ToString()); } return(RedirectToAction("Index")); }
public ActionResult File(string id) { Infrastructure.Logger.Info("Entering Download/File/{0}...", id); id = id + ".req"; try { //copy given file to user's directory string src = store.GetFilePath(id); string dst = Path.Combine( Infrastructure.GetUsersDirectory(User.Identity.Name), id); System.IO.File.Copy(src, dst); ViewBag.File = id; return(View()); } catch (Exception ex) { Infrastructure.Logger.Error(ex.ToString()); return(RedirectToAction("Index")); } }
public ActionResult Check(FormCollection collection) { try { CheckManager checkManager = new CheckManager(User.Identity.Name); List <string> filesToCheck = new List <string>(); if (String.IsNullOrEmpty(collection["filesToCheck"])) { Infrastructure.Logger.Error("Null to check files"); return(View()); } filesToCheck.AddRange(((string)collection["filesToCheck"]).Split(',')); List <string> reqFiles = new List <string>(); if (String.IsNullOrEmpty(collection["reqFiles"])) { Infrastructure.Logger.Error("Null req files"); return(View()); } reqFiles.AddRange(((string)collection["reqFiles"]).Split(',')); reqFiles = reqFiles .Select(x => checkManager.GetFilePath(x)) .ToList(); filesToCheck = filesToCheck .Select(x => checkManager.GetFilePath(x)) .ToList(); Infrastructure.Logger.Info("to check:" + String.Join(",", filesToCheck)); //!!! check collection values and add them if (ModelState.IsValid) { if (Request.Files.Count > 0) { foreach (HttpPostedFile file in Request.Files) { // add this file to current user string fileName = Path.Combine(Infrastructure.GetUsersDirectory(User.Identity.Name), file.FileName); //!!!check extension file.SaveAs(fileName); } } List <ReqFile> rqfiles = reqFiles.Select(f => new ReqFile(f)).ToList(); DocumentMatcher dm = new DocumentMatcher(rqfiles); List <CheckResult> results = new List <CheckResult>(); foreach (string fileName in filesToCheck) { FileToCheck fcheck = new FileToCheck(fileName); results.AddRange(dm.Check(fcheck)); Infrastructure.Logger.Info("After {0}: count is {1}", fileName, results.Count); } Infrastructure.Logger.Info("Message: " + results[0].ToString()); var model = new CheckResultModel() { Message = results[0].ToString().Split('\n').ToList(), ReqFile = Path.GetFileName(reqFiles[0]), DocxFile = Path.GetFileName(filesToCheck[0]) }; return(View("CheckResultView", model)); } } catch (Exception e) { Infrastructure.Logger.Error(e.ToString()); return(View()); } return(View()); }