protected void bindData(SiteFileInfo sfi)
    {
        //设置文件描述和下载链接
        try
        {
            hlFile.Text = sfi.description.Substring(0, 4);
        }
        catch
        {
            hlFile.Text = sfi.description;
        }
        hlFile.ToolTip = sfi.description;
        if (sfi.description.Length > 5)
            hlFile.Text += "...";
        //hlFile.Text = sfi.description;
        hlFile.NavigateUrl = "../" + sfi.url;
        //若无下载权限,链接置为空
        isAbleToDownload = Convert.ToBoolean(HiddenFieldDownloadRight.Value);
        if (!isAbleToDownload)
        {
            hlFile.NavigateUrl = "";
        }

        //获取文件扩展名
        String format;
        int lastDotIndex = sfi.url.LastIndexOf('.');
        if (-1 == lastDotIndex)
        {
            format = "";
        }
        else
        {
            format = sfi.url.Substring(lastDotIndex);
            format = format.Remove(0, 1);
            format = format.ToUpper();
        }
        lbFormat.Text = format;

        //获取文件大小
        FileInfo fi = new FileInfo(Server.MapPath("../") + sfi.url);
        lbSize.Text = CommonClass.formatFileSize(fi.Length);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// ����PageID���һ��SiteFileInfo���󼯺�
        /// </summary>
        /// <param name="pageID">�ļ�����ҳ���pageID(д��web.config��appsettings����)</param>
        /// <returns>SiteFile���󼯺�</returns>
        public List<SiteFileInfo> getSiteFilesByPageID(int pageID, string courseName)
        {
            List<SiteFileInfo> list = new List<SiteFileInfo>();

            SqlParameter[] parms = {
                new SqlParameter("@pageID", pageID),
                new SqlParameter("@courseName", courseName)
            };
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "[SP_GetSiteFilesByPageID]", parms);

            while (reader.Read())
            {
                SiteFileInfo sfi = new SiteFileInfo();

                sfi.id = Convert.ToInt32(reader["id"]);
                sfi.description = Convert.ToString(reader["description"]);
                sfi.url = Convert.ToString(reader["url"]);
                sfi.pageID = Convert.ToInt32(reader["pageID"]);
                sfi.addDate = Convert.ToDateTime(reader["addDate"]);

                list.Add(sfi);
            }

            return list;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ����FileID���һ��SiteFileInfo�����ն���
        /// </summary>
        /// <param name="fileID">�ļ�id</param>
        /// <returns>SiteFile�����ն���</returns>
        public SiteFileInfo getSiteFileByID(int fileID)
        {
            SqlParameter param = new SqlParameter("@id", fileID);
            SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "[SP_GetSiteFileByID]", param);

            //���ڸ�id��SiteFile������һ��SiteFileInfo����
            if (reader.Read())
            {
                SiteFileInfo sfi = new SiteFileInfo();

                sfi.id = Convert.ToInt32(reader["id"]);
                sfi.description = Convert.ToString(reader["description"]);
                sfi.url = Convert.ToString(reader["url"]);
                sfi.pageID = Convert.ToInt32(reader["pageID"]);
                sfi.addDate = Convert.ToDateTime(reader["addDate"]);

                return sfi;
            }

            //�����ڣ����ؿն���
            else
            {
                return null;
            }
        }