public JsonResult Upload() { var resultList = new List <ViewDataUploadFilesResult>(); var CurrentContext = HttpContext; filesHelper.UploadAndShowResults(CurrentContext, resultList); JsonFiles files = new JsonFiles(resultList); ViewDataUploadFilesResult Result = resultList.ElementAt(resultList.Count - 1); upload_file_tb filedetail = new upload_file_tb() { upload_file_name = Result.name, deleted_status = 0, user_ref = Lib.Security.CurrentUserName, link = Result.url, created_at = DateTime.Now }; bool error = _uploadfile.Insert(filedetail); if (!error) { return(Json("Error")); } bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error")); } else { return(Json(files)); } }
public JsonResult Upload(int imgtmpid, int thumbw, int thumbh) { var resultList = new List <ViewDataUploadFilesResult>(); var currentContext = HttpContext; filesHelper.UploadAndShowResults(currentContext, resultList, thumbw, thumbh); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error ")); } else { var lst = new List <ImgTmpDetail>(); foreach (var item in files.files) { ImgTmpDetail model = new ImgTmpDetail(); model.FullImage = item.url; model.Thumbnail = item.thumbnailUrl; model.ImgTmpId = imgtmpid; lst.Add(model); } if (lst.Any()) { __db.ImgTmpDetail.AddRange(lst); __db.SaveChanges(); } return(Json(files)); } }
public IHttpActionResult Get(int id) { JsonFiles listOfFiles = filesHelper.GetFileList(id); ViewDataUploadFilesResult[] files = listOfFiles.files; return(Ok(files)); }
/// <summary> /// Get file list /// </summary> /// <param name="images"></param> /// <returns></returns> private static JsonFiles ParseResultFileList(IEnumerable <ProductImage> images) { var data = images.Select(UploadResult).ToList(); var files = new JsonFiles(data); return(files); }
/// <summary> /// Desc:To get all the files /// </summary> /// <returns></returns> public JsonFiles GetFileList() { try { var r = new List <FileUploadViewModel>(); String fullPath = Path.Combine(StorageRoot); if (Directory.Exists(fullPath)) { DirectoryInfo dir = new DirectoryInfo(fullPath); foreach (FileInfo file in dir.GetFiles()) { int SizeInt = unchecked ((int)file.Length); r.Add(UploadResult(file.Name, SizeInt, file.FullName)); } } JsonFiles files = new JsonFiles(r); return(files); } catch (Exception ex) { throw; } }
public JsonResult Upload(ICollection <string> listNames) { var R_Id = Request.Cookies["idCookie"].Values["r_id"]; string tempPath = "~/Upload/Temp/"; string serverMapPath = $"~/Upload/Menu/{R_Id}"; string UrlBase = $"/Upload/Menu/{R_Id}"; string StorageRoot = Path.Combine(HostingEnvironment.MapPath(serverMapPath)); if (!Directory.Exists(Server.MapPath(serverMapPath))) { DirectoryInfo di = Directory.CreateDirectory(Server.MapPath(serverMapPath)); } FilesHelper filesHelper = new FilesHelper(DeleteURL, DeleteType, StorageRoot, UrlBase, tempPath, serverMapPath, listNames); var resultList = new List <ViewDataUploadFilesResult>(); var CurrentContext = HttpContext; filesHelper.UploadAndShowResults(CurrentContext, resultList); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error ")); } else { return(Json(files)); } }
public JsonResult Upload() { SelectOptions select = new SelectOptions(); var resultList = new List <ViewDataUploadFilesResult>(); var CurrentContext = HttpContext; var httpRequest = CurrentContext.Request; foreach (String inputTagName in httpRequest.Files) { var headers = httpRequest.Headers; var file = httpRequest.Files[inputTagName]; select.Text = file.FileName; file_namelist.Add(select); } filesHelper.UploadAndShowResults(CurrentContext, resultList); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error ")); } else { return(Json(files)); } ViewBag.Liste = file_namelist; }
public static JsonFile GetFile(Type itemType) { var id = itemType.AssemblyQualifiedName ?? string.Empty; var jsonFile = JsonFiles.GetOrAdd(id, x => new JsonFile(itemType)); return(jsonFile); }
internal JsonRootFolder(MyNode node, string root) { if (Directory.GetDirectories(node.Path).Length > 0) { JsonFolders = new List <JsonFolder>(); } if (Directory.GetFiles(node.Path).Length > 0) { JsonFiles = new List <JsonFile>(); } foreach (MyNode myNode in node.Nodes) { if (!myNode.Checked) { continue; } if (myNode.TypeOfNode == MyNode.NodeType.Folder) { JsonFolders.Add(new JsonFolder(myNode, root)); } else { JsonFiles.Add(new JsonFile(myNode, root)); } } }
public async override void OnTick() { string value = String.Empty; List <int> eList = JsonFiles.LoadJSONList("EntryList"); SelectedCars = JsonFiles.LoadJSONList("QSelected"); List <int> fastList = JsonFiles.LoadJSONList("Fastest"); value = ""; if (eList != null && eList.Count > 0 && settings.CarPosition > 0 && settings.CarPosition <= eList.Count) { value = eList[settings.CarPosition - 1].ToString(); } int carNum = 0; Int32.TryParse(value, out carNum); await Connection.SetTitleAsync($"{value}"); if (carNum > 0) { bool isSel = false; foreach (var l in SelectedCars) { if (l == carNum) { isSel = true; break; } } bool isFast = false; foreach (var l in fastList) { if (l == carNum) { isFast = true; break; } } if (isSel) { Image newImg = Image.FromFile("Images\\BackQ.png"); await Connection.SetImageAsync(newImg, null, true); } else { if (isFast) { Image newImg = Image.FromFile("Images\\BackFast.png"); await Connection.SetImageAsync(newImg, null, true); } else { Image newImg = Image.FromFile("Images\\Back.png"); await Connection.SetImageAsync(newImg, null, true); } } } }
public void GetIdFromUrl() { var id = JsonFiles.IdFromUrl("http://swapi.dev/api/people/55/"); Assert.IsTrue(id == 55); id = JsonFiles.IdFromUrl("http://swapi.dev/api/people/55"); Assert.IsTrue(id == 55); }
public ActionResult Index() { JsonFiles listOfFiles = _filesHelper.GetFileList(); var model = new FilesViewModel() { Files = listOfFiles.files }; return(View("Index2", model)); }
public ActionResult Show() { JsonFiles ListOfFiles = filesHelper.GetFileList(); var model = new FilesViewModel() { Files = ListOfFiles.files }; return(View(model)); }
public ActionResult Show() { JsonFiles ListOfFiles = archivoHelper.GetFileList(); var model = new ArchivoView() { Files = ListOfFiles.files }; return(View(model)); }
public async Task <ActionResult> Upload(List <IFormFile> files) { var result = await _fileUploadUtilities.Handle(HttpContext, files, CancellationToken.None); var jsonFiles = new JsonFiles(result.FileResults); return(result.FileResults.Count == 0 ? Json("Error") : Json(jsonFiles)); }
public JsonResult Upload(FileDropViewModel model) { var userName = ""; var resultList = new List <ViewDataUploadFilesResult>(); try { userName = User.Identity.GetUserName(); var CurrentContext = HttpContext; //Lägg till kontroll att antal filer > 0 (kan ha stoppats av användarens webbläsare (?)) var request = CurrentContext.Request; var numFiles = request.Files.Count; if (numFiles <= 0) { throw new System.ArgumentException("Filer saknas vid uppladdning av fil."); } _filesHelper.UploadTemplateFileAndShowResults(CurrentContext, resultList, User.Identity.GetUserId(), userName); } catch (ArgumentException e) { ErrorManager.WriteToErrorLog("FileUploadController", "Upload", e.ToString(), e.HResult, User.Identity.Name); var errorModel = new CustomErrorPageModel { Information = "Filer saknas vid uppladdning av fil.", ContactEmail = ConfigurationManager.AppSettings["ContactEmail"], }; RedirectToAction("CustomError", new { model = errorModel }); } catch (Exception e) { Console.WriteLine(e); ErrorManager.WriteToErrorLog("FileUploadController", "Upload", e.ToString(), e.HResult, User.Identity.Name); var errorModel = new CustomErrorPageModel { Information = "Ett fel inträffade vid uppladdning av fil.", ContactEmail = ConfigurationManager.AppSettings["ContactEmail"], }; RedirectToAction("CustomError", new { model = errorModel }); } JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error")); } else { return(Json(files)); } }
public ActionResult Show() { string subFolder = Request.QueryString["subFolder"] != null ? HttpContext.Request.QueryString["subFolder"].ToString() : "user-files"; JsonFiles ListOfFiles = filesHelper.GetFileList(subFolder); var model = new FilesViewModel() { Files = ListOfFiles.files }; return(View(model)); }
public IActionResult GetAll() { // to keep it simple, we're not paginating results var data = JsonFiles.LoadAll <Person>(); return(Ok(new Response <List <Person> >() { Count = data.Count(), Data = data.ToList() })); }
public ActionResult Show() { FilesHelper filesHelper = new FilesHelper(DeleteURL, DeleteType, StorageRoot, UrlBase, tempPath, serverMapPath); JsonFiles ListOfFiles = filesHelper.GetFileList(); var model = new Models.FilesViewModel() { Files = ListOfFiles.files }; return(View(model)); }
public void init(string path) { JsonFiles.Clear(); CheckPath = path; using (StreamReader sr = new StreamReader(Path.Combine(path, "function.txt"), Encoding.UTF8)) { String text = sr.ReadToEnd(); JObject obj = JObject.Parse(text); GameDir = obj["GamePath"].ToObject <string>(); } }
public ActionResult Show(string tab, string documentType) { JsonFiles ListOfFiles = filesHelper.GetFileList(); var model = new FilesViewModel() { Files = ListOfFiles.files }; ViewBag.Document = documentType; ViewBag.Tab = tab; return(View(model)); }
public override void KeyPressed(KeyPayload payload) { // Used for long press //keyPressStart = DateTime.Now; //keyPressed = true; List <int> eList = JsonFiles.LoadJSONList("EntryList"); SelectedCars = JsonFiles.LoadJSONList("Selected"); string hotkey = "Numpad"; string value = ""; int carNum = 0; if (eList != null && eList.Count > 0 && settings.CarPosition > 0 && settings.CarPosition <= eList.Count) { value = eList[settings.CarPosition - 1].ToString(); } for (int i = 0; i < value.Length; i++) { HotkeyHandler.RunHotkey("{" + hotkey + value[i] + "}"); } Int32.TryParse(value, out carNum); if (carNum > 0) { bool isSel = false; foreach (var l in SelectedCars) { if (l == carNum) { isSel = true; break; } } HotkeyHandler.RunHotkey("{Multiply}"); if (!isSel) { HotkeyHandler.RunHotkey("{Add}"); SelectedCars.Add(carNum); } else { HotkeyHandler.RunHotkey("{Subtract}"); SelectedCars.Remove(carNum); } JsonFiles.SaveJSONList("Selected", SelectedCars); } Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed"); }
public async Task <ActionResult> Upload(FileUploadUpload.Command command) { command.HttpContext = HttpContext; var result = await _mediator.Send(command); // I think we can move this into the mediatr class. var jsonFiles = new JsonFiles(result.FileResults); return(result.FileResults.Count == 0 ? Json("Error") : Json(jsonFiles)); }
private JsonFiles getFileList(long forignKeyId) { var r = new List <ViewDataUploadFilesResult>(); IEnumerable <IFileUploadInfoDTO> list = fileUploadService.GetListFileInfo(forignKeyId); foreach (IFileUploadInfoDTO file in list) { r.Add(uploadResult(file.Id, file.Name, file.Size, file.Type)); } JsonFiles files = new JsonFiles(r); return(files); }
public ActionResult Show() { JsonFiles ListOfFiles = filesHelper.GetFileList(); //IEnumerable<FilloggDetaljDTO> historyFileList = _portalService.HamtaHistorikForKommun(1); var model = new FilesViewModel() { Files = ListOfFiles.files, //HistorikLista = historyFileList.ToList() }; return(View(model)); }
public IActionResult Add([FromForm] string UserName, [FromForm] string Rating) { //Returns true after the C:\Temp\database.json is appended. IF the file doesn't exist it creates. bool jsonCreated = JsonFiles.CreateJsonFile(UserName, Rating, Request.Form["Comments"]); if (jsonCreated) { //Show success message return(Ok(string.Format("database.json is appended with username {0}, rating {1}", UserName, Rating))); } else { //Show error message return(BadRequest("JSon File not created")); } }
public JsonResult Upload() { var resultList = new List<ViewDataUploadFilesResult>(); _filesHelper.UploadWholeFile(Request, resultList); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return Json("Error "); } //here save image file name by extions to retrive it other time return Json(files); }
public void ImportPeople() { JsonFiles.DeleteAllFiles <Person>(); var onlineClient = new StarWarsApiClient(HostOptions.Online); var localClient = new StarWarsApiClient(HostOptions.Local); var onlinePeople = onlineClient.GetAllPeopleAsync().Result; foreach (var p in onlinePeople) { localClient.CreatePerson(p).Wait(); } var localPeople = localClient.GetAllPeopleAsync().Result; Assert.IsTrue(onlinePeople.Count().Equals(localPeople.Count())); }
public async Task <ActionResult> Upload(int?id) { if (!id.HasValue) { return(NotFound()); } var result = await _fileUploadUtilities.Handle(HttpContext, HttpContext.Request.Form.Files.ToList(), CancellationToken.None); var list = result.FileResults.Select(p => new PictureViewModel(p, id.GetValueOrDefault())).ToList(); await _pictureService.InsertAllAsync(list); var jsonFiles = new JsonFiles(result.FileResults); return(result.FileResults.Count == 0 ? Json("Error") : Json(jsonFiles)); }
public JsonResult Upload(Guid productId) { var resultList = new List <ViewDataUploadFilesResult>(); var CurrentContext = HttpContext; filesHelper.UploadAndShowResults(CurrentContext, resultList, productId); JsonFiles files = new JsonFiles(resultList); bool isEmpty = !resultList.Any(); if (isEmpty) { return(Json("Error ")); } else { return(Json(files)); } }