protected void Page_Load(object sender, EventArgs e)
        {
            string fid = Request.QueryString["fid"];
            string cbk = Request.QueryString["callback"];

            if (string.IsNullOrEmpty(fid) || string.IsNullOrEmpty(cbk))
            {
                Response.Write(cbk + "(0)");
                return;
            }

            //获取文件夹信息,和未完成的文件信息列表
            string json = DBFolder.GetFilesUnComplete(fid);

            Response.Write(cbk + "(" + json + ")");//必须返回jsonp格式数据
        }
Example #2
0
        /// <summary>
        /// 获取所有文件和文件夹列表,不包含子文件夹,包含已上传完的和未上传完的
        /// </summary>
        /// <param name="f_uid"></param>
        /// <returns></returns>
        static public string GetAll(int f_uid)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select ");
            sb.Append("f_id");
            sb.Append(",f_fdTask");
            sb.Append(",f_fdID");
            sb.Append(",f_nameLoc");
            sb.Append(",f_pathLoc");
            sb.Append(",f_md5");
            sb.Append(",f_lenLoc");
            sb.Append(",f_sizeLoc");
            sb.Append(",f_pos");
            sb.Append(",f_lenSvr");
            sb.Append(",f_perSvr");
            sb.Append(",f_complete");
            sb.Append(" from cloud2_files where f_uid=@f_uid and f_deleted=0 and f_fdChild=0;");

            List <xdb_files> files = new List <xdb_files>();
            DbHelper         db    = new DbHelper();
            DbCommand        cmd   = db.GetCommand(sb.ToString());

            db.AddInt(ref cmd, "@f_uid", f_uid);
            DbDataReader r = db.ExecuteReader(cmd);

            while (r.Read())
            {
                xdb_files f = new xdb_files();
                f.uid      = f_uid;
                f.idSvr    = r.GetInt32(0);
                f.f_fdTask = r.GetBoolean(1);
                f.f_fdID   = r.GetInt32(2);
                f.nameLoc  = r.IsDBNull(3) ? string.Empty : r.GetString(3);
                f.pathLoc  = r.IsDBNull(4) ? string.Empty : r.GetString(4);
                f.md5      = r.IsDBNull(5) ? string.Empty : r.GetString(5);
                f.lenLoc   = r.GetInt64(6);
                f.sizeLoc  = r.IsDBNull(7) ? string.Empty : r.GetString(7);
                f.FilePos  = r.GetInt64(8);
                f.lenSvr   = r.GetInt64(9);
                f.perSvr   = r.IsDBNull(10) ? string.Empty : r.GetString(10);
                f.complete = r.IsDBNull(11) ? false : r.GetBoolean(11);

                files.Add(f);
            }
            r.Close();

            JArray arrFiles = new JArray();

            foreach (xdb_files f in files)
            {
                //是文件夹任务=>取文件夹JSON
                if (f.f_fdTask)
                {
                    FolderInf fd = new FolderInf();
                    f.fd_json = DBFolder.GetFilesUnComplete(f.f_fdID, ref fd);
                    float pdPer     = 0;
                    long  lenPosted = DBFolder.GetLenPosted(f.f_fdID);
                    fd.lenSvr = lenPosted;
                    f.lenSvr  = lenPosted;//给客户端使用。
                    long len = fd.lenLoc;
                    if (lenPosted > 0 && len > 0)
                    {
                        pdPer = (float)Math.Round(((lenPosted * 1.0f) / len * 1.0f) * 100.0f, 2);
                    }
                    f.idSvr   = f.f_fdID;//将文件ID改为文件夹的ID,客户端续传文件夹时将会使用这个ID。
                    f.perSvr  = pdPer.ToString() + "%";
                    f.sizeLoc = fd.size;
                }
                arrFiles.Add((JObject)JToken.FromObject(f));
            }
            return(arrFiles.ToString());
        }