示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string uid        = Request.QueryString["uid"];
            string id         = Request.QueryString["id"];
            string lenLoc     = Request.QueryString["lenLoc"];
            string sizeLoc    = Request.QueryString["sizeLoc"];
            string blockSize  = Request.QueryString["blockSize"];
            string blockCount = Request.QueryString["blockCount"];
            string callback   = Request.QueryString["callback"];                  //jsonp参数
            //客户端使用的是encodeURIComponent编码,
            string pathLoc = PathTool.url_decode(Request.QueryString["pathLoc"]); //utf-8解码

            //参数为空
            if (string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(sizeLoc)
                )
            {
                Response.Write(callback + "({\"value\":null,\"inf\":\"参数为空,请检查uid,sizeLoc参数。\"})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.id         = id;
            fileSvr.uid        = int.Parse(uid);  //将当前文件UID设置为当前用户UID
            fileSvr.nameLoc    = Path.GetFileName(pathLoc);
            fileSvr.pathLoc    = pathLoc;
            fileSvr.lenLoc     = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc    = sizeLoc;
            fileSvr.blockSize  = int.Parse(blockSize);
            fileSvr.blockCount = int.Parse(blockCount);
            fileSvr.nameSvr    = fileSvr.nameLoc;

            PathGuidBuilder pb = new PathGuidBuilder();

            fileSvr.pathSvr = pb.genFile(fileSvr.uid, fileSvr.id, fileSvr.nameLoc);

            //添加到任务表
            DBFile.add(ref fileSvr);

            //触发事件
            up7_biz_event.file_create(fileSvr);

            string jv = JsonConvert.SerializeObject(fileSvr);

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

            Response.Write(json);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String id       = Request.QueryString["id"];
            String pathLoc  = Request.QueryString["pathLoc"];
            String sizeLoc  = Request.QueryString["sizeLoc"];
            String lenLoc   = Request.QueryString["lenLoc"];
            String uid      = Request.QueryString["uid"];
            String fCount   = Request.QueryString["filesCount"];
            String callback = Request.QueryString["callback"];

            pathLoc = PathTool.url_decode(pathLoc);

            FileInf f = new FileInf();

            f.nameLoc   = Path.GetFileName(pathLoc);
            f.nameSvr   = f.nameLoc;
            f.id        = id;
            f.pathLoc   = pathLoc;
            f.sizeLoc   = sizeLoc;
            f.lenLoc    = long.Parse(lenLoc);
            f.fileCount = int.Parse(fCount);
            f.fdTask    = true;
            f.uid       = int.Parse(uid);
            //生成路径,格式:upload/年/月/日/guid/文件夹名称
            PathGuidBuilder pb = new PathGuidBuilder();

            f.pathSvr = Path.Combine(pb.genFolder(f.uid, f.id), f.nameLoc);
            f.pathSvr = f.pathSvr.Replace("\\", "/");
            Directory.CreateDirectory(f.pathSvr);

            //添加到队列表
            DBFile.add(ref f);

            //添加到文件夹表
            DBFolder dbf = new DBFolder();

            dbf.add(ref f);

            //触发事件
            up7_biz_event.folder_create(f);

            string json = JsonConvert.SerializeObject(f);

            json = HttpUtility.UrlEncode(json);
            json = json.Replace("+", "%20");
            Response.Write(callback + "({\"value\":\"" + json + "\"})");
        }