فهرست منبع

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

xulisong 6 سال پیش
والد
کامیت
68366807e6

+ 5 - 5
MBI/Menu/MBITool.xml

@@ -136,13 +136,13 @@
       <Modules>MBITool</Modules>
     </Button>
     <Button ButtonStyles="Stacked">
-      <ButtonName>SAGA.MBI.CopyLocalIdCommand</ButtonName>
-      <ButtonText>复制设备编号的值</ButtonText>
+      <ButtonName>SAGA.MBI.CopyParameterValueCommand</ButtonName>
+      <ButtonText>复制指定参数A的值到指定参数B中</ButtonText>
       <ImageName>1、打开楼层模型</ImageName>
       <DllName>..\OutputDll\SAGA.MBI.exe</DllName>
-      <ClassName>SAGA.MBI.CopyLocalIdCommand</ClassName>
-      <ToolTip>将设备编号的值复制到设备本地编码中。</ToolTip>
-      <LongDescription>将设备编号的值复制到设备本地编码中,结果将列出本层复制失败的对象的id,如果本层都复制成功则没有提示。</LongDescription>
+      <ClassName>SAGA.MBI.CopyParameterValueCommand</ClassName>
+      <ToolTip>复制指定参数A的值到指定参数B中。</ToolTip>
+      <LongDescription>复制指定参数A的值到指定参数B中,在设置中选择需要复制的值名称。</LongDescription>
       <ToolTipImage></ToolTipImage>
       <MenuTab>MBITool_W</MenuTab>
       <Modules>MBITool</Modules>

+ 4 - 5
MBI/SAGA.DotNetUtils/WPF/Converter/StringToImageConverter.cs

@@ -5,6 +5,7 @@
  * ==============================================================================*/
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -12,6 +13,7 @@ using System.Windows.Data;
 using System.Windows.Media.Imaging;
 using System.Windows.Resources;
 using System.Windows;
+using System.Windows.Media;
 
 namespace SAGA.DotNetUtils.WPF.Converter
 {
@@ -24,14 +26,11 @@ namespace SAGA.DotNetUtils.WPF.Converter
         {
             BitmapImage img = new BitmapImage();
             if (value == null) return img;
-            //若要原始文件的站点,可以调用 Application 类的 GetRemoteStream 方法,同时传递标识原始文件的所需站点的 pack URI。 GetRemoteStream 将返回一个 StreamResourceInfo 对象,该对象将原始文件的该站点作为 Stream 公开,并描述其内容类型。
             try
             {
-                var uri = new Uri(value.ToString().Replace("%20", " "), UriKind.Relative);
-                StreamResourceInfo info = Application.GetRemoteStream(uri);
+                var bytes = File.ReadAllBytes(value.ToString());
                 img.BeginInit();
-                //img.UriSource = new Uri(value.ToString(), UriKind.Relative);
-                img.StreamSource = info.Stream;
+                img.StreamSource = new MemoryStream(bytes);
                 img.EndInit();
             }
             catch (Exception e)

+ 2 - 2
MBI/SAGA.DotNetUtils/WPF/UserControl/SelectPath_Start.xaml.cs

@@ -37,7 +37,7 @@ namespace SAGA.DotNetUtils.WPF.UserControl
             set { SetValue(BtnImageProperty, value); }
         }
 
-        public Action AttachAction;
+        public Action<System.Windows.Controls.UserControl,string> AttachAction;
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
@@ -48,7 +48,7 @@ namespace SAGA.DotNetUtils.WPF.UserControl
             {
                 string foldPath = dialog.SelectedPath;
                 Text = foldPath;
-                AttachAction?.Invoke();
+                AttachAction?.Invoke(this,foldPath);
             }
         }
 

+ 41 - 0
MBI/SAGA.MBI/Common/RegexConstPattern.cs

@@ -0,0 +1,41 @@
+/* ==============================================================================
+ * 功能描述:RegexPatten  
+ * 创 建 者:Garrett
+ * 创建日期:2019/5/29 14:12:17
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI.Common
+{
+    /// <summary>
+    /// RegexPatten
+    /// </summary>
+    class RegexConstPattern
+    {
+        public const string IsSpaceId = @"Si\S*";
+        public const string IsEquipId = @"Si\S*";
+        public const string IsEquipPartId = @"Si\S*";
+        public const string IsBeaconId = @"Si\S*";
+
+        public const string IsFamilyCode = @"\s*-\s*\S*";
+
+        public const string IsEquip = @"^[A-Z]{4}\s*-\s*\S*";
+        public const string IsEquipPart = @"^[A-Z]{6}\s*-\s*\S*";
+
+        public const string IsMBILevel = @"([BF][1-9]\d*M?\d?|RFM?\d?)";
+        public const string IsMBIView = @"^([BF][1-9]\d*M?\d?|RFM?\d?)-saga$";
+        public const string IsSandwich = @"([BF][1-9]\d*M\d?|RFM\d?)";
+
+        public const string IsRF = @"^RF(-saga)?$";
+        public const string IsRFM = @"RFM\d*";
+        public const string IsOnground = @"^F\s*";
+        public const string IsUnderground = @"^B\s*";
+
+        public const string IsPhoneNumber = @"^1[3|4|5|7|8][0-9]\d{8}$";
+
+    }
+}

+ 4 - 4
MBI/SAGA.MBI/DataArrange/DalCommon.cs

@@ -221,7 +221,7 @@ namespace SAGA.MBI.DataArrange
         public static bool Delete(string cloudId)
         {
             //空间
-            if (Regex.IsMatch(cloudId, @"Si\S*"))
+            if (Regex.IsMatch(cloudId, $"{RegexConstPattern.IsSpaceId}"))
             {
                 var rlt = new RltEquipInSpace(null, cloudId) { Operator = DocumentChangedOperator.Delete };
                 rlt.DelObject();
@@ -229,21 +229,21 @@ namespace SAGA.MBI.DataArrange
                 return SpaceConvert.DelSpace(cloudId);
             }
             //设备
-            if (Regex.IsMatch(cloudId, @"Eq\S*"))
+            if (Regex.IsMatch(cloudId, $"{RegexConstPattern.IsEquipId}"))
             {
                 var rlt = new RltEquipInSpace(cloudId, null) { Operator = DocumentChangedOperator.Delete };
                 rlt.DelObject();  //删除空间
                 return EquipmentConvert.DelEquipment(cloudId);
             }
             // 部件
-            if (Regex.IsMatch(cloudId, @"Ec\S*"))
+            if (Regex.IsMatch(cloudId, $"{RegexConstPattern.IsEquipPartId}"))
             {
                 var rlt = new RltEquipInSpace(cloudId, null) { Operator = DocumentChangedOperator.Delete };
                 rlt.DelObject();
                 return EquipmentPartConvert.DelEquipmentPart(cloudId);
             }
             //信标
-            if (Regex.IsMatch(cloudId, @"VOBc\S*"))
+            if (Regex.IsMatch(cloudId, $"{RegexConstPattern.IsBeaconId}"))
             {
                 var rltbeaconinsp = new RltBeaconinElementSp(cloudId, null) { Operator = DocumentChangedOperator.Delete };
                 rltbeaconinsp.DelObject();

+ 1 - 1
MBI/SAGA.MBI/Extend/DocExtend.cs

@@ -131,7 +131,7 @@ namespace SAGA.MBI.Tools
         {
             Func<string, bool> filterFamily = (t) =>
             {
-                return Regex.IsMatch(t, $@"{code}\s*-\s*\S*");
+                return Regex.IsMatch(t, $@"{code}{RegexConstPattern.IsFamilyCode}");
             };
             List<Family> listFamily = doc.GetFamilys();
             var fa = listFamily.FirstOrDefault(t => filterFamily(t.Name));

+ 4 - 7
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -44,7 +44,7 @@ namespace SAGA.MBI.Tools
             if (element is FamilyInstance fi)
             {
                 var family = fi.GetFamilyName();
-                result = Regex.IsMatch(family, @"^[A-Z]{4}\s*-\s*\S*");
+                result = Regex.IsMatch(family, $"{RegexConstPattern.IsEquip}");
             }
 
             return result;
@@ -60,7 +60,7 @@ namespace SAGA.MBI.Tools
             if (element is FamilyInstance fi)
             {
                 var family = fi.GetFamilyName();
-                result = Regex.IsMatch(family, @"^[A-Z]{6}\s*-\s*\S*");
+                result = Regex.IsMatch(family, $"{RegexConstPattern.IsEquipPart}");
             }
 
             return result;
@@ -70,12 +70,9 @@ namespace SAGA.MBI.Tools
         /// </summary>
         /// <param name="family"></param>
         /// <returns></returns>
-        public static bool IsMbiEquipment(this Family family)
+        public static bool IsMbiEquipment(this Element element)
         {
-            var familyName = family.Name;
-            if (string.IsNullOrEmpty(familyName))
-                return false;
-            return Regex.IsMatch(familyName, @"^[A-Z]{4}\s*-\s*\S*") || Regex.IsMatch(familyName, @"^[A-Z]{6}\s*-\s*\S*");
+            return element.IsEquipment()||element.IsEquipmentPart();
         }
         /// <summary>
         /// 判断是否为信标

+ 1 - 1
MBI/SAGA.MBI/RevitExport/ParseElement/ParseEquipment.cs

@@ -28,7 +28,7 @@ namespace SAGA.MBI.RevitExport.ParseElement
                     return;
                 var family = equipment.GetFamily();
                 var name = family.Name;
-                if (!family.IsMbiEquipment())
+                if (!equipment.IsMbiEquipment())
                 {
                     return;
                 }

+ 9 - 1
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -276,6 +276,7 @@
     <Compile Include="Common\MailLog.cs" />
     <Compile Include="Common\MessageManager.cs" />
     <Compile Include="Common\PhaseUtil.cs" />
+    <Compile Include="Common\RegexConstPattern.cs" />
     <Compile Include="Common\RevitBuiltInParameter.cs" />
     <Compile Include="Common\WaitingView.cs" />
     <Compile Include="DataArrange\DalInfoCode.cs" />
@@ -327,12 +328,15 @@
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />
     <Compile Include="RevitReference\RVTNoModeDutyOperate.cs" />
     <Compile Include="Service\InputService.cs" />
+    <Compile Include="Test\CopyParameterValue.cs" />
     <Compile Include="Test\CopyWallLocalName.cs" />
+    <Compile Include="Test\WinParameterDic.xaml.cs">
+      <DependentUpon>WinParameterDic.xaml</DependentUpon>
+    </Compile>
     <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheck.cs" />
     <Compile Include="ToolsData\DataCheck\DutyModeCodeDiffCheckResult.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheck.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheckResult.cs" />
-    <Compile Include="ToolsData\CopyLocalNameValue.cs" />
     <Compile Include="ToolsData\DelZeroSpace.cs" />
     <Compile Include="ToolsData\CheckBase\CheckOperation.cs" />
     <Compile Include="ToolsData\CheckBase\CheckType.cs" />
@@ -752,6 +756,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Test\WinParameterDic.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="ToolsData\CheckBase\WinDataCheckProgressBar.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 96 - 0
MBI/SAGA.MBI/Test/CopyParameterValue.cs

@@ -0,0 +1,96 @@
+/* ==============================================================================
+ * 功能描述:同步幕墙的本地名称、本地编码到幕墙嵌板中?
+ * 创 建 者:Garrett
+ * 创建日期:2018/7/11 14:34:26
+ * ==============================================================================*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Autodesk.Revit.DB;
+using Microsoft.Win32;
+using NPOI.OpenXmlFormats.Dml.Diagram;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using SAGA.DotNetUtils.Data;
+using SAGA.DotNetUtils.Extend;
+using SAGA.DotNetUtils.Logger;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Calc;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.Model;
+using SAGA.MBI.Tools;
+using SAGA.MBI.ToolsData;
+using SAGA.MBI.WinView.Upload;
+using SAGA.Models;
+using SAGA.RevitUtils.Extends;
+using ICell = NPOI.SS.UserModel.ICell;
+using CellType = NPOI.SS.UserModel.CellType;
+
+namespace SAGA.MBI.Test
+{
+    /// <summary>
+    /// CheckEquipInSpace
+    /// </summary>
+    public class CopyParameterValue : IDataCorrect
+    {
+        private Dictionary<string, string> m_parameterDic;
+        public void SetCopyParameterDic(Dictionary<string, string> dic)
+        {
+            m_parameterDic = dic;
+        }
+
+        public string Execute(MFloor floor)
+        {
+            try
+            {
+                string fullPah = floor.FullPath;
+                Document doc = ExternalDataWrapper.Current.UiApp.Application.OpenDocumentFile(fullPah);
+                OperateFloor(doc);
+                doc.Save();
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+            return null;
+        }
+
+        public string ExecuteAll()
+        {
+            var floors = DalProjectTree.GetAllFloors(false);
+            List<CalcContext> contexts = new List<CalcContext>();
+            foreach (MFloor floor in floors)
+            {
+                Execute(floor);
+            }
+
+            return null;
+        }
+
+        private void OperateFloor(Document doc)
+        {
+            using (Transaction trans = new Transaction(doc, "复制属性"))
+            {
+                trans.Start();
+                var elements = doc.GetMbiElements();
+                foreach (Element element in elements)
+                {
+                    if (element.GetFamilyCode() == "GMMP")
+                        foreach (var pair in m_parameterDic)
+                        {
+                            string origin = pair.Key;
+                            string target = pair.Value;
+                            if (origin.IsNotNullEmpty() && target.IsNotNullEmpty())
+                            {
+                                element.SetParameterValue(target, element.GetParameterString(origin));
+                            }
+                        }
+                }
+
+                trans.Commit();
+            }
+        }
+    }
+}

+ 44 - 0
MBI/SAGA.MBI/Test/WinParameterDic.xaml

@@ -0,0 +1,44 @@
+<Window x:Class="SAGA.MBI.Test.WinParameterDic"
+             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.MBI.Test"
+             mc:Ignorable="d" Title="配置参数" WindowStartupLocation="CenterScreen"
+             Height="300" Width="400">
+    <Window.Resources>
+        <Style  TargetType="TextBox">
+            <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
+            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+            <Setter Property="Height" Value="24"></Setter>
+        </Style>
+    </Window.Resources>
+    <Grid Margin="5">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="20"></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition Height="50"></RowDefinition>
+        </Grid.RowDefinitions>
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition></ColumnDefinition>
+                <ColumnDefinition Width="30"></ColumnDefinition>
+            </Grid.ColumnDefinitions>
+            <StackPanel Grid.Column="0">
+                <Label Height="25" Content="源参数名称(旧)" HorizontalContentAlignment="Center" Background="LightGray"></Label>
+                <TextBox Name="txt00" Text="车位编号"></TextBox>
+                <TextBox Name="txt10"></TextBox>
+            </StackPanel>
+            <StackPanel Grid.Column="1">
+                <Label Height="25" Content="目标参数名称(新)" HorizontalContentAlignment="Center" Background="LightGray"></Label>
+                <TextBox  Name="txt01" Text="设备本地编码"></TextBox>
+                <TextBox  Name="txt11"></TextBox>
+            </StackPanel>
+        </Grid>
+        <WrapPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
+            <Button Height="24" Width="100" Content="执行" Margin="10,0" IsDefault="True" Click="ButtonBase_OnClick"></Button>
+            <Button Height="24" Width="100" Content="取消" Margin="10,0" IsCancel="True"></Button>
+        </WrapPanel>
+    </Grid>
+</Window>

+ 45 - 0
MBI/SAGA.MBI/Test/WinParameterDic.xaml.cs

@@ -0,0 +1,45 @@
+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;
+using Exception = System.Exception;
+
+namespace SAGA.MBI.Test
+{
+    /// <summary>
+    /// WinParameterDic.xaml 的交互逻辑
+    /// </summary>
+    public partial class WinParameterDic
+    {
+        public WinParameterDic()
+        {
+            InitializeComponent();
+        }
+        public Dictionary<string,string> ParameterDic { get; set; }
+        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+        {
+            ParameterDic=new System.Collections.Generic.Dictionary<string, string>();
+            try
+            {
+                ParameterDic.Add(txt00.Text,txt01.Text);
+                ParameterDic.Add(txt10.Text,txt11.Text);
+            }
+            catch (Exception exception)
+            {
+                Console.WriteLine(exception);
+                
+            }
+            this.DialogResult = true;
+        }
+    }
+}

+ 26 - 15
MBI/SAGA.MBI/ToolCommand.cs

@@ -16,12 +16,14 @@ using Autodesk.Revit.DB.Plumbing;
 using Autodesk.Revit.UI;
 using FWindSoft.DataFramework;
 using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Data;
 using SAGA.DotNetUtils.Geometry;
 using SAGA.DotNetUtils.Logger;
 using SAGA.DotNetUtils.Others;
 using SAGA.MBI.Common;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Model;
+using SAGA.MBI.Test;
 using SAGA.MBI.Tools;
 using SAGA.MBI.ToolsData;
 using SAGA.MBI.ToolsData.CheckBase;
@@ -133,7 +135,7 @@ namespace SAGA.MBI
 
                 //外点 ==2
                 var testPoint = new Geometry2D.PointD(-100, 200);
-                int flag = Geometry2D.InSidePolygon( newPoints.ToArray(),testPoint ); 
+                int flag = Geometry2D.InSidePolygon(newPoints.ToArray(), testPoint);
                 //==0
                 var testPoint2 = new Geometry2D.PointD(50, 200);
                 int flag2 = Geometry2D.InSidePolygon(newPoints.ToArray(), testPoint2);
@@ -227,30 +229,39 @@ namespace SAGA.MBI
     }
 
     /// <summary>
-    /// 将设备编号的值复制到设备本地编码
+    /// 复制指定参数A的值到指定参数B
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
-    public class CopyLocalIdCommand : ExternalCommand
+    public class CopyParameterValueCommand : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
             try
             {
-                int count = 0;
-                var tip = MessageShowBase.Question2($"确定复制设备编号中的值到{RevitBuiltInParameter.EquipLocalID}中?\r\n是:修正全部楼层\r\n否:修正当前楼层\r\n取消:取消修正。");
-                switch (tip)
+                var tip = MessageShowBase.Question2("确定要复制参数\r\n是:全部楼层\r\n否:当前楼层\r\n取消:取消。");
+                if (tip == DialogResult.No || tip == DialogResult.Yes)
                 {
-                    case DialogResult.Yes:
-                        count = CopyLocalNameValue.OperateAll();
-                        break;
-                    case DialogResult.No:
-                        count = CopyLocalNameValue.OperateCurFloor();
-                        break;
-                    default:
-                        break;
+                    WinParameterDic win = new WinParameterDic();
+
+                    if (win.ShowDialog() == true)
+                    {
+                        SingleInstance<CopyParameterValue>.Instance.SetCopyParameterDic(win.ParameterDic);
+                        switch (tip)
+                        {
+                            case DialogResult.Yes:
+                                SingleInstance<CopyParameterValue>.Instance.ExecuteAll();
+                                break;
+                            case DialogResult.No:
+                                MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
+                                if (floor != null)
+                                    SingleInstance<CopyParameterValue>.Instance.Execute(floor);
+                                break;
+                        }
+                        MessageShowBase.Infomation("信息点的值复制完成");
+                    }
                 }
-                MessageShowBase.Infomation("信息点的值复制完成");
+
             }
             catch (Exception e)
             {

+ 0 - 153
MBI/SAGA.MBI/ToolsData/CopyLocalNameValue.cs

@@ -1,153 +0,0 @@
-/* ==============================================================================
- * 功能描述:复制本地名称或本地编码的值
- * 创 建 者:Garrett
- * 创建日期:2018/7/12 14:25:17
- * ==============================================================================*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using SAGA.DotNetUtils.Others;
-using SAGA.MBI.Calc;
-using SAGA.MBI.Model;
-using SAGA.MBI.RequestData;
-using SAGA.MBI.WinView.Upload;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Mechanical;
-using SAGA.DotNetUtils;
-using SAGA.DotNetUtils.Logger;
-using SAGA.MBI.Common;
-using SAGA.MBI.DataArrange;
-using SAGA.MBI.Tools;
-using SAGA.RevitUtils.Extends;
-
-namespace SAGA.MBI.ToolsData
-{
-    /// <summary>
-    /// CheckEquipCategory
-    /// </summary>
-    public class CopyLocalNameValue
-    {
-        /// <summary>
-        /// 检查并处理所有楼层
-        /// </summary>
-        public static int OperateAll()
-        {
-            int count = 0;
-            var floors = DalUploadFloor.GetHasFileFloors();
-            foreach (UploadFloor floor in floors)
-            {
-                count += Operate(floor.MFloor);
-            }
-            return count;
-        }
-        /// <summary>
-        /// 只处理当前楼层
-        /// </summary>
-        public static int OperateCurFloor()
-        {
-            int count = 0;
-            MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
-            if (floor != null)
-                count = Operate(floor);
-            return count;
-        }
-        /// <summary>
-        /// 检查并处理
-        /// </summary>
-        /// <param name="floor"></param>
-        /// <returns>失败的个数</returns>
-        private static int Operate(MFloor floor)
-        {
-            List<string> errorids = new List<string>();
-            var context = new CalcContext(floor);
-            try
-            {
-                context.OpenDocument();
-                var doc = context.RevitDoc;
-                using (Transaction trans = new Transaction(doc, "复制本地名称,本地编码的值"))
-                {
-                    trans.Start();
-                    try
-                    {
-                        var fis = doc.GetMbiElements();
-                        foreach (var fi in fis)
-                        {
-                            if (fi.IsEquipment() || fi.IsEquipmentPart())
-                                if (!CopyProperty(fi))
-                                    errorids.Add(fi.Id.ToString());
-                        }
-                        trans.Commit();
-                    }
-                    catch (Exception)
-                    {
-                        trans.RollBack();
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                MessageShowBase.Show(e);
-            }
-            finally
-            {
-                context.RevitDoc.CloseDoc();
-            }
-            //if (errorids.Count > 0)
-            //    MessageShowBase.Infomation($"楼层 {floor} 下列对象的参数复制失败,请检查!\r\n" + string.Join(",", errorids));
-            return errorids.Count;
-        }
-
-        /// <summary>
-        /// 复制值:
-        /// 从设备本地名称到设备本地名称2
-        /// 从设备本地编码到设备本地编码2
-        /// 从设备编号到设备本地编码
-        /// </summary>
-        /// <param name="fi"></param>
-        /// <returns>True成功,False失败</returns>
-        private static bool CopyProperty(Element fi, bool isBackupValue = false)
-        {
-            bool result = false;
-            try
-            {
-                Parameter localIdParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalID);
-                Parameter numParameter = fi.GetParameter("设备编号");
-                if (localIdParameter != null)
-                {
-                    if (isBackupValue)
-                    {
-                        Parameter localNameParameter = fi.GetParameter(RevitBuiltInParameter.EquipLocalName);
-                        Parameter localNameParameter2 = fi.GetParameter("设备本地名称2");
-                        Parameter localIdParameter2 = fi.GetParameter("设备本地编码2");
-                        if (localNameParameter != null)
-                        {
-                            if (localIdParameter2 != null && localNameParameter2 != null)
-                            {
-                                localIdParameter2.SetValueString(localIdParameter.GetParameterString());
-                                localNameParameter2.SetValueString(localNameParameter.GetParameterString());
-                            }
-                        }
-                    }
-
-                    if (numParameter != null)
-                    {
-                        string originValue = localIdParameter.GetParameterString();
-                        string numvalue = numParameter.GetParameterString();
-                        if (originValue.IsNullOrEmpty()&& numvalue.IsNotNullEmpty())
-                            result = localIdParameter.Set(numvalue);
-                    }
-
-                }
-            }
-            catch (Exception e)
-            {
-                Console.WriteLine(e);
-                return false;
-            }
-
-            return result;
-        }
-    }
-}

+ 2 - 1
MBI/SAGA.MBI/ToolsData/ExportAllDuty.cs

@@ -79,6 +79,7 @@ namespace SAGA.MBI.ToolsData
         {
             SaveFileDialog sflg = new SaveFileDialog();
             sflg.Filter = "Excel(*.xlsx)|*.xlsx";
+            sflg.FileName = $"{MBIControl.ProjectCur}岗位汇总表";
             if (sflg.ShowDialog() != true) return;
             ExportToExcel(contexts, sflg.FileName, sflg.FilterIndex);
         }
@@ -131,7 +132,7 @@ namespace SAGA.MBI.ToolsData
 
                     Action<MRevitEquipBase, string> action = (equip, type) =>
                      {
-                         var family = equip.EquipClassCode;
+                         string family = equip.EquipClassCode+"-"+equip.Family?.Name;
                          var id = equip.Id;
                          var bimid = equip.BimID.GetBIMID();
                          index++;

+ 1 - 1
MBI/SAGA.MBI/ToolsData/ModeCheck/DataCheckRule.cs

@@ -143,7 +143,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             {
                 Regex regex = new Regex(@"^[A-Z]{4}");
                 list = str.Split(new[] { ',', ',' })
-                    .Where(t => Regex.IsMatch(t, @"^[A-Z]{4}\s*-\s*\S*"))
+                    .Where(t => Regex.IsMatch(t, $"{RegexConstPattern.IsEquip}"))
                     .Select(tt => regex.Match(tt).Value).ToList();
             }
 

+ 4 - 35
MBI/SAGA.MBI/ToolsData/ModeCheck/ElementRangeCheck.cs

@@ -18,6 +18,7 @@ using SAGA.MBI.ToolsData.CheckBase;
 using SAGA.RevitUtils.Extends;
 using NPOI.SS.Util;
 using NPOI.XSSF.UserModel;
+using SAGA.MBI.Common;
 
 namespace SAGA.MBI.ToolsData.ModeCheck
 {
@@ -127,8 +128,8 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 //设置楼层底部高度
                 var curLevelName = result.RFloorName;
                 var levels = doc.GetLevels();
-                var mbiLevels = levels.Where(t => Regex.IsMatch(t.Name, @"([BF][1-9]\d*M?\d?|RFM?\d?)")).ToList();
-                Func<string, bool> isSandwichFunc = (str) => { return Regex.IsMatch(str, @"([BF][1-9]\d*M\d?|RFM?\d?)");};
+                var mbiLevels = levels.Where(t => Regex.IsMatch(t.Name, $"{RegexConstPattern.IsMBILevel}")).ToList();
+                Func<string, bool> isSandwichFunc = (str) => { return Regex.IsMatch(str, $"{RegexConstPattern.IsSandwich}");};
                 //设置楼层顶部高度
                 if (curLevelName == "RF")
                 {
@@ -149,39 +150,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     }
                 }
 
-                //if (curLevelName == "RF" || curLevelName == "RFM")
-                //{
-                //    result.HTop = double.MaxValue;
-                //    result.HSamdwich = double.MaxValue;
-                //}
-                //else
-                //{
-                //    if (topLevel == null)
-                //    {
-                //        throw new Exception($"标高编码不合法:{curLevelName}不应该是顶层,缺少标高RF或标高RF标注的位置不正确");
-                //    }
-                //    double nextL = topLevel.Elevation;
-                //    string tempTopLevelName = topLevel.Name;
-                //    //如果是夹层,获取夹层的上一层
-                //    if (Regex.IsMatch(tempTopLevelName, @"([BF][1-9]\d*M|RFM)"))
-                //    {
-                //        result.HSamdwich = nextL;
-                //        topLevel = mbiLevels.FirstOrDefault(t => t.Elevation.IsThan(nextL));
-                //        if (topLevel == null)
-                //        {
-                //            throw new Exception($"标高编码不合法:{tempTopLevelName}不应该是顶层,缺少标高RF或标高RF标注的位置不正确");
-                //        }
-                //        else
-                //        {
-                //            result.HTop = topLevel.Elevation;
-                //        }
-                //    }
-                //    else
-                //    {
-                //        result.HSamdwich = nextL;
-                //        result.HTop = nextL;
-                //    }
-                //}
+           
             }
             catch (Exception e)
             {

+ 48 - 62
MBI/SAGA.MBI/ToolsData/ModeCheck/FloorMissCheck.cs

@@ -47,7 +47,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             }
             //检查楼层顺序号
             IsRight = GetCheckResult();
-            Results.ForEach(t=>t.IsRight=IsRight);
+            Results.ForEach(t => t.IsRight = IsRight);
             RMessage = IsRight ? "" : "楼层平面图名称错误或缺失楼层,请检查";
             return IsRight;
         }
@@ -74,7 +74,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 {
                     var item0 = baseResults[i];
                     var item1 = baseResults[i + 1];
-                    if (item1.RFloorName == item0.RFloorName)
+                    if (item1.RPlanName == item0.RPlanName)
                     {
                         sequenceResult = false;
                         break;
@@ -88,6 +88,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                         }
                     }
                 }
+
             }
             RBase.Results.ForEach(t => Results.Add(new FloorMissCheckResult { RBase = t }));
 
@@ -127,7 +128,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     if (rbase == null)
                         continue;
 
-                    rowN.AddCell(0, rbase.RFloorName, style);
+                    rowN.AddCell(0, rbase.RPlanName, style);
                     rowN.AddCell(1, rbase.RFileName, style);
                     rowN.AddCell(2, rbase.RPath, style);
                     rowN.AddCell(3, rbase.RPlanName, style);
@@ -154,11 +155,11 @@ namespace SAGA.MBI.ToolsData.ModeCheck
 
     class SSCSComparerByFloorName : IComparer<SagaSignCheckResult>
     {
-        private static List<string> m_RuleFloorNames = new List<string> { "RF", "RFM", @"F\d*M?", @"B\d*M?" };
+        private static List<string> m_RuleFloorNames = new List<string> { RegexConstPattern.IsRF, RegexConstPattern.IsRFM, RegexConstPattern.IsOnground, RegexConstPattern.IsUnderground };
         public int Compare(SagaSignCheckResult x, SagaSignCheckResult y)
         {
-            string floorName0 = x.RFloorName;
-            string floorName1 = y.RFloorName;
+            string floorName0 = x.RPlanName;
+            string floorName1 = y.RPlanName;
             int result = 0;
             if (floorName0 == floorName1)
             {
@@ -171,20 +172,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 //分组组号对比
                 if (item0 == item1)
                 {
-                    int i0 = GetFloorNameIndex(floorName0);
-                    int i1 = GetFloorNameIndex(floorName1);
+                    double i0 = GetFloorNameIndex(floorName0);
+                    double i1 = GetFloorNameIndex(floorName1);
                     //楼层序号对比
-                    if (i0 == i1)
-                    {
-                        int j0 = IsSamdwich(floorName0);
-                        int j1 = IsSamdwich(floorName1);
-                        result = j0.CompareTo(j1);
-                    }
-                    else
-                    {
-                        //数字大的,大于数字小的
-                        result = i0.CompareTo(i1);
-                    }
+                    result = i0.CompareTo(i1);
                 }
                 else
                 {
@@ -192,78 +183,73 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     result = item1.CompareTo(item0);
                 }
             }
-            return -1*result;
+            return -1 * result;
         }
         /// <summary>
-        /// 获取楼层名中的序号
+        /// 获取楼层名中的序号,夹层转化为点F1M1--1.1
         /// </summary>
         /// <param name="name"></param>
         /// <returns></returns>
-        private static int GetFloorNameIndex(string name)
+        private static double GetFloorNameIndex(string name)
         {
-            var str = Regex.Replace(name, @"[^0-9]+", "");
-            var i = str.ToInt();
+            var str = Regex.Replace(name.Replace('M', '.'), @"[^0-9|.]+", "");
+            var i = str.ToDouble();
+            if (Regex.IsMatch(name, RegexConstPattern.IsSandwich))
+                i = i + 0.001;
             //如果是地下,序号为负
-            if (Regex.IsMatch(name, @"^B\s*"))
+            if (IsUnderground(name))
                 i = i * -1;
-            return i;
+            return i.Round(3);
         }
-        /// <summary>
-        /// 是否为夹层 是返回1,否返回0
-        /// </summary>
-        /// <returns></returns>
-        private static int IsSamdwich(string name)
+
+        private static bool IsRFoRFM(string name)
         {
-            return Regex.IsMatch(name, @"\s*M") ? 1 : 0;
+            return (Regex.IsMatch(name, $"{RegexConstPattern.IsRF}")) ||
+                   (Regex.IsMatch(name, $"{RegexConstPattern.IsRFM}"));
+        }
+
+        private static bool IsUpground(string name)
+        {
+            return (Regex.IsMatch(name, $"{RegexConstPattern.IsOnground}"));
+        }
+
+        private static bool IsUnderground(string name)
+        {
+            return (Regex.IsMatch(name, $"{RegexConstPattern.IsUnderground}"));
         }
         /// <summary>
-        /// 是否连续
+        /// 是否连续,x为上层,y为下层
         /// </summary>
         public static bool IsContinuous(SagaSignCheckResult x, SagaSignCheckResult y)
         {
             bool result = false;
-            string floorName0 = x.RFloorName;
-            string floorName1 = y.RFloorName;
-            if (floorName0 == floorName1)
+            string floorName0 = x.RPlanName;
+            string floorName1 = y.RPlanName;
+            double i0 = GetFloorNameIndex(floorName0);
+            double i1 = GetFloorNameIndex(floorName1);
+            //有一个RF或RFM,判断为连续
+            if (IsRFoRFM(floorName0) || IsRFoRFM(floorName1))
             {
                 result = true;
             }
             else
             {
-                if (floorName0 == m_RuleFloorNames[0] || floorName0 == m_RuleFloorNames[1])
+                var diff = i0 - i1;
+                if ((diff).IsBetween(0, 2))
                 {
-                    result = true;
-                }
-                else
-                {
-                    int i0 = GetFloorNameIndex(floorName0);
-                    int i1 = GetFloorNameIndex(floorName1);
-                    int j0 = IsSamdwich(floorName0);
-                    int j1 = IsSamdwich(floorName1);
-
-                    if (j0 == 1)
-                    {           
-                        //顶部为夹层
-                        //底部不能为夹层,且楼层序号应该相同
-                        result = j1!=1&&i0 == i1;
+                    if (diff.IsThan(1))
+                    {
+                        result = IsUpground(floorName0) && IsUnderground(floorName1);
                     }
                     else
                     {
-                        if (i0 > 0 && i1 < 0)
-                        {
-                            //地上和地下连续,序号为1和-1
-                            result = i0 == 1 && i1 == -1;
-                        }
-                        else
-                        {
-                            //其它情况连续为序号差为1
-                            result = i0 - i1 == 1;
-                        }
+                        result = true;
                     }
                 }
-            }
 
 
+            }
+
             return result;
         }
     }

+ 2 - 2
MBI/SAGA.MBI/ToolsData/ModeCheck/SagaSignCheck.cs

@@ -104,11 +104,11 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     result.RPlanName = sagaPlanName;
                     result.HBase = sagaPlan.GenLevel.Elevation;
                     //打标记的楼层名称必需为指定格式;B1,B1M,F1,F1M,RFM,RF
-                    if (Regex.IsMatch(sagaPlanName, @"^([BF][1-9]\d*M?|RFM?)-saga$"))
+                    if (Regex.IsMatch(sagaPlanName, $"{RegexConstPattern.IsMBIView}"))
                     {
 
                         result.RSequence = mFloor.Sequence;
-                        var rfLevel = document.GetLevels().FirstOrDefault(t => System.Text.RegularExpressions.Regex.IsMatch(t.Name, @"^RF(-saga)?$"));
+                        var rfLevel = document.GetLevels().FirstOrDefault(t => System.Text.RegularExpressions.Regex.IsMatch(t.Name, $"{RegexConstPattern.IsRF}"));
                         if (rfLevel == null)
                         {
                             result.IsRight = false;

+ 3 - 1
MBI/SAGA.MBI/ToolsData/ModeCheck/WinModeCheckSetting.xaml.cs

@@ -219,7 +219,9 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 if (chk.IsChecked == true)
                 {
                     var checkItem = chk.DataContext as ModeCheckBase;
-                    if (checkItem.RIsNeedTwoMoreFloors)
+                    if (checkItem == null) return;
+                    var floors = DalProjectTree.GetSelectedFloors();
+                    if (checkItem.RIsNeedTwoMoreFloors&&floors.Count<2)
                     {
                         MessageBox.Show("请选择两个及以上楼层再检查此项");
                     }

+ 3 - 2
MBI/SAGA.MBI/ToolsData/VerticalPipeAlign.cs

@@ -14,6 +14,7 @@ using Autodesk.Revit.DB.Plumbing;
 using SAGA.DotNetUtils.Data;
 using SAGA.DotNetUtils.Extend;
 using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Common;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Model;
 using SAGA.MBI.Tools;
@@ -234,7 +235,7 @@ namespace SAGA.MBI.ToolsData
             else
             {
                 var levels = doc.GetLevels();
-                var mbiLevels = levels.Where(t => Regex.IsMatch(t.Name, @"([BF][1-9]\d*M?|RFM?)"));
+                var mbiLevels = levels.Where(t => Regex.IsMatch(t.Name, $"{RegexConstPattern.IsMBILevel}"));
                 var topLevel = mbiLevels.FirstOrDefault(t => t.Elevation.IsThan(hb));
                 if (topLevel == null)
                 {
@@ -244,7 +245,7 @@ namespace SAGA.MBI.ToolsData
                 double nextL = topLevel.Elevation;
                 string tempTopLevelName = topLevel.Name;
                 //如果是夹层,获取夹层的上一层
-                if (Regex.IsMatch(tempTopLevelName, @"([BF][1-9]\d*M|RFM)"))
+                if (Regex.IsMatch(tempTopLevelName, $"{RegexConstPattern.IsSandwich}"))
                 {
                     hj = nextL;
                     topLevel = mbiLevels.FirstOrDefault(t => t.Elevation.IsThan(nextL));

+ 1 - 1
MBI/SAGA.MBI/WinView/Login/WinLogin.xaml.cs

@@ -153,7 +153,7 @@ namespace SAGA.MBI.WinView.Login
         /// <returns></returns>
         public bool IsHandset(string str_handset)
         {
-            return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^1[3|4|5|7|8][0-9]\d{8}$");
+            return System.Text.RegularExpressions.Regex.IsMatch(str_handset,$"{RegexConstPattern.IsPhoneNumber}");
         }
 
         private Timer timer = null;