Bladeren bron

xls:拓扑版本变更

xulisong 6 jaren geleden
bovenliggende
commit
086c39475e
25 gewijzigde bestanden met toevoegingen van 661 en 70 verwijderingen
  1. 4 0
      MBI/MBIResource/RevitEvents/RevitEvents.xml
  2. 4 0
      MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs
  3. 90 18
      MBI/SAGA.GplotManage/GplotCommand.cs
  4. 0 26
      MBI/SAGA.GplotManage/SAGA.GplotManage.csproj
  5. 29 0
      MBI/SAGA.GplotRelationComputerManage/Common/CacheFileState.cs
  6. 23 0
      MBI/SAGA.GplotRelationComputerManage/Common/FileMD5Util.cs
  7. 1 2
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/DistributionRelationshipHandler.cs
  8. 18 2
      MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs
  9. 2 0
      MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj
  10. 9 7
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerDataUtil.cs
  11. 2 2
      MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs
  12. 10 7
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/RelationTypeUtil.cs
  13. 20 1
      MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs
  14. 4 0
      MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs
  15. 59 0
      MBI/SAGA.MBI/Gplot/GplotFileItem.cs
  16. 89 0
      MBI/SAGA.MBI/Gplot/GplotWatch.cs
  17. 113 0
      MBI/SAGA.MBI/Gplot/JsonConfig.cs
  18. 129 0
      MBI/SAGA.MBI/Interaction/MBIGplotChanged.cs
  19. 1 1
      MBI/SAGA.MBI/ProjectLog/ProjectLogManager.cs
  20. 4 0
      MBI/SAGA.MBI/SAGA.MBI.csproj
  21. 21 0
      MBI/SAGA.RevitUtils/ExtendInterface/IDocumentChanged.cs
  22. 19 1
      MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsBingding.cs
  23. 7 1
      MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsSetting.cs
  24. 1 0
      MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj
  25. 2 2
      MBI/WPfPointInfo/InfoProperty/Converter/DateConvert.cs

+ 4 - 0
MBI/MBIResource/RevitEvents/RevitEvents.xml

@@ -4,6 +4,10 @@
     <DllName>OutputDll\SAGA.MBI.exe</DllName>
     <ClassName>SAGA.MBI.Interaction.MBIDocumentSaved</ClassName>
 </IDocumentSaved>
+<IDocumentChanged>
+    <DllName>OutputDll\SAGA.MBI.exe</DllName>
+    <ClassName>SAGA.MBI.Interaction.MBIGplotChanged</ClassName>
+</IDocumentChanged>
 <IUpdaterRegister>
     <DllName>OutputDll\SAGA.MBI.exe</DllName>
     <ClassName>SAGA.MBI.Interaction.MBILocalNameTrigger</ClassName>

+ 4 - 0
MBI/SAGA.GplotDrawData/WinDrawSpace-Web.xaml.cs

@@ -48,6 +48,8 @@ namespace SAGA.GplotDrawData
         public void InitVerticalSpaces()
         {
             var spaceData = SpaceComputerDataUtil.GetSpaceDataByType(SpaceRelatedEnum.Crossing);
+            if (spaceData == null)
+                return;
             InitVSpaceTree(spaceData.FloorDatas);
         }
         /// <summary>
@@ -142,6 +144,8 @@ namespace SAGA.GplotDrawData
             foreach (var seed in seeds)
             {
                 var spaceDatas = SpaceComputerDataUtil.GetSpaceDataByType(seed.Key);
+                if (spaceDatas == null)
+                    continue;
                 var floorItems = spaceDatas.FloorDatas;
                 var buildGroup = floorItems.GroupBy(f => f.BuildingId);
                 foreach (var build in buildGroup)

+ 90 - 18
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -24,11 +24,28 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            /*
+             * 交互逻辑:
+             * 1、缓存结果不存在,直接计算
+             * 2、缓存结果存在,且没有过期,直接显示
+             * 3、缓存结果存在,且数据过去,弹出提示框,用户选择是否重新计算
+             */
+            var state = SpaceComputerDataUtil.ComputeFileState();
+            if (state==CacheFileState.Miss)
             {
-                return Result.Succeeded;
+                SpaceComputerHandler.ComputerAllRelations();              
+            }
+            else if(state == CacheFileState.Expire)
+            {
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SpaceComputerHandler.ComputerAllRelations();
+                }
             }
-            SpaceComputerHandler.ComputerAllRelations();
             var win = new WinDrawSpace_Web(GplotShowType.ViewPlan);// 
             win.Show();
             return Result.Succeeded;
@@ -48,11 +65,22 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            var state = SpaceComputerDataUtil.ComputeFileState();
+            if (state == CacheFileState.Miss)
+            {
+                SpaceComputerHandler.ComputerAllRelations();
+            }
+            else if (state == CacheFileState.Expire)
             {
-                return Result.Succeeded;
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SpaceComputerHandler.ComputerAllRelations();
+                }
             }
-            SpaceComputerHandler.ComputerAllRelations();
             var win = new WinDrawSpace_Web(GplotShowType.VerticalPlan);
             win.Show();
             return Result.Succeeded;
@@ -73,11 +101,22 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            var state = SystemComputerHandler.ComputeFileState();
+            if (state == CacheFileState.Miss)
+            {
+                SystemComputerHandler.ComputerAllRelations();
+            }
+            else if (state == CacheFileState.Expire)
             {
-                return Result.Succeeded;
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SystemComputerHandler.ComputerAllRelations();
+                }
             }
-            SystemComputerHandler.ComputerAllRelations();
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
             floorWin.Show();
             return Result.Succeeded;
@@ -98,11 +137,22 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            var state = SystemComputerHandler.ComputeFileState();
+            if (state == CacheFileState.Miss)
             {
-                return Result.Succeeded;
+                SystemComputerHandler.ComputerAllRelations();
+            }
+            else if (state == CacheFileState.Expire)
+            {
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SystemComputerHandler.ComputerAllRelations();
+                }
             }
-            SystemComputerHandler.ComputerAllRelations();
             WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
             floorWin.Show();
             return Result.Succeeded;
@@ -123,11 +173,22 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            var state = SystemComputerHandler.ComputeFileState();
+            if (state == CacheFileState.Miss)
+            {
+                SystemComputerHandler.ComputerAllRelations();
+            }
+            else if (state == CacheFileState.Expire)
             {
-                return Result.Succeeded;
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SystemComputerHandler.ComputerAllRelations();
+                }
             }
-            SystemComputerHandler.ComputerAllRelations();
             WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);
             verticalWin.Show();
             return Result.Succeeded;
@@ -149,11 +210,22 @@ namespace SAGA.GplotManage
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
-            if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
+            //{
+            //    return Result.Succeeded;
+            //}
+            var state = SystemComputerHandler.ComputeFileState();
+            if (state == CacheFileState.Miss)
+            {
+                SystemComputerHandler.ComputerAllRelations();
+            }
+            else if (state == CacheFileState.Expire)
             {
-                return Result.Succeeded;
+                if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
+                {
+                    SystemComputerHandler.ComputerAllRelations();
+                }
             }
-            SystemComputerHandler.ComputerAllRelations();
             WinMachineRoom room = new WinMachineRoom();
             room.Show();
             return Result.Succeeded;

+ 0 - 26
MBI/SAGA.GplotManage/SAGA.GplotManage.csproj

@@ -100,33 +100,7 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="Command.cs" />
-    <Compile Include="Command\ColdGplot\ColdRoomSystemCompute.cs" />
-    <Compile Include="Command\ColdGplot\ColdRoomSystemParse.cs" />
-    <Compile Include="Command\ColdGplot\ColdRoomSystemView.cs" />
-    <Compile Include="Command\ColdRommFactory.cs" />
-    <Compile Include="Command\GplotClientFactory.cs" />
-    <Compile Include="Command\RoomShowHandler.cs" />
-    <Compile Include="GplotManage\DrawData.cs" />
-    <Compile Include="GplotManage\GplotDefinition\GplotTypeItem.cs" />
-    <Compile Include="GplotManage\GplotDefinition\GplotTypeManager.cs" />
-    <Compile Include="GplotManage\GplotEdgeItem.cs" />
-    <Compile Include="GplotManage\GplotFileItem.cs" />
-    <Compile Include="GplotManage\JsonConfig.cs" />
-    <Compile Include="GplotManage\LocalDataUtil.cs" />
-    <Compile Include="Command\MethodExtension.cs" />
     <Compile Include="GplotCommand.cs" />
-    <Compile Include="GplotManage\GplotClient.cs" />
-    <Compile Include="GplotManage\GplotClientContext.cs" />
-    <Compile Include="GplotManage\GplotCompute\GplotComputeData.cs" />
-    <Compile Include="GplotManage\GplotCompute\GplotCompute.cs" />
-    <Compile Include="GplotManage\GplotDefinition.cs" />
-    <Compile Include="GplotManage\GplotData.cs" />
-    <Compile Include="GplotManage\GplotDefinition\GplotDefinitionType.cs" />
-    <Compile Include="GplotManage\GplotParse\GplotParseData.cs" />
-    <Compile Include="GplotManage\GplotParse\GplotParse.cs" />
-    <Compile Include="GplotManage\GplotView\GplotViewData.cs" />
-    <Compile Include="GplotManage\GplotView\GplotView.cs" />
-    <Compile Include="Command\GplotUtil.cs" />
     <Compile Include="GraphTypeEnum.cs" />
     <Compile Include="RelationManager\ElectricalRelationUploader.cs" />
     <Compile Include="RelationManager\IRelationUploader.cs" />

+ 29 - 0
MBI/SAGA.GplotRelationComputerManage/Common/CacheFileState.cs

@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:CacheFileState
+ * 作者:xulisong
+ * 创建时间: 2019/5/17 15:19:24
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage
+{
+    /// <summary>
+    /// 缓存文件状态
+    /// </summary>
+    public enum CacheFileState
+    {
+        [Description("缺失")]
+        Miss,
+        [Description("过期")]
+        Expire,
+        [Description("正常")]
+        Normal,
+    }
+}

+ 23 - 0
MBI/SAGA.GplotRelationComputerManage/Common/FileMD5Util.cs

@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FileMD5Util
+ * 作者:xulisong
+ * 创建时间: 2019/5/16 19:08:32
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.GplotRelationComputerManage.Common
+{
+    public class FileMd5Item
+    {
+
+    }
+    public static class FileMD5Util
+    {
+    }
+}

+ 1 - 2
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/DistributionRelationshipHandler.cs

@@ -50,8 +50,7 @@ namespace SAGA.GplotRelationComputerManage
         /// <param name="context"></param>
         /// <returns></returns>
         public List<DataNode> GetViewData(PowerComputerContext context)
-        {
-          
+        {          
             var items = GetParseData(context);
             var originNodes = items.Select(i => context.ItemConvert(i)).ToList();
             foreach (var originNode in originNodes)

+ 18 - 2
MBI/SAGA.GplotRelationComputerManage/PowerDistribution/ComputerHandler/EquipPowerRelationshipHandler.cs

@@ -30,16 +30,32 @@ namespace SAGA.GplotRelationComputerManage
         public List<MBIItem> GetParseData(PowerComputerContext context)
         {
             List<MBIItem> items = new List<MBIItem>();
+            var types = new[] { MBIBuiltInCategory.TDHS, MBIBuiltInCategory.TDLS, MBIBuiltInCategory.TDTF, MBIBuiltInCategory.TDLSDW };
             var rootTypes = new[] {MBIBuiltInCategory.Eq, MBIBuiltInCategory.Si};
             List<JObject> nodeDatas = CommonConvert.QueryObjectInfoByTypes(rootTypes);
             foreach (var jobject in nodeDatas)
             {
                 //排除没有设置主控线的设备
-                if (((JObject)jobject["infos"]).Property(MBIBuiltInParameter.CTM_MainPower) == null)
-                    continue;
+                //if (((JObject)jobject["infos"]).Property(MBIBuiltInParameter.CTM_MainPower) == null)
+                //    continue;
                 var item = MBIItemFactory.Create(jobject);
                 if (item != null)
                 {
+                    if (item is MBIEquipItem mbiItem)
+                    {
+                        var useType = mbiItem.Category.Remove(0, 2);
+                        if (useType != null && !types.Contains(useType))
+                        {
+                            if (((JObject)jobject["infos"]).Property(MBIBuiltInParameter.CTM_MainPower) == null)
+                                continue;
+                        }
+                    }
+
+                    if (item is RoomItem)
+                    {
+                        if (((JObject)jobject["infos"]).Property(MBIBuiltInParameter.CTM_MainPower) == null)
+                            continue;
+                    }
                     items.Add(item);
                 }
             }

+ 2 - 0
MBI/SAGA.GplotRelationComputerManage/SAGA.GplotRelationComputerManage.csproj

@@ -101,8 +101,10 @@
     <Compile Include="ColdRoom\VectorExtension.cs" />
     <Compile Include="Common\AppSetting.cs" />
     <Compile Include="Common\BinaryRelationUtil.cs" />
+    <Compile Include="Common\CacheFileState.cs" />
     <Compile Include="Common\ComputerFileSetting.cs" />
     <Compile Include="Common\DataServerUtil.cs" />
+    <Compile Include="Common\FileMD5Util.cs" />
     <Compile Include="Common\FloorUtil.cs" />
     <Compile Include="Common\MBIInfoUtil.cs" />
     <Compile Include="Common\PointConverter.cs" />

+ 9 - 7
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerDataUtil.cs

@@ -10,6 +10,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using SAGA.MBI;
 using SAGA.Models;
 
 namespace SAGA.GplotRelationComputerManage
@@ -35,17 +36,18 @@ namespace SAGA.GplotRelationComputerManage
             return !DataServerUtil.Current.GetFile(ComputerFileSetting.SpaceData).Exists();
         }
         /// <summary>
-        /// 判断空间是否重新计算
+        /// 计算文件状态
         /// </summary>
         /// <returns></returns>
-        public static bool IsReCompute()
+        public static CacheFileState ComputeFileState()
         {
             if (IsMissData())
             {
-                return true;
+                GplotWatch.RefreshSpace(DateTime.Now);
+                return CacheFileState.Miss;
             }
-            var lastUpdateTime = RelationTypeUtil.GetLastWriteTime();
-            return IsExpired(lastUpdateTime);
+            var lastUpdateTime = GplotWatch.GetSpaceTime();// RelationTypeUtil.GetLastWriteTime();
+            return IsExpired(lastUpdateTime)?CacheFileState.Expire: CacheFileState.Normal;
         }
         #endregion
 
@@ -82,7 +84,7 @@ namespace SAGA.GplotRelationComputerManage
                 }
             }
             return spaces;         
-        } 
-        #endregion
+        }
+        #endregion   
     }
 }

+ 2 - 2
MBI/SAGA.GplotRelationComputerManage/SpaceRelation/SpaceComputerHandler.cs

@@ -66,8 +66,8 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         public void ComputerWidthCache()
         {
-            bool isReCoumpute = SpaceComputerDataUtil.IsReCompute();
-            if (isReCoumpute)
+            bool isCoumpute = SpaceComputerDataUtil.ComputeFileState()!=CacheFileState.Normal;
+            if (isCoumpute)
             {
                 Computer();
             }

+ 10 - 7
MBI/SAGA.GplotRelationComputerManage/SystemRelation/Common/RelationTypeUtil.cs

@@ -1,4 +1,5 @@
-using System;
+using SAGA.MBI;
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
@@ -17,25 +18,27 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         /// <param name="relationTypes"></param>
         /// <returns></returns>
-        public static List<string> NeedResetRelationTypes(List<string> relationTypes)
+        public static Dictionary<string, CacheFileState> NeedResetRelationTypes(List<string> relationTypes)
         {
-            List<string> result = new List<string>();
+            Dictionary<string, CacheFileState> result = new Dictionary<string, CacheFileState>();
             foreach (string relationType in relationTypes)
             {
                 RelationDataCheck check = new RelationDataCheck(relationType);
                 if(check.IsMissData())
                 {
-                    result.Add(relationType);
+                    result[relationType]= CacheFileState.Miss;
+                    GplotWatch.RefreshSystem(DateTime.Now);
                     continue;
                 }
                 //获取日志变更时间
-                DateTime dateTime = GetLastWriteTime();
+                DateTime dateTime = GplotWatch.GetSystemTime();// GetLastWriteTime();
                 if(check.IsExpired(dateTime))
                 {
                     //测试不验证事件
-                    result.Add(relationType);
+                    result[relationType] = CacheFileState.Expire;
                     continue;
                 }
+                
             }
 
             return result;
@@ -46,7 +49,7 @@ namespace SAGA.GplotRelationComputerManage
         /// </summary>
         /// <returns></returns>
         public static DateTime GetLastWriteTime()
-        {
+        {            
             DateTime dateTime = new DateTime(0);
             var files = RevitModelPath.GetAllRevitFiles();
             foreach (var file in files)

+ 20 - 1
MBI/SAGA.GplotRelationComputerManage/SystemRelation/SystemComputerHandler.cs

@@ -77,7 +77,7 @@ namespace SAGA.GplotRelationComputerManage
             {
                 return;
             }
-            Computer(useRelationTypes);
+            Computer(useRelationTypes.Keys.ToList());
         }
 
 
@@ -94,5 +94,24 @@ namespace SAGA.GplotRelationComputerManage
             SystemComputerHandler handler1 = new SystemComputerHandler();
             handler1.ComputerWidthCache(useRelations);
         }
+        /// <summary>
+        /// 判断是否重新计算
+        /// </summary>
+        /// <returns></returns>
+        public static CacheFileState ComputeFileState()
+        {
+            var useRelations = RelationTypeManager.GetSystemRelationTypeNames();          
+            var useRelationTypes = RelationTypeUtil.NeedResetRelationTypes(useRelations);
+            if (!useRelationTypes.Any())
+            {
+                return CacheFileState.Normal;
+            }
+
+            if (useRelationTypes.Any(s => s.Value == CacheFileState.Miss))
+            {           
+                return CacheFileState.Miss;
+            }
+            return CacheFileState.Expire;
+        }
     }
 }

+ 4 - 0
MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs

@@ -66,6 +66,9 @@ namespace SAGA.MBI.DataArrange
 
                     //下载成功清除本机本层的日志数据,其它用户的日志上传成功的时候才清除日志
                     ProjectLogManager.ClearFile(tuple.Item1);
+                    //更新拓扑计算结果版本
+                    GplotWatch.RefreshAll(DateTime.Now);
+                   
                     j++;
                 }
                 else
@@ -97,6 +100,7 @@ namespace SAGA.MBI.DataArrange
                 DalVisionOperate.SaveLocalVision(floorid, DalVisionOperate.GetCloudFileVision(floorid));
                 //下载成功清除本机本层的日志数据,其它用户的日志上传成功的时候才清除日志
                 ProjectLogManager.ClearFile(tuple.Item1);
+                GplotWatch.RefreshAll(DateTime.Now);
             }
             else
             {

+ 59 - 0
MBI/SAGA.MBI/Gplot/GplotFileItem.cs

@@ -0,0 +1,59 @@
+
+using SAGA.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI
+{
+    /// <summary>
+    /// 拓扑文件信息
+    /// </summary>
+    public class GplotFileItem
+    {
+        public GplotFileItem()
+        {
+
+        }
+        public GplotFileItem(DateTime dateTiem)
+        {
+            TimeStamp = dateTiem.ToString("yyyyMMddHHmmss");
+        }
+        /// <summary>
+        /// 时间戳信息
+        /// </summary>
+        public string TimeStamp { get; set; } = string.Empty;
+    }
+
+    public class GplotFileConfig : JsonConfig<GplotFileItem>
+    {
+        public GplotFileConfig(string filePath) : base(filePath)
+        {
+
+        }
+        #region 原型工厂
+        private static Dictionary<string, GplotFileConfig> m_Configs = new Dictionary<string, GplotFileConfig>();
+        /// <summary>
+        /// 当前项目配置
+        /// </summary>
+        public static GplotFileConfig Current
+        {
+            get {
+                var currentKey =Path.Combine(StaticData.DbDirectory,"GplotFileConfig.dll");
+
+                if (!m_Configs.TryGetValue(currentKey, out GplotFileConfig config))
+                {
+                    config = new GplotFileConfig(currentKey);
+                    config.Load();
+                    m_Configs[currentKey] = config;
+                }
+
+                return config;
+            }
+        }
+        #endregion
+    }
+}

+ 89 - 0
MBI/SAGA.MBI/Gplot/GplotWatch.cs

@@ -0,0 +1,89 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:GplotWatch
+ * 作者:xulisong
+ * 创建时间: 2019/5/17 12:04:04
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI
+{
+    public class GplotWatch
+    {
+        public const string Space = "Space";
+        public const string System = "System";
+
+        public static void RefreshAll(DateTime dateTime)
+        {
+            try
+            {
+                GplotWatch.RefreshSpace(dateTime);
+                GplotWatch.RefreshSystem(dateTime);
+            }
+            catch (Exception)
+            {
+            }          
+        }
+        public static void Refresh(string key,DateTime dateTime)
+        {
+            GplotFileConfig.Current[key] = new GplotFileItem(dateTime);
+        }
+        public static void RefreshSpace( DateTime dateTime)
+        {
+            Refresh(Space, dateTime);
+        }
+        public static void RefreshSystem(DateTime dateTime)
+        {
+            Refresh(System, dateTime);
+        }
+
+        public static string GetTimespan(string key)
+        {
+            string tempStamp= GplotFileConfig.Current[key]?.TimeStamp;
+            if (string.IsNullOrWhiteSpace(tempStamp))
+            {
+                Refresh(key,DateTime.Now);
+            }
+            return tempStamp;
+        }
+        public static string GetSpaceTimespan()
+        {
+            return GetTimespan(Space);
+        }
+        public static DateTime GetSpaceTime()
+        {
+            var strSpan= GetTimespan(Space);
+            return ConvertToDateTime(strSpan);
+        }
+        public static DateTime GetSystemTimespan()
+        {
+            var strSpan = GetTimespan(System);       
+            return ConvertToDateTime(strSpan);
+        }
+        public static DateTime GetSystemTime()
+        {
+            var strSpan = GetTimespan(System);
+            return ConvertToDateTime(strSpan);
+        }
+        private static DateTime ConvertToDateTime(string timeStr)
+        {
+            if (string.IsNullOrEmpty(timeStr))
+            {
+                return DateTime.Now;
+            }
+            string buildingTime =("yyyyMMddHHmmss");
+            if (DateTime.TryParseExact(timeStr.ToString(), buildingTime, CultureInfo.CurrentCulture,
+                DateTimeStyles.AssumeLocal, out DateTime dateTime))
+            {
+                return dateTime;
+            }
+            return DateTime.Now;
+        }
+    }
+}

+ 113 - 0
MBI/SAGA.MBI/Gplot/JsonConfig.cs

@@ -0,0 +1,113 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+namespace SAGA.MBI
+{
+    /// <summary>
+    /// Json配置文件
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public class JsonConfig<T>
+    {
+        
+        public JsonConfig(string filePath)
+        {
+            DefaultLocation = filePath;
+            Items = new Dictionary<string, T>();
+        }
+        public string DefaultLocation { get; private set; }
+        /// <summary>
+        /// 自定义设置
+        /// </summary>
+        public JsonSerializerSettings CustomJsonSettings { get; set; }
+        /// <summary>
+        /// 数据源
+        /// </summary>
+        private Dictionary<string,T> Items {  get;  set; }
+        public void Save()
+        {
+            Save(DefaultLocation);
+        }
+        public void Load()
+        {
+            Load(DefaultLocation);
+        }
+        public void Save(string filePath)
+        {
+            WaitCallback action = (state) =>
+            {
+                try
+                {
+                    var settings = GetCurrentJsonSetting();
+                    var jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(Items, settings);
+                    var path = filePath;
+                    var directory = Path.GetDirectoryName(path);
+                    if (directory != null && !Directory.Exists(directory))
+                    {
+                        Directory.CreateDirectory(directory);
+                    }
+                    File.WriteAllText(path, jsonStr, Encoding.UTF8);
+                }
+                catch (Exception ex)
+                {
+                    //todo 吞掉
+                   
+                }
+            };
+            ThreadPool.QueueUserWorkItem(action, null);
+        }
+
+        public void Load(string filePath)
+        {
+            var path = filePath;
+            if (File.Exists(path))
+            {
+                string str = File.ReadAllText(path, Encoding.UTF8);
+                var settings = GetCurrentJsonSetting();
+                var tempItems= Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string,T>>(str, settings);
+                foreach (var item in tempItems)
+                {
+                    Items[item.Key] = item.Value;
+                }
+            }
+        }
+        #region 私有方法
+        private JsonSerializerSettings GetCurrentJsonSetting()
+        {
+            var settings = CustomJsonSettings;
+            if (settings == null)
+            {
+                settings=new JsonSerializerSettings();
+                settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
+            }
+            return settings;
+        }
+        #endregion
+
+        public T this[string key]
+        {
+            get {
+                Items.TryGetValue(key, out T value);
+                return value; }
+            set {
+                Items[key] = value;
+                Save();
+            }
+        }
+        /// <summary>
+        /// 是否包含键值
+        /// </summary>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        public bool ContainKey(string key)
+        {
+            return Items.ContainsKey(key);
+        }
+
+    }
+}

+ 129 - 0
MBI/SAGA.MBI/Interaction/MBIGplotChanged.cs

@@ -0,0 +1,129 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MBIGplotChanged
+ * 作者:xulisong
+ * 创建时间: 2019/5/17 9:49:33
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Events;
+using SAGA.DotNetUtils.Extend;
+using SAGA.RevitUtils.ExtendInterface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI.Interaction
+{
+    public class MBIGplotChanged : IDocumentChanged
+    {
+        public void Handle(object sender, DocumentChangedEventArgs e)
+        {
+            var document = e.GetDocument();
+            var fileName = document.PathName?.GetFileName();
+            if (string.IsNullOrWhiteSpace(fileName) || !fileName.StartsWith("Fl"))
+            {
+                return;
+            }
+            bool affectSpace = false;
+            bool affectSystem = false;
+            var useFilter = CreateFilter();
+            var deleteElements = e.GetDeletedElementIds();
+            if (deleteElements.Any())
+            {
+                //如果有删除数据,则拓扑图需要更新
+                affectSpace = true;
+                affectSystem = true;
+                goto Record;
+            }
+            var addElements = e.GetAddedElementIds(useFilter);            
+            var updateElements = e.GetModifiedElementIds(useFilter);
+            var useElementIds = new List<ElementId>();
+            useElementIds.AddRange(addElements);
+            useElementIds.AddRange(updateElements);
+            
+            foreach (var item in useElementIds.Distinct())
+            {
+                var element = document.GetElement(item);
+                if (!element.IsValidObject)
+                {
+                    continue;
+                }
+
+                var categoryId = element?.Category?.Id;
+                if (categoryId == null)
+                {
+                    continue;
+                }
+
+                #region 判断空间受到影响
+                if (!affectSpace)
+                {
+                    if (categoryId.IntegerValue == (int)BuiltInCategory.OST_MEPSpaces ||
+                        categoryId.IntegerValue == (int)BuiltInCategory.OST_MEPSpaces ||
+                        categoryId.IntegerValue == (int)BuiltInCategory.OST_Doors ||
+                        categoryId.IntegerValue == (int)BuiltInCategory.OST_Windows)
+                    {
+                        //空间拓重新计算
+                        affectSpace = true;
+                    }
+                }
+                #endregion
+
+                #region 判断系统受到影响
+                if (!affectSystem)
+                {
+                    if (categoryId.IntegerValue == (int)BuiltInCategory.OST_PipeCurves ||
+                        categoryId.IntegerValue == (int)BuiltInCategory.OST_DuctCurves)
+                    {
+                        //系统拓重新计算
+                        affectSystem = true;
+                    }
+                    else if (element is FamilyInstance fi)
+                    {
+                        affectSystem = fi.MEPModel != null;
+                    }
+                } 
+                #endregion
+
+                if (affectSpace && affectSystem)
+                {
+                    break;
+                }
+            }
+
+        Record:
+            DateTime dateTime = DateTime.Now;
+            if (affectSpace)
+            {
+                //
+                GplotWatch.RefreshSpace(dateTime);
+            }
+            if (affectSystem)
+            {
+                GplotWatch.RefreshSystem(dateTime);
+            }
+        }
+
+        /// <summary>
+        /// 生成需要使用的过滤器
+        /// </summary>
+        /// <returns></returns>
+        private ElementFilter CreateFilter()
+        {
+            List<BuiltInCategory> builtCategories = new List<BuiltInCategory>()
+            {
+                BuiltInCategory.OST_MEPSpaces,
+                BuiltInCategory.OST_MEPSpaceTags,
+                BuiltInCategory.OST_PipeCurves,
+                BuiltInCategory.OST_DuctCurves,
+            };
+            var categoryFilter = new ElementMulticategoryFilter(builtCategories);
+            var classFiler= new ElementClassFilter(typeof(FamilyInstance));
+            ElementLogicalFilter filter = new LogicalOrFilter(new List<ElementFilter>() {categoryFilter, classFiler});
+            return filter;
+        }
+    }
+}

+ 1 - 1
MBI/SAGA.MBI/ProjectLog/ProjectLogManager.cs

@@ -49,7 +49,7 @@ namespace SAGA.MBI
             {
                 string noExtendFileName = fileName.GetFileName();
                 string key = CreateLogFileKey(noExtendFileName);
-                var delFiles = DeleteFiles(new List<string>() { key }) ?? new List<string>();
+                var delFiles = DeleteFiles(new List<string>() { key }) ?? new List<string>();               
                 return 1 == delFiles.Count;
             }
             catch (Exception)

+ 4 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -279,6 +279,9 @@
     <Compile Include="Common\RevitBuiltInParameter.cs" />
     <Compile Include="Common\WaitingView.cs" />
     <Compile Include="DataArrange\DalInfoCode.cs" />
+    <Compile Include="Gplot\GplotFileItem.cs" />
+    <Compile Include="Gplot\GplotWatch.cs" />
+    <Compile Include="Gplot\JsonConfig.cs" />
     <Compile Include="Html5Command.cs" />
     <Compile Include="Command.cs" />
     <Compile Include="Common\MBIAssistHelper.cs" />
@@ -300,6 +303,7 @@
     <Compile Include="DataArrange\DalProjectTree.cs" />
     <Compile Include="DataArrange\DalSpace.cs" />
     <Compile Include="DataArrange\DalUserMenuPermission.cs" />
+    <Compile Include="Interaction\MBIGplotChanged.cs" />
     <Compile Include="Interaction\MBILocalNameTrigger.cs" />
     <Compile Include="Interaction\MBIModelInfoManager.cs" />
     <Compile Include="JsonConvert\QRCodeConvert.cs" />

+ 21 - 0
MBI/SAGA.RevitUtils/ExtendInterface/IDocumentChanged.cs

@@ -0,0 +1,21 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IDocumentChanged
+ * 作者:xulisong
+ * 创建时间: 2019/5/17 9:46:22
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using Autodesk.Revit.DB.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.RevitUtils.ExtendInterface
+{
+    public interface IDocumentChanged
+    {
+        void Handle(object sender, DocumentChangedEventArgs e);
+    }
+}

+ 19 - 1
MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsBingding.cs

@@ -20,12 +20,16 @@ namespace SAGA.RevitUtils
         {
             CurrentApp = application;
             application.ControlledApplication.DocumentSaved += Application_DocumentSaved;
+            application.ControlledApplication.DocumentChanged += ControlledApplication_DocumentChanged;
             AddUpdater();
             ServiceSetting.LoadServices();
         }
+      
+
         public static void RemoveEvents(UIControlledApplication application)
         {
             application.ControlledApplication.DocumentSaved -= Application_DocumentSaved;
+            application.ControlledApplication.DocumentChanged -= ControlledApplication_DocumentChanged;
             RemoveUpdater();
             CurrentApp = application;
         }
@@ -48,7 +52,21 @@ namespace SAGA.RevitUtils
                 item.Handle(sender, e);
             }
         }
-
+        /// <summary>
+        /// 保存使用的扩展
+        /// </summary>
+        private static List<IDocumentChanged> DocumentChanged { get; set; }
+        private static void ControlledApplication_DocumentChanged(object sender, Autodesk.Revit.DB.Events.DocumentChangedEventArgs e)
+        {
+            if (DocumentChanged == null)
+            {
+                DocumentChanged = EventsSetting.GetEventObjects<IDocumentChanged>() ?? new List<IDocumentChanged>();
+            }
+            foreach (var item in DocumentChanged)
+            {
+                item.Handle(sender, e);
+            }
+        }
         private static List<IUpdaterRegister> UpdaterRegister { get; set; }
         public static void AddUpdater()
         {

+ 7 - 1
MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsSetting.cs

@@ -69,8 +69,14 @@ namespace SAGA.RevitUtils.ExtendInterface
         public virtual List<T> GetEventObjects<T>()
         {
             string key = typeof(T).Name;
-            return GetKeys(key).OfType<T>().ToList();
+            if (!m_CacheItems.TryGetValue(key, out List<object> useObjects))
+            {
+                useObjects = GetKeys(key);
+                m_CacheItems[key] = useObjects;
+            }
+            return useObjects.OfType<T>().ToList();
         }
 
+        public Dictionary<string, List<object>> m_CacheItems = new Dictionary<string, List<object>>();
     }
 }

+ 1 - 0
MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

@@ -208,6 +208,7 @@
     <Compile Include="ErrorSupports\TErrorSupport.cs">
       <SubType>Form</SubType>
     </Compile>
+    <Compile Include="ExtendInterface\IDocumentChanged.cs" />
     <Compile Include="ExtendInterface\IDocumentSaved.cs" />
     <Compile Include="ExtendInterface\RevitEventsSetting.cs" />
     <Compile Include="ExtendInterface\RevitTrigger.cs" />

+ 2 - 2
MBI/WPfPointInfo/InfoProperty/Converter/DateConvert.cs

@@ -25,7 +25,7 @@ namespace WPfPointInfo.InfoProperty
             DateTime dateTime = System.DateTime.Now;
             if (value == null)
                 return dateTime;
-            if (System.DateTime.TryParseExact(value.ToString(), "yyyyMMdd", CultureInfo.CurrentCulture,
+            if (System.DateTime.TryParseExact(value.ToString(), DataTimeFormat, CultureInfo.CurrentCulture,
                 DateTimeStyles.AssumeLocal, out dateTime))
             {
                 return dateTime;
@@ -38,7 +38,7 @@ namespace WPfPointInfo.InfoProperty
             try
             {
                 DateTime dateTime = (DateTime)value;
-                return dateTime.ToString("yyyyMMdd");
+                return dateTime.ToString(DataTimeFormat);
             }
             catch (Exception)
             {