专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > SharePoint

moss 利用内容类型aspx + webservice 上传附件 怎么加进度条的功能 急

发布时间:2010-06-13 14:10:59 文章来源:www.iduyao.cn 采编人员:星星草
moss 利用内容类型aspx + webservice 上传附件 如何加进度条的功能 急急急急急急急
由于现在写的aspx是以内容类型发布到moss的,后台代码用Inherits的方法继承。并且在moss中无法(不想修改moss本身的webconfig,改了也不知道有没有效果)修改webconfig里的<httpRuntime maxRequestLength="409600" executionTimeout="3600"></httpRuntime>,所以我把上传的部分放在webservice里来实现。

但是问题出现了,在别人机器上上传不知怎么的有时候快,有时候慢的要死,所以想做一个进度条。
然而,这毕竟不像在asp.net里这么自由的放上别人的控件显示进度条,网上有很多例子关于分块处理,但是看着自己的代码不知道怎么改了。

具体代码如下:
C# code

protected void btnfileup_Click(object sender, EventArgs e)//客户调用
        {
            WS.shouwen sw = new shouwenDLL.WS.shouwen();
            byte[] fileContent = fileup.FileBytes;//网上说这里一次性读到内存,所以慢,但是,这个代码中应该怎样分块处理呢?
            string fileName = fileup.FileName;

            if(sw.checkFileInDB(fileName,Session["fida"].ToString()) == false)//检查是否已经上传
            {
            string fida = sw.UploadFile(fileContent, fileName, 0).ToString();//让webservice实行上传,并且插入数据库,多上传用。
            Session["fida"] += fida + ",";
            BindDL(Session["fida"].ToString().TrimEnd(','));
            }
        }


上传功能,有数据库操作
C# code

[WebMethod(MessageName = "文件上传")]
    public int UploadFile(byte[] fs, string fileName, int id)
    {
        try
        {
            System.IO.MemoryStream m = new System.IO.MemoryStream(fs);
            string year = DateTime.Now.Year.ToString();
            string month = DateTime.Now.Month.ToString();
            string serverPath = "\\" + year + "\\" + month + "\\" + DateTime.Now.ToLongTimeString().Replace(':','_') + "\\";
            string serverPsyPath = System.Configuration.ConfigurationManager.AppSettings["AttachmentPath"].ToString() + serverPath;
            if (!Directory.Exists(serverPsyPath))
            {
                Directory.CreateDirectory(serverPsyPath);
            }
            string strFile = serverPsyPath + fileName;
            System.IO.FileStream fl = new System.IO.FileStream(strFile, FileMode.OpenOrCreate);

            m.WriteTo(fl);
            m.Close();
            fl.Close();
            m = null;
            fl = null;

            return FileInsertDB(id, fileName, serverPath);
        }
        catch (Exception ex)
        {
            string exStr = ex.ToString();
            return 0;
        }

    }

    public int FileInsertDB(int id, string fileName,string serverPath)
    {
        serverPath = serverPath.Replace('\\', '/');
        //申明:文件虚拟路径按照年月分eg:/2009/12/
        string insertSql = "SET NOCOUNT ON;INSERT fileup (id,filename,path) values ('{0}','{1}','{2}');SELECT SCOPE_IDENTITY() AS ida;";
        insertSql = string.Format(insertSql, id, fileName, serverPath);
        return int.Parse(db.ExecuteDataSet(CommandType.Text, insertSql).Tables[0].Rows[0]["ida"].ToString());
    }



跪求各位大侠帮忙,还有分没有了,请楼主赐分 
qq:444266832

------解决方案--------------------
为什么这个帖子不存在sharepoint?
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: