コード例 #1
0
        public JsonResult CreateNode(FileNodeOperationDateContract contract)
        {
            if (contract == null)
                throw new ArgumentNullException("the argument is null!!!!!");

            PicNode parent = PicNode.Load(contract.ParentId.Value);

            if (parent == null)
                throw new ArgumentException("the parentid is null!!!!");

            PicNode temp = PicNode.FindByPath(parent.Path + "/" + contract.Name);

            if (temp != null)
                return Json(new { status = 0, success = false, message = "请确定文件夹名称在该目录下是否唯一!" });

            PicNode node = new PicNode();
            node.IsFile = false;
            node.Status = 0;
            node.Root = parent.Root;
            node.Name = contract.Name;
            node.Path = parent.Path + "/" + node.Name;
            PicNode.Insert(node);
            return Json(new { id = node.Id.ToString(), status = node.Status.ToString(), success = true, message = "成功创建文件夹!" });
        }
コード例 #2
0
        public JsonResult ReNameNode(FileNodeOperationDateContract contract)
        {
            if (contract == null)
                throw new ArgumentNullException("the argument is null!!!!!");

            PicNode node = PicNode.Load(contract.Id.Value);
            node.Name = contract.Name;
            node.Save();

            return Json(new { id = node.Id, status = 1, success = true, message = "成功将文件夹重新命名!" });
        }
コード例 #3
0
        public JsonResult Operation(FileNodeOperationDateContract contract)
        {
            if (ReferenceEquals(contract, null))
                throw new ArgumentNullException("contract is null!!!!");

            if (string.IsNullOrEmpty(contract.Operation)) throw new ArgumentException("the operation contained is null or empty!!!");

            if (operations[contract.Operation] == null) throw new ArgumentException("the operation is not exist!!!");

            return this.operations[contract.Operation](contract);
        }
コード例 #4
0
        public JsonResult RemoveNode(FileNodeOperationDateContract contract)
        {
            if (contract == null)
                throw new ArgumentNullException("the argument is null!!!!!");

            //  修改
            IList<PicNode> roots = PicNode.GetRoots().ToList();

            bool isdelete = true;

            if (roots.Count == 1 && contract.Id == roots[0].Id)
            {
                isdelete = false;
                return Json(new { id = contract.Id.ToString(), status = 0, success = false, message = "该文件夹是根目录不能删除!" });
            }

            if (isdelete)
            {
                PicNode.Delete(contract.Id.Value);
            }

            return Json(new { id = contract.Id.ToString(), status = 1, success = true, message = "成功将文件夹移除!" });
        }
コード例 #5
0
        public JsonResult GetChildren(FileNodeOperationDateContract contract)
        {
            if (contract == null)
                throw new ArgumentNullException("the argument is null!!!!!");

            IList<PicNode> nodes = new List<PicNode>();

            IList<Node> results = new List<Node>();

            if (contract.Id == null || !contract.Id.HasValue)
            {
                nodes = PicNode.GetRoots().ToList();
            }
            else
            {
                nodes = PicNode.GetSubs(contract.Id.Value).ToList();
            }

            foreach (var n in nodes)
            {
                results.Add(new Node(n.Name, n.Id.ToString()));
            }

            return Json(results, JsonRequestBehavior.AllowGet);
        }