Browse Source

xls:增加模型同步触发器,按钮同步,上传模型自动同步

xulisong 6 năm trước cách đây
mục cha
commit
0cdfcbd331

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

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

+ 15 - 0
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -336,6 +336,7 @@
     <Compile Include="Utilities\CompressUtil.cs" />
     <Compile Include="Utilities\FileUp.cs" />
     <Compile Include="Utilities\IniOperator.cs" />
+    <Compile Include="Utilities\IWaitingView.cs" />
     <Compile Include="Utilities\PinyinUtil.cs" />
     <Compile Include="Utilities\SharpZip.cs" />
     <Compile Include="WinForms\EditorItemValueChangedEventArgs.cs" />
@@ -432,7 +433,13 @@
     <Compile Include="WPF\UserControl\UnitTextbox_PlusDouble.xaml.cs">
       <DependentUpon>UnitTextbox_PlusDouble.xaml</DependentUpon>
     </Compile>
+    <Compile Include="WPF\UserControl\WaitingCircle.xaml.cs">
+      <DependentUpon>WaitingCircle.xaml</DependentUpon>
+    </Compile>
     <Compile Include="WPF\VisualTreeExtend.cs" />
+    <Compile Include="WPF\Windows\WinIndeterminationWaiting.xaml.cs">
+      <DependentUpon>WinIndeterminationWaiting.xaml</DependentUpon>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Logger\log4net.config">
@@ -478,6 +485,14 @@
       <SubType>Designer</SubType>
       <Generator>XamlIntelliSenseFileGenerator</Generator>
     </Page>
+    <Page Include="WPF\UserControl\WaitingCircle.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="WPF\Windows\WinIndeterminationWaiting.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Resource Include="Image\page_edit.png">

+ 22 - 0
MBI/SAGA.DotNetUtils/Utilities/IWaitingView.cs

@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IWaitingView
+ * 作者:xulisong
+ * 创建时间: 2018/12/26 17:42:48
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils
+{
+    public interface IWaitingView
+    {
+        void Start();
+        void Close();
+        void Update(object args);
+    }
+}

+ 103 - 0
MBI/SAGA.DotNetUtils/WPF/UserControl/WaitingCircle.xaml

@@ -0,0 +1,103 @@
+<UserControl x:Class="SAGA.DotNetUtils.WPF.UserControl.WaitingCircle"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:SAGA.DotNetUtils.WPF.UserControl"
+             mc:Ignorable="d" 
+             d:DesignHeight="50" d:DesignWidth="50" Height="{Binding Height, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UIElement}}" Width="{Binding Width, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UIElement}}">
+    <Grid>
+        <Grid.Resources>
+            <DrawingBrush x:Key="brush" Stretch="None" AlignmentX="Center" AlignmentY="Top">
+                <DrawingBrush.Drawing>
+                    <GeometryDrawing Brush="Black">
+                        <GeometryDrawing.Geometry>
+                            <EllipseGeometry RadiusX="2" RadiusY="5"/>
+                        </GeometryDrawing.Geometry>
+                    </GeometryDrawing>
+                </DrawingBrush.Drawing>
+            </DrawingBrush>
+        </Grid.Resources>
+
+        <Rectangle x:Name="r01" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="0"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r02" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="30"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r03" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="60"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r04" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="90"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r05" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="120"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r06" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="150"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r07" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="180"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r08" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="210"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r09" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="240"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r10" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="270"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r11" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="300"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Rectangle x:Name="r12" Fill="{StaticResource brush}" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
+            <Rectangle.RenderTransform>
+                <RotateTransform Angle="330"/>
+            </Rectangle.RenderTransform>
+        </Rectangle>
+        <Grid.Triggers>
+            <EventTrigger RoutedEvent="Grid.Loaded">
+                <BeginStoryboard>
+                    <Storyboard RepeatBehavior="Forever">
+                        <DoubleAnimation Storyboard.TargetName="r01" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.00000" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r02" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.08333" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r03" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.16666" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r04" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.24999" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r05" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.33332" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r06" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.41665" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r07" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.49998" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r08" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.58331" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r09" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.66664" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r10" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.74997" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r11" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.83330" To="0"/>
+                        <DoubleAnimation Storyboard.TargetName="r12" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.91663" To="0"/>
+                    </Storyboard>
+                </BeginStoryboard>
+            </EventTrigger>
+        </Grid.Triggers>
+    </Grid>
+</UserControl>

+ 28 - 0
MBI/SAGA.DotNetUtils/WPF/UserControl/WaitingCircle.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SAGA.DotNetUtils.WPF.UserControl
+{
+    /// <summary>
+    /// WaittingCircle.xaml 的交互逻辑
+    /// </summary>
+    public partial class WaitingCircle : System.Windows.Controls.UserControl
+    {
+        public WaitingCircle()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 33 - 0
MBI/SAGA.DotNetUtils/WPF/Windows/WinIndeterminationWaiting.xaml

@@ -0,0 +1,33 @@
+<Window x:Class="SAGA.DotNetUtils.WPF.Windows.WinIndeterminationWaiting" 
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:SAGA.DotNetUtils.WPF.Windows"
+             xmlns:userControl="clr-namespace:SAGA.DotNetUtils.WPF.UserControl"
+             mc:Ignorable="d" Name="this" Height="200" Width="400"
+             d:DesignHeight="200" d:DesignWidth="400" BorderThickness="0" WindowStyle="None" AllowsTransparency="True"    Background="LightGray"  Opacity="0.7" WindowStartupLocation="CenterOwner">
+
+    <WindowChrome.WindowChrome>
+        <WindowChrome />
+    </WindowChrome.WindowChrome>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition></RowDefinition>
+            <RowDefinition Height="50"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="1" Margin="10,0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="50"></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <userControl:WaitingCircle></userControl:WaitingCircle>
+            <TextBlock FontSize="20" Grid.Column="1" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"  Text="{Binding Message,ElementName=this}" VerticalAlignment="Center" >
+                <TextBlock.ToolTip>
+                    <TextBlock Text="{Binding Message,ElementName=this}"></TextBlock>
+                </TextBlock.ToolTip>
+            </TextBlock>
+        </Grid>
+    </Grid>
+</Window>

+ 35 - 0
MBI/SAGA.DotNetUtils/WPF/Windows/WinIndeterminationWaiting.xaml.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SAGA.DotNetUtils.WPF.Windows
+{
+    /// <summary>
+    /// WinIndeterminationWaiting.xaml 的交互逻辑
+    /// </summary>
+    public partial class WinIndeterminationWaiting : Window
+    {
+        public WinIndeterminationWaiting()
+        {
+            InitializeComponent();
+        }
+        public string Message
+        {
+            get { return (string)GetValue(MessageProperty); }
+            set { SetValue(MessageProperty, value); }
+        }     
+        public static readonly DependencyProperty MessageProperty =
+            DependencyProperty.Register("Message", typeof(string), typeof(WinIndeterminationWaiting), new PropertyMetadata(""));
+    }
+}

+ 0 - 178
MBI/SAGA.GplotManage/Command/ColdGplot/WinDrawSpace-Web.xaml.cs

@@ -1,178 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-using CEFSharpWPF;
-using DrawData;
-using SAGA.DotNetUtils.Logger;
-using SAGA.MBI.Common;
-using SAGA.Models;
-
-namespace SAGA.GplotDrawData
-{
-    /// <summary>
-    /// WinDrawSpace_Web.xaml 的交互逻辑
-    /// </summary>
-    public partial class WinDrawSpace_Web : Window
-    {
-        public WinDrawSpace_Web()
-        {
-            InitializeComponent();
-            Vertex.SetRadius(6, 6);
-        }
-
-        private GplotShowType m_showType;
-        public WinDrawSpace_Web(GplotShowType showType) : this()
-        {
-
-            this.m_showType = showType;
-            this.Loaded += WinDrawWaterNode_Loaded;
-        }
-        private bool IsRead = true;
-
-        private void WinDrawWaterNode_Loaded(object sender, RoutedEventArgs e)
-        {
-            if (m_showType == GplotShowType.VerticalPlan)
-            {
-                //this.rootNode.Visibility = Visibility.Collapsed;
-                //grid.ColumnDefinitions[0].Width = new GridLength(0);
-                //DrawVSpaces();
-                InitVerticalSpaces();
-
-            }
-            else
-            {
-                var node = GetSpaceData();
-                this.rootNode.ItemsSource = new List<DataNode>() { node };
-            }
-        }
-        #region 立面空间处理
-        /// <summary>
-        /// 立面空间相关数据源
-        /// </summary>
-        private SpaceData VerticalSpaces { get; set; }
-        public void InitVerticalSpaces()
-        {
-            var spaceDatas = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
-            this.VerticalSpaces = spaceDatas;
-            InitVSpaceTree();
-        }
-        /// <summary>
-        /// 绘制立面空间
-        /// </summary>
-        private void DrawVSpaces(DataNode node)
-        {
-            if (node == null)
-                return;
-            //rootNode.Visibility = Visibility.Collapsed;
-            var spaceDatas = VerticalSpaces;// DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
-            VirticalSpaceGraphView view = new VirticalSpaceGraphView();
-            view.SpaceType = node.Sno;
-            var db = view.CreateDb(spaceDatas);
-            ConstData.ResponseData = db.CreateJObjectGroup();
-            ucShowElement.Show(WebGplotSettings.VSpaceUrl);
-        }
-        public void InitVSpaceTree()
-        {
-            List<DataNode> dataNode = new List<DataNode>();
-          
-            dataNode.Add(new DataNode() { EName = "楼梯间",Sno="140" });
-            dataNode.Add(new DataNode() { EName = "中庭", Sno = "150" });
-            dataNode.Add(new DataNode() { EName = "竖井", Sno = "1B0" });
-            dataNode.Add(new DataNode() { EName = "其他公共区域", Sno = "1A0" });
-            this.rootNode.ItemsSource = dataNode;
-        }  
-        #endregion
-
-        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
-        {
-            if (rootNode.SelectedItem is DataNode ln)
-            {
-                if (m_showType == GplotShowType.ViewPlan)
-                {
-                    if (ln.GetData<FloorSpaceData>() is FloorSpaceData fd)
-                        Draw(fd);
-                }
-                else
-                {
-                    DrawVSpaces(ln);
-                }
-              
-            }
-        }
-
-        void Draw(FloorSpaceData fd)
-        {
-            SpaceGraphView view = new SpaceGraphView();
-            var db = view.CreateDb(fd);
-            //db.SaveToFile(@"c:\space.json");
-            ConstData.ResponseData = db.CreateJObjectGroup();
-            ucShowElement.Show(WebGplotSettings.GplotUrl);    
-        }
-
-
-        private DataNode GetSpaceData()
-        {
-            var aData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.All);
-            var tData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Crossing);
-
-            var vData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Ventilation);
-            var rData = DrawDataServer.GetSpaceData(SpaceRelatedEnum.Radiation);
-            DataNode root = new DataNode("空间关系");
-            DataNode a = new DataNode("空间临接关系")
-            {
-                Childrens = aData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-
-            DataNode t = new DataNode("建筑交通关系")
-            {
-                Childrens = tData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            DataNode v = new DataNode("空气流通关系")
-            {
-                Childrens = vData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            DataNode r = new DataNode("光照辐射关系")
-            {
-                Childrens = rData.FloorDatas.Reverse<FloorSpaceData>().Select(f =>
-                {
-                    var dn = new DataNode(f.Name);
-                    dn.SetData(f);
-                    return dn;
-                }).ToList()
-            };
-            root.Childrens.AddRange(new List<DataNode>() { a, t, v, r });
-            return root;
-        }   
-        /// <summary>
-        /// 外部命令启动计算
-        /// </summary>
-        public Action ComputerAction;      
-    }
-}

+ 0 - 80
MBI/SAGA.GplotManage/Command/ColdGplot/WinMachineRoomView-Web.xaml.cs

@@ -1,80 +0,0 @@
-using CEFSharpWPF;
-using SAGA.GplotDrawData.Draw;
-using SAGA.Models;
-using SAGA.RevitUtils.Windows;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-using SAGA.Models.Graphs;
-
-namespace SAGA.GplotDrawData
-{
-    /// <summary>
-    /// WinMachineRoomView_Web.xaml 的交互逻辑
-    /// </summary>
-    public partial class WinMachineRoomView_Web : WinBase
-    {
-        public WinMachineRoomView_Web()
-        {
-            InitializeComponent();
-        }
-        public Func<List<DocumentNode>> LoadData;
-        private ObservableCollection<DocumentNode> DocumentNodes { get; set; }
-        protected override void OnLoaded(object sender, RoutedEventArgs e)
-        {
-            base.OnLoaded(sender, e);
-
-            DocumentNodes = new ObservableCollection<DocumentNode>(this.LoadData?.Invoke() ?? new List<DocumentNode>());
-            this.TreeRootNode.ItemsSource = DocumentNodes;
-            //if (DocumentNodes.Any())
-            //{
-            //    SetSelectedItem(DocumentNodes[0].GetLeaves().FirstOrDefault() as DocumentNode);
-            //}
-        }
-        private void SetSelectedItem(DocumentNode node)
-        {
-            node.IsSelected = true;
-            node.IsExpanded = true;
-            var parent = node.Parent;
-            while (parent != null)
-            {
-                parent.IsExpanded = true;
-                parent = parent.Parent;
-            }
-
-            RootNode_OnSelectedItemChanged(null, null);
-        }
-
-        #region 事件相关
-        private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
-        {
-            if (TreeRootNode.SelectedItem is DocumentNode ln)
-            {
-                Draw(ln);
-            }
-        }
-        #endregion
-        private void Draw(DocumentNode docNode)
-        {
-            if (docNode?.Tag == null)
-                return;
-            //GplotDocument document = docNode.LinkDocument;
-            //RoomGraphView view = new RoomGraphView();
-            RoomGraphView2 view = new RoomGraphView2();
-            var db = view.CreateDb( docNode.Tag as List<GNodeGraph>);
-            ConstData.ResponseData = db.CreateJObjectGroup();
-            ucShowElement.Show(WebGplotSettings.GplotUrl);
-        }
-    }
-}

+ 3 - 3
MBI/SAGA.GplotManage/GplotCommand.cs

@@ -5,6 +5,7 @@ using Autodesk.Revit.DB;
 using Autodesk.Revit.UI;
 using SAGA.GplotDrawData;
 using SAGA.GplotManage.UploadRelated;
+using SAGA.MBI.Common;
 using SAGA.Models;
 using SAGA.RevitUtils.Extends;
 
@@ -18,10 +19,9 @@ namespace SAGA.GplotManage
     public class SpaceComputerGraph : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {
+        {        
             var space = GplotFactory.Create(GraphTypeEnum.ElementSpNeighborhood);
-            space.Show(GplotShowType.ViewPlan);
-      
+            space.Show(GplotShowType.ViewPlan);           
             return Result.Succeeded;
         }
 

+ 8 - 5
MBI/SAGA.MBI/Command.cs

@@ -412,17 +412,20 @@ namespace SAGA.MBI
         {
             try
             {
-
+                WaitingView wait = new WaitingView();
+                wait.Start();
                 var floors = DalUploadFloor.GetHasFileFloors();
                 List<CalcContext> contexts = new List<CalcContext>();
                 foreach (UploadFloor floor in floors)
                 {
-
+                    if (floor.MFloor.FloorLock.LockState != MFloorLockState.LockBySelf)
+                    {
+                        continue;
+                    }
                     contexts.Add(new CalcContext(floor.MFloor));
                 }
                  MBIModelInfoManager.SyncPlatformToRevit(contexts);
-                //var doc = ExternalDataWrapper.Current.Doc;             
-                //MBIModelInfoManager.SyncPlatformToRevit(doc);
+                wait.Close();
             }
             catch (Exception e)
             {
@@ -434,7 +437,7 @@ namespace SAGA.MBI
 
         public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
-            return false;
+            return true;
         }
     }
 }

+ 71 - 0
MBI/SAGA.MBI/Common/WaitingView.cs

@@ -0,0 +1,71 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:WaitingView
+ * 作者:xulisong
+ * 创建时间: 2018/12/26 17:46:49
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Interop;
+using System.Windows.Threading;
+using FWindSoft.Tools;
+using FWindSoft.Wpf;
+using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.WPF.Windows;
+
+namespace SAGA.MBI.Common
+{
+    public class WaitingView : IWaitingView
+    {
+        private WinIndeterminationWaiting m_Win;
+        public void Close()
+        {
+            m_Win.Dispatcher.Invoke(() =>
+                {
+                    if (IsWinValid())
+                    {
+                        m_Win.Close();
+                    }
+                }
+            );
+        }
+        public void Start()
+        {
+            TaskUtil.StartSTATask(() =>
+            {
+                if (!IsWinValid())
+                {
+                    m_Win = new WinIndeterminationWaiting();
+                    WindowInteropHelper helper = new WindowInteropHelper(m_Win);
+                    helper.Owner = WindowHelper.HWndRevit.Handle;
+                    WindowHelper.SetWindowForeground(helper.EnsureHandle());
+                }
+
+                SetMessage("正在执行,请稍等...");
+                //m_Win.ShowDialog();
+                m_Win.Show();
+                //一定要处理退出机制,不然该监控线程不会消失,有时间再研究
+              Dispatcher.Run();
+            });
+        }
+
+        public void Update(object args)
+        {
+            SetMessage(args.ToString());
+        }
+
+        private bool IsWinValid()
+        {
+            return !(m_Win == null || m_Win.IsDisposed());          
+        }
+
+        private void SetMessage(string message)
+        {
+            m_Win.Dispatcher.BeginInvoke(new Action(() => m_Win.Message = message),DispatcherPriority.Background,null);
+        }
+    }
+}

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

@@ -19,6 +19,7 @@ using SAGA.MBI.Calc;
 using SAGA.MBI.Common;
 using SAGA.MBI.Extend;
 using SAGA.MBI.FileStream;
+using SAGA.MBI.Interaction;
 using SAGA.MBI.JsonConvert;
 using SAGA.MBI.Model;
 using SAGA.MBI.RequestData;
@@ -231,6 +232,10 @@ namespace SAGA.MBI.DataArrange
                     //检测到自己加锁 才读取日志
                     if (uploadFloor.MFloor.FloorLock.LockState != MFloorLockState.LockBySelf)
                         continue;
+                    #region 同步空间名称
+                    var document = ExternalDataWrapper.Current.App.OpenDocumentFile(uploadFloor.MFloor.FullPath);
+                    MBIModelInfoManager.SyncPlatformToRevit(document);
+                    #endregion
                     //检测有日志文件,才上传
                     var logs = DalLogOperate.GetLogs(uploadFloor.MFloor.Id);
                     if (!logs.Any()) continue;

+ 75 - 0
MBI/SAGA.MBI/Interaction/MBILocalNameTrigger.cs

@@ -0,0 +1,75 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:MBILocalNameTrigger
+ * 作者:xulisong
+ * 创建时间: 2018/12/27 13:12:48
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+using SAGA.DotNetUtils.Extend;
+using SAGA.RevitUtils;
+using SAGA.RevitUtils.ExtendInterface;
+using SAGA.RevitUtils.Extends;
+
+namespace SAGA.MBI.Interaction
+{
+    public class MBILocalNameTrigger : UpdaterRegister
+    {
+        private readonly Guid GUID = Guid.NewGuid();
+
+        private static bool m_IsPause;
+        public static void Suspend()
+        {
+            m_IsPause = true;
+        }
+        public static void Resume()
+        {
+            m_IsPause = false;
+        }
+        protected override List<RevitTrigger> GetTriggers()
+        {
+            List<RevitTrigger> triggers = new List<RevitTrigger>();
+            var changeType = Element.GetChangeTypeParameter(new ElementId((int) BuiltInParameter.ROOM_NAME));
+            triggers.Add(new RevitTrigger(new ElementCategoryFilter(BuiltInCategory.OST_MEPSpaces), changeType));
+            return triggers;
+        }
+
+        protected override RevitUpdater GetUpdater()
+        {
+            var  addInId= RevitEventsBingding.CurrentApp.ActiveAddInId;
+            RevitUpdater updaer = new RevitUpdater(new UpdaterId(addInId, GUID), (data) =>
+            {
+                if (m_IsPause)
+                    return;
+                var document = data.GetDocument();
+                if (!document.PathName.GetFileName().StartsWith("Fl"))
+                    return;
+                foreach (var modifiedElementId in data.GetModifiedElementIds())
+                {
+                    var element = document.GetElement(modifiedElementId);
+                    if (element != null)
+                    {
+                        #region 异步调用线程更新
+                        Task.Factory.StartNew(() =>
+                                      {
+                                          try
+                                          {
+                                              element.UpdateMBIName(element.GetParameterString(BuiltInParameter.ROOM_NAME));
+                                          }
+                                          catch (Exception)
+                                          {
+                                          }
+                                      }); 
+                        #endregion
+                    }
+                }                
+            });
+            return updaer;
+        }
+    }
+}

+ 7 - 9
MBI/SAGA.MBI/Interaction/MBIModelInfoManager.cs

@@ -60,15 +60,13 @@ namespace SAGA.MBI.Interaction
                                 {
                                     continue;
                                 }
-                                 element.UdpateName(mbiItem.LocalName);
-                            
+                                 element.UdpateName(mbiItem.LocalName,true);                           
                                 sub.Commit();
                             }
                             catch (Exception e)
                             {
                                 sub.RollBack();
                             }
-
                         } 
                         #endregion
                     }
@@ -80,6 +78,11 @@ namespace SAGA.MBI.Interaction
                     flag = false;
                 }
             }
+
+            if (flag)
+            {
+                document.Save();
+            }
             return flag;
         }
 
@@ -97,13 +100,8 @@ namespace SAGA.MBI.Interaction
                 bool isOpened = false;
                 try
                 {
-
                     isOpened = documents.Any(d => d.PathName == context.MFloor.FullPath);
-                    //if (!isOpened)
-                    //{
-                    //开,全部开启.;关,新打开的关掉
-                        context.OpenDocument();
-                  //  }               
+                    context.OpenDocument();            
                     Document doc = context.RevitDoc;                   
                     var floorId = doc.PathName.GetFileName();
                     var flag = SyncPlatformToRevit(doc);

+ 3 - 2
MBI/SAGA.MBI/Model/MRevitEquipBase.cs

@@ -22,6 +22,7 @@ using SAGA.MBI.JsonConvert;
 using SAGA.MBI.RequestData;
 using SAGA.MBI.Tools;
 using SAGA.MBI.WinView.ModeInfoMaintenance;
+using SAGA.RevitUtils.Windows;
 using WPG.Data;
 
 namespace SAGA.MBI.Model
@@ -258,7 +259,7 @@ namespace SAGA.MBI.Model
             var attributes = info?.GetCustomAttributes(typeof(DescriptionAttribute));
             var att = attributes?.FirstOrDefault();
             if (att == null) return;
-
+           
             if (att is DescriptionAttribute descriptionAttribute)
             {
                 var description = descriptionAttribute.Description;
@@ -270,7 +271,7 @@ namespace SAGA.MBI.Model
                     {
                         if (info.PropertyType == typeof(int))
                             value = ((int)value).ToString();
-
+                        RevitParameterUpdate.UpdateParameter(BimID, description, value.ToString());
                         UpdateSingleProperty(description, (string)value);
                     }
                 }

+ 98 - 1
MBI/SAGA.MBI/RevitModelHandle/RevitParameterUpdate.cs

@@ -5,7 +5,16 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Autodesk.Revit.DB.Mechanical;
+using Newtonsoft.Json.Linq;
+using SAGA.DotNetUtils;
+using SAGA.MBI.Common;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.Interaction;
+using SAGA.MBI.RequestData;
+using SAGA.Models;
+using SAGA.RevitUtils;
 using SAGA.RevitUtils.Extends;
+using SAGA.RevitUtils.Windows;
 
 namespace SAGA.MBI
 {
@@ -14,6 +23,7 @@ namespace SAGA.MBI
     /// </summary>
     public static class RevitParameterUpdate
     {
+        #region 同步模型
         /// <summary>
         /// 更新模型名称
         /// </summary>
@@ -26,7 +36,7 @@ namespace SAGA.MBI
             {
                 if (element is Space space)
                 {
-                    if (space.Name == useName || space.GetParameterString(BuiltInParameter.ROOM_NAME) == useName)
+                    if (space.Name != useName && space.GetParameterString(BuiltInParameter.ROOM_NAME) != useName)
                     {
                         space.SetParameter(BuiltInParameter.ROOM_NAME, useName);
 
@@ -34,5 +44,92 @@ namespace SAGA.MBI
                 }
             } while (false);
         }
+        /// <summary>
+        /// 更新元素名称
+        /// </summary>
+        /// <param name="element"></param>
+        /// <param name="name"></param>
+        /// <param name="stopLocalTrigger">是否暂停触发器,暂停触发器则不会发送对数据平台的同步</param>
+        public static void UdpateName(this Element element, string name, bool stopLocalTrigger)
+        {
+            if (!stopLocalTrigger)
+            {
+                UdpateName(element, name);
+                return;
+            }
+            try
+            {
+                MBILocalNameTrigger.Suspend();
+                UdpateName(element, name);
+            }
+            catch (Exception ex)
+            {
+            }
+            finally
+            {
+                MBILocalNameTrigger.Resume();
+            }
+        }
+
+        public static void UpdateNameAsync(this Element element, string name)
+        {
+            ExecuteCmd.ExecuteCommand(() =>
+            {
+                using (Transaction tran = new Transaction(element.Document, "同步"))
+                {
+                    try
+                    {
+                        tran.Start();
+                        UdpateName(element, name, true);
+                        tran.Commit();
+                    }
+                    catch (Exception e)
+                    {
+                        tran.RollBack();
+                    }
+                }
+                return Autodesk.Revit.UI.Result.Succeeded;
+            });
+        }
+        public static void UpdateNameAsync(string bimId, string name)
+        {
+            if (bimId == null)
+                return;
+            var ids = bimId.Split(':');
+            if (ids.Count() < 2)
+                return;
+            int elementID = ids[1].ToInt();
+            var doc = ExternalDataWrapper.Current.Doc;
+            if (doc == null)
+                return;
+            var element = ExternalDataWrapper.Current.Doc.GetElement(new ElementId(elementID));
+            if (element == null)
+                return;
+            UpdateNameAsync(element, name);
+        }
+
+
+        public static void UpdateParameter(string bimId, string parameterName,string value)
+        {
+            if (parameterName == MBIBuiltInParameter.RoomLocalName)
+            {
+                UpdateNameAsync(bimId, value);
+            }         
+        }
+
+        #endregion
+        public static void UpdateMBIName(this Element element, string name)
+        {
+            //更新物理世界信息点内容
+            var bimId = element.GetBimId();         
+            JArray jArray = CommonTool.GetPropertyJArray(name);
+            JObject jObject = new JObject();
+            jObject.Add(MBIBuiltInParameter.RoomLocalName, jArray);
+            var cloudElement = DalCommon.GetEquipmentQueryId(element);
+            if (cloudElement == null)
+                return;
+            CommonConvert.UpdateInfosSigle(cloudElement.Id, jObject);
+           // MessageShow.Infomation(bimId);
+        }
     }
 }

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

@@ -242,6 +242,7 @@
     <Compile Include="CmbData\BuildingCmbVm.cs" />
     <Compile Include="CmbData\ProvinceCityVm.cs" />
     <Compile Include="Common\CacheAspect.cs" />
+    <Compile Include="Common\WaitingView.cs" />
     <Compile Include="Html5Command.cs" />
     <Compile Include="Command.cs" />
     <Compile Include="Common\MBIAssistHelper.cs" />
@@ -263,6 +264,7 @@
     <Compile Include="DataArrange\DalProjectTree.cs" />
     <Compile Include="DataArrange\DalSpace.cs" />
     <Compile Include="DataArrange\DalUserMenuPermission.cs" />
+    <Compile Include="Interaction\MBILocalNameTrigger.cs" />
     <Compile Include="Interaction\MBIModelInfoManager.cs" />
     <Compile Include="JsonConvert\QRCodeConvert.cs" />
     <Compile Include="ModeInfoEdit\WinPointMergeTip.xaml.cs">

+ 33 - 2
MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsBingding.cs

@@ -15,17 +15,24 @@ namespace SAGA.RevitUtils
         static RevitEventsBingding()
         {
             EventsSetting = new RevitEventsSetting();
-        }
-        
+        }        
         public static void AddEvents(UIControlledApplication application)
         {
+            CurrentApp = application;
             application.ControlledApplication.DocumentSaved += Application_DocumentSaved;
+            AddUpdater();
         }
         public static void RemoveEvents(UIControlledApplication application)
         {
             application.ControlledApplication.DocumentSaved -= Application_DocumentSaved;
+            RemoveUpdater();
+            CurrentApp = application;
         }
         /// <summary>
+        /// 关联引用程序
+        /// </summary>
+        public static UIControlledApplication CurrentApp { get;private set; }
+        /// <summary>
         /// 保存使用的扩展
         /// </summary>
         private static List<IDocumentSaved> DocumentSaved { get;  set; }
@@ -40,5 +47,29 @@ namespace SAGA.RevitUtils
                 item.Handle(sender, e);
             }
         }
+
+        private static List<IUpdaterRegister> UpdaterRegister { get; set; }
+        public static void AddUpdater()
+        {
+            if (UpdaterRegister == null)
+            {
+                UpdaterRegister = EventsSetting.GetEventObjects<IUpdaterRegister>() ?? new List<IUpdaterRegister>();
+            }
+            foreach (var item in UpdaterRegister)
+            {
+                item.Register();
+            }
+        }
+        public static void RemoveUpdater()
+        {
+            if (UpdaterRegister == null)
+            {
+                UpdaterRegister = EventsSetting.GetEventObjects<IUpdaterRegister>() ?? new List<IUpdaterRegister>();
+            }
+            foreach (var item in UpdaterRegister)
+            {
+                item.UnRegist();
+            }
+        }
     }
 }

+ 221 - 0
MBI/SAGA.RevitUtils/ExtendInterface/RevitTrigger.cs

@@ -0,0 +1,221 @@
+using System;
+using System.Collections.Generic;
+using Autodesk.Revit.DB;
+
+namespace SAGA.RevitUtils.ExtendInterface
+{
+    #region 系统类封装
+    /*
+* 不知道revit的机制是不是一样的触发器会合并所有Updater,待测试。
+* 但一个updater可以被几个触发器关联
+*/
+    public class RevitUpdater : IUpdater
+    {
+        /*
+         * 可以通过扩展继承该类
+         */
+        protected Action<UpdaterData> m_Execute;
+        public RevitUpdater(UpdaterId id, Action<UpdaterData> execute)
+        {
+            this.Id = id;
+            this.m_Execute = execute;
+        }
+        #region 接口继承方法
+        public virtual void Execute(UpdaterData data)
+        {
+            if (m_Execute != null)
+            {
+                m_Execute(data);
+            }
+        }
+        public string GetAdditionalInformation()
+        {
+            return AdditionalInformation ?? string.Empty;
+        }
+
+        public ChangePriority GetChangePriority()
+        {
+            return ChangePriority;
+        }
+        public UpdaterId GetUpdaterId()
+        {
+            return Id;
+        }
+
+        public string GetUpdaterName()
+        {
+            return UpdaterName ?? this.GetType().ToString();
+        }
+        #endregion
+
+        #region 相关属性延伸
+        /// <summary>
+        /// 附加信息
+        /// </summary>
+        public string AdditionalInformation { get; set; }
+        /// <summary>
+        /// 触发器名称
+        /// </summary>
+        public string UpdaterName { get; set; }
+
+        /// <summary>
+        /// 改变优先级
+        /// </summary>
+        public ChangePriority ChangePriority { get; set; }
+        /// <summary>
+        /// UpdaterId
+        /// </summary>
+        public UpdaterId Id { get; protected set; }
+        #endregion
+
+
+        #region 注册和注销
+        private bool IsExistId(Document doc)
+        {
+            bool flag = false;
+            if (doc == null)
+            {
+                flag = UpdaterRegistry.IsUpdaterRegistered(this.GetUpdaterId());
+            }
+            else
+            {
+                flag = UpdaterRegistry.IsUpdaterRegistered(this.GetUpdaterId(), doc);
+            }
+            return flag;
+        }
+
+        public void RegisterUpdater(Document doc, bool isOptional = true)
+        {
+            if (IsExistId(doc))
+                return;
+            if (doc == null)
+            {
+                UpdaterRegistry.RegisterUpdater(this, isOptional);
+            }
+            else
+            {
+                UpdaterRegistry.RegisterUpdater(this, doc, isOptional);
+            }
+        }
+        public void UnregisterUpdater(Document doc)
+        {
+            if (!IsExistId(doc))
+                return;
+            if (doc == null)
+            {
+                UpdaterRegistry.UnregisterUpdater(this.Id);
+            }
+            else
+            {
+                UpdaterRegistry.UnregisterUpdater(this.Id, doc);
+            }
+        }
+        #endregion  
+    }
+
+    /// <summary>
+    /// 触发器就是过滤器
+    /// </summary>
+    public class RevitTrigger
+    {
+        public RevitTrigger(ElementFilter filter, ChangeType change)
+        {
+            Filter = filter;
+            ChangeType = change;
+        }
+        public RevitTrigger(Document document, ElementFilter filter, ChangeType change) : this(filter, change)
+        {
+            Document = document;
+        }
+        public RevitTrigger(Document document, ICollection<ElementId> elements, ChangeType change) : this(document, filter: null, change: change)
+        {
+            ElementIds = elements;
+        }
+        #region 触发器关联属性
+        public Document Document { get; set; }
+        public ICollection<ElementId> ElementIds { get; set; }
+        public ChangeType ChangeType { get; set; }
+        public ElementFilter Filter { get; set; }
+        #endregion
+        #region 方法标记
+        /// <summary>
+        /// 附加触发器
+        /// </summary>
+        /// <param name="updater"></param>
+        public void AttachUpdater(RevitUpdater updater)
+        {
+            AttachUpdaterId(updater.GetUpdaterId());
+        }
+        public void AttachUpdaterId(UpdaterId updaterId)
+        {
+            if (Document == null)
+            {
+                UpdaterRegistry.AddTrigger(updaterId, Filter, ChangeType);
+            }
+            else if (ElementIds == null)
+            {
+                UpdaterRegistry.AddTrigger(updaterId, Document, Filter, ChangeType);
+            }
+            else if (Filter == null)
+            {
+                UpdaterRegistry.AddTrigger(updaterId, Document, ElementIds, ChangeType);
+            }
+        }
+        #endregion
+    } 
+    #endregion
+
+    public interface IUpdaterRegister
+    {
+        void Register();
+        void UnRegist();
+    }
+
+    /// <summary>
+    /// 注册updater相关
+    /// </summary>
+    public abstract class UpdaterRegister : IUpdaterRegister
+    {
+        public UpdaterRegister()
+        {
+        }
+        /// <summary>
+        /// 关联项目
+        /// </summary>
+        public Document RefDocument { get; set; }
+        public bool IsOptional { get; set; }
+        /// <summary>
+        /// 当前updater,注册后生效
+        /// </summary>
+        public RevitUpdater CurrentUpdater { get; private set; }
+        /// <summary>
+        /// 注册更新触发器
+        /// </summary>
+        public virtual  void Register()
+        {
+            CurrentUpdater = GetUpdater();
+            if (CurrentUpdater == null)
+                return;
+            CurrentUpdater.RegisterUpdater(RefDocument, IsOptional);
+            var triggers = GetTriggers();
+            foreach (var revitTrigger in triggers)
+            {
+                revitTrigger.AttachUpdater(CurrentUpdater);
+            }
+        }
+        /// <summary>
+        /// 注销更新触发器
+        /// </summary>
+        public virtual  void UnRegist()
+        {
+            CurrentUpdater = CurrentUpdater??GetUpdater();
+            if (CurrentUpdater == null)
+            {
+                return;
+            }
+            CurrentUpdater.UnregisterUpdater(RefDocument);
+        }
+        protected abstract List<RevitTrigger> GetTriggers();
+        protected abstract RevitUpdater GetUpdater();
+    }
+}

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

@@ -175,6 +175,7 @@
     </Compile>
     <Compile Include="ExtendInterface\IDocumentSaved.cs" />
     <Compile Include="ExtendInterface\RevitEventsSetting.cs" />
+    <Compile Include="ExtendInterface\RevitTrigger.cs" />
     <Compile Include="Extends\ArcExtend.cs" />
     <Compile Include="Extends\Configuration.cs" />
     <Compile Include="Extends\CurveArrayExtend.cs" />