[Route("api/file/load/{*folder?}")]//{username}")] public IHttpActionResult Load(string folder = "") { FTPabilitazioni utente = db.FTPabilitazioni.Where(e => e.ftpUser == User.Identity.Name).FirstOrDefault(); Boolean bCheck = false; if (utente == null) { return(Content(HttpStatusCode.NoContent, "Abilitazione non trovata")); } var nodes = new List <FtpModel>(); string sDir = "C:\\inetpub\\wwwroot\\FTP"; if (folder == "") { //FTPabilitazioni utente = db.FTPabilitazioni.Where(e => e.ftpUser == User.Identity.Name).FirstOrDefault(); nodes.Add(new FtpModel() { FileName = "FTP", Folder = "#", Type = "Folder", ReadWrite = "R" }); var data = DirSearch(sDir, nodes); } else { folder = folder.Replace("#/", ""); folder = folder.Replace('/', Path.DirectorySeparatorChar); string cartella = (sDir + "\\" + folder); string cartellaAttuale = cartella.Substring(sDir.Length + 1); string[] percorso = cartellaAttuale.Split(Path.DirectorySeparatorChar); string sRight; using (ExtranetDB dbContext = new ExtranetDB()) { string toCheck = percorso[0]; UserShares abilitazioni = dbContext.UserShares.Where(e => e.username == User.Identity.Name && e.SharePath == toCheck).FirstOrDefault(); if (abilitazioni != null) { bCheck = true; } sRight = abilitazioni.abilitazione; } if (bCheck == false) { return(Content(HttpStatusCode.NoContent, "404")); } DirectoryInfo nomeFolder = new DirectoryInfo(cartella); nodes.Add(new FtpModel() { FileName = nomeFolder.Name, Folder = folder, Type = "Folder", Size = GetDirectorySize(nomeFolder.FullName).ToString(), ReadWrite = sRight }); var data = DirSearch(cartella, nodes); } return(Ok(nodes));//, System.Web.Mvc.Jso.nRequestBehavior.AllowGet); }
//public ActionResult Download(string id) //{ // try // { // string filePath = id; // filePath = filePath.Substring(5); // filePath = filePath.Replace('/', '\\'); // // System.Diagnostics.Debugger.Break(); // //byte[] fileBytes = System.IO.File.ReadAllBytes(@"c:\folder\myfile.ext"); // byte[] fileBytes = System.IO.File.ReadAllBytes(@"C:\\inetpub\\wwwroot\\Condivisione\\" + filePath); // string fileName = filePath.Substring(filePath.LastIndexOf('\\') + 1); // return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName); // } // catch (System.Exception e) // { // Console.WriteLine(e.Message); // return View(); // } //} public ActionResult FTPmain() { using (ExtranetDB dbContext = new ExtranetDB()) { FTPabilitazioni utente = dbContext.FTPabilitazioni.Where(e => e.ftpUser == User.Identity.Name).FirstOrDefault(); //ICollection<UserShares> test = dbContext.UserShares.Where(e => e.username == utente.ftpUser).ToList(); //ICollection<UserShares> test2 = dbContext.UserShares.Where(e => e.username == User.Identity.Name).ToList(); var bubu = utente.UserShares; var tt = dbContext.Shares.Where(e => e.ShareID == 4).Select(e => e.UserShares).ToList(); //var bubu7 = dbContext.UserShares.Where(e => e.username == "paolo.oliva").ToList(); var yoghi = bubu.Select(e => e.Shares.SharePath).ToList(); } return(View()); }