版本发布:

一、局域网共享文件方式

 

发布界面:

更新界面:

 

二、FTP方式

发布界面

更新界面:

 

 

(只会更新有变动的文件)
同步新增,替换与删除
实现方式XML(文件名+文件最后修改时间)
状态判断:LINQ(通过对比本地XML和服务器XML的不同)

 

XML实质是一张DataSet

包含两张表

#region 获得数据集结构
/// <summary>
/// 获得数据集结构
/// </summary>
/// <returns></returns>
protected DataSet GenerateDataSchema()
{
DataTable dtV = new DataTable(DataSchema.VersionSchema.TableName);
dtV.Columns.Add(DataSchema.VersionSchema.Version); DataTable dtD = new DataTable(DataSchema.DetailSchema.TableName);
dtD.Columns.Add(DataSchema.DetailSchema.Name, typeof(System.String));//名称
dtD.Columns.Add(DataSchema.DetailSchema.EditDate, typeof(System.DateTime));//修改时间
dtD.Columns.Add(DataSchema.DetailSchema.Size, typeof(System.String));//大小
dtD.Columns.Add(DataSchema.DetailSchema.Path, typeof(System.String));//路径 DataSet ds = new DataSet(); ds.Tables.Add(dtV);
ds.Tables.Add(dtD); return ds;
}
#endregion

 

LINQ服务器和本地对比代码:

版本发布:

//需要新增的
//需要删除的
//需要替换的 var DataEdit = from dtLocation in LocalDetailFiles.AsEnumerable()
join dtServer in ServerDetailFiles.AsEnumerable()
on dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name) equals
dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name)
where dtLocation.Field<DateTime>(DataSchema.DetailSchema.EditDate) > dtServer.Field<DateTime>(DataSchema.DetailSchema.EditDate)
select new
{
Name = dtLocation.Field<string>(DataSchema.DetailSchema.Name),
Path = dtLocation.Field<string>(DataSchema.DetailSchema.Path)
};
var DataAdd = from dtLocal in LocalDetailFiles.AsEnumerable()
where !ServerDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtLocal.Field<string>(DataSchema.DetailSchema.Path) + dtLocal.Field<string>(DataSchema.DetailSchema.Name))
select new
{
Name = dtLocal.Field<string>(DataSchema.DetailSchema.Name),
Path = dtLocal.Field<string>(DataSchema.DetailSchema.Path)
};
var DataDelete = from dtServer in ServerDetailFiles.AsEnumerable()
where !LocalDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name))
select new
{
Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
}; dtUpdateFiles = new DataTable();
dtUpdateFiles.Columns.Add("Name", typeof(System.String));
dtUpdateFiles.Columns.Add("Path", typeof(System.String));
dtUpdateFiles.Columns.Add("Type", typeof(System.String)); foreach (var v in DataAdd)
{
DataRow dr = dtUpdateFiles.Rows.Add();
dr["Type"] = "1";
dr["Name"] = v.Name;
dr["Path"] = v.Path; //ListViewItem item = new ListViewItem("新增");
//item.SubItems.Add(v.Name);//文件名
//item.SubItems.Add(v.Path);//路径
//LVFile.Items.Add(item);
}
foreach (var v in DataEdit)
{
DataRow dr = dtUpdateFiles.Rows.Add();
dr["Type"] = "2";
dr["Name"] = v.Name;
dr["Path"] = v.Path; //ListViewItem item = new ListViewItem("替换");
//item.SubItems.Add(v.Name);//文件名
//item.SubItems.Add(v.Path);//路径
//LVFile.Items.Add(item);
}
foreach (var v in DataDelete)
{
DataRow dr = dtUpdateFiles.Rows.Add();
dr["Type"] = "3";
dr["Name"] = v.Name;
dr["Path"] = v.Path; //ListViewItem item = new ListViewItem("删除");
//item.SubItems.Add(v.Name);//文件名
//item.SubItems.Add(v.Path);//路径
//LVFile.Items.Add(item);
}

版本更新:

//需要新增的
//需要删除的
//需要替换的 var DataEdit = from dtServer in ServerDetailFiles.AsEnumerable()
join dtLocation in LocalDetailFiles.AsEnumerable()
on dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name) equals
dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name)
where dtServer.Field<DateTime>(DataSchema.DetailSchema.EditDate) > dtLocation.Field<DateTime>(DataSchema.DetailSchema.EditDate)
select new
{
Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
};
var DataAdd = from dtServer in ServerDetailFiles.AsEnumerable()
where !LocalDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name))
select new
{
Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
};
var DataDelete = from dtLocation in LocalDetailFiles.AsEnumerable()
where !ServerDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name))
select new
{
Name = dtLocation.Field<string>(DataSchema.DetailSchema.Name),
Path = dtLocation.Field<string>(DataSchema.DetailSchema.Path)
};

最新文章

  1. android:clipChildren属性的作用
  2. Python的方法解析顺序(MRO)
  3. 让PictureBox支持URL显示图片
  4. Theme皮肤文件(json解析、多文件管理)
  5. CLLocationManagerDelegate不调用didUpdateLocations (地图)
  6. 清空form表单下所有的input值-------------jquery
  7. 进入git diff 界面,无法继续输入命令
  8. shopnc2014年11版数据库字典
  9. iphone 6 设置自定义铃声(未越狱)
  10. JavaScript 风格指导(Airbnb版)
  11. [记录]ns_error_unexpected firefox tinymce
  12. NOI2011 兔兔与蛋蛋游戏
  13. php测试时不出现错误信息
  14. jmeter实例演示
  15. codeforces 522D. Closest Equals 线段树+离线
  16. PHP函数积累
  17. 在jsp中用一数组存储了数据库表中某一字段的值,然后在页面中输出其中的值。
  18. hadoop学习视频
  19. live2d+cocos2dx示例工程
  20. ElasticSearch(三)不仅仅是查询

热门文章

  1. 一、Java基础--01
  2. 使用node-webkit开发exe窗口程序
  3. android实操--练习1
  4. android 学习随笔三(测试与单元测试框架)
  5. Overview of Flashback Technology
  6. HDU 5795:A Simple Nim(博弈)
  7. GDCPC2016 省赛随笔
  8. php函数:PHP pathinfo() 函数
  9. 《图解TCP/IP》
  10. $q服务的API详解