浏览代码

xls:空间管理对接模型上传测试打通

xulisong 6 年之前
父节点
当前提交
7fda162e1d

+ 2 - 2
MBI/SAGA.MBI/Interaction/MBIDocumentSaved.cs

@@ -51,8 +51,8 @@ namespace SAGA.MBI.Interaction
             * 5、删除文件
             */
 
-
-            var oldFileKey = DocumentLogManager.GetLogFileKey(document);
+            //2018年12月13日11:53:29 取键值的逻辑用不到了,直接去项目无扩展文件名
+            var oldFileKey = ProjectLogManager.CreateLogFileKey(document);// DocumentLogManager.GetLogFileKey(document);
             var oldLog = string.Empty;
 
             #region 获取服务器日志文件

+ 16 - 37
MBI/SAGA.MBI/ProjectLog/ProjectLogManager.cs

@@ -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);

+ 19 - 16
MBI/SAGA.MBI/RevitExport/MbiElementManager.cs

@@ -39,23 +39,26 @@ namespace SAGA.MBI.RevitExport
         /// </summary>
         /// <param name="doc"></param>
         public static void ExecuteExport(Document doc)
-        {
-            var str = string.Empty;
+        {;
             InitDb();
-            using (Transaction tran = new Transaction(doc, "导出"))
-            {
-                try
-                {
-                    tran.Start();
-                    MbiElementManager manager = new MbiElementManager();
-                    MBIDb = manager.ExportMbiEelemntDB(doc);
-                    tran.RollBack();
-                }
-                catch (Exception e)
-                {
-                    tran.RollBack();
-                }
-            }
+            MbiElementManager manager = new MbiElementManager();
+            MBIDb = manager.ExportMbiEelemntDB(doc);
+            #region 事物形式
+            //using (Transaction tran = new Transaction(doc, "导出"))
+            //{
+            //    try
+            //    {
+            //        tran.Start();
+            //        MbiElementManager manager = new MbiElementManager();
+            //        MBIDb = manager.ExportMbiEelemntDB(doc);
+            //        tran.RollBack();
+            //    }
+            //    catch (Exception e)
+            //    {
+            //        tran.RollBack();
+            //    }
+            //} 
+            #endregion
             return ;
         }
         /// <summary>

+ 16 - 12
MBI/SAGA.MBI/WinView/Space/WinCreateSpace.xaml.cs

@@ -660,19 +660,23 @@ namespace SAGA.MBI.WinView.Space
                 Logs.Log($"{DateTime.Now}被保存!!!!!!!!!!!!!!!!!!");
                 if (m_isCreaded)
                 {
-                    try
-                    {
-                        string str = "";
-                        UploadModeCommand command = new UploadModeCommand();
-                        command.Execute(null, ref str, null);
-                    }
-                    catch (Exception exception)
-                    {
-                        Console.WriteLine(exception);
-                        MessageBox.Show(exception.Message);
-                    }
+                    //放在命令里面
+                    //ExecuteCmd.ExecuteCommand(() =>
+                    //{
+                        try
+                        {
+                            string str = "";
+                            UploadModeCommand command = new UploadModeCommand();
+                            command.Execute(null, ref str, null);
+                        }
+                        catch (Exception exception)
+                        {
+                            Console.WriteLine(exception);
+                            MessageBox.Show(exception.Message);
+                        }
+                    //    return Result.Succeeded;
+                    //});            
                     m_isCreaded = false;
-
                 }
                 timer.Stop();
                 m_isAsynFinished = false;