Example #1
0
        public ActionResult FilesUploadAjax(string guidlist, string deleteid)
        {
            FileManagerProvider manager = new FileManagerProvider();
            string username             = GetCurrentUserName();

            if (!string.IsNullOrEmpty(guidlist))
            {
                using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
                {
                    foreach (string strguid in guidlist.Split('/'))
                    {
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(new Guid(strguid));
                        if (file == null)
                        {
                            continue;
                        }
                        //savefile here
                        manager.MoveFile(username, file.GetTempFilePath(), file.FileName, null);
                    }
                }
            }

            if (!string.IsNullOrEmpty(deleteid))
            {
                FileItem file = manager.GetFileByID(username, deleteid);
                if (file != null)
                {
                    file.Delete();
                }
            }

            FileItem[] files = manager.GetFiles(username);
            Array.Reverse(files);
            FileManagerJsonItem[] items = new FileManagerJsonItem[files.Length];
            string baseurl = Response.ApplyAppPathModifier("~/FileManagerDownload.ashx?user="******"&file=");

            for (int i = 0; i < files.Length; i++)
            {
                FileItem            file = files[i];
                FileManagerJsonItem item = new FileManagerJsonItem();
                item.FileID      = file.FileID;
                item.FileName    = file.FileName;
                item.Description = file.Description;
                item.UploadTime  = file.UploadTime.ToString("yyyy-MM-dd HH:mm:ss");
                item.FileSize    = file.FileSize;
                item.FileUrl     = baseurl + file.FileID;
                items[i]         = item;
            }
            JsonResult json = new JsonResult();

            json.Data = items;
            return(json);
        }
Example #2
0
        public ActionResult FileUploadAjaxWithoutSave(string guidlist, string limitcount, string hascount)
        {
            List <FileManagerJsonItem> items = new List <FileManagerJsonItem>();
            int maxcount   = 0;
            int existcount = 0;

            int.TryParse(hascount, out existcount);
            int.TryParse(limitcount, out maxcount);
            if (!string.IsNullOrEmpty(guidlist))
            {
                using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))
                {
                    int ix = 0;
                    foreach (string strguid in guidlist.Split('/'))
                    {
                        if (maxcount > 0 && ix + existcount >= maxcount)
                        {
                            break;
                        }
                        CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(new Guid(strguid));
                        if (file == null)
                        {
                            continue;
                        }
                        ix++;
                        FileManagerJsonItem item = new FileManagerJsonItem();
                        item.FileID   = file.FileGuid.ToString();
                        item.FileName = file.FileName;
                        item.FileSize = file.FileSize;
                        items.Add(item);
                    }
                }
            }
            JsonResult json = new JsonResult();

            json.Data = items;
            return(json);
        }