Example #1
0
        public ActionResult FileAccessDefault(FileExplorerParams args)
        {
            try
            {
                FileAccessOperations operation = new FileAccessOperations(GetRules());
                if (args.ActionType != "Paste" && args.ActionType != "GetDetails")
                {
                    FileExplorerOperations opeartion = new FileExplorerOperations();
                    var FilePath = opeartion.GetPhysicalPath(opeartion.ToAbsolute(args.Path));
                    if (!FilePath.ToLower().Contains("filecontent"))
                    {
                        throw new ArgumentException("'" + FilePath + "' is not accessible. Access is denied.");
                    }
                }
                switch (args.ActionType)
                {
                case "Read":
                    return(Json(operation.Read(args.Path, args.ExtensionsAllow)));

                //case "CreateFolder":
                //    return Json(operation.CreateFolder(args.Path, args.Name));
                //case "Paste":
                //    return Json(operation.Paste(args.LocationFrom, args.LocationTo, args.Names, args.Action, args.CommonFiles));
                //case "Remove":
                //    return Json(operation.Remove(args.Names, args.Path));
                //case "Rename":
                //    return Json(operation.Rename(args.Path, args.Name, args.NewName, args.CommonFiles));
                case "GetDetails":
                    return(Json(operation.GetDetails(args.Path, args.Names)));

                case "Download":
                    operation.Download(args.Path, args.Names);
                    break;

                //case "Upload":
                //    operation.Upload(args.FileUpload, args.Path);
                //    break;
                case "Search":
                    return(Json(operation.Search(args.Path, args.ExtensionsAllow, args.SearchString, args.CaseSensitive)));

                //provide restriction to modify data in our online samples
                default:
                    return(new HttpStatusCodeResult(403, "Restricted to modify data in online demo."));
                }
                return(Json(""));
            }
            catch (Exception e)
            {
                FileExplorerResponse Response = new FileExplorerResponse();
                Response.error = e.GetType().FullName + ", " + e.Message;
                return(Json(Response));
            }
        }
        public static object FileActionDefault(string ActionType, string Path, string ExtensionsAllow, string LocationFrom, string LocationTo, string Name, string[] Names, string NewName, string Action, bool CaseSensitive, string SearchString, IEnumerable <CommonFileDetails> CommonFiles)
        {
            try
            {
                FileExplorerOperations opeartion = new FileExplorerOperations();
                if (ActionType != "Paste" && ActionType != "GetDetails")
                {
                    var FilePath = opeartion.GetPhysicalPath(opeartion.ToAbsolute(Path));
                    if (!FilePath.ToLower().Contains("filecontent"))
                    {
                        throw new ArgumentException("'" + FilePath + "' is not accessible. Access is denied.");
                    }
                }
                AccessControl        Rule      = new AccessControl();
                FileAccessOperations operation = new FileAccessOperations(Rule.GetRules());
                switch (ActionType)
                {
                case "Read":
                    return(operation.Read(Path, ExtensionsAllow));

                //case "CreateFolder":
                //    return (operation.CreateFolder(Path, Name));
                //case "Paste":
                //    operation.Paste(LocationFrom, LocationTo, Names, Action, CommonFiles);
                //    break;
                //case "Remove":
                //    operation.Remove(Names, Path);
                //    break;
                //case "Rename":
                //    operation.Rename(Path, Name, NewName, CommonFiles);
                //    break;
                case "GetDetails":
                    return(operation.GetDetails(Path, Names));

                case "Search":
                    return(operation.Search(Path, ExtensionsAllow, SearchString, CaseSensitive));

                //provide restriction to modify data in our online samples
                default:
                    throw new Exception("Restricted to modify data in online demo.");
                }
                //return "";
            }
            catch (Exception e)
            {
                FileExplorerResponse Response = new FileExplorerResponse();
                Response.error = e.GetType().FullName + ", " + e.Message;
                return(Response);
            }
        }