从up6-down2升级到down3

概述:

添加存储过程down_f_process.sql,down_f_del.sql

更新DnFile.updateProcess,DnFile.Delete

更新down.js

更新down.folder.js

更新f_down.aspx.cs

更新folder_appender.cs

更新存储过程fd_add_batch.sql

 

1.  新增存储过程down_f_process.sql

6d8dd1d5-9f25-4163-8661-2e0d5ae4983d

代码:

USE [HttpUploader6]

GO

/****** 对象:  StoredProcedure [dbo].[f_process]    脚本日期: 10/30/2012 15:20:07 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

 

-- =============================================

-- Author:         Xproer

-- Create date: 2012-10-25

-- Description:    更新文件进度

-- =============================================

--drop procedure [dbo].[down_f_process]

CREATE PROCEDURE [dbo].[down_f_process]

     -- Add the parameters for the stored procedure here

      @f_lenLoc bigint

     ,@f_perLoc nvarchar(6)

     ,@f_uid int

     ,@f_id int

 

AS

BEGIN

     -- SET NOCOUNT ON added to prevent extra result sets from

     -- interfering with SELECT statements.

     SET NOCOUNT ON;

 

    DECLARE @sql nvarchar(4000);

     DECLARE @ParamDef nvarchar(500);

 

    SET @sql=N'update down_files set f_lenLoc=@f_lenLoc,f_perLoc=@f_perLoc where f_uid=@f_uid and f_id=@f_id'

     SET @ParamDef = N'@f_lenLoc bigint

                       ,@f_perLoc nvarchar(6)

                       ,@f_uid bit

                       ,@f_id int';

 

    -- Insert statements for procedure here

     EXEC sp_executesql @sql,@ParamDef,@f_lenLoc,@f_perLoc,@f_uid,@f_id

END

 

 

2.  新增存储过程down_f_del.sql

9b6c43c0-287f-4b38-b472-0a87b5ca0334

代码:

USE [HttpUploader6]

GO

/****** 对象:  StoredProcedure [dbo].[f_process]    脚本日期: 10/30/2012 15:20:07 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

 

-- =============================================

-- Author:         Xproer

-- Create date: 2012-10-25

-- Description:    删除文件

-- =============================================

--drop procedure [dbo].[down_del]

CREATE PROCEDURE [dbo].[down_f_del]

     -- Add the parameters for the stored procedure here

      @f_uid int

     ,@f_id int

 

AS

BEGIN

     -- SET NOCOUNT ON added to prevent extra result sets from

     -- interfering with SELECT statements.

     SET NOCOUNT ON;

 

    DECLARE @sql nvarchar(4000);

     DECLARE @ParamDef nvarchar(500);

 

    SET @sql=N'delete from down_files where f_id=@f_id and f_uid=@f_uid'

     SET @ParamDef = N'@f_id int

                       ,@f_uid int';

 

    -- Insert statements for procedure here

     EXEC sp_executesql @sql,@ParamDef,@f_id,@f_uid

 

     --清除子文件

     SET @sql = N'delete from down_files where f_pidRoot=@f_id and f_uid=@f_uid;'

     EXEC sp_executesql @sql,@ParamDef,@f_id,@f_uid

END

 

3.  更新方法DnFile.updateProcess

4533ea0c-3be3-48f9-9f28-3a1df01df0bb

 

4.  更新方法DnFile.Delete

采用存储过程:down_f_del

更新前:

61092316-dd32-4d03-99b8-29a77db90f71

 

更新后:

77d038b0-7d63-4d9a-b590-e7c80e58bfc6

 

5.  更新down.js中控件信息

取消ClsidDown配置属性。

更新前:

74bc346b-13a6-40ed-8d1e-5e2d09ccf00a

更新后:

a9aeda5c-a41c-4276-bf2b-e29f0aad821a

 

6.  新增线程配置项

2881c94f-dde6-4b0f-aed6-dcea547cec1d

 

7.  更新down.jschrome 45+控件信息

浏览器对象采用down3的对象,与down2区分

更新前:

8d8fcebb-de18-4b83-bba9-0622468267bb

更新后:

01de4a1f-f668-49e6-bd9c-55983f8383a8

 

8.  更新down.folder.js

8.1. 更新方法down_complete

每个文件上传完后更新数据库进度。如果文件较小则不会触发down_part事件。

更新前:

7cf35240-9c91-4ea2-bf4b-a32295178c8a

更新后:

ff5c5a8e-4e83-4de2-bb49-ad31b39af6ac

 

svr_update

更新前:

0ea98529-0e12-4e4b-9454-3cf08b54d44e

 

更新后:

585ac6bd-be25-4259-abe5-970f0c683e88

 

down_recv_size

更新前:

b18e3600-0c62-4670-8b06-5aaa8ed847ad

 

更新后:

d4a507d4-6b77-4865-8a5c-98c34becd5c7

 

svr_create

更新前:

abca6b85-72b6-485f-bc9a-d2e3c7bbb9fc

 

更新后:

9acd2e03-a9a0-42cd-ae1b-721e8e1443ef

 

8.2. 更新方法svr_create

在添加文件夹后初始化时,隐藏上传按钮,在初始化完毕后显示按钮。

在文件数量比较多的情况下,如果没有初始化完就开始上传可能会导致数据库错误。

a023299e-1d30-41ba-9bb6-5cd5e00b37ea

 

9.  更新f_down.aspx.cs

增加对Range协议的支持,完善续传逻辑,完善对1byte文件的下载逻辑。

更新前:

52b8818a-9b67-4c1c-86d3-896ef6ff7177

 

更新后:

09dc456c-9f29-4331-aa1a-1dac5b1c14e0

 

更新代码:

                // Total bytes to read:

                long dataToRead = iStream.Length;

 

                Response.ContentType = "application/octet-stream";

                Response.AddHeader("Content-Disposition", "attachment; filename="" + fnUtf8 + """);

                /*

                    表示头500个字节:bytes=0-499

                    表示第二个500字节:bytes=500-999

                    表示最后500个字节:bytes=-500

                    表示500字节以后的范围:bytes=500-

                    第一个和最后一个字节:bytes=0-0,-1

                    同时指定几个范围:bytes=500-600,601-999

                */

                string range = Request.Headers.Get("Range");//续传

                if (!string.IsNullOrEmpty(range))

                {

                    string[] rs = range.Split("-".ToCharArray());//bytes=10254

                    int posBegin = rs[0].IndexOf("=") + 1;

                    string pos = rs[0].Substring(posBegin);

                    long offset_begin = long.Parse(pos);

                    iStream.Seek(offset_begin, SeekOrigin.Begin);

 

                    string con_range;

                    if (rs.Length == 2)

                    {

                        string offset_end = rs[1];

                        long totalLen = long.Parse(offset_end) - offset_begin;

                        ++totalLen;//字段大小+1

                        dataToRead = totalLen;//

                        con_range = string.Format("bytes {0}-{1}/{2}", offset_begin, offset_end, iStream.Length);

                    }

                    else

                    {

                        dataToRead -= offset_begin;//fix(2015-08-12):修复返回长度不正确的问题。

                        con_range = string.Format("bytes {0}-{1}/{2}", offset_begin, dataToRead, iStream.Length);

                    }

 

                    //add(2016-08-30):添加content-range,为多线程提供支持

                    Response.AddHeader("Content-Range", con_range);

                }

                Response.AddHeader("Content-Length", dataToRead.ToString());

 

10. 更新folder_appender.cs

取消使用字符串返回ID列表,改为使用临时表返回ID列表。使用临时表可处理更大的文件夹。

更新前:

294643ad-0b73-4c2e-822b-08e67a937082

更新后:

53e81b17-78cd-417a-b5a6-a4342e5e3260

 

更新前:

58b77a6e-4659-4833-aece-a14547fc72fc

 

更新后:

ec64211c-3158-49c6-adc4-2aaa6106e03a

 

11. 更新存储过程fd_add_batch.sql

更新前:

5326690f-7922-4e14-aaf0-a23638b3dbbb

 

更新后:

86263899-8723-4efe-bca9-d47bb1b7df62

 

原文地址:https://www.cnblogs.com/xproer/p/5861832.html