예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id    = this.reqString("id");
            string uid   = this.reqString("uid");
            string cak   = this.reqString("callback");
            int    cover = this.reqToInt("cover");
            int    ret   = 0;

            if (string.IsNullOrEmpty(id) ||
                uid.Length < 1)
            {
            }
            else
            {
                DbFolder db     = new DbFolder();
                FileInf  folder = db.read(id);
                folder.uid = int.Parse(uid);
                FileInf fdExist = db.read(folder.pathRel, folder.pid, id);
                if (1 == cover && fdExist != null)
                {
                    folder.id      = fdExist.id;
                    folder.pid     = fdExist.pid;
                    folder.pidRoot = fdExist.pidRoot;
                }

                //根节点
                FileInf root = new FileInf();
                root.id  = folder.pidRoot;
                root.uid = folder.uid;
                //当前节点是根节点
                if (string.IsNullOrEmpty(root.id))
                {
                    root.id = folder.id;
                }

                //上传完毕
                DBConfig cfg = new DBConfig();
                DBFile   dbf = cfg.db();
                dbf.fd_complete(id, uid);

                //扫描文件夹结构,
                fd_scan sa = cfg.sa();
                sa.root = root;//

                //清理同名子文件
                if (1 == cover && fdExist != null)
                {
                    //覆盖同名子文件
                    sa.cover(folder, folder.pathSvr);
                }

                //添加文件记录
                sa.scan(folder, folder.pathSvr);

                //更新扫描状态
                dbf.fd_scan(id, uid);

                up6_biz_event.folder_post_complete(id);

                //删除当前目录
                if (1 == cover && fdExist != null)
                {
                    cfg.folder().del(id, int.Parse(uid));
                }

                ret = 1;
            }
            this.toContentJson(cak + "(" + ret + ")");
        }
예제 #2
0
        void file_rename()
        {
            bool exist = false;
            var  o     = this.request_to_json();

            DBConfig cfg    = new DBConfig();
            SqlExec  se     = cfg.se();
            bool     fdTask = o["f_fdTask"].ToString() == "true" || o["f_fdTask"].ToString() == "1";

            //根目录
            if (string.IsNullOrEmpty(o["f_pid"].ToString()))
            {
                fdTask = false;
            }

            if (fdTask)
            {
                //同名目录
                var s = se.read("up6_folders", "f_id,f_pathRel"
                                , new SqlParam[] {
                    new SqlParam("f_pid", o["f_pid"].ToString()),
                    new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                });
                exist = s != null;

                if (!exist)
                {
                    s = se.read("up6_folders", "f_pathRel", new SqlParam[] { new SqlParam("f_id", o["f_id"].ToString()) });
                    //更新相对路径
                    var pathRel    = s["f_pathRel"].ToString();
                    var pathRelOld = pathRel;
                    var index      = pathRel.LastIndexOf("/");
                    pathRel  = pathRel.Substring(0, index + 1);
                    pathRel += o["f_nameLoc"].ToString();
                    var pathRelNew = pathRel;

                    se.update("up6_folders"
                              , new SqlParam[] {
                        new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                        new SqlParam("f_pathRel", pathRel)
                    },
                              new SqlParam[] {
                        new SqlParam("f_id", o["f_id"].ToString())
                    });
                    //
                    this.folder_renamed(pathRelOld, pathRelNew);
                }
            }
            else
            {
                DbFolder db = new DbFolder();
                var      s  = db.read(o["f_pid"].ToString(), o["f_nameLoc"].ToString());
                exist = s != null;

                if (!exist)
                {
                    s = se.read("up6_files", "f_pathRel", new SqlParam[] { new SqlParam("f_id", o["f_id"].ToString()) });
                    //更新相对路径
                    var pathRel    = s["f_pathRel"].ToString();
                    var pathRelOld = pathRel;
                    var index      = pathRel.LastIndexOf("/");
                    pathRel  = pathRel.Substring(0, index + 1);
                    pathRel += o["f_nameLoc"].ToString();
                    var pathRelNew = pathRel;

                    se.update("up6_files"
                              , new SqlParam[] {
                        new SqlParam("f_nameLoc", o["f_nameLoc"].ToString()),
                        new SqlParam("f_pathRel", pathRel)
                    },
                              new SqlParam[] {
                        new SqlParam("f_id", o["f_id"].ToString())
                    });

                    this.folder_renamed(pathRelOld, pathRelNew);
                }
            }

            //存在同名项
            if (exist)
            {
                var res = new JObject {
                    { "state", false }, { "msg", "存在同名项" }
                };
                this.toContent(res);
            }
            else
            {
                var ret = new JObject {
                    { "state", true }
                };
                this.toContent(ret);
            }
        }