断点续传

Posted yyl001

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了断点续传相关的知识,希望对你有一定的参考价值。

//读入文件表到内存表
FilesTable ctb = new FilesTable(Application.StartupPath + "\\TableData\\");
ctb.GetFileModel(CommonRse.ds_file);

 

设置一个 技术分享图片 这样的表

 

public void Start()
{
while (true)
{
//重置医院列表
HospitalList = BLL.ExecuteQuery.GetHospitalList(false);
HospI = 0;

#region 拿到续传参数
if (BLL.ExecuteQuery.GetCloseInfoCount() == 0)
{
//新建一条
BLL.ExecuteQuery.AddCloseInfo();
}
DataTable CloseInfo_Tb = BLL.ExecuteQuery.GetCloseInfo();
bool chongzhi = true;
//拿到记录医院ID,得到索引
for (int i = 0; i < HospitalList.Rows.Count; i++)
{
if(HospitalList.Rows[i]["HospID"].ToString() == CloseInfo_Tb.Rows[0]["i"].ToString())
{
HospI = i;
chongzhi = false;
break;
}
}
//判断是否是断点续传
if(chongzhi)
{
Number = 0;
}
else
{
try
{
Number = String.IsNullOrEmpty(CloseInfo_Tb.Rows[0]["Number"].ToString()) ? 0 : Convert.ToInt32(CloseInfo_Tb.Rows[0]["Number"]);
}
catch
{
Number = 0;
//清空
cleardgv();
}
if(Number!=0)
{
try
{
endTime = String.IsNullOrEmpty(CloseInfo_Tb.Rows[0]["EndTime"].ToString()) ? default(DateTime) : DateTime.Parse(CloseInfo_Tb.Rows[0]["EndTime"].ToString());
}
catch
{
endTime = default(DateTime);
}
}
}
#endregion

//遍历每个医院
for (int i = HospI; i < HospitalList.Rows.Count; i++)
{
SetStateText("正在初始化医院信息...");
#region 医院登录初始化,拿到上一次时间
signover = false;
sgbtnover = false;
qybtnover = false;
HospI = i;
startTime = DateTime.Parse(HospitalList.Rows[i]["Time"].ToString().Trim());
AesKey = HospitalList.Rows[i]["Aes"].ToString().Trim();
Hid = HospitalList.Rows[i]["HospID"].ToString().Trim();
HospName = HospitalList.Rows[i]["HospName"].ToString().Trim();
OrgID = HospitalList.Rows[i]["OrgID"].ToString().Trim();
ProductCode = HospitalList.Rows[i]["ProductCode"].ToString().Trim();
RegCodeList = HospitalList.Rows[i]["RegCodeList"].ToString().Trim();
StartID = HospitalList.Rows[i]["StartID"].ToString().Trim();
RegCodeID = BLL.ExecuteQuery.GetRegCodeID(RegCodeList);

DPStart_GRUD(true, startTime, Hid, HospName);
//设置区域时间【startTime - endTime】
SetStateText("获取服务器时间中...");
int errori = 0;
try
{
if(endTime == default(DateTime))
{

endTime = DateTime.Parse(znjtys.GetServerTime());

//if()
//记录尾巴时间到 数据库
BLL.ExecuteQuery.UpdateCloseInfo(endTime.ToString("yyyy-MM-dd HH:mm:ss"));
}
errori = -1;
}
catch{}
while (errori == 0)
{
errori++;
SetStateText($"获取服务器时间失败.正在重新尝试第[{errori.ToString()}]次...");
try
{
endTime = DateTime.Parse(znjtys.GetServerTime());
//记录尾巴时间到 数据库
BLL.ExecuteQuery.UpdateCloseInfo(endTime.ToString("yyyy-MM-dd HH:mm:ss"));
break;
}
catch { errori = 0; }
Thread.Sleep(500);
}
//endTime = DateTime.Parse("2018-04-09 18:00:00");
//获取医院所有医生
SetStateText("获取医生列表中...");
doctorlist = GetDoctorList(Hid, AesKey);
errori = 0;
while (doctorlist == null)
{
errori++;
SetStateText($"获取医生列表失败.正在重新尝试第[{errori.ToString()}]次...");
doctorlist = GetDoctorList(Hid, AesKey);
Thread.Sleep(5500);
}
#endregion
//设置基础信息
new gw_api().setdocmsg(null, ProductCode, RegCodeList, RegCodeID, OrgID);
//设置运行时必须的参数
SetRunInfo();
//点击同步
if (Number == 0)
{
signBtn_Click(new object(), new EventArgs());
}
else
{
signover = true;
}
//等待同步结束
while (!signover) { Thread.Sleep(1000); }
//全选用户表和签约表
checkedAll();
Thread.Sleep(500);
//点击上传两个按钮
scBtn_Click(new object(), new EventArgs());
while (!sgbtnover) { Thread.Sleep(500); }
qyBtn_Click(new object(), new EventArgs());//签约上传

//等待两个上传结束
while (!sgbtnover ) { Thread.Sleep(1000); }
//启动下载类
//new AutoDown(startTime,Hid,AesKey,ProductCode, StartID).Start();
//写入时间
BLL.ExecuteQuery.SetHospitalTime(Hid, endTime);
BLL.ExecuteQuery.UpdateCloseInfo(Hid, "","");
endTime = default(DateTime);
Thread.Sleep(3000);
}
//清空续传记录
BLL.ExecuteQuery.UpdateCloseInfo("", "","");
Thread.Sleep(20000);
}
}

 

























































































































































以上是关于断点续传的主要内容,如果未能解决你的问题,请参考以下文章

Linux下实现断点续传的原理介绍

用C实现断点续传的功能,详细点的实现原理是啥嘞

chrome 怎么http断点续传

java实现文件的断点续传和断点下载,有知道的交流下。

如何用Java实现HTTP断点续传功能

如何实现HTML5文件断点续传