Ejemplo n.º 1
0
        public static string GetFolderData(int fid, ref FolderInf root)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select ");
            sb.Append("xf.fd_name");
            sb.Append(",xf.fd_length");
            sb.Append(",xf.fd_size");
            sb.Append(",xf.fd_pid");
            sb.Append(",xf.fd_pathLoc");
            sb.Append(",xf.fd_pathSvr");
            sb.Append(",xf.fd_folders");
            sb.Append(",xf.fd_files");
            sb.Append(",xf.fd_filesComplete");
            sb.Append(" from down_folders as df");
            sb.Append(" left join xdb_files as xf");
            sb.Append(" on xf.fd_id = df.fd_id");
            sb.Append(" where df.fd_id=@fd_id and xf.fd_complete=1;");

            DbHelper  db  = new DbHelper();
            DbCommand cmd = db.GetCommand(sb.ToString());

            db.AddInInt32(cmd, "@fd_id", fid);
            DbDataReader r = db.ExecuteReader(cmd);

            //FolderInf root = new FolderInf();
            if (r.Read())
            {
                root.m_name        = r.GetString(0);
                root.m_lenLoc      = r.GetInt64(1);
                root.m_size        = r.GetString(2);
                root.m_pidSvr      = r.GetInt32(3);
                root.m_idSvr       = fid;
                root.m_pathLoc     = r.GetString(4);
                root.m_pathSvr     = r.GetString(5);
                root.foldersCount  = r.GetInt32(6);
                root.filesCount    = r.GetInt32(7);
                root.filesComplete = r.GetInt32(8);
            }
            r.Close();

            //单独取已上传长度
            root.lenSvr = DBFolder.GetLenPosted(fid);

            //取文件信息
            JArray        files = new JArray();
            List <string> ids   = new List <string>();

            DBFile.GetCompletes(fid, ref files, ref ids);

            JObject obj = (JObject)JToken.FromObject(root);

            obj["files"]  = files;
            obj["length"] = root.m_lenLoc;
            obj["ids"]    = string.Join(",", ids.ToArray());
            return(obj.ToString());
        }