コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        public IHttpActionResult Get(int id)
        {
            JsonFiles listOfFiles = filesHelper.GetFileList(id);

            ViewDataUploadFilesResult[] files = listOfFiles.files;
            return(Ok(files));
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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;
            }
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        public static JsonFile GetFile(Type itemType)
        {
            var id       = itemType.AssemblyQualifiedName ?? string.Empty;
            var jsonFile = JsonFiles.GetOrAdd(id, x => new JsonFile(itemType));

            return(jsonFile);
        }
コード例 #9
0
        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));
                }
            }
        }
コード例 #10
0
        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);
                    }
                }
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        public ActionResult Index()
        {
            JsonFiles listOfFiles = _filesHelper.GetFileList();
            var       model       = new FilesViewModel()
            {
                Files = listOfFiles.files
            };

            return(View("Index2", model));
        }
コード例 #13
0
        public ActionResult Show()
        {
            JsonFiles ListOfFiles = filesHelper.GetFileList();
            var       model       = new FilesViewModel()
            {
                Files = ListOfFiles.files
            };

            return(View(model));
        }
コード例 #14
0
        public ActionResult Show()
        {
            JsonFiles ListOfFiles = archivoHelper.GetFileList();
            var       model       = new ArchivoView()
            {
                Files = ListOfFiles.files
            };

            return(View(model));
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        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));
            }
        }
コード例 #17
0
        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));
        }
コード例 #18
0
        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()
            }));
        }
コード例 #19
0
        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));
        }
コード例 #20
0
        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>();
            }
        }
コード例 #21
0
        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));
        }
コード例 #22
0
        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");
        }
コード例 #23
0
        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));
        }
コード例 #24
0
        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);
        }
コード例 #25
0
ファイル: FileUploadController.cs プロジェクト: mahlin/Inrapp
        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));
        }
コード例 #26
0
        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"));
            }
        }
コード例 #27
0
ファイル: UploadFileController.cs プロジェクト: sc01/SC-RS01
        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);
        }
コード例 #28
0
        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()));
        }
コード例 #29
0
ファイル: FoldersController.cs プロジェクト: vahidqsmi/Hatra
        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));
        }
コード例 #30
0
        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));
            }
        }