|
@@ -9,36 +9,20 @@ using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using DevExpress.Data.Helpers;
|
|
|
|
|
|
namespace SAGA.MBI
|
|
|
{
|
|
|
public class ProjectLogManager
|
|
|
{
|
|
|
- public static string FilePath { get;private set; } = "";
|
|
|
- /// <summary>
|
|
|
- /// revit文件名称初始化
|
|
|
- /// </summary>
|
|
|
- /// <param name="filePath"></param>
|
|
|
- public static void InitSetting(string filePath)
|
|
|
- {
|
|
|
- FilePath = filePath;
|
|
|
- }
|
|
|
#region 键值相关
|
|
|
/// <summary>
|
|
|
/// 创建文件键值
|
|
|
/// </summary>
|
|
|
- /// <param name="prefix"></param>
|
|
|
- /// <param name="fileName">暂时无用</param>
|
|
|
+ /// <param name="fileName">无扩展名名称</param>
|
|
|
/// <returns></returns>
|
|
|
- public static string CreateLogFileKey(string prefix, string fileName)
|
|
|
+ public static string CreateLogFileKey(string fileName)
|
|
|
{
|
|
|
- //StringBuilder builder = new StringBuilder();
|
|
|
- //builder.Append(SystemInfoUtil.GetMacAddress());
|
|
|
- //builder.Append(fileName.ToMD5());
|
|
|
- //return $"{prefix}_{builder.ToString().ToMD5()}";
|
|
|
- return prefix;
|
|
|
+ return fileName;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 创建指定项目的服务器文件键值
|
|
@@ -47,10 +31,9 @@ namespace SAGA.MBI
|
|
|
/// <returns></returns>
|
|
|
public static string CreateLogFileKey(Document doc)
|
|
|
{
|
|
|
- string fileName = doc.PathName;
|
|
|
- string path = fileName.GetFileName();
|
|
|
- string prefix = path ?? string.Empty;
|
|
|
- return CreateLogFileKey(prefix, fileName);
|
|
|
+ string pathName = doc.PathName;
|
|
|
+ string fileName = pathName.GetFileName();
|
|
|
+ return CreateLogFileKey(fileName??string.Empty);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -64,9 +47,8 @@ namespace SAGA.MBI
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- string prefix = fileName.GetFileName();
|
|
|
- string key = CreateLogFileKey(prefix, fileName);
|
|
|
- //var delFiles = UpLoadFileRequest.DeleteFiles(FileServiceSetting.RevitSetting, new List<string>(){key}) ?? new List<string>();
|
|
|
+ string noExtendFileName = fileName.GetFileName();
|
|
|
+ string key = CreateLogFileKey(noExtendFileName);
|
|
|
var delFiles = DeleteFiles(new List<string>() { key }) ?? new List<string>();
|
|
|
return 1 == delFiles.Count;
|
|
|
}
|
|
@@ -76,14 +58,19 @@ namespace SAGA.MBI
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 清除指定前缀的文件
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="prefix"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static bool ClearFiles(string prefix)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var files = GetFiles(prefix);//UpLoadFileRequest.GetFiles(FileServiceSetting.RevitSetting, prefix);
|
|
|
+ var files = GetFiles(prefix);
|
|
|
if (files==null||files.IsNullOrEmptyExt())
|
|
|
return true;
|
|
|
- var delFiles = DeleteFiles(files ?? new List<string>()); //UpLoadFileRequest.DeleteFiles(FileServiceSetting.RevitSetting, files)??new List<string>();
|
|
|
+ var delFiles = DeleteFiles(files ?? new List<string>());
|
|
|
|
|
|
return files.Count== delFiles.Count;
|
|
|
}
|
|
@@ -95,12 +82,7 @@ namespace SAGA.MBI
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region 获取日志内容
|
|
|
- public static string GetLogInfo(Document doc)
|
|
|
- {
|
|
|
- var fileKey = RevitUtils.Log.DocumentLogManager.GetLogFileKey(doc);
|
|
|
- return GetLogInfo(fileKey);
|
|
|
- }
|
|
|
+ #region 获取日志内容
|
|
|
/// <summary>
|
|
|
/// 获取日志内容,
|
|
|
/// </summary>
|
|
@@ -114,7 +96,6 @@ namespace SAGA.MBI
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- //var bytes = UpLoadFileRequest.DownloadFile(FileServiceSetting.RevitSetting, fileKey);
|
|
|
var bytes = DownLoadFile(fileKey);
|
|
|
if (bytes != null)
|
|
|
{
|
|
@@ -136,7 +117,6 @@ namespace SAGA.MBI
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- //return Path.Combine(MBIControl.ProjectBasePath,MBIControl.ProjectCur.Id)
|
|
|
return MBIControl.ProjectCur.LocalPath;
|
|
|
}
|
|
|
}
|
|
@@ -159,7 +139,6 @@ namespace SAGA.MBI
|
|
|
|
|
|
public static bool UpLoadFile(string fileKey, byte[] bytes)
|
|
|
{
|
|
|
- //UpLoadFileRequest.UploadFile(FileServiceSetting.RevitSetting, newFileKey, newBytes);
|
|
|
try
|
|
|
{
|
|
|
string path = Path.Combine(LogDirectory, fileKey);
|