|
@@ -81,8 +81,8 @@ namespace SAGA.MBI.DataArrange
|
|
|
if (!File.Exists(path)) return result;
|
|
|
try
|
|
|
{
|
|
|
- //关闭文档
|
|
|
- DocExtend.CloseDoc(path);
|
|
|
+ //关闭文档,注释掉是害怕此处更改模型,mxg,20181218
|
|
|
+ //DocExtend.CloseDoc(path);
|
|
|
string floorid = path.GetFileName();
|
|
|
RevitFileVision cvision = GetCloudFileVision(floorid);
|
|
|
cvision.Vision = cvision.Vision + 1;
|
|
@@ -98,36 +98,16 @@ namespace SAGA.MBI.DataArrange
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 判断两个文件是否一样
|
|
|
- /// 模型文件管理,不一样就可以替换
|
|
|
- /// 只要对比新文件MD5和本地版本文件的Md5
|
|
|
- /// </summary>
|
|
|
- /// <param name="becopyPath">将要对比的文件</param>
|
|
|
- /// <param name="floorid">旧文件的id,从本地版本配置中取Md5</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static bool IsNotSameFile(string becopyPath, string floorid)
|
|
|
- {
|
|
|
- bool result = false;
|
|
|
- if (!File.Exists(becopyPath)) return result;
|
|
|
- //关闭文档
|
|
|
- DocExtend.CloseDoc(becopyPath);
|
|
|
- var newmd5 = MD5Tools.GetMD5HashFromFile(becopyPath);
|
|
|
- if (newmd5.IsNullOrEmpty()) return result;
|
|
|
- RevitFileVision lvision = GetLocalFileVision(floorid);
|
|
|
- return (lvision?.MD5Code != newmd5);
|
|
|
- }
|
|
|
/// <summary>
|
|
|
/// 上传之前先检查文件是否变化,变化才出现在上传列表中
|
|
|
/// 直接对比,更新后Vision文件的md5值与revit文件的md5值
|
|
|
/// </summary>
|
|
|
/// <param name="path"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static bool IsFileChanged(string path)
|
|
|
+ public static bool IsFileChanged(string path,string floorName)
|
|
|
{
|
|
|
- string floorid = path.GetFileName();
|
|
|
- return IsNotSameFile(path, floorid);
|
|
|
+ var tuple = GetDownBackupState(path, floorName);
|
|
|
+ return (tuple?.Item2 == 1||tuple?.Item2 == 2 || tuple?.Item2 == 3);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -161,7 +141,9 @@ namespace SAGA.MBI.DataArrange
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取需要下载文件的状态
|
|
|
- /// 1,下载;2,备份并下载
|
|
|
+ /// 1,下载;
|
|
|
+ /// 2,备份并下载
|
|
|
+ /// 3,文件改变了
|
|
|
/// cloudvision初始值为1
|
|
|
/// </summary>
|
|
|
/// <param name="floorPath"></param>
|
|
@@ -175,11 +157,13 @@ namespace SAGA.MBI.DataArrange
|
|
|
var lvision = GetLocalFileVision(floorid);
|
|
|
if (!File.Exists(floorPath) && cvision.Vision != 0)
|
|
|
{
|
|
|
- //本文件不存在,服务器有文件。下载,不备份
|
|
|
+ //本地文件不存在,服务器有文件。下载,不备份
|
|
|
tuple = new Tuple<string, int, string>(floorPath, 1, floorName);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ #region 求MD5前关闭Doc
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
//Revit启动前无法加载RevitAPI.dll报错
|
|
@@ -190,26 +174,34 @@ namespace SAGA.MBI.DataArrange
|
|
|
{
|
|
|
Console.WriteLine(e);
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
var tempMd5 = MD5Tools.GetMD5HashFromFile(floorPath);
|
|
|
- if (cvision.MD5Code != tempMd5 && cvision.Vision > lvision.Vision)
|
|
|
+ if (tempMd5.IsNotNullEmpty())
|
|
|
{
|
|
|
- if (tempMd5.IsNullOrEmpty()) return tuple;
|
|
|
- if (tempMd5 == lvision.MD5Code)
|
|
|
- {//本地文件没有进行过更改,不备份
|
|
|
- tuple = new Tuple<string, int, string>(floorPath, 1, floorName);
|
|
|
+ //首先对比大版本号
|
|
|
+ if (cvision.Vision > lvision.Vision)
|
|
|
+ {
|
|
|
+ //对比小版本号,判断文件是否更改。如果不一样,说明发生更改,需要备份
|
|
|
+ if (tempMd5 == lvision.MD5Code)
|
|
|
+ {//本地文件没有进行过更改,不备份
|
|
|
+ tuple = new Tuple<string, int, string>(floorPath, 1, floorName);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {//本地文件发生了更改,进行备份
|
|
|
+ tuple = new Tuple<string, int, string>(floorPath, 2, floorName);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
- {//本地文件发生了更改,进行备份
|
|
|
- tuple = new Tuple<string, int, string>(floorPath, 2, floorName);
|
|
|
+ {
|
|
|
+ //大版本号不变,小版本号变了, 文件改变
|
|
|
+ if (tempMd5 != lvision.MD5Code)
|
|
|
+ {
|
|
|
+ tuple = new Tuple<string, int, string>(floorPath, 3, floorName);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //不需要下载的文件,同步版本号
|
|
|
- if (tuple == null)
|
|
|
- {
|
|
|
- lvision.Vision = cvision.Vision;
|
|
|
- lvision.MD5Code = cvision.MD5Code;
|
|
|
- }
|
|
|
return tuple;
|
|
|
}
|
|
|
/// <summary>
|