Bläddra i källkod

Merge branch 'master' of http://dev.dp.sagacloud.cn:8886/r/Revit/SAGA.MBI

xulisong 6 år sedan
förälder
incheckning
c61fc71974

BIN
MBI/MBIResource/DataCheck/模型检查结果输出格式-模版.xlsx


+ 63 - 0
MBI/SAGA.DotNetUtils/Cache/MemoryCacheHelper.cs

@@ -0,0 +1,63 @@
+/* ==============================================================================
+ * 功能描述:使用MemoryCache进行缓存
+ * 创 建 者:Garrett
+ * 创建日期:2018/12/21 17:29:40
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Caching;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Cache
+{
+    /// <summary>
+    /// 基于MemoryCache的缓存辅助类
+    /// </summary>
+    public static class MemoryCacheHelper
+    {
+        private static readonly Object _locker = new object();
+
+        public static T GetCacheItem<T>(String key, Func<T> cachePopulate, TimeSpan? slidingExpiration = null, DateTime? absoluteExpiration = null)
+        {
+            if (String.IsNullOrWhiteSpace(key)) throw new ArgumentException("Invalid cache key");
+            if (cachePopulate == null) throw new ArgumentNullException("cachePopulate");
+            if (slidingExpiration == null && absoluteExpiration == null) throw new ArgumentException("Either a sliding expiration or absolute must be provided");
+
+            if (MemoryCache.Default[key] == null)
+            {
+                lock (_locker)
+                {
+                    if (MemoryCache.Default[key] == null)
+                    {
+                        var item = new CacheItem(key, cachePopulate());
+                        var policy = CreatePolicy(slidingExpiration, absoluteExpiration);
+
+                        MemoryCache.Default.Add(item, policy);
+                    }
+                }
+            }
+
+            return (T)MemoryCache.Default[key];
+        }
+
+        private static CacheItemPolicy CreatePolicy(TimeSpan? slidingExpiration, DateTime? absoluteExpiration)
+        {
+            var policy = new CacheItemPolicy();
+
+            if (absoluteExpiration.HasValue)
+            {
+                policy.AbsoluteExpiration = absoluteExpiration.Value;
+            }
+            else if (slidingExpiration.HasValue)
+            {
+                policy.SlidingExpiration = slidingExpiration.Value;
+            }
+
+            policy.Priority = CacheItemPriority.Default;
+
+            return policy;
+        }
+    }
+}

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

@@ -179,6 +179,7 @@
     <Reference Include="System.Drawing" />
     <Reference Include="System.IO.Compression" />
     <Reference Include="System.Management" />
+    <Reference Include="System.Runtime.Caching" />
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.ServiceModel" />
     <Reference Include="System.Transactions" />
@@ -196,6 +197,7 @@
   <ItemGroup>
     <Compile Include="AOP\AopAttribute.cs" />
     <Compile Include="AOP\IAop.cs" />
+    <Compile Include="Cache\MemoryCacheHelper.cs" />
     <Compile Include="Component\AllowDisposableSet!1.cs" />
     <Compile Include="Component\ChangedEventArgs.cs" />
     <Compile Include="Component\ChangedEventHandler.cs" />

+ 1 - 1
MBI/SAGA.MBI/CmbData/FloorCmbVm.cs

@@ -1,5 +1,5 @@
 /* ==============================================================================
- * 功能描述:ProvinceCityVm  
+ * 功能描述:
  * 创 建 者:Garrett
  * 创建日期:2018/4/17 14:34:03
  * ==============================================================================*/

+ 34 - 0
MBI/SAGA.MBI/Common/CacheAspect.cs

@@ -0,0 +1,34 @@
+/* ==============================================================================
+ * 功能描述:AOP缓存
+ * 创 建 者:Garrett
+ * 创建日期:2018/12/21 17:33:03
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ArxOne.MrAdvice.Advice;
+using SAGA.DotNetUtils.Cache;
+
+namespace SAGA.MBI.Common
+{
+    /// <summary>
+    /// CacheAspect
+    /// </summary>
+    class CacheAspect : Attribute, IMethodAdvice
+    {
+        public void Advise(MethodAdviceContext context)
+        {
+            string key = $"{context.TargetType.FullName}.{context.TargetMethod.Name}.{string.Join(".", context.Parameters.Cast<string>())}";
+            var result = MemoryCacheHelper.GetCacheItem(key,
+                delegate ()
+                {
+                    context.Proceed();
+                    return context.ReturnValue;
+                },
+                new TimeSpan(12, 30, 0));//30分钟过期
+            context.ReturnValue = result;
+        }
+    }
+}

+ 1 - 0
MBI/SAGA.MBI/DataArrange/DalCmd.cs

@@ -14,6 +14,7 @@ using SAGA.DotNetUtils;
 using SAGA.DotNetUtils.Extend;
 using SAGA.DotNetUtils.WPF.UserControl.ComboboxTreeView;
 using SAGA.MBI.CmbData;
+using SAGA.MBI.Common;
 
 namespace SAGA.MBI.DataArrange
 {

+ 15 - 5
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -102,14 +102,13 @@ namespace SAGA.MBI.Tools
             var id = elem.Id.ToString();
             return CommonTool.GetCloudBIMId(docName, id);
         }
-
         /// <summary>
-        /// 获取MBI存储的位置信息
+        /// 获取MBI的定位点
         /// </summary>
+        /// <param name="element"></param>
         /// <returns></returns>
-        public static string GetLocationPointMBI(this Element element)
+        public static XYZ GetLocationPointMBIXYZ(this Element element)
         {
-            string str = ",,";
             //定位点不可靠,未来可能会更改为Box的中心点
             XYZ bimXyz = element.GetLocationPoint();
             if (element is FamilyInstance fi)
@@ -120,6 +119,17 @@ namespace SAGA.MBI.Tools
                     bimXyz = fi.GetBoxCenter();
                 }
             }
+
+            return bimXyz;
+        }
+        /// <summary>
+        /// 获取MBI存储的位置信息
+        /// </summary>
+        /// <returns></returns>
+        public static string GetLocationPointMBI(this Element element)
+        {
+            string str = ",,";
+            XYZ bimXyz = element.GetLocationPointMBIXYZ();
             if (bimXyz != null)
             {
                 str = bimXyz.FromApi().ToString(null);
@@ -178,7 +188,7 @@ namespace SAGA.MBI.Tools
             //没有Space属性,取定位点,判断定位点所在空间
             if (space == null)
             {
-                var origin = fi.GetLocationPointMBI().ToXyz().ConvertToApi();
+                var origin = fi.GetLocationPointMBIXYZ();
                 space = spaces.FirstOrDefault(t => t.IsValidObject && t.IsPointInSpace(origin));
             }
             //还没有找到空间,取Box中心点,判断点所在空间

+ 10 - 0
MBI/SAGA.MBI/JsonConvert/CmbDataSourceConvert.cs

@@ -30,6 +30,7 @@ namespace SAGA.MBI.JsonConvert
         /// 查询地理信息--省市信息
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<ProvinceInfo> GeographyDic()
         {
             List<ProvinceInfo> list = new List<ProvinceInfo>();
@@ -116,6 +117,7 @@ namespace SAGA.MBI.JsonConvert
         /// 查询地理信息--省市信息,使用TreeNodeItem形式表达
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<CMBTreeNodeItem<ICMBTreeNodeItem>> GeographyTree()
         {
             List<CMBTreeNodeItem<ICMBTreeNodeItem>> list = new List<CMBTreeNodeItem<ICMBTreeNodeItem>>();
@@ -160,6 +162,7 @@ namespace SAGA.MBI.JsonConvert
         /// 气候区
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<ClimaticRegion> ClimateDic()
         {
             List<ClimaticRegion> list = new List<ClimaticRegion>();
@@ -191,6 +194,7 @@ namespace SAGA.MBI.JsonConvert
         /// 气候区
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<CMBTreeNodeItem<ICMBTreeNodeItem>> ClimateTree()
         {
             List<CMBTreeNodeItem<ICMBTreeNodeItem>> list = new List<CMBTreeNodeItem<ICMBTreeNodeItem>>();
@@ -212,6 +216,7 @@ namespace SAGA.MBI.JsonConvert
         /// 建筑功能类型
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<CMBTreeNodeItem<ICMBTreeNodeItem>> BuildFuncTypeDic()
         {
             List<CMBTreeNodeItem<ICMBTreeNodeItem>> list = new List<CMBTreeNodeItem<ICMBTreeNodeItem>>();
@@ -246,6 +251,7 @@ namespace SAGA.MBI.JsonConvert
         /// </summary>
         /// <param name="infoPointCode"></param>
         /// <returns></returns>
+        [CacheAspect]
         public static List<CMBTreeNodeItem<ICMBTreeNodeItem>> BuildingInfoDS(string infoPointCode)
         {
             MInfoCode infoCode = BuildingDic().FirstOrDefault(t => t.InfoPointCode == infoPointCode);
@@ -255,6 +261,7 @@ namespace SAGA.MBI.JsonConvert
         /// 建筑体的数据字典
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<MInfoCode> BuildingDic()
         {
             List<MInfoCode> list = new List<MInfoCode>();
@@ -276,6 +283,7 @@ namespace SAGA.MBI.JsonConvert
         /// </summary>
         /// <param name="infoPointCode"></param>
         /// <returns></returns>
+        [CacheAspect]
         public static List<CMBTreeNodeItem<ICMBTreeNodeItem>> FloorInfoDS(string infoPointCode)
         {
             List<MInfoCode> list = FloorDic();
@@ -286,6 +294,7 @@ namespace SAGA.MBI.JsonConvert
         /// 楼层的数据字典
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<MInfoCode> FloorDic()
         {
             List<MInfoCode> list = new List<MInfoCode>();
@@ -307,6 +316,7 @@ namespace SAGA.MBI.JsonConvert
         /// 设备种族类型编码
         /// </summary>
         /// <returns></returns>
+        [CacheAspect]
         public static List<MEquipmentFamily> EquipmentFamilyDic()
         {
             List<MEquipmentFamily> list = new List<MEquipmentFamily>();

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

@@ -241,6 +241,7 @@
     <Compile Include="CmbData\ProvinceCityInfo.cs" />
     <Compile Include="CmbData\BuildingCmbVm.cs" />
     <Compile Include="CmbData\ProvinceCityVm.cs" />
+    <Compile Include="Common\CacheAspect.cs" />
     <Compile Include="Html5Command.cs" />
     <Compile Include="Command.cs" />
     <Compile Include="Common\MBIAssistHelper.cs" />
@@ -274,6 +275,7 @@
     <Compile Include="RequestData\QRCodeRequest.cs" />
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />
     <Compile Include="RevitReference\RVTNoModeDutyOperate.cs" />
+    <Compile Include="ToolsData\DelZeroSpace.cs" />
     <Compile Include="ToolsData\CheckBase\CheckOperation.cs" />
     <Compile Include="ToolsData\CheckBase\CheckType.cs" />
     <Compile Include="ToolsData\CheckBase\ICheckBase.cs" />
@@ -308,8 +310,8 @@
     <Compile Include="ToolsData\ModeCheck\EquipmentInSpaceCheckResult.cs" />
     <Compile Include="ToolsData\ModeCheck\FloorMissCheck.cs" />
     <Compile Include="ToolsData\ModeCheck\FloorMissCheckResult.cs" />
-    <Compile Include="ToolsData\ModeCheck\DataCheckProcessAspect.cs" />
-    <Compile Include="ToolsData\ModeCheck\DataCheckProgressBarClient.cs" />
+    <Compile Include="ToolsData\CheckBase\CheckProcessAspect.cs" />
+    <Compile Include="ToolsData\CheckBase\CheckProgressBarClient.cs" />
     <Compile Include="ToolsData\ModeCheck\SagaPositionCheck.cs" />
     <Compile Include="ToolsData\ModeCheck\FloorSequenceCheck.cs" />
     <Compile Include="ToolsData\ModeCheck\SagaPositionCheckCheckResult.cs" />
@@ -339,6 +341,7 @@
     <Compile Include="ToolsData\ExportAllCategory.cs" />
     <Compile Include="ToolsData\ExportAllEquipmentAll.cs" />
     <Compile Include="ToolsData\IToolCommand.cs" />
+    <Compile Include="ToolsData\ExportAllDuty.cs" />
     <Compile Include="ToolsData\UpdateRelationEquipinSpace.cs" />
     <Compile Include="WinView\BeModingDutyList\MEquipNoMode.cs" />
     <Compile Include="WinView\BeModingDutyList\VMBeModeDutyList.cs" />

+ 99 - 67
MBI/SAGA.MBI/ToolCommand.cs

@@ -44,24 +44,51 @@ namespace SAGA.MBI
         {
             try
             {
-                var doc = ExternalDataWrapper.Current.Doc;
-                using (Transaction trans = new Transaction(doc, "删除"))
+                int count = 0;
+                var tip = MessageShowBase.Question2("确定要删除所有楼层周长为零的空间?\r\n是:修正全部楼层\r\n否:修正当前楼层\r\n取消:取消修正。");
+                switch (tip)
                 {
-                    trans.Start();
-                    try
-                    {
-                        var spaces = doc.GetSpaces().Where(t => t.IsDeleteSpace());
-                        doc.Delete(spaces.Select(t => t.Id).ToList());
-                        trans.Commit();
-                        MessageShowBase.Infomation("删除成功");
-                    }
-                    catch (Exception)
-                    {
-                        trans.RollBack();
-
-                    }
+                    case DialogResult.Yes:
+                        count=DelZeroSpace.OperateAll();
+                        break;
+                    case DialogResult.No:
+                        count=DelZeroSpace.OperateCurFloor();
+                        break;
+                    default:
+                        break;
                 }
+                if(tip== DialogResult.Yes||tip== DialogResult.No)
+                    MessageShowBase.Infomation($"此次操作共删除{count}个空间");
+
+            }
+            catch (Exception e)
+            {
+                MessageShow.Show(e);
+                return Result.Cancelled;
+            }
+            return Result.Succeeded;
+        }
+
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
+    /// <summary>
+    /// 导出类别
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class ExportCategoriesCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            try
+            {
 
+                var tip = MessageShow.Question("确定要导出所有的族类别?");
+                if (tip)
+                    BllFactory<ExportAllCategory>.Instance.Operate();
             }
             catch (Exception e)
             {
@@ -70,6 +97,16 @@ namespace SAGA.MBI
             }
             return Result.Succeeded;
         }
+
+
+        /// <summary>
+        /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
+        /// when a document is open.
+        /// </summary>
+        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
     }
     /// <summary>
     /// 报告设备所在空间
@@ -94,6 +131,44 @@ namespace SAGA.MBI
             return Result.Succeeded;
         }
     }
+    /// <summary>
+    /// 导出所有的岗位
+    /// </summary>
+    [Transaction(TransactionMode.Manual)]
+    [Regeneration(RegenerationOption.Manual)]
+    public class ExportAllDutyCommand : ExternalCommand
+    {
+        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+        {
+            try
+            {
+                var tip = MessageShowBase.Question2("确定要导出所有岗位?\r\n是:全部楼层\r\n否:当前楼层\r\n取消:取消。");
+                switch (tip)
+                {
+                    case DialogResult.Yes:
+                        ExportAllDuty.OperateAll();
+                        break;
+                    case DialogResult.No:
+                        ExportAllDuty.OperateCurFloor();
+                        break;
+                    default:
+                        break;
+                }
+
+            }
+            catch (Exception e)
+            {
+                MessageShow.Show(e);
+                return Result.Cancelled;
+            }
+            return Result.Succeeded;
+        }
+
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        {
+            return true;
+        }
+    }
     #endregion
 
 
@@ -119,16 +194,6 @@ namespace SAGA.MBI
             }
             return Result.Succeeded;
         }
-
-
-        /// <summary>
-        /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
-        /// when a document is open.
-        /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
-        {
-            return false;
-        }
     }
 
     /// <summary>
@@ -136,7 +201,7 @@ namespace SAGA.MBI
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
-    public class AddEquipLocationCommand : ExternalCommand, IExternalCommandAvailability
+    public class AddEquipLocationCommand : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
@@ -168,7 +233,7 @@ namespace SAGA.MBI
         /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
         /// when a document is open.
         /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
             return true;
         }
@@ -178,7 +243,7 @@ namespace SAGA.MBI
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
-    public class CheckEquipinFloorCommand : ExternalCommand, IExternalCommandAvailability
+    public class CheckEquipinFloorCommand : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
@@ -201,7 +266,7 @@ namespace SAGA.MBI
         /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
         /// when a document is open.
         /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
             return true;
         }
@@ -211,7 +276,7 @@ namespace SAGA.MBI
     /// </summary>
     [Transaction(TransactionMode.Manual)]
     [Regeneration(RegenerationOption.Manual)]
-    public class UpdateEquipinSpaceCommand : ExternalCommand, IExternalCommandAvailability
+    public class UpdateEquipinSpaceCommand : ExternalCommand
     {
         public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
         {
@@ -243,45 +308,12 @@ namespace SAGA.MBI
         /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
         /// when a document is open.
         /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
-        {
-            return true;
-        }
-    }
-    /// <summary>
-    /// 导出类别
-    /// </summary>
-    [Transaction(TransactionMode.Manual)]
-    [Regeneration(RegenerationOption.Manual)]
-    public class ExportCategoriesCommand : ExternalCommand
-    {
-        public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {
-            try
-            {
-
-                var tip = MessageShow.Question("确定要导出所有的族类别?");
-                if (tip)
-                    BllFactory<ExportAllCategory>.Instance.Operate();
-            }
-            catch (Exception e)
-            {
-                MessageShow.Show(e);
-                return Result.Cancelled;
-            }
-            return Result.Succeeded;
-        }
-
-
-        /// <summary>
-        /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
-        /// when a document is open.
-        /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+        public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
         {
             return true;
         }
     }
+   
 
 
     /// <summary>
@@ -304,7 +336,7 @@ namespace SAGA.MBI
             }
             catch (Exception e)
             {
-                DataCheckProgressBarClient.Stop();
+                CheckProgressBarClient.Stop();
                 MessageShow.Show(e);
                 return Result.Cancelled;
             }
@@ -342,7 +374,7 @@ namespace SAGA.MBI
             }
             catch (Exception e)
             {
-                DataCheckProgressBarClient.Stop();
+                CheckProgressBarClient.Stop();
                 MessageShow.Show(e);
                 return Result.Cancelled;
             }

+ 3 - 3
MBI/SAGA.MBI/ToolsData/CheckBase/CheckOperation.cs

@@ -94,11 +94,11 @@ namespace SAGA.MBI.ToolsData.CheckBase
         /// <param name="context"></param>
         public static void Execute(List<ICheckBase> list, CheckContext context)
         {
-            DataCheckProgressBarClient.Start("正在进行数据检查", list.Count(t => t.RIsChecked), false);
+            CheckProgressBarClient.Start("正在进行数据检查", list.Count(t => t.RIsChecked), false);
             //检查
             list.ForEach(t => t.Check2(context));
 
-            DataCheckProgressBarClient.UpdateBigTip("正在进行数据保存");
+            CheckProgressBarClient.UpdateBigTip("正在进行数据保存");
             //重置workbook准备保存结果
             DCRExport.ClearWorkbook();
             //保存
@@ -107,7 +107,7 @@ namespace SAGA.MBI.ToolsData.CheckBase
             DCRExport.Save(context.SavePath, DCRExport.GetWorkbook());
             //关闭所有窗体
             DocumentQueue.CloseAll();
-            DataCheckProgressBarClient.UpdateBigTip("结束");
+            CheckProgressBarClient.UpdateBigTip("结束");
         }
         /// <summary>
         /// 获取保存模版的地址

+ 7 - 8
MBI/SAGA.MBI/ToolsData/ModeCheck/DataCheckProcessAspect.cs

@@ -5,11 +5,10 @@
  * ==============================================================================*/
 
 using System;
-using System.Threading;
 using ArxOne.MrAdvice.Advice;
-using SAGA.MBI.ToolsData.CheckBase;
+using SAGA.MBI.ToolsData.ModeCheck;
 
-namespace SAGA.MBI.ToolsData.ModeCheck
+namespace SAGA.MBI.ToolsData.CheckBase
 {
     [Serializable]
     public class DataCheckProcessAspect :Attribute,IMethodAdvice //, OnMethodBoundaryAspect
@@ -30,10 +29,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             var icheck = context.Target as ICheckBase;
             if (icheck == null) return;
             string name = icheck?.Name;
-            DataCheckProgressBarClient.Increase(name);
+            CheckProgressBarClient.Increase(name);
             startTime = DateTime.Now;
-            DataCheckProgressBarClient.UpdataLog($"{name}:");
-            DataCheckProgressBarClient.UpdataLog($"\t开始时间:{DateTime.Now}");
+            CheckProgressBarClient.UpdataLog($"{name}:");
+            CheckProgressBarClient.UpdataLog($"\t开始时间:{DateTime.Now}");
             //Thread.Sleep(500);
         }
 
@@ -44,8 +43,8 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             var icheck = context.Target as ICheckBase;
             if (icheck == null) return;
             var duringTime = (DateTime.Now - startTime);
-            DataCheckProgressBarClient.UpdataLog($"\t结束时间:{DateTime.Now}");
-            DataCheckProgressBarClient.UpdataLog(string.Format("\t耗时:{0}{1}{2}{3}"
+            CheckProgressBarClient.UpdataLog($"\t结束时间:{DateTime.Now}");
+            CheckProgressBarClient.UpdataLog(string.Format("\t耗时:{0}{1}{2}{3}"
                 , duringTime.Hours == 0 ? "" : $"{duringTime.Hours}小时"
                 , duringTime.Minutes == 0 ? "" : $"{duringTime.Minutes}分钟"
                 , duringTime.Seconds == 0 ? "" : $"{duringTime.Seconds}秒"

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

@@ -4,12 +4,12 @@
  * 创建日期:2018/11/13 15:38:49
  * ==============================================================================*/
  
-namespace SAGA.MBI.ToolsData.ModeCheck
+namespace SAGA.MBI.ToolsData.CheckBase
 {
     /// <summary>
     /// ProgressBarClient
     /// </summary>
-    class DataCheckProgressBarClient
+    class CheckProgressBarClient
     {
         private static int MaxValue { get; set; }
 

+ 96 - 0
MBI/SAGA.MBI/ToolsData/DelZeroSpace.cs

@@ -0,0 +1,96 @@
+/* ==============================================================================
+ * 功能描述:删除周长为零的空间
+ * 创 建 者: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.DataArrange;
+using SAGA.MBI.Tools;
+using SAGA.RevitUtils.Extends;
+
+namespace SAGA.MBI.ToolsData
+{
+    /// <summary>
+    /// CheckEquipCategory
+    /// </summary>
+    public class DelZeroSpace
+    {
+        /// <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)
+        {
+            int count = 0;
+            var context = DalCommon.DownLoadCouldData(floor);
+            context.OpenDocument();
+            try
+            {
+                var doc = context.RevitDoc;
+                using (Transaction trans = new Transaction(doc, "删除"))
+                {
+                    trans.Start();
+                    try
+                    {
+                        var spaces = doc.GetSpaces().Where(t => t.IsDeleteSpace()).ToList();
+                        count = spaces.Count;
+                        doc.Delete(spaces.Select(t => t.Id).ToList());
+                        trans.Commit();
+                    }
+                    catch (Exception)
+                    {
+                        trans.RollBack();
+
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+            finally
+            {
+                context.RevitDoc.CloseDoc();
+            }
+            return count;
+        }
+    }
+}

+ 284 - 0
MBI/SAGA.MBI/ToolsData/ExportAllDuty.cs

@@ -0,0 +1,284 @@
+/* ==============================================================================
+ * 功能描述:导出所有的岗位
+ * 创 建 者:Garrett
+ * 创建日期:2018/8/10 16:36:26
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.Revit.DB;
+using Autodesk.Revit.DB.Mechanical;
+using Microsoft.Win32;
+using Newtonsoft.Json.Linq;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Logger;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Calc;
+using SAGA.MBI.Common;
+using SAGA.MBI.DataArrange;
+using SAGA.MBI.Model;
+using SAGA.MBI.RequestData;
+using SAGA.MBI.Tools;
+using SAGA.MBI.WinView.Upload;
+using SAGA.RevitUtils.Extends;
+using CellType = Autodesk.Revit.DB.CellType;
+
+namespace SAGA.MBI.ToolsData
+{
+    /// <summary>
+    /// UpdateRelationEquipinFloor
+    /// </summary>
+    public class ExportAllDuty
+    {
+        /// <summary>
+        /// 检查并处理所有楼层
+        /// </summary>
+        public static void OperateAll()
+        {
+            var floors = DalUploadFloor.GetHasFileFloors();
+            List<CalcContext> contexts = new List<CalcContext>();
+            foreach (UploadFloor floor in floors)
+            {
+                contexts.Add(Operate(floor.MFloor));
+            }
+            ExportToExcel(contexts);
+        }
+        /// <summary>
+        /// 只处理当前楼层
+        /// </summary>
+        public static void OperateCurFloor()
+        {
+            MFloor floor = ExternalDataWrapper.Current.Doc.GetCurMFloor();
+            if (floor != null)
+            {
+                var context = Operate(floor);
+                ExportToExcel(new List<CalcContext>() { context });
+            }
+        }
+        /// <summary>
+        /// 检查并处理
+        /// </summary>
+        /// <param name="floor"></param>
+        /// <returns></returns>
+        private static CalcContext Operate(MFloor floor)
+        {
+            var context = DalCommon.DownLoadFloorDataByBIMFloorInfo(floor);
+            return context;
+        }
+
+        /// <summary>
+        /// 导出数据
+        /// </summary>
+        /// <param name="xyzsList"></param>
+        public static void ExportToExcel(List<CalcContext> contexts)
+        {
+            SaveFileDialog sflg = new SaveFileDialog();
+            sflg.Filter = "Excel(*.xlsx)|*.xlsx";
+            if (sflg.ShowDialog() != true) return;
+            ExportToExcel(contexts, sflg.FileName, sflg.FilterIndex);
+        }
+
+        /// <summary>
+        /// 导出数据到指定目录
+        /// </summary>
+        /// <param name="xyzsList"></param>
+        /// <param name="fileName"></param>
+        private static void ExportToExcel(List<CalcContext> contexts, string fileName, int filterIndex = 0)
+        {
+            try
+            {
+                IWorkbook book = new XSSFWorkbook();
+
+                #region 添加数据
+
+                foreach (var context in contexts)
+                {
+                    int index = 0;
+                    var floorName = context.MFloor.ToString();
+                    var floorPath = context.MFloor.FullPath;
+                    ISheet sheet = book.CreateSheet(floorName);
+
+                    #region 添加表头
+
+                    IRow row = sheet.CreateRow(0);
+                    NPOI.SS.UserModel.ICell cell0 = row.CreateCell(0);
+                    cell0.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell0.SetCellValue("楼层名称");
+
+                    ICell cell1 = row.CreateCell(1);
+                    cell1.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell1.SetCellValue("类型");
+
+                    ICell cell2 = row.CreateCell(2);
+                    cell2.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell2.SetCellValue("族名称");
+
+                    ICell cell3 = row.CreateCell(3);
+                    cell3.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell3.SetCellValue("Dutyid");
+
+
+                    ICell cell4 = row.CreateCell(3);
+                    cell4.SetCellType(NPOI.SS.UserModel.CellType.String);
+                    cell4.SetCellValue("BIMID");
+
+                    #endregion
+
+                    Action<MRevitEquipBase, string> action = (equip, type) =>
+                     {
+                         var family = equip.EquipClassCode;
+                         var id = equip.Id;
+                         var bimid = equip.BimID.GetBIMID();
+                         index++;
+
+                         row = sheet.CreateRow(index);
+
+                         ICell cell = row.CreateCell(0, NPOI.SS.UserModel.CellType.String);
+                         cell.SetCellValue(floorName);
+
+                         cell = row.CreateCell(1, NPOI.SS.UserModel.CellType.String);
+                         cell.SetCellValue(type);
+
+                         cell = row.CreateCell(2, NPOI.SS.UserModel.CellType.String);
+                         cell.SetCellValue(family);
+
+                         cell = row.CreateCell(3, NPOI.SS.UserModel.CellType.String);
+                         cell.SetCellValue(id);
+
+                         cell = row.CreateCell(4, NPOI.SS.UserModel.CellType.String);
+                         cell.SetCellValue(bimid);
+                     };
+                    foreach (var equip in context.MEquipments)
+                    {
+                        action(equip, "设备");
+                    }
+                    foreach (var part in context.MEquipmentParts)
+                    {
+                        action(part, "部件");
+                    }
+                    foreach (var beacon in context.MBeacons)
+                    {
+                        action(beacon, "信标");
+                    }
+                    foreach (var space in context.MSpaces)
+                    {
+                        action(space, "空间");
+                    }
+                }
+
+                #endregion
+
+                #region 写入
+
+                MemoryStream ms = new MemoryStream();
+                book.Write(ms);
+                book = null;
+
+                using (System.IO.FileStream fs = new System.IO.FileStream(fileName, FileMode.Create, FileAccess.Write))
+                {
+                    byte[] data = ms.ToArray();
+                    fs.Write(data, 0, data.Length);
+                    fs.Flush();
+                }
+                ms.Close();
+                ms.Dispose();
+
+                #endregion
+
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+        }
+
+        /// <summary>
+        /// 导出数据到指定目录
+        /// </summary>
+        /// <param name="xyzsList"></param>
+        /// <param name="fileName"></param>
+        private static void ExportToExcel2(List<CalcContext> contexts, string fileName, int filterIndex = 0)
+        {
+            try
+            {
+                IWorkbook book = new XSSFWorkbook();
+
+                #region 添加数据
+                ISheet sheet = book.CreateSheet("Summary");
+
+                #region 添加表头
+
+                IRow row = sheet.CreateRow(0);
+                NPOI.SS.UserModel.ICell cell0 = row.CreateCell(0);
+                cell0.SetCellType(NPOI.SS.UserModel.CellType.String);
+                cell0.SetCellValue("楼层名称");
+
+                ICell cell1 = row.CreateCell(1);
+                cell1.SetCellType(NPOI.SS.UserModel.CellType.String);
+                cell1.SetCellValue("类型");
+
+                ICell cell2 = row.CreateCell(2);
+                cell2.SetCellType(NPOI.SS.UserModel.CellType.String);
+                cell2.SetCellValue("总数");
+
+                List<string> list = new List<string>() { "FASE-光电感烟探测器", "FASE-智能感温探测器", "FSCP-消火栓起泵按钮" };
+                var list2 = list.Select(tt => tt.Substring(0, 4)).ToList();
+                int index = 0;
+                foreach (var context in contexts)
+                {
+                    var floorName = context.MFloor.ToString();
+
+
+                    #endregion
+                    Action<int> action = (count) =>
+                    {
+                        index++;
+
+                        row = sheet.CreateRow(index);
+
+                        ICell cell = row.CreateCell(0, NPOI.SS.UserModel.CellType.String);
+                        cell.SetCellValue(floorName);
+
+                        cell = row.CreateCell(1, NPOI.SS.UserModel.CellType.String);
+                        cell.SetCellValue(string.Join(",", list));
+
+                        cell = row.CreateCell(2, NPOI.SS.UserModel.CellType.String);
+                        cell.SetCellValue(count);
+
+                    };
+                    action(context.MEquipments.Where(t => list2.Contains(t.EquipClassCode)).Count());
+
+                }
+
+                #endregion
+
+                #region 写入
+
+                MemoryStream ms = new MemoryStream();
+                book.Write(ms);
+                book = null;
+
+                using (System.IO.FileStream fs = new System.IO.FileStream(fileName, FileMode.Create, FileAccess.Write))
+                {
+                    byte[] data = ms.ToArray();
+                    fs.Write(data, 0, data.Length);
+                    fs.Flush();
+                }
+                ms.Close();
+                ms.Dispose();
+
+                #endregion
+
+            }
+            catch (Exception e)
+            {
+                MessageShowBase.Show(e);
+            }
+        }
+    }
+}

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

@@ -207,7 +207,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                     else if (fi.IsEquipment() || fi.IsEquipmentPart() || fi.IsBeacon())
                     {
                         result.RType = GetRType(fi);
-                        zb = fi.GetLocationPoint().Z;
+                        zb = fi.GetLocationPointMBIXYZ().Z;
                         rb = zb.IsBetween(hb, ht);
                         result.IsRight = rb;
                         result.RMessage = result.IsRight ? "" : "构件范围不满足要求;请检查构件位置";

+ 1 - 0
MBI/SAGA.Revit.sln.DotSettings.user

@@ -1,4 +1,5 @@
 <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+	<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String>
 	<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
   &lt;Assembly Path="D:\SVNCode\MBI\Dlls\Newtonsoft.Json.dll" /&gt;&#xD;
   &lt;Assembly Path="D:\SVNCode\MBI\Dlls\FirmLibDll\FWindSoft.Wpf.dll" /&gt;&#xD;