public ActionResult ShowFilesFromUser(string ToUser) { var User = new Users(); var files = User.GetFiles(); var StringList = new List <string>(); var ToRList = new List <string>(); var byteList = new List <FilesCompressionElements>(); var counter = 0; foreach (FilesCompressionElements elements in files) { if ((elements.Transmitter == Request.Cookies["User"]["username"]) && (elements.Reciever == ToUser)) { StringList.Add(elements.direction); ToRList.Add("1"); } else { if ((elements.Transmitter == ToUser) && (elements.Reciever == Request.Cookies["User"]["username"])) { StringList.Add(elements.direction); ToRList.Add("0"); } } } foreach (string element in ToRList) { var File = new FilesCompressionElements(); File.Transmitter = ToRList[counter] == "1" ? Request.Cookies["User"]["username"] : ToUser; File.Reciever = ToRList[counter] == "1" ? ToUser : Request.Cookies["User"]["username"]; File.direction = StringList[counter]; byteList.Add(File); counter++; } return(View(byteList)); }
public ActionResult RecieveFile(HttpPostedFileBase postedFile) { var ToUser = Request.Form["UserList"].ToString(); bool Exists; string Paths = Server.MapPath("~/Files/"); Exists = Directory.Exists(Paths); if (!Exists) { Directory.CreateDirectory(Paths); } if (postedFile != null) { string rutaDirectorioUsuario = Server.MapPath(""); string ArchivoLeido = rutaDirectorioUsuario + Path.GetFileName(postedFile.FileName); Tree send = new Tree(); var fileName = Path.GetFileName(postedFile.FileName).Substring(0, Path.GetFileName(postedFile.FileName).IndexOf(".")); send.UserPaths(rutaDirectorioUsuario, fileName); postedFile.SaveAs(ArchivoLeido); Huffman HuffmanProcess = new Huffman(); diccionario = HuffmanProcess.LecturaArchivoCompresion(diccionario, ArchivoLeido, bufferLengt, ref ListaByte); lista = HuffmanProcess.OrdenamientoDelDiccionario(diccionario, lista, ListaByte); var FileElement = new FilesCompressionElements(); FileElement.direction = postedFile.FileName; FileElement.Reciever = ToUser; FileElement.Transmitter = Request.Cookies["User"]["username"]; var User = new Users(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:58992"); var postjob = client.PostAsync("api/FilesCompression", new StringContent(new JavaScriptSerializer().Serialize(FileElement), Encoding.UTF8, "application/json")); postjob.Wait(); } return(RedirectToAction("Arbol", new { rutaDirectorioUsuario, fileName })); } return(RedirectToAction("Index")); }
public void Post(FilesCompressionElements file) { files.Insertar(file); }
//Insertar public FilesCompressionElements Insertar(FilesCompressionElements file) { _files.InsertOne(file); return(file); }