Beispiel #1
0
        void mkpath()
        {
            var id      = this.reqString("id");
            var pathLoc = this.reqStringDecode("pathLoc");

            FileInf fileSvr = new FileInf();

            fileSvr.id      = id;
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.nameSvr = fileSvr.nameLoc;
            fileSvr.pathLoc = pathLoc;

            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFile(id, fileSvr.nameLoc);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");

            //数据库存在相同文件
            DBFile  db        = new DBFile();
            FileInf fileExist = new FileInf();

            db.Add(ref fileSvr);
            //触发事件
            up6_biz_event.file_create(fileSvr);

            //
            JObject o = new JObject();

            o["pathSvr"] = fileSvr.pathSvr;
            this.toContent(o);
        }
Beispiel #2
0
        void file_init()
        {
            string md5      = Request.QueryString["md5"];
            string id       = Request.QueryString["id"];
            string pid      = Request.QueryString["pid"];
            string pidRoot  = Request.QueryString["pidRoot"];
            string uid      = Request.QueryString["uid"];
            string lenLoc   = Request.QueryString["lenLoc"];
            string sizeLoc  = Request.QueryString["sizeLoc"];
            string callback = Request.QueryString["callback"];                      //jsonp参数
            //客户端使用的是encodeURIComponent编码,
            string pathLoc = HttpUtility.UrlDecode(Request.QueryString["pathLoc"]); //utf-8解码

            //参数为空
            if (string.IsNullOrEmpty(md5) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(sizeLoc))
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.fdChild = false;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.pidRoot = pidRoot;
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.md5     = md5;
            fileSvr.nameSvr = fileSvr.nameLoc;

            //所有单个文件均以uuid/file方式存储
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFile(fileSvr.uid, ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");

            //数据库存在相同文件
            DBFile  db        = new DBFile();
            FileInf fileExist = new FileInf();

            if (db.exist_file(md5, ref fileExist))
            {
                fileSvr.nameSvr  = fileExist.nameSvr;
                fileSvr.pathSvr  = fileExist.pathSvr;
                fileSvr.perSvr   = fileExist.perSvr;
                fileSvr.lenSvr   = fileExist.lenSvr;
                fileSvr.complete = fileExist.complete;
                db.Add(ref fileSvr);

                //触发事件
                up6_biz_event.file_create_same(fileSvr);
            }//数据库不存在相同文件
            else
            {
                db.Add(ref fileSvr);
                //触发事件
                up6_biz_event.file_create(fileSvr);

                //2.0创建器。仅创建一个空白文件
                FileBlockWriter fr = new FileBlockWriter();
                fr.make(fileSvr.pathSvr, fileSvr.lenLoc);
            }
            string jv = JsonConvert.SerializeObject(fileSvr);

            jv = HttpUtility.UrlEncode(jv);
            jv = jv.Replace("+", "%20");
            string json = callback + "({\"value\":\"" + jv + "\"})";//返回jsonp格式数据。

            Response.Write(json);
        }
Beispiel #3
0
        void folder_init()
        {
            string id       = Request.QueryString["id"];
            string pid      = Request.QueryString["pid"];
            string pidRoot  = Request.QueryString["pidRoot"];
            string uid      = Request.QueryString["uid"];
            string lenLoc   = Request.QueryString["lenLoc"];
            string sizeLoc  = Request.QueryString["sizeLoc"];
            string pathLoc  = HttpUtility.UrlDecode(Request.QueryString["pathLoc"]);
            string callback = Request.QueryString["callback"];//jsonp参数

            if (string.IsNullOrEmpty(id) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(pathLoc)
                )
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.pidRoot = pidRoot;
            fileSvr.fdChild = false;
            fileSvr.fdTask  = true;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.nameSvr = fileSvr.nameLoc;

            //生成存储路径
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFolder(ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");
            if (!Directory.Exists(fileSvr.pathSvr))
            {
                Directory.CreateDirectory(fileSvr.pathSvr);
            }

            //添加到文件表
            DBFile db = new DBFile();

            db.Add(ref fileSvr);
            //添加到目录表
            SqlExec se = new SqlExec();

            se.insert("up6_folders", new SqlParam[] {
                new SqlParam("f_id", id)
                , new SqlParam("f_pathLoc", fileSvr.pathLoc)
                , new SqlParam("f_size", fileSvr.sizeLoc)
                , new SqlParam("f_nameLoc", fileSvr.nameLoc)
                , new SqlParam("f_pid", pid)
                , new SqlParam("f_pidRoot", pidRoot)
            });
            up6_biz_event.folder_create(fileSvr);

            string json = JsonConvert.SerializeObject(fileSvr);

            json = HttpUtility.UrlEncode(json);
            json = json.Replace("+", "%20");
            var jo = new JObject {
                { "value", json }
            };

            json = callback + string.Format("({0})", JsonConvert.SerializeObject(jo));
            PageTool.to_content(json);
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id       = this.reqString("id");
            string pid      = this.reqString("pid");
            string pidRoot  = this.reqString("pidRoot");
            string uid      = this.reqString("uid");
            string lenLoc   = this.reqString("lenLoc");
            string sizeLoc  = this.reqString("sizeLoc");
            string pathLoc  = this.reqStringDecode("pathLoc");
            string callback = this.reqString("callback");//jsonp参数

            if (string.IsNullOrEmpty(pid))
            {
                pid = string.Empty;
            }
            if (string.IsNullOrEmpty(pidRoot))
            {
                pidRoot = pid;
            }

            if (string.IsNullOrEmpty(id) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(pathLoc)
                )
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.pidRoot = pidRoot;
            fileSvr.fdChild = false;
            fileSvr.fdTask  = true;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.nameSvr = fileSvr.nameLoc;

            //生成存储路径
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFolder(ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");
            if (!Directory.Exists(fileSvr.pathSvr))
            {
                Directory.CreateDirectory(fileSvr.pathSvr);
            }

            //添加成根目录
            if (string.IsNullOrEmpty(pid))
            {
                DBConfig cfg = new DBConfig();
                DBFile   db  = cfg.db();
                db.Add(ref fileSvr);
            }//添加成子目录
            else
            {
                DBConfig cfg = new DBConfig();
                SqlExec  se  = cfg.se();
                se.insert("up6_folders", new SqlParam[] {
                    new SqlParam("f_id", fileSvr.id)
                    , new SqlParam("f_nameLoc", fileSvr.nameLoc)
                    , new SqlParam("f_pid", fileSvr.pid)
                    , new SqlParam("f_pidRoot", fileSvr.pidRoot)
                    , new SqlParam("f_lenLoc", fileSvr.lenLoc)
                    , new SqlParam("f_sizeLoc", fileSvr.sizeLoc)
                    , new SqlParam("f_pathLoc", fileSvr.pathLoc)
                    , new SqlParam("f_pathSvr", fileSvr.pathSvr)
                    , new SqlParam("f_uid", fileSvr.uid)
                });
            }

            //加密
            ConfigReader cr      = new ConfigReader();
            var          sec     = cr.module("path");
            var          encrypt = (bool)sec.SelectToken("$.security.encrypt");

            if (encrypt)
            {
                CryptoTool ct = new CryptoTool();
                fileSvr.pathSvr = ct.encode(fileSvr.pathSvr);
            }

            up6_biz_event.folder_create(fileSvr);

            string json = JsonConvert.SerializeObject(fileSvr);

            json = HttpUtility.UrlEncode(json);
            json = json.Replace("+", "%20");
            var jo = new JObject {
                { "value", json }
            };

            json = callback + string.Format("({0})", JsonConvert.SerializeObject(jo));
            this.toContentJson(json);
        }
Beispiel #5
0
        void fd_create()
        {
            string id       = Request.QueryString["id"];
            string pid      = Request.QueryString["pid"];
            string uid      = Request.QueryString["uid"];
            string lenLoc   = Request.QueryString["lenLoc"];
            string sizeLoc  = Request.QueryString["sizeLoc"];
            string pathLoc  = HttpUtility.UrlDecode(Request.QueryString["pathLoc"]);
            string pathRel  = this.reqString("pathRel");
            string callback = Request.QueryString["callback"];//jsonp参数

            if (string.IsNullOrEmpty(pid))
            {
                pid = string.Empty;
            }
            pid = pid.Trim();

            if (string.IsNullOrEmpty(id) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(pathLoc)
                )
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.pidRoot = "";
            fileSvr.fdChild = false;
            fileSvr.fdTask  = true;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.pathRel = PathTool.combin(pathRel, fileSvr.nameLoc);
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.nameSvr = fileSvr.nameLoc;

            //检查同名目录
            //DbFolder df = new DbFolder();
            //if (df.exist_same_folder(fileSvr.nameLoc, pid))
            //{
            //    var o = new JObject { { "value", null }, { "ret", false }, { "code", "102" } };
            //    var js = callback + string.Format("({0})", JsonConvert.SerializeObject(o));
            //    this.toContent(js);
            //    return;
            //}

            //生成存储路径
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFolder(ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");
            if (!Directory.Exists(fileSvr.pathSvr))
            {
                Directory.CreateDirectory(fileSvr.pathSvr);
            }

            //添加成根目录
            if (string.IsNullOrEmpty(pid))
            {
                DBConfig cfg = new DBConfig();
                DBFile   db  = cfg.db();
                db.Add(ref fileSvr);
            }//添加成子目录
            else
            {
                DBConfig cfg = new DBConfig();
                SqlExec  se  = cfg.se();
                se.insert("up6_folders", new SqlParam[] {
                    new SqlParam("f_id", fileSvr.id)
                    , new SqlParam("f_nameLoc", fileSvr.nameLoc)
                    , new SqlParam("f_pid", fileSvr.pid)
                    , new SqlParam("f_pidRoot", "")
                    , new SqlParam("f_lenLoc", fileSvr.lenLoc)
                    , new SqlParam("f_sizeLoc", fileSvr.sizeLoc)
                    , new SqlParam("f_pathLoc", fileSvr.pathLoc)
                    , new SqlParam("f_pathSvr", fileSvr.pathSvr)
                    , new SqlParam("f_pathRel", fileSvr.pathRel)
                    , new SqlParam("f_uid", fileSvr.uid)
                });
            }

            //加密
            ConfigReader cr      = new ConfigReader();
            var          sec     = cr.module("path");
            var          encrypt = (bool)sec.SelectToken("$.security.encrypt");

            if (encrypt)
            {
                CryptoTool ct = new CryptoTool();
                fileSvr.pathSvr = ct.encode(fileSvr.pathSvr);
            }

            up6_biz_event.folder_create(fileSvr);

            string json = JsonConvert.SerializeObject(fileSvr);

            json = HttpUtility.UrlEncode(json);
            json = json.Replace("+", "%20");
            var jo = new JObject {
                { "value", json }, { "ret", true }
            };

            json = callback + string.Format("({0})", JsonConvert.SerializeObject(jo));
            this.toContent(json);
        }
Beispiel #6
0
        void f_create()
        {
            string pid      = Request.QueryString["pid"];
            string pidRoot  = Request.QueryString["pidRoot"];
            string md5      = Request.QueryString["md5"];
            string id       = Request.QueryString["id"];
            string uid      = Request.QueryString["uid"];
            string lenLoc   = Request.QueryString["lenLoc"];
            string sizeLoc  = Request.QueryString["sizeLoc"];
            string callback = Request.QueryString["callback"];                      //jsonp参数
            //客户端使用的是encodeURIComponent编码,
            string pathLoc = HttpUtility.UrlDecode(Request.QueryString["pathLoc"]); //utf-8解码
            string pathRel = this.reqString("pathRel");

            if (string.IsNullOrEmpty(pid))
            {
                pid = string.Empty;
            }
            if (string.IsNullOrEmpty(pidRoot))
            {
                pidRoot = pid;
            }

            //参数为空
            if (string.IsNullOrEmpty(md5) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(sizeLoc))
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.fdChild = false;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.fdChild = !string.IsNullOrEmpty(pid);
            fileSvr.pidRoot = pidRoot;
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.pathRel = PathTool.combin(pathRel, fileSvr.nameLoc);
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.md5     = md5;
            fileSvr.nameSvr = fileSvr.nameLoc;

            //同名文件检测
            //DbFolder df = new DbFolder();
            //if (df.exist_same_file(fileSvr.nameLoc, pid))
            //{
            //    var data = callback + "({'value':'','ret':false,'code':'101'})";
            //    this.toContent(data);
            //    return;
            //}

            //所有单个文件均以uuid/file方式存储
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFile(fileSvr.uid, ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");

            //数据库存在相同文件
            DBConfig cfg       = new DBConfig();
            DBFile   db        = cfg.db();
            FileInf  fileExist = new FileInf();

            if (db.exist_file(md5, ref fileExist))
            {
                fileSvr.nameSvr  = fileExist.nameSvr;
                fileSvr.pathSvr  = fileExist.pathSvr;
                fileSvr.perSvr   = fileExist.perSvr;
                fileSvr.lenSvr   = fileExist.lenSvr;
                fileSvr.complete = fileExist.complete;
                db.Add(ref fileSvr);

                //触发事件
                up6_biz_event.file_create_same(fileSvr);
            }//数据库不存在相同文件
            else
            {
                db.Add(ref fileSvr);
                //触发事件
                up6_biz_event.file_create(fileSvr);

                //2.0创建器。仅创建一个空白文件
                FileBlockWriter fr = new FileBlockWriter();
                fr.make(fileSvr.pathSvr, fileSvr.lenLoc);
            }

            //加密
            ConfigReader cr      = new ConfigReader();
            var          sec     = cr.module("path");
            var          encrypt = (bool)sec.SelectToken("$.security.encrypt");

            if (encrypt)
            {
                CryptoTool ct = new CryptoTool();
                fileSvr.pathSvr = ct.encode(fileSvr.pathSvr);
            }

            string jv = JsonConvert.SerializeObject(fileSvr);

            jv = HttpUtility.UrlEncode(jv);
            jv = jv.Replace("+", "%20");
            string json = callback + "({\"value\":\"" + jv + "\",\"ret\":true})";//返回jsonp格式数据。

            this.toContent(json);
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string op       = this.reqString("op");
            string pid      = this.reqString("pid");
            string pidRoot  = this.reqString("pidRoot");
            string md5      = this.reqString("md5");
            string id       = this.reqString("id");
            string uid      = this.reqString("uid");
            string lenLoc   = this.reqString("lenLoc");
            string sizeLoc  = this.reqString("sizeLoc");
            string token    = this.reqString("token");
            string callback = this.reqString("callback");     //jsonp参数
            //客户端使用的是encodeURIComponent编码,
            string pathLoc = this.reqStringDecode("pathLoc"); //utf-8解码

            if (op == "mkpath")
            {
                this.mkpath();
            }

            if (string.IsNullOrEmpty(pid))
            {
                pid = string.Empty;
            }
            if (string.IsNullOrEmpty(pidRoot))
            {
                pidRoot = pid;
            }

            //参数为空
            if (string.IsNullOrEmpty(md5) ||
                string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(sizeLoc)
                )
            {
                Response.Write(callback + "({\"value\":null})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.fdChild = false;
            fileSvr.uid     = int.Parse(uid);//将当前文件UID设置为当前用户UID
            fileSvr.id      = id;
            fileSvr.pid     = pid;
            fileSvr.fdChild = !string.IsNullOrEmpty(pid);
            fileSvr.pidRoot = pidRoot;
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.pathLoc = pathLoc;
            fileSvr.lenLoc  = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc = sizeLoc;
            fileSvr.deleted = false;
            fileSvr.md5     = md5;
            fileSvr.nameSvr = fileSvr.nameLoc;

            WebSafe ws  = new WebSafe();
            var     ret = ws.validToken(token, fileSvr);

            //token验证失败
            if (!ret)
            {
                string m = callback + "({\"value\":\"0\",\"ret\":false,\"msg\":\"token error\"})";//返回jsonp格式数据。
                this.toContentJson(m);
                return;
            }

            //所有单个文件均以uuid/file方式存储
            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFile(fileSvr.uid, ref fileSvr);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");

            //数据库存在相同文件
            DBConfig cfg       = new DBConfig();
            DBFile   db        = cfg.db();
            FileInf  fileExist = new FileInf();

            if (db.exist_file(md5, ref fileExist))
            {
                fileSvr.nameSvr  = fileExist.nameSvr;
                fileSvr.pathSvr  = fileExist.pathSvr;
                fileSvr.perSvr   = fileExist.perSvr;
                fileSvr.lenSvr   = fileExist.lenSvr;
                fileSvr.complete = fileExist.complete;
                db.Add(ref fileSvr);

                //触发事件
                up6_biz_event.file_create_same(fileSvr);
            }//数据库不存在相同文件
            else
            {
                db.Add(ref fileSvr);
                //触发事件
                up6_biz_event.file_create(fileSvr);

                //2.0创建器。仅创建一个空白文件
                FileBlockWriter fr = new FileBlockWriter();
                fr.make(fileSvr.pathSvr, fileSvr.lenLoc);
            }

            //将路径转换成相对路径
            fileSvr.pathSvr = pb.absToRel(fileSvr.pathSvr);
            //加密
            ConfigReader cr      = new ConfigReader();
            var          sec     = cr.module("path");
            var          encrypt = (bool)sec.SelectToken("$.security.encrypt");

            if (encrypt)
            {
                CryptoTool ct = new CryptoTool();
                fileSvr.pathSvr = ct.encode(fileSvr.pathSvr);
            }

            string jv = JsonConvert.SerializeObject(fileSvr);

            jv = HttpUtility.UrlEncode(jv);
            jv = jv.Replace("+", "%20");
            string json = callback + "({\"value\":\"" + jv + "\",\"ret\":true})";//返回jsonp格式数据。

            this.toContentJson(json);
        }